@rvoh/dream 2.3.2 → 2.4.0-alpha.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/bin/index.js +2 -0
- package/dist/cjs/src/cli/index.js +3 -1
- package/dist/cjs/src/dream-app/index.js +4 -0
- package/dist/cjs/src/helpers/cli/generateDream.js +2 -0
- package/dist/cjs/src/helpers/cli/generateDreamContent.js +9 -1
- package/dist/cjs/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/cjs/src/helpers/cli/generateSerializerContent.js +12 -2
- package/dist/esm/src/bin/index.js +2 -0
- package/dist/esm/src/cli/index.js +3 -1
- package/dist/esm/src/dream-app/index.js +4 -0
- package/dist/esm/src/helpers/cli/generateDream.js +2 -0
- package/dist/esm/src/helpers/cli/generateDreamContent.js +9 -1
- package/dist/esm/src/helpers/cli/generateSerializer.js +2 -1
- package/dist/esm/src/helpers/cli/generateSerializerContent.js +12 -2
- package/dist/types/src/bin/index.d.ts +2 -0
- package/dist/types/src/cli/index.d.ts +2 -1
- package/dist/types/src/helpers/EnvInternal.d.ts +1 -1
- package/dist/types/src/helpers/cli/generateDream.d.ts +1 -0
- package/dist/types/src/helpers/cli/generateDreamContent.d.ts +1 -0
- package/dist/types/src/helpers/cli/generateSerializer.d.ts +2 -1
- package/dist/types/src/helpers/cli/generateSerializerContent.d.ts +2 -1
- package/dist/types/src/helpers/path/windowsSafePath.d.ts +4 -4
- package/dist/types/src/helpers/sspawn.d.ts +1 -1
- package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +10 -10
- package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +10 -10
- package/dist/types/src/serializer/helpers/inferSerializerFromDreamOrViewModel.d.ts +1 -1
- package/dist/types/src/types/serializer.d.ts +1 -1
- package/dist/types/src/types/serializer.ts +1 -3
- package/docs/assets/hierarchy.js +1 -0
- package/docs/assets/icons.js +1 -1
- package/docs/assets/icons.svg +1 -1
- package/docs/assets/main.js +5 -5
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1440 -1255
- package/docs/classes/db.DreamMigrationHelpers.html +42 -37
- package/docs/classes/db.KyselyQueryDriver.html +94 -94
- package/docs/classes/db.PostgresQueryDriver.html +95 -95
- package/docs/classes/db.QueryDriverBase.html +86 -86
- package/docs/classes/errors.CheckConstraintViolation.html +33 -12
- package/docs/classes/errors.ColumnOverflow.html +33 -12
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +33 -12
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +33 -12
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +33 -12
- package/docs/classes/errors.GlobalNameNotSet.html +33 -12
- package/docs/classes/errors.InvalidCalendarDate.html +36 -15
- package/docs/classes/errors.InvalidClockTime.html +36 -15
- package/docs/classes/errors.InvalidClockTimeTz.html +36 -15
- package/docs/classes/errors.InvalidDateTime.html +36 -15
- package/docs/classes/errors.MissingSerializersDefinition.html +33 -12
- package/docs/classes/errors.NonLoadedAssociation.html +35 -14
- package/docs/classes/errors.NotNullViolation.html +33 -12
- package/docs/classes/errors.RecordNotFound.html +34 -13
- package/docs/classes/errors.ValidationError.html +35 -14
- package/docs/classes/index.CalendarDate.html +138 -138
- package/docs/classes/index.ClockTime.html +156 -147
- package/docs/classes/index.ClockTimeTz.html +171 -160
- package/docs/classes/index.DateTime.html +526 -310
- package/docs/classes/index.Decorators.html +67 -66
- package/docs/classes/index.Dream.html +502 -439
- package/docs/classes/index.DreamApp.html +42 -47
- package/docs/classes/index.DreamTransaction.html +5 -5
- package/docs/classes/index.Env.html +18 -18
- package/docs/classes/index.Query.html +214 -214
- package/docs/classes/system.CliFileWriter.html +18 -8
- package/docs/classes/system.DreamBin.html +11 -11
- package/docs/classes/system.DreamCLI.html +12 -14
- package/docs/classes/system.DreamImporter.html +5 -5
- package/docs/classes/system.DreamLogos.html +4 -4
- package/docs/classes/system.DreamSerializerBuilder.html +72 -42
- package/docs/classes/system.ObjectSerializerBuilder.html +41 -41
- package/docs/classes/system.PathHelpers.html +8 -8
- package/docs/classes/utils.Encrypt.html +6 -6
- package/docs/classes/utils.Range.html +5 -5
- 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 +2 -2
- package/docs/functions/utils.camelize.html +4 -4
- package/docs/functions/utils.capitalize.html +3 -3
- package/docs/functions/utils.cloneDeepSafe.html +6 -6
- package/docs/functions/utils.compact.html +4 -4
- package/docs/functions/utils.groupBy.html +5 -5
- package/docs/functions/utils.hyphenize.html +4 -4
- package/docs/functions/utils.intersection.html +4 -4
- package/docs/functions/utils.isEmpty.html +4 -4
- package/docs/functions/utils.normalizeUnicode.html +5 -5
- package/docs/functions/utils.pascalize.html +4 -4
- package/docs/functions/utils.percent.html +5 -5
- package/docs/functions/utils.range.html +1 -0
- package/docs/functions/utils.round.html +4 -4
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +4 -4
- package/docs/functions/utils.sort.html +2 -2
- package/docs/functions/utils.sortBy.html +5 -5
- 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 +5 -5
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +12 -7
- 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 +14 -14
- package/docs/interfaces/types.DecoratorContext.html +8 -8
- package/docs/interfaces/types.DreamAppInitOptions.html +3 -3
- package/docs/interfaces/types.DreamAppOpts.html +8 -8
- package/docs/interfaces/types.DurationObject.html +12 -12
- package/docs/interfaces/types.EncryptOptions.html +3 -3
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +4 -4
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +4 -4
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/modules/db.html +1 -10
- package/docs/modules/errors.html +1 -17
- package/docs/modules/index.html +1 -18
- package/docs/modules/openapi.html +1 -49
- package/docs/modules/system.html +1 -12
- package/docs/modules/types.html +1 -54
- package/docs/modules/utils.html +1 -24
- package/docs/modules.html +1 -0
- 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 +2 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +2 -1
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +2 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +2 -1
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +2 -1
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +2 -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 +2 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +2 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +2 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +6 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +4 -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.CalendarDateDurationUnit.html +1 -1
- package/docs/types/types.CalendarDateObject.html +2 -2
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.ClockTimeObject.html +2 -2
- 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 +5 -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.DurationUnit.html +2 -2
- 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.PrimaryKeyType.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 +2 -1
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WeekdayName.html +2 -2
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes.html +1 -0
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes.html +1 -0
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -1
- package/package.json +25 -34
- package/docs/functions/utils.range-1.html +0 -1
- package/docs/variables/openapi.openapiPrimitiveTypes-1.html +0 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes-1.html +0 -1
|
@@ -48,6 +48,7 @@ export default class DreamBin {
|
|
|
48
48
|
columnsWithTypes,
|
|
49
49
|
options: {
|
|
50
50
|
includeAdminSerializers: options.adminSerializers ?? false,
|
|
51
|
+
includeInternalSerializers: options.internalSerializers ?? false,
|
|
51
52
|
...options,
|
|
52
53
|
},
|
|
53
54
|
});
|
|
@@ -58,6 +59,7 @@ export default class DreamBin {
|
|
|
58
59
|
columnsWithTypes,
|
|
59
60
|
options: {
|
|
60
61
|
includeAdminSerializers: options.adminSerializers ?? false,
|
|
62
|
+
includeInternalSerializers: options.internalSerializers ?? false,
|
|
61
63
|
...options,
|
|
62
64
|
stiBaseSerializer: false,
|
|
63
65
|
},
|
|
@@ -42,7 +42,7 @@ ${INDENT} - integer[]
|
|
|
42
42
|
${INDENT}
|
|
43
43
|
${INDENT} - decimal:
|
|
44
44
|
${INDENT} - decimal[]:
|
|
45
|
-
${INDENT} scale
|
|
45
|
+
${INDENT} precision,scale is required, e.g.: volume:decimal:3,2 or volume:decimal:3,2:optional
|
|
46
46
|
${INDENT}
|
|
47
47
|
${INDENT} leveraging arrays, add the "[]" suffix, e.g.: volume:decimal[]:3,2
|
|
48
48
|
${INDENT}
|
|
@@ -135,6 +135,7 @@ export default class DreamCLI {
|
|
|
135
135
|
.option('--table-name <tableName>', 'explicit table name to use instead of the auto-generated one (useful when model namespaces produce long names)')
|
|
136
136
|
.option('--model-name <modelName>', 'explicit model class name to use instead of the auto-generated one (e.g. --model-name=Kitchen for Room/Kitchen)')
|
|
137
137
|
.option('--admin-serializers', 'generate admin serializer variants (AdminSerializer and AdminSummarySerializer) in addition to the default serializers')
|
|
138
|
+
.option('--internal-serializers', 'generate internal serializer variants (InternalSerializer and InternalSummarySerializer) in addition to the default serializers')
|
|
138
139
|
.argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
|
|
139
140
|
.argument('[columnsWithTypes...]', columnsWithTypesDescription)
|
|
140
141
|
.action(async (modelName, columnsWithTypes, options) => {
|
|
@@ -150,6 +151,7 @@ export default class DreamCLI {
|
|
|
150
151
|
.option('--connection-name', 'the db connection you want this model attached to (defaults to the default connection)', 'default')
|
|
151
152
|
.option('--model-name <modelName>', 'explicit model class name to use instead of the auto-generated one (e.g. --model-name=Kitchen for Room/Kitchen)')
|
|
152
153
|
.option('--admin-serializers', 'generate admin serializer variants (AdminSerializer and AdminSummarySerializer) in addition to the default serializers')
|
|
154
|
+
.option('--internal-serializers', 'generate internal serializer variants (InternalSerializer and InternalSummarySerializer) in addition to the default serializers')
|
|
153
155
|
.argument('<childModelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
|
|
154
156
|
.argument('<extends>', 'just the word "extends"')
|
|
155
157
|
.argument('<parentModelName>', `fully qualified name of the parent model, e.g.:
|
|
@@ -414,6 +414,10 @@ function loggerArgToString(arg) {
|
|
|
414
414
|
return arg;
|
|
415
415
|
if (typeof arg === 'boolean')
|
|
416
416
|
return arg;
|
|
417
|
+
if (arg === null)
|
|
418
|
+
return 'null';
|
|
419
|
+
if (arg === undefined)
|
|
420
|
+
return 'undefined';
|
|
417
421
|
if (arg instanceof DateTime || arg instanceof CalendarDate || arg instanceof BaseClockTime) {
|
|
418
422
|
return arg.toISO();
|
|
419
423
|
}
|
|
@@ -18,6 +18,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
|
|
|
18
18
|
fullyQualifiedParentName,
|
|
19
19
|
serializer: options.serializer,
|
|
20
20
|
includeAdminSerializers: options.includeAdminSerializers,
|
|
21
|
+
includeInternalSerializers: options.includeInternalSerializers ?? false,
|
|
21
22
|
connectionName: options.connectionName,
|
|
22
23
|
tableName: options.tableName,
|
|
23
24
|
modelClassName,
|
|
@@ -33,6 +34,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
|
|
|
33
34
|
fullyQualifiedParentName,
|
|
34
35
|
stiBaseSerializer: options.stiBaseSerializer,
|
|
35
36
|
includeAdminSerializers: options.includeAdminSerializers,
|
|
37
|
+
includeInternalSerializers: options.includeInternalSerializers ?? false,
|
|
36
38
|
modelClassName,
|
|
37
39
|
});
|
|
38
40
|
const isSTI = !!fullyQualifiedParentName;
|
|
@@ -177,10 +177,18 @@ function buildSerializersMethod(config, options) {
|
|
|
177
177
|
admin: '${adminSerializer}',
|
|
178
178
|
adminSummary: '${adminSummarySerializer}',`;
|
|
179
179
|
}
|
|
180
|
+
let internalSerializers = '';
|
|
181
|
+
if (options.includeInternalSerializers) {
|
|
182
|
+
const internalSerializer = defaultSerializer.replace(/Serializer$/, 'InternalSerializer');
|
|
183
|
+
const internalSummarySerializer = summarySerializer.replace(/SummarySerializer$/, 'InternalSummarySerializer');
|
|
184
|
+
internalSerializers = `
|
|
185
|
+
internal: '${internalSerializer}',
|
|
186
|
+
internalSummary: '${internalSummarySerializer}',`;
|
|
187
|
+
}
|
|
180
188
|
return ` public ${overrideKeyword}get serializers(): DreamSerializers<${config.modelClassName}> {
|
|
181
189
|
return {
|
|
182
190
|
default: '${defaultSerializer}',
|
|
183
|
-
summary: '${summarySerializer}',${adminSerializers}
|
|
191
|
+
summary: '${summarySerializer}',${adminSerializers}${internalSerializers}
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
194
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import generateSerializerContent from './generateSerializerContent.js';
|
|
2
2
|
import writeGeneratedFile from './writeGeneratedFile.js';
|
|
3
|
-
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }) {
|
|
3
|
+
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }) {
|
|
4
4
|
await writeGeneratedFile({
|
|
5
5
|
dreamPathKey: 'serializers',
|
|
6
6
|
fileName: `${fullyQualifiedModelName}Serializer.ts`,
|
|
@@ -10,6 +10,7 @@ export default async function generateSerializer({ fullyQualifiedModelName, colu
|
|
|
10
10
|
fullyQualifiedParentName,
|
|
11
11
|
stiBaseSerializer,
|
|
12
12
|
includeAdminSerializers,
|
|
13
|
+
includeInternalSerializers: includeInternalSerializers ?? false,
|
|
13
14
|
modelClassName,
|
|
14
15
|
}),
|
|
15
16
|
logLabel: 'serializer',
|
|
@@ -4,7 +4,7 @@ import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFu
|
|
|
4
4
|
import absoluteDreamPath from '../path/absoluteDreamPath.js';
|
|
5
5
|
import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
|
|
6
6
|
import uniq from '../uniq.js';
|
|
7
|
-
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }) {
|
|
7
|
+
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }) {
|
|
8
8
|
fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
|
|
9
9
|
const additionalImports = [];
|
|
10
10
|
const dreamImports = [];
|
|
@@ -35,6 +35,10 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
|
|
|
35
35
|
const adminSerializerClassName = serializerClassName.replace(/Serializer$/, 'AdminSerializer');
|
|
36
36
|
const adminSummarySerializerClassName = summarySerializerClassName.replace(/SummarySerializer$/, 'AdminSummarySerializer');
|
|
37
37
|
// end:Admin variants
|
|
38
|
+
// Internal variants
|
|
39
|
+
const internalSerializerClassName = serializerClassName.replace(/Serializer$/, 'InternalSerializer');
|
|
40
|
+
const internalSummarySerializerClassName = summarySerializerClassName.replace(/SummarySerializer$/, 'InternalSummarySerializer');
|
|
41
|
+
// end:Internal variants
|
|
38
42
|
const additionalModelImports = [];
|
|
39
43
|
const dreamImport = dreamImports.length
|
|
40
44
|
? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n`
|
|
@@ -62,7 +66,13 @@ ${defaultSerializer}${!includeAdminSerializers
|
|
|
62
66
|
|
|
63
67
|
${summarySerializer.replace(summarySerializerClassName, adminSummarySerializerClassName)}
|
|
64
68
|
|
|
65
|
-
${defaultSerializer.replace(serializerClassName, adminSerializerClassName).replace(summarySerializerClassName, adminSummarySerializerClassName)}`}
|
|
69
|
+
${defaultSerializer.replace(serializerClassName, adminSerializerClassName).replace(summarySerializerClassName, adminSummarySerializerClassName)}`}${!includeInternalSerializers
|
|
70
|
+
? ''
|
|
71
|
+
: `
|
|
72
|
+
|
|
73
|
+
${summarySerializer.replace(summarySerializerClassName, internalSummarySerializerClassName)}
|
|
74
|
+
|
|
75
|
+
${defaultSerializer.replace(serializerClassName, internalSerializerClassName).replace(summarySerializerClassName, internalSummarySerializerClassName)}`}
|
|
66
76
|
`;
|
|
67
77
|
}
|
|
68
78
|
function attribute(modelClassName, name, type, attr, stiBaseSerializer) {
|
|
@@ -48,6 +48,7 @@ export default class DreamBin {
|
|
|
48
48
|
columnsWithTypes,
|
|
49
49
|
options: {
|
|
50
50
|
includeAdminSerializers: options.adminSerializers ?? false,
|
|
51
|
+
includeInternalSerializers: options.internalSerializers ?? false,
|
|
51
52
|
...options,
|
|
52
53
|
},
|
|
53
54
|
});
|
|
@@ -58,6 +59,7 @@ export default class DreamBin {
|
|
|
58
59
|
columnsWithTypes,
|
|
59
60
|
options: {
|
|
60
61
|
includeAdminSerializers: options.adminSerializers ?? false,
|
|
62
|
+
includeInternalSerializers: options.internalSerializers ?? false,
|
|
61
63
|
...options,
|
|
62
64
|
stiBaseSerializer: false,
|
|
63
65
|
},
|
|
@@ -42,7 +42,7 @@ ${INDENT} - integer[]
|
|
|
42
42
|
${INDENT}
|
|
43
43
|
${INDENT} - decimal:
|
|
44
44
|
${INDENT} - decimal[]:
|
|
45
|
-
${INDENT} scale
|
|
45
|
+
${INDENT} precision,scale is required, e.g.: volume:decimal:3,2 or volume:decimal:3,2:optional
|
|
46
46
|
${INDENT}
|
|
47
47
|
${INDENT} leveraging arrays, add the "[]" suffix, e.g.: volume:decimal[]:3,2
|
|
48
48
|
${INDENT}
|
|
@@ -135,6 +135,7 @@ export default class DreamCLI {
|
|
|
135
135
|
.option('--table-name <tableName>', 'explicit table name to use instead of the auto-generated one (useful when model namespaces produce long names)')
|
|
136
136
|
.option('--model-name <modelName>', 'explicit model class name to use instead of the auto-generated one (e.g. --model-name=Kitchen for Room/Kitchen)')
|
|
137
137
|
.option('--admin-serializers', 'generate admin serializer variants (AdminSerializer and AdminSummarySerializer) in addition to the default serializers')
|
|
138
|
+
.option('--internal-serializers', 'generate internal serializer variants (InternalSerializer and InternalSummarySerializer) in addition to the default serializers')
|
|
138
139
|
.argument('<modelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
|
|
139
140
|
.argument('[columnsWithTypes...]', columnsWithTypesDescription)
|
|
140
141
|
.action(async (modelName, columnsWithTypes, options) => {
|
|
@@ -150,6 +151,7 @@ export default class DreamCLI {
|
|
|
150
151
|
.option('--connection-name', 'the db connection you want this model attached to (defaults to the default connection)', 'default')
|
|
151
152
|
.option('--model-name <modelName>', 'explicit model class name to use instead of the auto-generated one (e.g. --model-name=Kitchen for Room/Kitchen)')
|
|
152
153
|
.option('--admin-serializers', 'generate admin serializer variants (AdminSerializer and AdminSummarySerializer) in addition to the default serializers')
|
|
154
|
+
.option('--internal-serializers', 'generate internal serializer variants (InternalSerializer and InternalSummarySerializer) in addition to the default serializers')
|
|
153
155
|
.argument('<childModelName>', 'the name of the model to create, e.g. Post or Settings/CommunicationPreferences')
|
|
154
156
|
.argument('<extends>', 'just the word "extends"')
|
|
155
157
|
.argument('<parentModelName>', `fully qualified name of the parent model, e.g.:
|
|
@@ -414,6 +414,10 @@ function loggerArgToString(arg) {
|
|
|
414
414
|
return arg;
|
|
415
415
|
if (typeof arg === 'boolean')
|
|
416
416
|
return arg;
|
|
417
|
+
if (arg === null)
|
|
418
|
+
return 'null';
|
|
419
|
+
if (arg === undefined)
|
|
420
|
+
return 'undefined';
|
|
417
421
|
if (arg instanceof DateTime || arg instanceof CalendarDate || arg instanceof BaseClockTime) {
|
|
418
422
|
return arg.toISO();
|
|
419
423
|
}
|
|
@@ -18,6 +18,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
|
|
|
18
18
|
fullyQualifiedParentName,
|
|
19
19
|
serializer: options.serializer,
|
|
20
20
|
includeAdminSerializers: options.includeAdminSerializers,
|
|
21
|
+
includeInternalSerializers: options.includeInternalSerializers ?? false,
|
|
21
22
|
connectionName: options.connectionName,
|
|
22
23
|
tableName: options.tableName,
|
|
23
24
|
modelClassName,
|
|
@@ -33,6 +34,7 @@ export default async function generateDream({ fullyQualifiedModelName, columnsWi
|
|
|
33
34
|
fullyQualifiedParentName,
|
|
34
35
|
stiBaseSerializer: options.stiBaseSerializer,
|
|
35
36
|
includeAdminSerializers: options.includeAdminSerializers,
|
|
37
|
+
includeInternalSerializers: options.includeInternalSerializers ?? false,
|
|
36
38
|
modelClassName,
|
|
37
39
|
});
|
|
38
40
|
const isSTI = !!fullyQualifiedParentName;
|
|
@@ -177,10 +177,18 @@ function buildSerializersMethod(config, options) {
|
|
|
177
177
|
admin: '${adminSerializer}',
|
|
178
178
|
adminSummary: '${adminSummarySerializer}',`;
|
|
179
179
|
}
|
|
180
|
+
let internalSerializers = '';
|
|
181
|
+
if (options.includeInternalSerializers) {
|
|
182
|
+
const internalSerializer = defaultSerializer.replace(/Serializer$/, 'InternalSerializer');
|
|
183
|
+
const internalSummarySerializer = summarySerializer.replace(/SummarySerializer$/, 'InternalSummarySerializer');
|
|
184
|
+
internalSerializers = `
|
|
185
|
+
internal: '${internalSerializer}',
|
|
186
|
+
internalSummary: '${internalSummarySerializer}',`;
|
|
187
|
+
}
|
|
180
188
|
return ` public ${overrideKeyword}get serializers(): DreamSerializers<${config.modelClassName}> {
|
|
181
189
|
return {
|
|
182
190
|
default: '${defaultSerializer}',
|
|
183
|
-
summary: '${summarySerializer}',${adminSerializers}
|
|
191
|
+
summary: '${summarySerializer}',${adminSerializers}${internalSerializers}
|
|
184
192
|
}
|
|
185
193
|
}
|
|
186
194
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import generateSerializerContent from './generateSerializerContent.js';
|
|
2
2
|
import writeGeneratedFile from './writeGeneratedFile.js';
|
|
3
|
-
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }) {
|
|
3
|
+
export default async function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }) {
|
|
4
4
|
await writeGeneratedFile({
|
|
5
5
|
dreamPathKey: 'serializers',
|
|
6
6
|
fileName: `${fullyQualifiedModelName}Serializer.ts`,
|
|
@@ -10,6 +10,7 @@ export default async function generateSerializer({ fullyQualifiedModelName, colu
|
|
|
10
10
|
fullyQualifiedParentName,
|
|
11
11
|
stiBaseSerializer,
|
|
12
12
|
includeAdminSerializers,
|
|
13
|
+
includeInternalSerializers: includeInternalSerializers ?? false,
|
|
13
14
|
modelClassName,
|
|
14
15
|
}),
|
|
15
16
|
logLabel: 'serializer',
|
|
@@ -4,7 +4,7 @@ import globalClassNameFromFullyQualifiedModelName from '../globalClassNameFromFu
|
|
|
4
4
|
import absoluteDreamPath from '../path/absoluteDreamPath.js';
|
|
5
5
|
import standardizeFullyQualifiedModelName from '../standardizeFullyQualifiedModelName.js';
|
|
6
6
|
import uniq from '../uniq.js';
|
|
7
|
-
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }) {
|
|
7
|
+
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes = [], fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }) {
|
|
8
8
|
fullyQualifiedModelName = standardizeFullyQualifiedModelName(fullyQualifiedModelName);
|
|
9
9
|
const additionalImports = [];
|
|
10
10
|
const dreamImports = [];
|
|
@@ -35,6 +35,10 @@ export default function generateSerializerContent({ fullyQualifiedModelName, col
|
|
|
35
35
|
const adminSerializerClassName = serializerClassName.replace(/Serializer$/, 'AdminSerializer');
|
|
36
36
|
const adminSummarySerializerClassName = summarySerializerClassName.replace(/SummarySerializer$/, 'AdminSummarySerializer');
|
|
37
37
|
// end:Admin variants
|
|
38
|
+
// Internal variants
|
|
39
|
+
const internalSerializerClassName = serializerClassName.replace(/Serializer$/, 'InternalSerializer');
|
|
40
|
+
const internalSummarySerializerClassName = summarySerializerClassName.replace(/SummarySerializer$/, 'InternalSummarySerializer');
|
|
41
|
+
// end:Internal variants
|
|
38
42
|
const additionalModelImports = [];
|
|
39
43
|
const dreamImport = dreamImports.length
|
|
40
44
|
? `import { ${uniq(dreamImports).join(', ')} } from '@rvoh/dream'\n`
|
|
@@ -62,7 +66,13 @@ ${defaultSerializer}${!includeAdminSerializers
|
|
|
62
66
|
|
|
63
67
|
${summarySerializer.replace(summarySerializerClassName, adminSummarySerializerClassName)}
|
|
64
68
|
|
|
65
|
-
${defaultSerializer.replace(serializerClassName, adminSerializerClassName).replace(summarySerializerClassName, adminSummarySerializerClassName)}`}
|
|
69
|
+
${defaultSerializer.replace(serializerClassName, adminSerializerClassName).replace(summarySerializerClassName, adminSummarySerializerClassName)}`}${!includeInternalSerializers
|
|
70
|
+
? ''
|
|
71
|
+
: `
|
|
72
|
+
|
|
73
|
+
${summarySerializer.replace(summarySerializerClassName, internalSummarySerializerClassName)}
|
|
74
|
+
|
|
75
|
+
${defaultSerializer.replace(serializerClassName, internalSerializerClassName).replace(summarySerializerClassName, internalSummarySerializerClassName)}`}
|
|
66
76
|
`;
|
|
67
77
|
}
|
|
68
78
|
function attribute(modelClassName, name, type, attr, stiBaseSerializer) {
|
|
@@ -15,12 +15,14 @@ export default class DreamBin {
|
|
|
15
15
|
connectionName: string;
|
|
16
16
|
tableName?: string;
|
|
17
17
|
adminSerializers?: boolean;
|
|
18
|
+
internalSerializers?: boolean;
|
|
18
19
|
modelName?: string;
|
|
19
20
|
}): Promise<void>;
|
|
20
21
|
static generateStiChild(fullyQualifiedModelName: string, fullyQualifiedParentName: string, columnsWithTypes: string[], options: {
|
|
21
22
|
serializer: boolean;
|
|
22
23
|
connectionName: string;
|
|
23
24
|
adminSerializers?: boolean;
|
|
25
|
+
internalSerializers?: boolean;
|
|
24
26
|
modelName?: string;
|
|
25
27
|
}): Promise<void>;
|
|
26
28
|
static generateMigration(migrationName: string, columnsWithTypes: string[], connectionName: string): Promise<void>;
|
|
@@ -3,7 +3,7 @@ import { Command } from 'commander';
|
|
|
3
3
|
import DreamApp, { DreamAppInitOptions } from '../dream-app/index.js';
|
|
4
4
|
import DreamCliLogger from './logger/DreamCliLogger.js';
|
|
5
5
|
export declare const CLI_INDENT = " ";
|
|
6
|
-
export declare const baseColumnsWithTypesDescription = "space separated snake-case (except for belongs_to model name) properties like this:\n title:citext subtitle:string body_markdown:text style:enum:post_styles:formal,informal User:belongs_to\n \n all properties default to not nullable; null can be allowed by appending ':optional':\n subtitle:string:optional\n \n supported types:\n - uuid:\n - uuid[]:\n a column optimized for storing UUIDs\n \n - citext:\n - citext[]:\n case insensitive text (indexes and queries are automatically case insensitive)\n \n - string:\n - string[]:\n varchar; allowed length defaults to 255, but may be customized, e.g.: subtitle:string:128 or subtitle:string:128:optional\n \n - text\n - text[]\n - date\n - date[]\n - datetime\n - datetime[]\n - time\n - time[]\n - timetz\n - timetz[]\n - integer\n - integer[]\n \n - decimal:\n - decimal[]:\n scale
|
|
6
|
+
export declare const baseColumnsWithTypesDescription = "space separated snake-case (except for belongs_to model name) properties like this:\n title:citext subtitle:string body_markdown:text style:enum:post_styles:formal,informal User:belongs_to\n \n all properties default to not nullable; null can be allowed by appending ':optional':\n subtitle:string:optional\n \n supported types:\n - uuid:\n - uuid[]:\n a column optimized for storing UUIDs\n \n - citext:\n - citext[]:\n case insensitive text (indexes and queries are automatically case insensitive)\n \n - string:\n - string[]:\n varchar; allowed length defaults to 255, but may be customized, e.g.: subtitle:string:128 or subtitle:string:128:optional\n \n - text\n - text[]\n - date\n - date[]\n - datetime\n - datetime[]\n - time\n - time[]\n - timetz\n - timetz[]\n - integer\n - integer[]\n \n - decimal:\n - decimal[]:\n precision,scale is required, e.g.: volume:decimal:3,2 or volume:decimal:3,2:optional\n \n leveraging arrays, add the \"[]\" suffix, e.g.: volume:decimal[]:3,2\n \n - enum:\n - enum[]:\n include the enum name to automatically create the enum:\n type:enum:room_types:bathroom,kitchen,bedroom or type:enum:room_types:bathroom,kitchen,bedroom:optional\n \n omit the enum values to leverage an existing enum (omits the enum type creation):\n type:enum:room_types or type:enum:room_types:optional\n \n leveraging arrays, add the \"[]\" suffix, e.g.: type:enum[]:room_types:bathroom,kitchen,bedroom";
|
|
7
7
|
export default class DreamCLI {
|
|
8
8
|
/**
|
|
9
9
|
* Starts the Dream console
|
|
@@ -31,6 +31,7 @@ export default class DreamCLI {
|
|
|
31
31
|
serializer: boolean;
|
|
32
32
|
stiBaseSerializer: boolean;
|
|
33
33
|
includeAdminSerializers: boolean;
|
|
34
|
+
includeInternalSerializers?: boolean;
|
|
34
35
|
tableName?: string | undefined;
|
|
35
36
|
/**
|
|
36
37
|
* Optional model class name override. If provided, generators use it
|
|
@@ -2,5 +2,5 @@ import Env from './Env.js';
|
|
|
2
2
|
declare const EnvInternal: Env<{
|
|
3
3
|
string: "DREAM_CORE_DEVELOPMENT" | "TZ";
|
|
4
4
|
boolean: "ALLOW_BENCHMARKS" | "DREAM_BYPASS_PACKAGE_MANAGER_CHECK" | "DREAM_CORE_DEVELOPMENT" | "DREAM_CORE_SPEC_RUN" | "PSYCHIC_CORE_DEVELOPMENT";
|
|
5
|
-
}, "
|
|
5
|
+
}, "DREAM_CORE_DEVELOPMENT" | "TZ", never, "DREAM_CORE_DEVELOPMENT" | "ALLOW_BENCHMARKS" | "DREAM_BYPASS_PACKAGE_MANAGER_CHECK" | "DREAM_CORE_SPEC_RUN" | "PSYCHIC_CORE_DEVELOPMENT">;
|
|
6
6
|
export default EnvInternal;
|
|
@@ -5,6 +5,7 @@ interface GenerateDreamContentOptions {
|
|
|
5
5
|
connectionName?: string;
|
|
6
6
|
serializer: boolean;
|
|
7
7
|
includeAdminSerializers: boolean;
|
|
8
|
+
includeInternalSerializers?: boolean;
|
|
8
9
|
tableName?: string | undefined;
|
|
9
10
|
/** Model class name, computed once via modelClassNameFrom in the orchestrator. */
|
|
10
11
|
modelClassName: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }: {
|
|
1
|
+
export default function generateSerializer({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes: string[];
|
|
4
4
|
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
stiBaseSerializer: boolean;
|
|
6
6
|
includeAdminSerializers: boolean;
|
|
7
|
+
includeInternalSerializers?: boolean;
|
|
7
8
|
modelClassName: string;
|
|
8
9
|
}): Promise<void>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, modelClassName, }: {
|
|
1
|
+
export default function generateSerializerContent({ fullyQualifiedModelName, columnsWithTypes, fullyQualifiedParentName, stiBaseSerializer, includeAdminSerializers, includeInternalSerializers, modelClassName, }: {
|
|
2
2
|
fullyQualifiedModelName: string;
|
|
3
3
|
columnsWithTypes?: string[] | undefined;
|
|
4
4
|
fullyQualifiedParentName?: string | undefined;
|
|
5
5
|
stiBaseSerializer: boolean;
|
|
6
6
|
includeAdminSerializers: boolean;
|
|
7
|
+
includeInternalSerializers?: boolean;
|
|
7
8
|
/** Model class name, computed once via modelClassNameFrom in the orchestrator. */
|
|
8
9
|
modelClassName: string;
|
|
9
10
|
}): string;
|
|
@@ -9,12 +9,12 @@ declare const windowsSafePath: {
|
|
|
9
9
|
dirname(path: string): string;
|
|
10
10
|
basename(path: string, suffix?: string): string;
|
|
11
11
|
extname(path: string): string;
|
|
12
|
-
sep: "\\" | "/";
|
|
13
|
-
delimiter: ";" | ":";
|
|
14
12
|
parse(path: string): path.ParsedPath;
|
|
15
13
|
format(pathObject: path.FormatInputPathObject): string;
|
|
16
14
|
toNamespacedPath(path: string): string;
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
sep: "\\" | "/";
|
|
16
|
+
delimiter: ";" | ":";
|
|
17
|
+
posix: typeof path;
|
|
18
|
+
win32: typeof path;
|
|
19
19
|
};
|
|
20
20
|
export default windowsSafePath;
|
|
@@ -4,4 +4,4 @@ export default function sspawn(command: string, opts?: SpawnOptions & {
|
|
|
4
4
|
}): Promise<unknown>;
|
|
5
5
|
export declare function ssspawn(command: string, opts?: SpawnOptions & {
|
|
6
6
|
onStdout?: (str: string) => void;
|
|
7
|
-
}): import("child_process").ChildProcess;
|
|
7
|
+
}): import("node:child_process").ChildProcess;
|
|
@@ -131,15 +131,15 @@ export default class DreamSerializerBuilder<DataTypeForOpenapi extends typeof Dr
|
|
|
131
131
|
rendersOne<ProvidedModelType = undefined, ProvidedAttributeName extends ProvidedModelType extends undefined ? undefined : Exclude<keyof ProvidedModelType, keyof Dream> = ProvidedModelType extends undefined ? undefined : Exclude<keyof ProvidedModelType, keyof Dream>, ActualDataType extends ProvidedModelType extends undefined ? DataType : ProvidedModelType = ProvidedModelType extends undefined ? DataType : ProvidedModelType, AttributeName extends ProvidedAttributeName extends undefined ? Exclude<keyof ActualDataType, keyof Dream> : ProvidedAttributeName & keyof ActualDataType = ProvidedAttributeName extends undefined ? Exclude<keyof ActualDataType, keyof Dream> : ProvidedAttributeName & keyof ActualDataType, AssociatedModelType = Exclude<ActualDataType[AttributeName], null>, SerializerOptions = AssociatedModelType extends Dream ? {
|
|
132
132
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
133
133
|
} | {
|
|
134
|
-
serializer?: SerializerType
|
|
134
|
+
serializer?: SerializerType;
|
|
135
135
|
} : AssociatedModelType extends ViewModel ? {
|
|
136
136
|
viewModelClass: ViewModelClass;
|
|
137
137
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
138
138
|
} | {
|
|
139
|
-
serializer: SerializerType
|
|
140
|
-
} :
|
|
141
|
-
serializer: SerializerType
|
|
142
|
-
}
|
|
139
|
+
serializer: SerializerType;
|
|
140
|
+
} : {
|
|
141
|
+
serializer: SerializerType;
|
|
142
|
+
}, BaseOptions = {
|
|
143
143
|
as?: string;
|
|
144
144
|
flatten?: boolean;
|
|
145
145
|
optional?: boolean;
|
|
@@ -176,15 +176,15 @@ export default class DreamSerializerBuilder<DataTypeForOpenapi extends typeof Dr
|
|
|
176
176
|
rendersMany<ProvidedModelType = undefined, ProvidedAttributeName extends ProvidedModelType extends undefined ? undefined : Exclude<keyof ProvidedModelType, keyof Dream> = ProvidedModelType extends undefined ? undefined : Exclude<keyof ProvidedModelType, keyof Dream>, ActualDataType extends ProvidedModelType extends undefined ? DataType : ProvidedModelType = ProvidedModelType extends undefined ? DataType : ProvidedModelType, AttributeName extends ProvidedAttributeName extends undefined ? Exclude<keyof ActualDataType, keyof Dream> : ProvidedAttributeName & keyof ActualDataType = ProvidedAttributeName extends undefined ? Exclude<keyof ActualDataType, keyof Dream> : ProvidedAttributeName & keyof ActualDataType, AssociatedModelType = ActualDataType[AttributeName] extends (Dream | ViewModel)[] ? ActualDataType[AttributeName] extends (infer U)[] ? U : object : object, SerializerOptions = AssociatedModelType extends Dream ? {
|
|
177
177
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
178
178
|
} | {
|
|
179
|
-
serializer?: SerializerType
|
|
179
|
+
serializer?: SerializerType;
|
|
180
180
|
} : AssociatedModelType extends ViewModel ? {
|
|
181
181
|
viewModelClass: ViewModelClass;
|
|
182
182
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
183
183
|
} | {
|
|
184
|
-
serializer: SerializerType
|
|
185
|
-
} :
|
|
186
|
-
serializer: SerializerType
|
|
187
|
-
}
|
|
184
|
+
serializer: SerializerType;
|
|
185
|
+
} : {
|
|
186
|
+
serializer: SerializerType;
|
|
187
|
+
}, BaseOptions = {
|
|
188
188
|
as?: string;
|
|
189
189
|
}>(name: AttributeName, options?: BaseOptions & SerializerOptions): this;
|
|
190
190
|
/**
|
|
@@ -134,15 +134,15 @@ export default class ObjectSerializerBuilder<MaybeNullDataType extends object |
|
|
|
134
134
|
dreamClass: typeof Dream;
|
|
135
135
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
136
136
|
} | {
|
|
137
|
-
serializer: SerializerType
|
|
137
|
+
serializer: SerializerType;
|
|
138
138
|
} : AssociatedModelType extends ViewModel ? {
|
|
139
139
|
viewModelClass: ViewModelClass;
|
|
140
140
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
141
141
|
} | {
|
|
142
|
-
serializer: SerializerType
|
|
143
|
-
} :
|
|
144
|
-
serializer: SerializerType
|
|
145
|
-
}
|
|
142
|
+
serializer: SerializerType;
|
|
143
|
+
} : {
|
|
144
|
+
serializer: SerializerType;
|
|
145
|
+
}>(name: AttributeName, options: {
|
|
146
146
|
as?: string;
|
|
147
147
|
flatten?: boolean;
|
|
148
148
|
optional?: boolean;
|
|
@@ -184,15 +184,15 @@ export default class ObjectSerializerBuilder<MaybeNullDataType extends object |
|
|
|
184
184
|
dreamClass: typeof Dream;
|
|
185
185
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
186
186
|
} | {
|
|
187
|
-
serializer: SerializerType
|
|
187
|
+
serializer: SerializerType;
|
|
188
188
|
} : AssociatedModelType extends ViewModel ? {
|
|
189
189
|
viewModelClass: ViewModelClass;
|
|
190
190
|
serializerKey?: DreamOrViewModelSerializerKey<AssociatedModelType>;
|
|
191
191
|
} | {
|
|
192
|
-
serializer: SerializerType
|
|
193
|
-
} :
|
|
194
|
-
serializer: SerializerType
|
|
195
|
-
}
|
|
192
|
+
serializer: SerializerType;
|
|
193
|
+
} : {
|
|
194
|
+
serializer: SerializerType;
|
|
195
|
+
}>(name: AttributeName, options: {
|
|
196
196
|
as?: string;
|
|
197
197
|
} & SerializerOptions): this;
|
|
198
198
|
/**
|
|
@@ -2,5 +2,5 @@ import Dream from '../../Dream.js';
|
|
|
2
2
|
import { ViewModel, ViewModelClass } from '../../types/dream.js';
|
|
3
3
|
import { DreamModelSerializerType, SerializerType, SimpleObjectSerializerType } from '../../types/serializer.js';
|
|
4
4
|
export declare const DEFAULT_SERIALIZER_KEY = "default";
|
|
5
|
-
export default function inferSerializerFromDreamOrViewModel<T extends Dream | ViewModel | null | undefined, ReturnType extends T extends null | undefined ? null : T extends Dream | ViewModel ? SerializerType
|
|
5
|
+
export default function inferSerializerFromDreamOrViewModel<T extends Dream | ViewModel | null | undefined, ReturnType extends T extends null | undefined ? null : T extends Dream | ViewModel ? SerializerType : never>(obj: T, serializerKey?: string | undefined): ReturnType;
|
|
6
6
|
export declare function inferSerializersFromDreamClassOrViewModelClass(classDef: typeof Dream | ViewModelClass | null | undefined, serializerKey?: string | undefined): (DreamModelSerializerType | SimpleObjectSerializerType)[];
|
|
@@ -76,4 +76,4 @@ export type NonAutomaticSerializerAttributeOptionsWithPossibleDecimalRenderOptio
|
|
|
76
76
|
};
|
|
77
77
|
export type DreamModelSerializerType = (data: any, passthroughData?: any) => DreamSerializerBuilder<any, any>;
|
|
78
78
|
export type SimpleObjectSerializerType = (data: any, passthroughData?: any) => ObjectSerializerBuilder<any, any>;
|
|
79
|
-
export type SerializerType
|
|
79
|
+
export type SerializerType = DreamModelSerializerType | SimpleObjectSerializerType;
|
|
@@ -113,6 +113,4 @@ export type SimpleObjectSerializerType = (
|
|
|
113
113
|
passthroughData?: any
|
|
114
114
|
) => ObjectSerializerBuilder<any, any>
|
|
115
115
|
|
|
116
|
-
export type SerializerType
|
|
117
|
-
? DreamModelSerializerType
|
|
118
|
-
: SimpleObjectSerializerType
|
|
116
|
+
export type SerializerType = DreamModelSerializerType | SimpleObjectSerializerType
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
window.hierarchyData = "eJyVks1uAiEURt/lrtE6P+LIspomTVPbJk27MC5w5tohMmCAsZkY372hbqi1HdwAIffjHOAewGjtLLBlQtOcTEcrAgY3EksntLLADjAd+VHxBoHBS4ummxuxR3PLLQKBrVAVsCQtCLRGAoNScmvR3lTr4Vn1sHaNBHKqAAbOVgMfH5w2CJS1kJVBBWyZZpPVkUCaTQL6Q2dRdsGpPfxf9dcYJBktvIKfA4dnbd2HQRtvcSHR4+Gp4yKkzmostzOtrDNcKPcmtOT+h/5DozHa2OFf0QgHOqKhg5Zto572aDZSf8aQfwRieGke8Obc8XtV6mbHnVhLfBeu9ntrbvFOoKwiFHrPuKojxkVB/KOQhOYZSShNvhuE5tmZ9mu3w9Pt/epR2Ia7so70vRyOeT6aBB4L7RatlNe0ynmkj3k8fgGG6267"
|