axe-api 1.1.0 → 1.2.0
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.
|
@@ -181,13 +181,105 @@ export interface IContext extends IRouteData {
|
|
|
181
181
|
isTransactionOpen: boolean;
|
|
182
182
|
validator: IValidator;
|
|
183
183
|
queryParser?: QueryService;
|
|
184
|
+
params?: any;
|
|
185
|
+
/**
|
|
186
|
+
* @deprecated Use special hook type instead of IContext like IBeforeInsertContext
|
|
187
|
+
*/
|
|
184
188
|
conditions?: IQuery;
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated Use special hook type instead of IContext like IBeforeInsertContext
|
|
191
|
+
*/
|
|
185
192
|
query?: Knex.QueryBuilder;
|
|
186
|
-
|
|
193
|
+
/**
|
|
194
|
+
* @deprecated Use special hook type instead of IContext like IBeforeInsertContext
|
|
195
|
+
*/
|
|
187
196
|
result?: any;
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated Use special hook type instead of IContext like IBeforeInsertContext
|
|
199
|
+
*/
|
|
188
200
|
item?: any;
|
|
201
|
+
/**
|
|
202
|
+
* @deprecated Use special hook type instead of IContext like IBeforeInsertContext
|
|
203
|
+
*/
|
|
189
204
|
formData?: any;
|
|
190
205
|
}
|
|
206
|
+
export interface IBeforeInsertContext extends IContext {
|
|
207
|
+
formData: any;
|
|
208
|
+
}
|
|
209
|
+
export interface IBeforeUpdateQueryContext extends IContext {
|
|
210
|
+
query: Knex.QueryBuilder;
|
|
211
|
+
}
|
|
212
|
+
export interface IBeforeUpdateContext extends IContext {
|
|
213
|
+
query: Knex.QueryBuilder;
|
|
214
|
+
item: any;
|
|
215
|
+
formData: any;
|
|
216
|
+
}
|
|
217
|
+
export interface IBeforeDeleteQueryContext extends IContext {
|
|
218
|
+
query: Knex.QueryBuilder;
|
|
219
|
+
}
|
|
220
|
+
export interface IBeforeDeleteContext extends IContext {
|
|
221
|
+
query: Knex.QueryBuilder;
|
|
222
|
+
}
|
|
223
|
+
export interface IBeforeForceDeleteQueryContext extends IContext {
|
|
224
|
+
query: Knex.QueryBuilder;
|
|
225
|
+
}
|
|
226
|
+
export interface IBeforeForceDeleteContext extends IContext {
|
|
227
|
+
query: Knex.QueryBuilder;
|
|
228
|
+
}
|
|
229
|
+
export interface IBeforePaginateContext extends IContext {
|
|
230
|
+
query: Knex.QueryBuilder;
|
|
231
|
+
conditions: IQuery;
|
|
232
|
+
}
|
|
233
|
+
export interface IBeforeAllContext extends IContext {
|
|
234
|
+
query: Knex.QueryBuilder;
|
|
235
|
+
conditions: IQuery;
|
|
236
|
+
}
|
|
237
|
+
export interface IBeforeShowContext extends IContext {
|
|
238
|
+
query: Knex.QueryBuilder;
|
|
239
|
+
conditions: IQuery;
|
|
240
|
+
}
|
|
241
|
+
export interface IAfterInsertContext extends IContext {
|
|
242
|
+
item: any;
|
|
243
|
+
formData: any;
|
|
244
|
+
}
|
|
245
|
+
export interface IAfterUpdateQueryContext extends IContext {
|
|
246
|
+
query: Knex.QueryBuilder;
|
|
247
|
+
item: any;
|
|
248
|
+
}
|
|
249
|
+
export interface IAfterUpdateContext extends IContext {
|
|
250
|
+
query: Knex.QueryBuilder;
|
|
251
|
+
item: any;
|
|
252
|
+
formData: any;
|
|
253
|
+
}
|
|
254
|
+
export interface IAfterDeleteQueryContext extends IContext {
|
|
255
|
+
query: Knex.QueryBuilder;
|
|
256
|
+
item: any;
|
|
257
|
+
}
|
|
258
|
+
export interface IAfterDeleteContext extends IContext {
|
|
259
|
+
item: any;
|
|
260
|
+
}
|
|
261
|
+
export interface IAfterForceDeleteQueryContext extends IContext {
|
|
262
|
+
query: Knex.QueryBuilder;
|
|
263
|
+
item: any;
|
|
264
|
+
}
|
|
265
|
+
export interface IAfterForceDeleteContext extends IContext {
|
|
266
|
+
item: any;
|
|
267
|
+
}
|
|
268
|
+
export interface IAfterPaginateContext extends IContext {
|
|
269
|
+
query: Knex.QueryBuilder;
|
|
270
|
+
conditions: IQuery;
|
|
271
|
+
result: any;
|
|
272
|
+
}
|
|
273
|
+
export interface IAfterAllContext extends IContext {
|
|
274
|
+
query: Knex.QueryBuilder;
|
|
275
|
+
conditions: IQuery;
|
|
276
|
+
result: any;
|
|
277
|
+
}
|
|
278
|
+
export interface IAfterShowContext extends IContext {
|
|
279
|
+
query: Knex.QueryBuilder;
|
|
280
|
+
conditions: IQuery;
|
|
281
|
+
item: any;
|
|
282
|
+
}
|
|
191
283
|
export interface IRouteDocumentation {
|
|
192
284
|
version: string;
|
|
193
285
|
handler: string;
|
|
@@ -191,9 +191,22 @@ class ModelResolver {
|
|
|
191
191
|
const fileResolver = new FileResolver_1.default();
|
|
192
192
|
const serializations = yield fileResolver.resolveContent(this.version.folders.serialization);
|
|
193
193
|
for (const model of modelList.get()) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
// Old serialization
|
|
195
|
+
const oldName = `${model.name}Serialization`;
|
|
196
|
+
let isOldNamingUsed = false;
|
|
197
|
+
if (serializations[oldName]) {
|
|
198
|
+
isOldNamingUsed = true;
|
|
199
|
+
const file = serializations[oldName];
|
|
200
|
+
model.setSerialization(file.default);
|
|
201
|
+
Services_1.LogService.warn(`'${oldName}.ts' naming is deprecated. You can use '${oldName.replace("Serialization", "")}.ts' instead.`);
|
|
202
|
+
}
|
|
203
|
+
// New
|
|
204
|
+
const newName = `${model.name}`;
|
|
205
|
+
if (serializations[newName]) {
|
|
206
|
+
if (isOldNamingUsed) {
|
|
207
|
+
throw new Error(`You cannot use '${oldName}.ts' and '${newName}.ts' at the same time.`);
|
|
208
|
+
}
|
|
209
|
+
const file = serializations[newName];
|
|
197
210
|
model.setSerialization(file.default);
|
|
198
211
|
}
|
|
199
212
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axe-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "AXE API is a simple tool to create Rest APIs quickly.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,8 +29,7 @@
|
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "rm -rf build && tsc && rm -rf build/dev-kit",
|
|
31
31
|
"build:watch": "tsc -w",
|
|
32
|
-
"dev": "
|
|
33
|
-
"dev-kit": "ts-node-dev --respawn --clear dev-kit.ts",
|
|
32
|
+
"dev-kit": "tsx watch dev-kit.ts",
|
|
34
33
|
"dev-kit:install": "node ./scripts/dev-kit-install.js",
|
|
35
34
|
"dev-kit:remove": "node ./scripts/dev-kit-remove.js",
|
|
36
35
|
"test": "jest --runInBand",
|
|
@@ -107,13 +106,13 @@
|
|
|
107
106
|
"pg": "^8.11.3",
|
|
108
107
|
"prettier": "^3.2.5",
|
|
109
108
|
"redis": "^4.6.13",
|
|
109
|
+
"robust-validator": "^1.1.0",
|
|
110
110
|
"serve-static": "^1.15.0",
|
|
111
111
|
"set-value": ">=4.1.0",
|
|
112
112
|
"sqlite3": "^5.1.7",
|
|
113
113
|
"ts-node": "^10.9.2",
|
|
114
|
-
"
|
|
115
|
-
"typescript": "^5.3.3"
|
|
116
|
-
"robust-validator": "^1.1.0"
|
|
114
|
+
"tsx": "^4.7.1",
|
|
115
|
+
"typescript": "^5.3.3"
|
|
117
116
|
},
|
|
118
117
|
"lint-staged": {
|
|
119
118
|
"**/*": "prettier --write --ignore-unknown"
|