@rvoh/dream 0.43.0-beta.4 → 0.43.0-beta.5
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/errors/serializers/AttemptedToDeriveDescendentSerializersFromNonSerializer.js +1 -1
- package/dist/cjs/src/errors/serializers/ExpectedSerializerForRendersOneOrManyOption.js +36 -0
- package/dist/cjs/src/errors/serializers/ObjectSerializerRendersOneAndManyRequireClassType.js +1 -1
- package/dist/cjs/src/helpers/cloneDeepSafe.js +13 -12
- package/dist/cjs/src/helpers/groupBy.js +11 -0
- package/dist/cjs/src/helpers/sortObjectByValue.js +16 -0
- package/dist/cjs/src/index.js +8 -2
- package/dist/cjs/src/openapi/allSerializersToRefsInOpenapi.js +6 -6
- package/dist/cjs/src/serializer/SerializerOpenapiRenderer.js +196 -161
- package/dist/cjs/src/serializer/SerializerRenderer.js +134 -123
- package/dist/cjs/src/serializer/builders/DreamSerializerBuilder.js +10 -8
- package/dist/cjs/src/serializer/builders/ObjectSerializerBuilder.js +10 -8
- package/dist/esm/src/errors/serializers/AttemptedToDeriveDescendentSerializersFromNonSerializer.js +1 -1
- package/dist/esm/src/errors/serializers/ExpectedSerializerForRendersOneOrManyOption.js +33 -0
- package/dist/esm/src/errors/serializers/ObjectSerializerRendersOneAndManyRequireClassType.js +1 -1
- package/dist/esm/src/helpers/cloneDeepSafe.js +13 -12
- package/dist/esm/src/helpers/groupBy.js +8 -0
- package/dist/esm/src/helpers/sortObjectByValue.js +13 -0
- package/dist/esm/src/index.js +3 -0
- package/dist/esm/src/openapi/allSerializersToRefsInOpenapi.js +6 -6
- package/dist/esm/src/serializer/SerializerOpenapiRenderer.js +196 -161
- package/dist/esm/src/serializer/SerializerRenderer.js +134 -123
- package/dist/esm/src/serializer/builders/DreamSerializerBuilder.js +10 -8
- package/dist/esm/src/serializer/builders/ObjectSerializerBuilder.js +10 -8
- package/dist/types/src/errors/serializers/ExpectedSerializerForRendersOneOrManyOption.d.ts +8 -0
- package/dist/types/src/helpers/cloneDeepSafe.d.ts +9 -10
- package/dist/types/src/helpers/groupBy.d.ts +1 -0
- package/dist/types/src/helpers/sortObjectByValue.d.ts +3 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/openapi/allSerializersToRefsInOpenapi.d.ts +1 -1
- package/dist/types/src/serializer/SerializerOpenapiRenderer.d.ts +2 -4
- package/dist/types/src/serializer/builders/DreamSerializerBuilder.d.ts +8 -12
- package/dist/types/src/serializer/builders/ObjectSerializerBuilder.d.ts +8 -12
- package/dist/types/src/types/serializer.d.ts +6 -2
- package/dist/types/src/types/serializer.ts +6 -5
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Benchmark.html +2 -2
- package/docs/classes/CalendarDate.html +2 -2
- package/docs/classes/CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/Decorators.html +19 -19
- package/docs/classes/Dream.html +131 -131
- package/docs/classes/DreamApp.html +4 -4
- package/docs/classes/DreamBin.html +2 -2
- package/docs/classes/DreamCLI.html +4 -4
- package/docs/classes/DreamImporter.html +2 -2
- package/docs/classes/DreamLogos.html +2 -2
- package/docs/classes/DreamMigrationHelpers.html +7 -7
- package/docs/classes/DreamSerializerBuilder.html +2 -6
- 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/ObjectSerializerBuilder.html +2 -6
- package/docs/classes/Query.html +51 -51
- package/docs/classes/Range.html +2 -2
- package/docs/classes/RecordNotFound.html +3 -3
- package/docs/classes/SerializerOpenapiRenderer.html +2 -2
- package/docs/classes/ValidationError.html +3 -3
- package/docs/functions/DreamSerializer.html +1 -1
- package/docs/functions/ObjectSerializer.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/cloneDeepSafe.html +9 -0
- package/docs/functions/closeAllDbConnections.html +1 -1
- package/docs/functions/compact.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/groupBy.html +1 -0
- package/docs/functions/hyphenize.html +1 -1
- package/docs/functions/inferSerializerFromDreamOrViewModel.html +1 -1
- package/docs/functions/inferSerializersFromDreamClassOrViewModelClass.html +1 -1
- package/docs/functions/intersection.html +1 -1
- package/docs/functions/isDreamSerializer.html +1 -1
- package/docs/functions/isEmpty.html +1 -1
- package/docs/functions/isOpenapiShorthand.html +1 -1
- package/docs/functions/loadRepl.html +1 -1
- package/docs/functions/lookupClassByGlobalName.html +1 -1
- package/docs/functions/maybeNullOpenapiShorthandToOpenapiShorthand.html +1 -1
- package/docs/functions/openapiShorthandToOpenapi.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/sortObjectByKey.html +1 -1
- package/docs/functions/sortObjectByValue.html +1 -0
- package/docs/functions/standardizeFullyQualifiedModelName.html +1 -1
- package/docs/functions/uncapitalize.html +1 -1
- package/docs/functions/uniq.html +1 -1
- package/docs/functions/untypedDb.html +1 -1
- package/docs/functions/validateColumn.html +1 -1
- package/docs/functions/validateTable.html +1 -1
- package/docs/interfaces/DecoratorContext.html +2 -2
- package/docs/interfaces/DreamAppInitOptions.html +2 -2
- package/docs/interfaces/DreamAppOpts.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/interfaces/SerializerRendererOpts.html +2 -0
- package/docs/modules.html +4 -0
- package/docs/types/Camelized.html +1 -1
- package/docs/types/CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/DateTime.html +1 -1
- package/docs/types/DbConnectionType.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/DreamModelSerializerType.html +1 -1
- package/docs/types/DreamOrViewModelClassSerializerArrayKeys.html +1 -1
- package/docs/types/DreamOrViewModelClassSerializerKey.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/DreamSerializable.html +1 -1
- package/docs/types/DreamSerializableArray.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/OpenapiPrimitiveBaseTypes.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/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/OpenapiShorthandPrimitiveBaseTypes.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/SerializerCasing.html +1 -1
- package/docs/types/SimpleObjectSerializerType.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/ViewModel.html +1 -1
- package/docs/types/ViewModelClass.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
- package/dist/cjs/src/errors/serializers/SerializerInsteadOfSerializerCallback.js +0 -49
- package/dist/esm/src/errors/serializers/SerializerInsteadOfSerializerCallback.js +0 -46
- package/dist/types/src/errors/serializers/SerializerInsteadOfSerializerCallback.d.ts +0 -8
package/dist/cjs/src/errors/serializers/AttemptedToDeriveDescendentSerializersFromNonSerializer.js
CHANGED
|
@@ -9,7 +9,7 @@ class AttemptedToDeriveDescendentSerializersFromNonSerializer extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
get message() {
|
|
11
11
|
return `
|
|
12
|
-
Attempted to derive
|
|
12
|
+
Attempted to derive descendant serializers from non serializer:
|
|
13
13
|
${(0, node_util_1.inspect)(this.serializer)}`;
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class ExpectedSerializerForRendersOneOrManyOption extends Error {
|
|
4
|
+
rendersOneOrMany;
|
|
5
|
+
referencingSerializerName;
|
|
6
|
+
attribute;
|
|
7
|
+
constructor(rendersOneOrMany, referencingSerializerName, attribute) {
|
|
8
|
+
super();
|
|
9
|
+
this.rendersOneOrMany = rendersOneOrMany;
|
|
10
|
+
this.referencingSerializerName = referencingSerializerName;
|
|
11
|
+
this.attribute = attribute;
|
|
12
|
+
}
|
|
13
|
+
get message() {
|
|
14
|
+
const baseString = `
|
|
15
|
+
The \`serializer\` option on the \`${this.attribute.name}\` \`${this.rendersOneOrMany}\`
|
|
16
|
+
on serializer \`${this.referencingSerializerName}\``;
|
|
17
|
+
if (this.attribute.options?.serializer) {
|
|
18
|
+
return `${baseString}
|
|
19
|
+
specifies something other than a serializer.
|
|
20
|
+
It should look something like the following:
|
|
21
|
+
|
|
22
|
+
\`\`\`
|
|
23
|
+
.${this.rendersOneOrMany}('${this.attribute.name}', {
|
|
24
|
+
serializer: MySerializer
|
|
25
|
+
})
|
|
26
|
+
\`\`\`
|
|
27
|
+
`;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return `${baseString}
|
|
31
|
+
is throwing an error.
|
|
32
|
+
`;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.default = ExpectedSerializerForRendersOneOrManyOption;
|
package/dist/cjs/src/errors/serializers/ObjectSerializerRendersOneAndManyRequireClassType.js
CHANGED
|
@@ -10,7 +10,7 @@ class ObjectSerializerRendersOneAndManyRequireClassType extends Error {
|
|
|
10
10
|
return `
|
|
11
11
|
ObjectSerializer \`rendersOne\` and \`rendersMany\`
|
|
12
12
|
options must include \`dreamClass\`, \`viewModelClass\`, or
|
|
13
|
-
\`
|
|
13
|
+
\`serializer\`.
|
|
14
14
|
|
|
15
15
|
rendersOne/Many name: ${this.associationName}
|
|
16
16
|
`;
|
|
@@ -8,18 +8,17 @@ const DateTime_js_1 = require("./DateTime.js");
|
|
|
8
8
|
const range_js_1 = require("./range.js");
|
|
9
9
|
const typechecks_js_1 = require("./typechecks.js");
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Accepts any value and returns a valid clone of that object.
|
|
12
|
+
* Dream instances, Query instances, and other special types are
|
|
13
|
+
* automatically cloned using their specialized cloning methods.
|
|
12
14
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* will
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param original - the value to clone
|
|
19
|
-
* @param includePrimaryKey - Whether or not to copy the primary key when cloning a dream instance
|
|
20
|
-
* @returns Either a clone, or else the original value
|
|
15
|
+
* @param original - The value to clone
|
|
16
|
+
* @param unsupportedTypeCloneFunction - Optional function to handle cloning of unsupported types.
|
|
17
|
+
* If not provided, an error will be thrown for unsupported types.
|
|
18
|
+
* @returns Either a clone of the original value, or the original value itself for immutable types
|
|
19
|
+
* @throws {TypeUnsupportedByClone} When an unsupported type is encountered and no unsupportedTypeCloneFunction is provided
|
|
21
20
|
*/
|
|
22
|
-
function cloneDeepSafe(original) {
|
|
21
|
+
function cloneDeepSafe(original, unsupportedTypeCloneFunction) {
|
|
23
22
|
if (original === undefined)
|
|
24
23
|
return original;
|
|
25
24
|
if (original === null)
|
|
@@ -43,12 +42,14 @@ function cloneDeepSafe(original) {
|
|
|
43
42
|
if (original?.isSelectQueryBuilder)
|
|
44
43
|
return original;
|
|
45
44
|
if (Array.isArray(original))
|
|
46
|
-
return original.map(value => cloneDeepSafe(value));
|
|
45
|
+
return original.map(value => cloneDeepSafe(value, unsupportedTypeCloneFunction));
|
|
47
46
|
if ((0, typechecks_js_1.isObject)(original) && original.constructor.name === 'Object') {
|
|
48
47
|
const clone = { ...original };
|
|
49
|
-
Object.keys(clone).forEach(key => (clone[key] = cloneDeepSafe(clone[key])));
|
|
48
|
+
Object.keys(clone).forEach(key => (clone[key] = cloneDeepSafe(clone[key], unsupportedTypeCloneFunction)));
|
|
50
49
|
return clone;
|
|
51
50
|
}
|
|
51
|
+
if (unsupportedTypeCloneFunction)
|
|
52
|
+
return unsupportedTypeCloneFunction(original);
|
|
52
53
|
throw new TypeUnsupportedByClone(original);
|
|
53
54
|
}
|
|
54
55
|
class TypeUnsupportedByClone extends Error {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = groupBy;
|
|
4
|
+
function groupBy(arr, toKey) {
|
|
5
|
+
return arr.reduce((acc, val) => {
|
|
6
|
+
const key = toKey(val);
|
|
7
|
+
acc[key] ||= [];
|
|
8
|
+
acc[key].push(val);
|
|
9
|
+
return acc;
|
|
10
|
+
}, {});
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = sortObjectByValue;
|
|
4
|
+
const sortBy_js_1 = require("./sortBy.js");
|
|
5
|
+
function sortObjectByValue(obj, valueToCompare = x => x) {
|
|
6
|
+
const tuples = Object.entries(obj);
|
|
7
|
+
const sortedTuples = (0, sortBy_js_1.default)(tuples, (tuple) => {
|
|
8
|
+
const t = tuple[1];
|
|
9
|
+
return valueToCompare(t);
|
|
10
|
+
});
|
|
11
|
+
return sortedTuples.reduce((accumulator, tuple) => {
|
|
12
|
+
;
|
|
13
|
+
accumulator[tuple[0]] = tuple[1];
|
|
14
|
+
return accumulator;
|
|
15
|
+
}, {});
|
|
16
|
+
}
|
package/dist/cjs/src/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ObjectSerializerBuilder = exports.DreamSerializerBuilder = exports.ObjectSerializer = exports.DreamSerializer = exports.SerializerOpenapiRenderer = exports.serializerNameFromFullyQualifiedModelName = exports.isDreamSerializer = exports.inferSerializersFromDreamClassOrViewModelClass = exports.inferSerializerFromDreamOrViewModel = exports.ops = exports.openapiShorthandToOpenapi = exports.maybeNullOpenapiShorthandToOpenapiShorthand = exports.isOpenapiShorthand = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortObjectByKey = exports.sortBy = exports.sort = void 0;
|
|
3
|
+
exports.range = exports.Range = exports.sharedPathPrefix = exports.relativeDreamPath = exports.dreamPath = exports.pascalize = exports.loadRepl = exports.isEmpty = exports.intersection = exports.hyphenize = exports.groupBy = exports.globalClassNameFromFullyQualifiedModelName = exports.Env = exports.DreamLogos = exports.DateTime = exports.compact = exports.cloneDeepSafe = exports.generateDream = exports.capitalize = exports.camelize = exports.CalendarDate = exports.Benchmark = exports.ValidationError = exports.RecordNotFound = exports.GlobalNameNotSet = exports.CreateOrFindByFailedToCreateAndFind = exports.NonLoadedAssociation = exports.Encrypt = exports.Query = exports.DreamTransaction = exports.openapiShorthandPrimitiveTypes = exports.openapiPrimitiveTypes = exports.DreamConst = exports.Dream = exports.DreamApp = exports.lookupClassByGlobalName = exports.DreamImporter = exports.Decorators = exports.STI = exports.SoftDelete = exports.ReplicaSafe = exports.validateTable = exports.validateColumn = exports.DreamMigrationHelpers = exports.untypedDb = exports.pgErrorType = exports.dreamDbConnections = exports.closeAllDbConnections = exports.DreamCLI = exports.DreamBin = void 0;
|
|
4
|
+
exports.ObjectSerializerBuilder = exports.DreamSerializerBuilder = exports.ObjectSerializer = exports.DreamSerializer = exports.SerializerOpenapiRenderer = exports.serializerNameFromFullyQualifiedModelName = exports.isDreamSerializer = exports.inferSerializersFromDreamClassOrViewModelClass = exports.inferSerializerFromDreamOrViewModel = exports.ops = exports.openapiShorthandToOpenapi = exports.maybeNullOpenapiShorthandToOpenapiShorthand = exports.isOpenapiShorthand = exports.uniq = exports.uncapitalize = exports.standardizeFullyQualifiedModelName = exports.sortObjectByValue = exports.sortObjectByKey = exports.sortBy = exports.sort = exports.snakeify = exports.round = void 0;
|
|
5
5
|
var index_js_1 = require("./bin/index.js");
|
|
6
6
|
Object.defineProperty(exports, "DreamBin", { enumerable: true, get: function () { return index_js_1.default; } });
|
|
7
7
|
var index_js_2 = require("./cli/index.js");
|
|
@@ -65,6 +65,8 @@ var capitalize_js_1 = require("./helpers/capitalize.js");
|
|
|
65
65
|
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return capitalize_js_1.default; } });
|
|
66
66
|
var generateDream_js_1 = require("./helpers/cli/generateDream.js");
|
|
67
67
|
Object.defineProperty(exports, "generateDream", { enumerable: true, get: function () { return generateDream_js_1.default; } });
|
|
68
|
+
var cloneDeepSafe_js_1 = require("./helpers/cloneDeepSafe.js");
|
|
69
|
+
Object.defineProperty(exports, "cloneDeepSafe", { enumerable: true, get: function () { return cloneDeepSafe_js_1.default; } });
|
|
68
70
|
var compact_js_1 = require("./helpers/compact.js");
|
|
69
71
|
Object.defineProperty(exports, "compact", { enumerable: true, get: function () { return compact_js_1.default; } });
|
|
70
72
|
var DateTime_js_1 = require("./helpers/DateTime.js");
|
|
@@ -75,6 +77,8 @@ var Env_js_1 = require("./helpers/Env.js");
|
|
|
75
77
|
Object.defineProperty(exports, "Env", { enumerable: true, get: function () { return Env_js_1.default; } });
|
|
76
78
|
var globalClassNameFromFullyQualifiedModelName_js_1 = require("./helpers/globalClassNameFromFullyQualifiedModelName.js");
|
|
77
79
|
Object.defineProperty(exports, "globalClassNameFromFullyQualifiedModelName", { enumerable: true, get: function () { return globalClassNameFromFullyQualifiedModelName_js_1.default; } });
|
|
80
|
+
var groupBy_js_1 = require("./helpers/groupBy.js");
|
|
81
|
+
Object.defineProperty(exports, "groupBy", { enumerable: true, get: function () { return groupBy_js_1.default; } });
|
|
78
82
|
var hyphenize_js_1 = require("./helpers/hyphenize.js");
|
|
79
83
|
Object.defineProperty(exports, "hyphenize", { enumerable: true, get: function () { return hyphenize_js_1.default; } });
|
|
80
84
|
var intersection_js_1 = require("./helpers/intersection.js");
|
|
@@ -104,6 +108,8 @@ var sortBy_js_1 = require("./helpers/sortBy.js");
|
|
|
104
108
|
Object.defineProperty(exports, "sortBy", { enumerable: true, get: function () { return sortBy_js_1.default; } });
|
|
105
109
|
var sortObjectByKey_js_1 = require("./helpers/sortObjectByKey.js");
|
|
106
110
|
Object.defineProperty(exports, "sortObjectByKey", { enumerable: true, get: function () { return sortObjectByKey_js_1.default; } });
|
|
111
|
+
var sortObjectByValue_js_1 = require("./helpers/sortObjectByValue.js");
|
|
112
|
+
Object.defineProperty(exports, "sortObjectByValue", { enumerable: true, get: function () { return sortObjectByValue_js_1.default; } });
|
|
107
113
|
var standardizeFullyQualifiedModelName_js_1 = require("./helpers/standardizeFullyQualifiedModelName.js");
|
|
108
114
|
Object.defineProperty(exports, "standardizeFullyQualifiedModelName", { enumerable: true, get: function () { return standardizeFullyQualifiedModelName_js_1.default; } });
|
|
109
115
|
var uncapitalize_js_1 = require("./helpers/uncapitalize.js");
|
|
@@ -3,18 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.default = allSerializersToRefsInOpenapi;
|
|
4
4
|
const typechecks_js_1 = require("../helpers/typechecks.js");
|
|
5
5
|
const SerializerOpenapiRenderer_js_1 = require("../serializer/SerializerOpenapiRenderer.js");
|
|
6
|
-
function allSerializersToRefsInOpenapi(openapi
|
|
6
|
+
function allSerializersToRefsInOpenapi(openapi) {
|
|
7
7
|
if (!openapi)
|
|
8
8
|
return {};
|
|
9
|
-
return transformValue(openapi
|
|
9
|
+
return transformValue(openapi);
|
|
10
10
|
}
|
|
11
|
-
function transformValue(value
|
|
11
|
+
function transformValue(value) {
|
|
12
12
|
if (!value)
|
|
13
13
|
return value;
|
|
14
14
|
// If this is an object with a $serializer property, replace it with $ref
|
|
15
15
|
if (value.$serializer) {
|
|
16
16
|
const { $serializer, ...rest } = value;
|
|
17
|
-
const openapiRenderer = new SerializerOpenapiRenderer_js_1.default($serializer
|
|
17
|
+
const openapiRenderer = new SerializerOpenapiRenderer_js_1.default($serializer).serializerRef;
|
|
18
18
|
return {
|
|
19
19
|
...rest,
|
|
20
20
|
...openapiRenderer,
|
|
@@ -24,14 +24,14 @@ function transformValue(value, schemaDelimiter) {
|
|
|
24
24
|
// Recurse into objects
|
|
25
25
|
const transformed = {};
|
|
26
26
|
for (const [key, val] of Object.entries(value)) {
|
|
27
|
-
transformed[key] = transformValue(val
|
|
27
|
+
transformed[key] = transformValue(val);
|
|
28
28
|
}
|
|
29
29
|
return transformed;
|
|
30
30
|
//
|
|
31
31
|
}
|
|
32
32
|
else if (Array.isArray(value)) {
|
|
33
33
|
// Recurse into arrays
|
|
34
|
-
return value.map(val => transformValue(val
|
|
34
|
+
return value.map(val => transformValue(val));
|
|
35
35
|
//
|
|
36
36
|
}
|
|
37
37
|
else {
|