@spinajs/orm-api 2.0.180 → 2.0.182
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/lib/cjs/PlainJsonCollectionTransformer.d.ts +8 -8
- package/lib/cjs/PlainJsonCollectionTransformer.js +29 -29
- package/lib/cjs/PlainJsonCollectionTransformer.js.map +1 -1
- package/lib/cjs/config/orm-api.d.ts +16 -16
- package/lib/cjs/config/orm-api.js +24 -24
- package/lib/cjs/controllers/JsonApi.js +244 -244
- package/lib/cjs/controllers/crud/Create.d.ts +15 -15
- package/lib/cjs/controllers/crud/Create.js +144 -144
- package/lib/cjs/controllers/crud/Create.js.map +1 -1
- package/lib/cjs/controllers/crud/Delete.d.ts +15 -15
- package/lib/cjs/controllers/crud/Delete.js +157 -157
- package/lib/cjs/controllers/crud/Delete.js.map +1 -1
- package/lib/cjs/controllers/crud/Read.d.ts +39 -39
- package/lib/cjs/controllers/crud/Read.js +226 -226
- package/lib/cjs/controllers/crud/Read.js.map +1 -1
- package/lib/cjs/controllers/crud/Update.d.ts +12 -12
- package/lib/cjs/controllers/crud/Update.js +98 -98
- package/lib/cjs/controllers/crud/Update.js.map +1 -1
- package/lib/cjs/dto/QueryArgs.d.ts +8 -8
- package/lib/cjs/dto/QueryArgs.js +27 -27
- package/lib/cjs/dto/QueryArgs.js.map +1 -1
- package/lib/cjs/dto/QueryFilter.d.ts +5 -5
- package/lib/cjs/dto/QueryFilter.js +30 -30
- package/lib/cjs/dto/QueryFilter.js.map +1 -1
- package/lib/cjs/dto/QueryIncludes.d.ts +4 -4
- package/lib/cjs/dto/QueryIncludes.js +30 -30
- package/lib/cjs/dto/QueryIncludes.js.map +1 -1
- package/lib/cjs/hydrators/QueryFilterHydrator.d.ts +4 -4
- package/lib/cjs/hydrators/QueryFilterHydrator.js +14 -14
- package/lib/cjs/hydrators/QueryIncludesHydrator.d.ts +4 -4
- package/lib/cjs/hydrators/QueryIncludesHydrator.js +20 -20
- package/lib/cjs/index.d.ts +28 -28
- package/lib/cjs/index.js +100 -100
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces.d.ts +41 -41
- package/lib/cjs/interfaces.js +49 -49
- package/lib/cjs/interfaces.js.map +1 -1
- package/lib/cjs/middleware.d.ts +21 -21
- package/lib/cjs/middleware.js +30 -30
- package/lib/cjs/policies/FindModelType.d.ts +7 -7
- package/lib/cjs/policies/FindModelType.js +42 -42
- package/lib/cjs/policies/FindModelType.js.map +1 -1
- package/lib/cjs/route-args/ModelType.d.ts +12 -12
- package/lib/cjs/route-args/ModelType.js +38 -38
- package/lib/cjs/route-args/ModelType.js.map +1 -1
- package/lib/cjs/schemas/QueryArgs.schema.d.ts +19 -19
- package/lib/cjs/schemas/QueryArgs.schema.js +12 -12
- package/lib/cjs/schemas/QueryFilter.schema.d.ts +20 -20
- package/lib/cjs/schemas/QueryFilter.schema.js +15 -15
- package/lib/cjs/schemas/QueryIncludes.schema.d.ts +7 -7
- package/lib/cjs/schemas/QueryIncludes.schema.js +9 -9
- package/lib/mjs/PlainJsonCollectionTransformer.d.ts +8 -8
- package/lib/mjs/PlainJsonCollectionTransformer.js +26 -26
- package/lib/mjs/PlainJsonCollectionTransformer.js.map +1 -1
- package/lib/mjs/config/orm-api.d.ts +16 -16
- package/lib/mjs/config/orm-api.js +22 -22
- package/lib/mjs/controllers/JsonApi.d.ts +1 -1
- package/lib/mjs/controllers/JsonApi.js +245 -245
- package/lib/mjs/controllers/crud/Create.d.ts +15 -15
- package/lib/mjs/controllers/crud/Create.js +138 -138
- package/lib/mjs/controllers/crud/Create.js.map +1 -1
- package/lib/mjs/controllers/crud/Crud.d.ts +1 -1
- package/lib/mjs/controllers/crud/Crud.js +1 -1
- package/lib/mjs/controllers/crud/Delete.d.ts +15 -15
- package/lib/mjs/controllers/crud/Delete.js +154 -154
- package/lib/mjs/controllers/crud/Delete.js.map +1 -1
- package/lib/mjs/controllers/crud/Read.d.ts +39 -39
- package/lib/mjs/controllers/crud/Read.js +223 -223
- package/lib/mjs/controllers/crud/Read.js.map +1 -1
- package/lib/mjs/controllers/crud/Update.d.ts +12 -12
- package/lib/mjs/controllers/crud/Update.js +95 -95
- package/lib/mjs/controllers/crud/Update.js.map +1 -1
- package/lib/mjs/dto/QueryArgs.d.ts +8 -8
- package/lib/mjs/dto/QueryArgs.js +21 -21
- package/lib/mjs/dto/QueryArgs.js.map +1 -1
- package/lib/mjs/dto/QueryFilter.d.ts +5 -5
- package/lib/mjs/dto/QueryFilter.js +24 -24
- package/lib/mjs/dto/QueryFilter.js.map +1 -1
- package/lib/mjs/dto/QueryIncludes.d.ts +4 -4
- package/lib/mjs/dto/QueryIncludes.js +24 -24
- package/lib/mjs/dto/QueryIncludes.js.map +1 -1
- package/lib/mjs/hydrators/QueryFilterHydrator.d.ts +4 -4
- package/lib/mjs/hydrators/QueryFilterHydrator.js +10 -10
- package/lib/mjs/hydrators/QueryIncludesHydrator.d.ts +4 -4
- package/lib/mjs/hydrators/QueryIncludesHydrator.js +13 -13
- package/lib/mjs/index.d.ts +28 -28
- package/lib/mjs/index.js +94 -94
- package/lib/mjs/index.js.map +1 -1
- package/lib/mjs/interfaces.d.ts +41 -41
- package/lib/mjs/interfaces.js +44 -44
- package/lib/mjs/interfaces.js.map +1 -1
- package/lib/mjs/middleware.d.ts +21 -21
- package/lib/mjs/middleware.js +26 -26
- package/lib/mjs/policies/FindModelType.d.ts +7 -7
- package/lib/mjs/policies/FindModelType.js +39 -39
- package/lib/mjs/policies/FindModelType.js.map +1 -1
- package/lib/mjs/route-args/ModelType.d.ts +12 -12
- package/lib/mjs/route-args/ModelType.js +34 -34
- package/lib/mjs/route-args/ModelType.js.map +1 -1
- package/lib/mjs/schemas/QueryArgs.schema.d.ts +19 -19
- package/lib/mjs/schemas/QueryArgs.schema.js +10 -10
- package/lib/mjs/schemas/QueryFilter.schema.d.ts +20 -20
- package/lib/mjs/schemas/QueryFilter.schema.js +13 -13
- package/lib/mjs/schemas/QueryIncludes.schema.d.ts +7 -7
- package/lib/mjs/schemas/QueryIncludes.schema.js +7 -7
- package/lib/tsconfig.cjs.tsbuildinfo +1 -1
- package/lib/tsconfig.mjs.tsbuildinfo +1 -1
- package/package.json +12 -12
|
@@ -1,155 +1,155 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
};
|
|
10
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
-
};
|
|
13
|
-
import { Orm, RelationType } from '@spinajs/orm';
|
|
14
|
-
import { BasePath, Ok, Post, Query, Del, Body, PKey, ParameterType, Policy, Param } from '@spinajs/http';
|
|
15
|
-
import { Permission } from '@spinajs/rbac-http';
|
|
16
|
-
import { Autoinject } from '@spinajs/di';
|
|
17
|
-
import { BadRequest, ResourceNotFound } from '@spinajs/exceptions';
|
|
18
|
-
import { ModelType } from '../../route-args/ModelType.js';
|
|
19
|
-
import { FindModelType } from '../../policies/FindModelType.js';
|
|
20
|
-
import { Log, Logger } from '@spinajs/log';
|
|
21
|
-
import { AccessControl } from '@spinajs/rbac';
|
|
22
|
-
import { Crud } from './../../interfaces.js';
|
|
23
|
-
let CrudDelete = class CrudDelete extends Crud {
|
|
24
|
-
async batchDelete(model, ids) {
|
|
25
|
-
const tModel = this.getModelDescriptor(model);
|
|
26
|
-
const result = await model.destroy().whereIn(tModel.PrimaryKey, ids);
|
|
27
|
-
this.Log.trace(`Deleted ${result.RowsAffected} records from ${tModel.Name}`);
|
|
28
|
-
return new Ok({
|
|
29
|
-
[tModel.PrimaryKey]: ids,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
async del(model, id) {
|
|
33
|
-
const descriptor = this.getModelDescriptor(model);
|
|
34
|
-
const result = await model.destroy(id);
|
|
35
|
-
this.Log.trace(`Deleted ${result.RowsAffected} records from ${descriptor.Name} with id ${id}`);
|
|
36
|
-
return new Ok({
|
|
37
|
-
[descriptor.PrimaryKey]: [id],
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
async deleteRelationBatch(model, id, relation, relationIds) {
|
|
41
|
-
const descriptor = this.getRelationDescriptor(model, relation);
|
|
42
|
-
if (descriptor.Type === RelationType.One) {
|
|
43
|
-
throw new BadRequest('Cannot delete batch from one to one relation');
|
|
44
|
-
}
|
|
45
|
-
const exists = await model.exists(id);
|
|
46
|
-
if (!exists) {
|
|
47
|
-
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
48
|
-
Resource: model.name,
|
|
49
|
-
Id: id,
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
const result = await descriptor.TargetModel.destroy(relationIds).where(descriptor.ForeignKey, id);
|
|
53
|
-
this.Log.trace(`Deleted ${result.RowsAffected} records from ${descriptor.Name} with id ${id}`);
|
|
54
|
-
return new Ok(relationIds);
|
|
55
|
-
}
|
|
56
|
-
async deleteRelation(model, id, relation, relationId) {
|
|
57
|
-
const descriptor = this.getRelationDescriptor(model, relation);
|
|
58
|
-
const tModel = this.getModelDescriptor(descriptor.TargetModel);
|
|
59
|
-
const exists = await model.exists(id);
|
|
60
|
-
if (!exists) {
|
|
61
|
-
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
62
|
-
Resource: model.name,
|
|
63
|
-
Id: id,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const result = await descriptor.TargetModel.destroy(relationId).when(descriptor.Type !== RelationType.One, function () {
|
|
67
|
-
this.where({ [descriptor.ForeignKey]: id });
|
|
68
|
-
});
|
|
69
|
-
this.Log.trace(`Deleted related ${result.RowsAffected} records from ${tModel.Name} with id ${id}`);
|
|
70
|
-
return new Ok({
|
|
71
|
-
[tModel.PrimaryKey]: relationId,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
async deleteRelationAll(model, id, relation) {
|
|
75
|
-
const descriptor = this.getRelationDescriptor(model, relation);
|
|
76
|
-
const tModel = this.getModelDescriptor(descriptor.TargetModel);
|
|
77
|
-
const exists = await model.exists(id);
|
|
78
|
-
if (!exists) {
|
|
79
|
-
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
80
|
-
Resource: model.name,
|
|
81
|
-
Id: id,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
const result = await descriptor.TargetModel.destroy().when(descriptor.Type !== RelationType.One, function () {
|
|
85
|
-
this.where(descriptor.ForeignKey, id);
|
|
86
|
-
});
|
|
87
|
-
this.Log.trace(`Deleted related ${result.RowsAffected} records from ${tModel.Name} with id ${id}`);
|
|
88
|
-
return new Ok();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
__decorate([
|
|
92
|
-
Logger('orm-http:api'),
|
|
93
|
-
__metadata("design:type", Log)
|
|
94
|
-
], CrudDelete.prototype, "Log", void 0);
|
|
95
|
-
__decorate([
|
|
96
|
-
Autoinject(),
|
|
97
|
-
__metadata("design:type", Orm)
|
|
98
|
-
], CrudDelete.prototype, "Orm", void 0);
|
|
99
|
-
__decorate([
|
|
100
|
-
Autoinject(),
|
|
101
|
-
__metadata("design:type", AccessControl)
|
|
102
|
-
], CrudDelete.prototype, "Ac", void 0);
|
|
103
|
-
__decorate([
|
|
104
|
-
Post(':model/__batchDelete'),
|
|
105
|
-
__param(0, ModelType()),
|
|
106
|
-
__param(1, Body()),
|
|
107
|
-
__metadata("design:type", Function),
|
|
108
|
-
__metadata("design:paramtypes", [Object, Array]),
|
|
109
|
-
__metadata("design:returntype", Promise)
|
|
110
|
-
], CrudDelete.prototype, "batchDelete", null);
|
|
111
|
-
__decorate([
|
|
112
|
-
Del(':model/:id'),
|
|
113
|
-
Permission('deleteAny'),
|
|
114
|
-
__param(0, ModelType()),
|
|
115
|
-
__param(1, Param()),
|
|
116
|
-
__metadata("design:type", Function),
|
|
117
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
118
|
-
__metadata("design:returntype", Promise)
|
|
119
|
-
], CrudDelete.prototype, "del", null);
|
|
120
|
-
__decorate([
|
|
121
|
-
Post(':model/:id/:relation/__batchDelete'),
|
|
122
|
-
Permission('deleteAny'),
|
|
123
|
-
__param(0, ModelType()),
|
|
124
|
-
__param(1, Param()),
|
|
125
|
-
__param(2, Param()),
|
|
126
|
-
__param(3, Body()),
|
|
127
|
-
__metadata("design:type", Function),
|
|
128
|
-
__metadata("design:paramtypes", [Object, Object, String, Array]),
|
|
129
|
-
__metadata("design:returntype", Promise)
|
|
130
|
-
], CrudDelete.prototype, "deleteRelationBatch", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
Del(':model/:id/:relation/:relationId'),
|
|
133
|
-
__param(0, ModelType()),
|
|
134
|
-
__param(1, Param()),
|
|
135
|
-
__param(2, Param()),
|
|
136
|
-
__param(3, Param()),
|
|
137
|
-
__metadata("design:type", Function),
|
|
138
|
-
__metadata("design:paramtypes", [Object, Object, String, Number]),
|
|
139
|
-
__metadata("design:returntype", Promise)
|
|
140
|
-
], CrudDelete.prototype, "deleteRelation", null);
|
|
141
|
-
__decorate([
|
|
142
|
-
Del(':model/:id/:relation'),
|
|
143
|
-
__param(0, ModelType()),
|
|
144
|
-
__param(1, PKey(ParameterType.FromQuery)),
|
|
145
|
-
__param(2, Query()),
|
|
146
|
-
__metadata("design:type", Function),
|
|
147
|
-
__metadata("design:paramtypes", [Object, Object, String]),
|
|
148
|
-
__metadata("design:returntype", Promise)
|
|
149
|
-
], CrudDelete.prototype, "deleteRelationAll", null);
|
|
150
|
-
CrudDelete = __decorate([
|
|
151
|
-
BasePath('crud'),
|
|
152
|
-
Policy(FindModelType)
|
|
153
|
-
], CrudDelete);
|
|
154
|
-
export { CrudDelete };
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Orm, RelationType } from '@spinajs/orm';
|
|
14
|
+
import { BasePath, Ok, Post, Query, Del, Body, PKey, ParameterType, Policy, Param } from '@spinajs/http';
|
|
15
|
+
import { Permission } from '@spinajs/rbac-http';
|
|
16
|
+
import { Autoinject } from '@spinajs/di';
|
|
17
|
+
import { BadRequest, ResourceNotFound } from '@spinajs/exceptions';
|
|
18
|
+
import { ModelType } from '../../route-args/ModelType.js';
|
|
19
|
+
import { FindModelType } from '../../policies/FindModelType.js';
|
|
20
|
+
import { Log, Logger } from '@spinajs/log';
|
|
21
|
+
import { AccessControl } from '@spinajs/rbac';
|
|
22
|
+
import { Crud } from './../../interfaces.js';
|
|
23
|
+
let CrudDelete = class CrudDelete extends Crud {
|
|
24
|
+
async batchDelete(model, ids) {
|
|
25
|
+
const tModel = this.getModelDescriptor(model);
|
|
26
|
+
const result = await model.destroy().whereIn(tModel.PrimaryKey, ids);
|
|
27
|
+
this.Log.trace(`Deleted ${result.RowsAffected} records from ${tModel.Name}`);
|
|
28
|
+
return new Ok({
|
|
29
|
+
[tModel.PrimaryKey]: ids,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async del(model, id) {
|
|
33
|
+
const descriptor = this.getModelDescriptor(model);
|
|
34
|
+
const result = await model.destroy(id);
|
|
35
|
+
this.Log.trace(`Deleted ${result.RowsAffected} records from ${descriptor.Name} with id ${id}`);
|
|
36
|
+
return new Ok({
|
|
37
|
+
[descriptor.PrimaryKey]: [id],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async deleteRelationBatch(model, id, relation, relationIds) {
|
|
41
|
+
const descriptor = this.getRelationDescriptor(model, relation);
|
|
42
|
+
if (descriptor.Type === RelationType.One) {
|
|
43
|
+
throw new BadRequest('Cannot delete batch from one to one relation');
|
|
44
|
+
}
|
|
45
|
+
const exists = await model.exists(id);
|
|
46
|
+
if (!exists) {
|
|
47
|
+
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
48
|
+
Resource: model.name,
|
|
49
|
+
Id: id,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const result = await descriptor.TargetModel.destroy(relationIds).where(descriptor.ForeignKey, id);
|
|
53
|
+
this.Log.trace(`Deleted ${result.RowsAffected} records from ${descriptor.Name} with id ${id}`);
|
|
54
|
+
return new Ok(relationIds);
|
|
55
|
+
}
|
|
56
|
+
async deleteRelation(model, id, relation, relationId) {
|
|
57
|
+
const descriptor = this.getRelationDescriptor(model, relation);
|
|
58
|
+
const tModel = this.getModelDescriptor(descriptor.TargetModel);
|
|
59
|
+
const exists = await model.exists(id);
|
|
60
|
+
if (!exists) {
|
|
61
|
+
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
62
|
+
Resource: model.name,
|
|
63
|
+
Id: id,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
const result = await descriptor.TargetModel.destroy(relationId).when(descriptor.Type !== RelationType.One, function () {
|
|
67
|
+
this.where({ [descriptor.ForeignKey]: id });
|
|
68
|
+
});
|
|
69
|
+
this.Log.trace(`Deleted related ${result.RowsAffected} records from ${tModel.Name} with id ${id}`);
|
|
70
|
+
return new Ok({
|
|
71
|
+
[tModel.PrimaryKey]: relationId,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
async deleteRelationAll(model, id, relation) {
|
|
75
|
+
const descriptor = this.getRelationDescriptor(model, relation);
|
|
76
|
+
const tModel = this.getModelDescriptor(descriptor.TargetModel);
|
|
77
|
+
const exists = await model.exists(id);
|
|
78
|
+
if (!exists) {
|
|
79
|
+
throw new ResourceNotFound(`Record with id ${id} not found`, {
|
|
80
|
+
Resource: model.name,
|
|
81
|
+
Id: id,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const result = await descriptor.TargetModel.destroy().when(descriptor.Type !== RelationType.One, function () {
|
|
85
|
+
this.where(descriptor.ForeignKey, id);
|
|
86
|
+
});
|
|
87
|
+
this.Log.trace(`Deleted related ${result.RowsAffected} records from ${tModel.Name} with id ${id}`);
|
|
88
|
+
return new Ok();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__decorate([
|
|
92
|
+
Logger('orm-http:api'),
|
|
93
|
+
__metadata("design:type", Log)
|
|
94
|
+
], CrudDelete.prototype, "Log", void 0);
|
|
95
|
+
__decorate([
|
|
96
|
+
Autoinject(),
|
|
97
|
+
__metadata("design:type", Orm)
|
|
98
|
+
], CrudDelete.prototype, "Orm", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
Autoinject(),
|
|
101
|
+
__metadata("design:type", AccessControl)
|
|
102
|
+
], CrudDelete.prototype, "Ac", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
Post(':model/__batchDelete'),
|
|
105
|
+
__param(0, ModelType()),
|
|
106
|
+
__param(1, Body()),
|
|
107
|
+
__metadata("design:type", Function),
|
|
108
|
+
__metadata("design:paramtypes", [Object, Array]),
|
|
109
|
+
__metadata("design:returntype", Promise)
|
|
110
|
+
], CrudDelete.prototype, "batchDelete", null);
|
|
111
|
+
__decorate([
|
|
112
|
+
Del(':model/:id'),
|
|
113
|
+
Permission('deleteAny'),
|
|
114
|
+
__param(0, ModelType()),
|
|
115
|
+
__param(1, Param()),
|
|
116
|
+
__metadata("design:type", Function),
|
|
117
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
118
|
+
__metadata("design:returntype", Promise)
|
|
119
|
+
], CrudDelete.prototype, "del", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
Post(':model/:id/:relation/__batchDelete'),
|
|
122
|
+
Permission('deleteAny'),
|
|
123
|
+
__param(0, ModelType()),
|
|
124
|
+
__param(1, Param()),
|
|
125
|
+
__param(2, Param()),
|
|
126
|
+
__param(3, Body()),
|
|
127
|
+
__metadata("design:type", Function),
|
|
128
|
+
__metadata("design:paramtypes", [Object, Object, String, Array]),
|
|
129
|
+
__metadata("design:returntype", Promise)
|
|
130
|
+
], CrudDelete.prototype, "deleteRelationBatch", null);
|
|
131
|
+
__decorate([
|
|
132
|
+
Del(':model/:id/:relation/:relationId'),
|
|
133
|
+
__param(0, ModelType()),
|
|
134
|
+
__param(1, Param()),
|
|
135
|
+
__param(2, Param()),
|
|
136
|
+
__param(3, Param()),
|
|
137
|
+
__metadata("design:type", Function),
|
|
138
|
+
__metadata("design:paramtypes", [Object, Object, String, Number]),
|
|
139
|
+
__metadata("design:returntype", Promise)
|
|
140
|
+
], CrudDelete.prototype, "deleteRelation", null);
|
|
141
|
+
__decorate([
|
|
142
|
+
Del(':model/:id/:relation'),
|
|
143
|
+
__param(0, ModelType()),
|
|
144
|
+
__param(1, PKey(ParameterType.FromQuery)),
|
|
145
|
+
__param(2, Query()),
|
|
146
|
+
__metadata("design:type", Function),
|
|
147
|
+
__metadata("design:paramtypes", [Object, Object, String]),
|
|
148
|
+
__metadata("design:returntype", Promise)
|
|
149
|
+
], CrudDelete.prototype, "deleteRelationAll", null);
|
|
150
|
+
CrudDelete = __decorate([
|
|
151
|
+
BasePath('crud'),
|
|
152
|
+
Policy(FindModelType)
|
|
153
|
+
], CrudDelete);
|
|
154
|
+
export { CrudDelete };
|
|
155
155
|
//# sourceMappingURL=Delete.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.js","sourceRoot":"","sources":["../../../../src/controllers/crud/Delete.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAgB,GAAG,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACzG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAItC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,IAAI;IAWrB,AAAN,KAAK,CAAC,WAAW,CAAc,KAAmB,EAAU,GAAU;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,C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E,CAAA;IAAuB,WAAA,KAAK,EAAE,CAAA;IAAW,WAAA,KAAK,EAAE,CAAA;IAAoB,WAAA,KAAK,EAAE,CAAA;;;;gDAqBlH;AAGY;IADZ,GAAG,CAAC,sBAAsB,CAAC;IACI,WAAA,SAAS,EAAE,CAAA;IAAuB,WAAA,IAAI,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;IAAW,WAAA,KAAK,EAAE,CAAA;;;;mDAmBhH;AAvGU,UAAU;IAFtB,QAAQ,CAAC,MAAM,CAAC;IAChB,MAAM,CAAC,aAAa,CAAC;GACT,UAAU,CAwGtB"}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { Permission } from 'accesscontrol';
|
|
2
|
-
import { Orm, IModelStatic } from '@spinajs/orm';
|
|
3
|
-
import { Ok } from '@spinajs/http';
|
|
4
|
-
import { User as UserModel, AccessControl } from '@spinajs/rbac';
|
|
5
|
-
import { BadRequest } from '@spinajs/exceptions';
|
|
6
|
-
import { Log } from '@spinajs/log';
|
|
7
|
-
import '@spinajs/rbac';
|
|
8
|
-
import { QueryArgs } from '../../dto/QueryArgs.js';
|
|
9
|
-
import { QueryFilter } from '../../dto/QueryFilter.js';
|
|
10
|
-
import { QueryIncludes } from '../../dto/QueryIncludes.js';
|
|
11
|
-
import { Crud } from './../../interfaces.js';
|
|
12
|
-
export declare class CrudRead extends Crud {
|
|
13
|
-
protected Log: Log;
|
|
14
|
-
protected Orm: Orm;
|
|
15
|
-
protected Ac: AccessControl;
|
|
16
|
-
/**
|
|
17
|
-
* retrieve resource name, if model does not have @OrmResource decorator set
|
|
18
|
-
* model name is default resource name
|
|
19
|
-
* @param model
|
|
20
|
-
* @returns
|
|
21
|
-
*/
|
|
22
|
-
protected getResourceName(model: IModelStatic): string;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* Creates query on model and ansures that user have proper permission to access it
|
|
26
|
-
*
|
|
27
|
-
* @param model model to query against
|
|
28
|
-
* @param user user for permission check
|
|
29
|
-
* @returns
|
|
30
|
-
*/
|
|
31
|
-
protected getSafeQuery(model: IModelStatic, user: UserModel): {
|
|
32
|
-
query: import("@spinajs/orm").ISelectQueryBuilder<import("@spinajs/orm").ModelBase<unknown>[]>;
|
|
33
|
-
permission: Permission;
|
|
34
|
-
};
|
|
35
|
-
getAll(model: IModelStatic, getParams: QueryArgs, filters: QueryFilter, includes: QueryIncludes, user: UserModel): Promise<Ok>;
|
|
36
|
-
get(user: UserModel, model: IModelStatic, id: number, includes: QueryIncludes): Promise<Ok>;
|
|
37
|
-
getRelation(model: IModelStatic, id: any, relation: string, relationId: any, includes: QueryIncludes, user?: UserModel): Promise<Ok | BadRequest>;
|
|
38
|
-
getRelations(model: IModelStatic, id: any, relation: string, params: QueryArgs, filters: QueryFilter, includes: QueryIncludes, user?: UserModel): Promise<Ok | BadRequest>;
|
|
39
|
-
}
|
|
1
|
+
import { Permission } from 'accesscontrol';
|
|
2
|
+
import { Orm, IModelStatic } from '@spinajs/orm';
|
|
3
|
+
import { Ok } from '@spinajs/http';
|
|
4
|
+
import { User as UserModel, AccessControl } from '@spinajs/rbac';
|
|
5
|
+
import { BadRequest } from '@spinajs/exceptions';
|
|
6
|
+
import { Log } from '@spinajs/log';
|
|
7
|
+
import '@spinajs/rbac';
|
|
8
|
+
import { QueryArgs } from '../../dto/QueryArgs.js';
|
|
9
|
+
import { QueryFilter } from '../../dto/QueryFilter.js';
|
|
10
|
+
import { QueryIncludes } from '../../dto/QueryIncludes.js';
|
|
11
|
+
import { Crud } from './../../interfaces.js';
|
|
12
|
+
export declare class CrudRead extends Crud {
|
|
13
|
+
protected Log: Log;
|
|
14
|
+
protected Orm: Orm;
|
|
15
|
+
protected Ac: AccessControl;
|
|
16
|
+
/**
|
|
17
|
+
* retrieve resource name, if model does not have @OrmResource decorator set
|
|
18
|
+
* model name is default resource name
|
|
19
|
+
* @param model
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
protected getResourceName(model: IModelStatic): string;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* Creates query on model and ansures that user have proper permission to access it
|
|
26
|
+
*
|
|
27
|
+
* @param model model to query against
|
|
28
|
+
* @param user user for permission check
|
|
29
|
+
* @returns
|
|
30
|
+
*/
|
|
31
|
+
protected getSafeQuery(model: IModelStatic, user: UserModel): {
|
|
32
|
+
query: import("@spinajs/orm").ISelectQueryBuilder<import("@spinajs/orm").ModelBase<unknown>[]>;
|
|
33
|
+
permission: Permission;
|
|
34
|
+
};
|
|
35
|
+
getAll(model: IModelStatic, getParams: QueryArgs, filters: QueryFilter, includes: QueryIncludes, user: UserModel): Promise<Ok>;
|
|
36
|
+
get(user: UserModel, model: IModelStatic, id: number, includes: QueryIncludes): Promise<Ok>;
|
|
37
|
+
getRelation(model: IModelStatic, id: any, relation: string, relationId: any, includes: QueryIncludes, user?: UserModel): Promise<Ok | BadRequest>;
|
|
38
|
+
getRelations(model: IModelStatic, id: any, relation: string, params: QueryArgs, filters: QueryFilter, includes: QueryIncludes, user?: UserModel): Promise<Ok | BadRequest>;
|
|
39
|
+
}
|
|
40
40
|
//# sourceMappingURL=Read.d.ts.map
|