identity-admin 1.26.16 → 1.26.18
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.
|
@@ -671,10 +671,10 @@ let DashboardController = DashboardController_1 = class DashboardController {
|
|
|
671
671
|
: undefined;
|
|
672
672
|
var neighbor;
|
|
673
673
|
if (neighborRecordType === helpers_1.NeighborTypes.NEXT) {
|
|
674
|
-
neighbor = yield (model === null || model === void 0 ? void 0 : model.findOne(handler ? handler(req, nextQuery, currentUser, neighborRecordType) : nextQuery).sort(nextSortQuery).limit(1));
|
|
674
|
+
neighbor = yield (model === null || model === void 0 ? void 0 : model.findOne(handler ? yield handler(req, nextQuery, currentUser, neighborRecordType) : nextQuery).sort(nextSortQuery).limit(1));
|
|
675
675
|
}
|
|
676
676
|
else {
|
|
677
|
-
neighbor = yield (model === null || model === void 0 ? void 0 : model.findOne(handler ? handler(req, prevQuery, currentUser, neighborRecordType) : prevQuery).sort(previousSortQuery).limit(1));
|
|
677
|
+
neighbor = yield (model === null || model === void 0 ? void 0 : model.findOne(handler ? yield handler(req, prevQuery, currentUser, neighborRecordType) : prevQuery).sort(previousSortQuery).limit(1));
|
|
678
678
|
}
|
|
679
679
|
const hasNeighbor = record && neighbor && neighbor._id ? true : false;
|
|
680
680
|
const neighborRecordId = hasNeighbor ? neighbor._id : undefined;
|
|
@@ -54,7 +54,7 @@ class ResourceGenerator {
|
|
|
54
54
|
? JSON.parse(JSON.stringify(resource.properties.model))
|
|
55
55
|
: undefined;
|
|
56
56
|
const actionsCheck = resource.properties.actions;
|
|
57
|
-
const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource);
|
|
57
|
+
const modelAndPopulatedString = SchemaGenerator_1.default.generateSchema(schema, modelCheck, modelName, resource, configurations);
|
|
58
58
|
modifiedResource.properties.model = modelAndPopulatedString[0];
|
|
59
59
|
modifiedResource.properties.populatedString = modelAndPopulatedString[1];
|
|
60
60
|
const modifiedProperties = ResourceHelper_1.default.addVirtualFields(JSON.parse(JSON.stringify(recordFields)), modelCheck);
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { IResourceFile } from
|
|
1
|
+
import { IResourceFile } from '../types/IResourceFile';
|
|
2
|
+
import { IConfiguartionFile } from '../types/IConfigurationFile';
|
|
2
3
|
export default class SchemaGenerator {
|
|
3
|
-
static generateSchema(schema: any, model: any, modelName: string, resource: IResourceFile): any[];
|
|
4
|
+
static generateSchema(schema: any, model: any, modelName: string, resource: IResourceFile, configurations?: IConfiguartionFile): any[];
|
|
4
5
|
private static setNestedSchema;
|
|
6
|
+
private static getRefPath;
|
|
5
7
|
}
|
|
@@ -8,13 +8,13 @@ const ResourceHelper_1 = __importDefault(require("./ResourceHelper"));
|
|
|
8
8
|
const helpers_1 = require("../types/helpers");
|
|
9
9
|
var pluralize = require('pluralize');
|
|
10
10
|
class SchemaGenerator {
|
|
11
|
-
static generateSchema(schema, model, modelName, resource) {
|
|
11
|
+
static generateSchema(schema, model, modelName, resource, configurations) {
|
|
12
12
|
const schemaFields = Object.keys(schema);
|
|
13
13
|
var populatedString = '';
|
|
14
14
|
if (!model) {
|
|
15
15
|
model = {};
|
|
16
16
|
}
|
|
17
|
-
schemaFields.forEach(field => {
|
|
17
|
+
schemaFields.forEach((field) => {
|
|
18
18
|
const schemaField = schema[field];
|
|
19
19
|
const refCheck = schemaField.options.ref;
|
|
20
20
|
const translation = ResourceHelper_1.default.checkResourceTranslation(resource, field);
|
|
@@ -47,7 +47,7 @@ class SchemaGenerator {
|
|
|
47
47
|
else if (schema[field].caster.options.ref) {
|
|
48
48
|
populatedString = StringUtils_1.default.getPopulatedString(populatedString, field);
|
|
49
49
|
model[field].path = StringUtils_1.default.lowerCaseFirstLetter(schema[field].caster.options.ref);
|
|
50
|
-
model[field].apiRoute = model[field].apiRoute ? model[field].apiRoute :
|
|
50
|
+
model[field].apiRoute = model[field].apiRoute ? model[field].apiRoute : this.getRefPath(schema[field].caster.options.ref, configurations);
|
|
51
51
|
model[field].arrayType = model[field].arrayType ? model[field].arrayType : helpers_1.FieldTypes.REFERENCE;
|
|
52
52
|
}
|
|
53
53
|
else if (schema[field].caster.enumValues && schema[field].caster.enumValues.length > 0) {
|
|
@@ -61,9 +61,26 @@ class SchemaGenerator {
|
|
|
61
61
|
model[field].type = model[field].type ? model[field].type : fieldType;
|
|
62
62
|
model[field].defaultValue = schema[field].defaultValue ? schema[field].defaultValue : undefined;
|
|
63
63
|
model[field].required = model[field].required ? model[field].required : schemaField.isRequired ? schemaField.isRequired : false;
|
|
64
|
-
model[field].apiRoute = model[field].apiRoute
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
model[field].apiRoute = model[field].apiRoute
|
|
65
|
+
? model[field].apiRoute
|
|
66
|
+
: schemaField.options.ref
|
|
67
|
+
? this.getRefPath(schemaField.options.ref, configurations)
|
|
68
|
+
: undefined;
|
|
69
|
+
model[field].enumValues =
|
|
70
|
+
model[field].type === helpers_1.FieldTypes.ENUM || model[field].arrayType === helpers_1.FieldTypes.ENUM
|
|
71
|
+
? model[field].enumValues
|
|
72
|
+
? model[field].enumValues
|
|
73
|
+
: schemaField.enumValues
|
|
74
|
+
: undefined;
|
|
75
|
+
model[field].value = model[field].value
|
|
76
|
+
? model[field].value
|
|
77
|
+
: translation
|
|
78
|
+
? translation
|
|
79
|
+
: refCheck
|
|
80
|
+
? StringUtils_1.default.checkRefId(field)
|
|
81
|
+
? StringUtils_1.default.convertCamelCaseToWord(field.slice(0, -2))
|
|
82
|
+
: StringUtils_1.default.convertCamelCaseToWord(field)
|
|
83
|
+
: StringUtils_1.default.convertCamelCaseToWord(field);
|
|
67
84
|
model[field].isDraggable = model[field].isDraggable === false ? false : true;
|
|
68
85
|
});
|
|
69
86
|
if (model.virtuals) {
|
|
@@ -72,7 +89,9 @@ class SchemaGenerator {
|
|
|
72
89
|
model[extraField].type = model.virtuals[extraField].type;
|
|
73
90
|
model[extraField].arrayType = model.virtuals[extraField].arrayType ? model.virtuals[extraField].arrayType : undefined;
|
|
74
91
|
model[extraField].required = model.virtuals[extraField].required;
|
|
75
|
-
model[extraField].value = ResourceHelper_1.default.checkResourceTranslation(resource, extraField)
|
|
92
|
+
model[extraField].value = ResourceHelper_1.default.checkResourceTranslation(resource, extraField)
|
|
93
|
+
? ResourceHelper_1.default.checkResourceTranslation(resource, extraField)
|
|
94
|
+
: StringUtils_1.default.convertCamelCaseToWord(extraField);
|
|
76
95
|
model[extraField].path = StringUtils_1.default.getRefPath(extraField);
|
|
77
96
|
}
|
|
78
97
|
}
|
|
@@ -97,5 +116,15 @@ class SchemaGenerator {
|
|
|
97
116
|
model[field].keys = nestedSchemaKeys;
|
|
98
117
|
return [model, populatedString];
|
|
99
118
|
}
|
|
119
|
+
static getRefPath(refField, configurations) {
|
|
120
|
+
var baseApiUrl = 'admin/';
|
|
121
|
+
if (configurations && configurations.baseApiUrl) {
|
|
122
|
+
baseApiUrl = configurations.baseApiUrl;
|
|
123
|
+
if (!baseApiUrl.endsWith('/')) {
|
|
124
|
+
baseApiUrl += '/';
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return baseApiUrl + StringUtils_1.default.lowerCaseFirstLetter(pluralize(refField));
|
|
128
|
+
}
|
|
100
129
|
}
|
|
101
130
|
exports.default = SchemaGenerator;
|