axe-api 0.30.0-rc11 → 0.30.0-rc12
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.
|
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
const AxeError_1 = __importDefault(require("../Exceptions/AxeError"));
|
|
16
16
|
const Enums_1 = require("../Enums");
|
|
17
17
|
const Services_1 = require("../Services");
|
|
18
|
+
const constants_1 = require("../constants");
|
|
18
19
|
const COLUMN_BASED_QUERY_LIMITS = [
|
|
19
20
|
Enums_1.QueryFeature.Sorting,
|
|
20
21
|
Enums_1.QueryFeature.WhereEqual,
|
|
@@ -52,7 +53,7 @@ class SchemaValidatorService {
|
|
|
52
53
|
if (!key) {
|
|
53
54
|
return "";
|
|
54
55
|
}
|
|
55
|
-
const [, field] = key
|
|
56
|
+
const [, field] = key.split(".");
|
|
56
57
|
return field;
|
|
57
58
|
});
|
|
58
59
|
return items;
|
|
@@ -120,6 +121,7 @@ class SchemaValidatorService {
|
|
|
120
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
122
|
const logger = Services_1.LogService.getInstance();
|
|
122
123
|
this.version.modelList.get().forEach((model) => {
|
|
124
|
+
this.checkModelReservedKeywordsOrFail(model);
|
|
123
125
|
this.checkModelColumnsOrFail(model, this.getModelFillableColumns(model));
|
|
124
126
|
this.checkModelColumnsOrFail(model, this.getModelFormValidationColumns(model));
|
|
125
127
|
this.checkModelColumnsOrFail(model, this.getModelHiddenColumns(model));
|
|
@@ -132,6 +134,22 @@ class SchemaValidatorService {
|
|
|
132
134
|
logger.info(`[${this.version.name}] Database schema has been validated.`);
|
|
133
135
|
});
|
|
134
136
|
}
|
|
137
|
+
checkModelReservedKeywordsOrFail(model) {
|
|
138
|
+
const reservedKeywords = [];
|
|
139
|
+
constants_1.RESERVED_KEYWORDS.forEach((keyword) => {
|
|
140
|
+
if (model.columnNames.includes(keyword) ||
|
|
141
|
+
model.name.toLowerCase().includes(keyword)) {
|
|
142
|
+
reservedKeywords.push(keyword);
|
|
143
|
+
}
|
|
144
|
+
for (const relation of model.relations) {
|
|
145
|
+
if (relation.name === keyword)
|
|
146
|
+
reservedKeywords.push(relation.name);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
if (reservedKeywords.length > 0) {
|
|
150
|
+
throw new Error(`The following keywords are reserved for the framework; "${reservedKeywords.join(",")}"`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
135
153
|
checkModelColumnsOrFail(model, modelColumns) {
|
|
136
154
|
const undefinedColumns = modelColumns.filter((modelColumn) => !model.columnNames.includes(modelColumn));
|
|
137
155
|
if (undefinedColumns.length > 0) {
|
package/build/src/constants.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const LOG_COLORS: {
|
|
|
11
11
|
fgWhite: string;
|
|
12
12
|
fgReset: string;
|
|
13
13
|
};
|
|
14
|
+
export declare const RESERVED_KEYWORDS: string[];
|
|
14
15
|
export declare const DEFAULT_HANDLERS: HandlerTypes[];
|
|
15
16
|
export declare const DEFAULT_METHODS_OF_MODELS: string[];
|
|
16
17
|
export declare const API_ROUTE_TEMPLATES: {
|
package/build/src/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_VERSION_CONFIG = exports.RelationQueryFeatureMap = exports.ConditionQueryFeatureMap = exports.API_ROUTE_TEMPLATES = exports.DEFAULT_METHODS_OF_MODELS = exports.DEFAULT_HANDLERS = exports.LOG_COLORS = void 0;
|
|
3
|
+
exports.DEFAULT_VERSION_CONFIG = exports.RelationQueryFeatureMap = exports.ConditionQueryFeatureMap = exports.API_ROUTE_TEMPLATES = exports.DEFAULT_METHODS_OF_MODELS = exports.DEFAULT_HANDLERS = exports.RESERVED_KEYWORDS = exports.LOG_COLORS = void 0;
|
|
4
4
|
const Enums_1 = require("./Enums");
|
|
5
5
|
const LimitService_1 = require("./Services/LimitService");
|
|
6
6
|
exports.LOG_COLORS = {
|
|
@@ -14,6 +14,17 @@ exports.LOG_COLORS = {
|
|
|
14
14
|
fgWhite: "\x1b[37m",
|
|
15
15
|
fgReset: "\x1b[0m",
|
|
16
16
|
};
|
|
17
|
+
exports.RESERVED_KEYWORDS = [
|
|
18
|
+
"force",
|
|
19
|
+
"model",
|
|
20
|
+
"api",
|
|
21
|
+
"routes",
|
|
22
|
+
"docs",
|
|
23
|
+
"hook",
|
|
24
|
+
"hooks",
|
|
25
|
+
"event",
|
|
26
|
+
"events",
|
|
27
|
+
];
|
|
17
28
|
exports.DEFAULT_HANDLERS = [
|
|
18
29
|
Enums_1.HandlerTypes.INSERT,
|
|
19
30
|
Enums_1.HandlerTypes.PAGINATE,
|
package/package.json
CHANGED