@minimaltech/node-infra 0.3.13 → 0.3.14
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/base/controllers/crud.controller.d.ts +8 -0
- package/dist/base/controllers/crud.controller.js +68 -33
- package/dist/base/controllers/crud.controller.js.map +1 -1
- package/dist/base/controllers/index.d.ts +2 -1
- package/dist/base/controllers/index.js +2 -1
- package/dist/base/controllers/index.js.map +1 -1
- package/dist/base/controllers/relational.controller.js +17 -19
- package/dist/base/controllers/relational.controller.js.map +1 -1
- package/dist/base/controllers/service-crud.controller.d.ts +51 -0
- package/dist/base/controllers/service-crud.controller.js +415 -0
- package/dist/base/controllers/service-crud.controller.js.map +1 -0
- package/dist/base/index.d.ts +1 -1
- package/dist/base/index.js +1 -1
- package/dist/base/index.js.map +1 -1
- package/dist/base/services/base-crud.service.d.ts +23 -0
- package/dist/base/services/base-crud.service.js +67 -0
- package/dist/base/services/base-crud.service.js.map +1 -0
- package/dist/base/{base.service.d.ts → services/base.service.d.ts} +2 -2
- package/dist/base/{base.service.js → services/base.service.js} +1 -1
- package/dist/base/services/base.service.js.map +1 -0
- package/dist/base/services/index.d.ts +2 -0
- package/dist/base/services/index.js +19 -0
- package/dist/base/services/index.js.map +1 -0
- package/dist/common/types.d.ts +27 -1
- package/dist/components/authenticate/services/basic-token.service.d.ts +1 -1
- package/dist/components/authenticate/services/basic-token.service.js +2 -2
- package/dist/components/authenticate/services/basic-token.service.js.map +1 -1
- package/dist/components/authenticate/services/jwt-token.service.d.ts +1 -1
- package/dist/components/authenticate/services/jwt-token.service.js +2 -2
- package/dist/components/authenticate/services/jwt-token.service.js.map +1 -1
- package/dist/components/authenticate/services/oauth2.service.d.ts +1 -1
- package/dist/components/authenticate/services/oauth2.service.js +2 -2
- package/dist/components/authenticate/services/oauth2.service.js.map +1 -1
- package/package.json +1 -1
- package/dist/base/base.service.js.map +0 -1
@@ -0,0 +1,415 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5
|
+
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;
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7
|
+
};
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
10
|
+
};
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
13
|
+
};
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
21
|
+
});
|
22
|
+
};
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
24
|
+
exports.defineServiceCrudController = void 0;
|
25
|
+
const core_1 = require("@loopback/core");
|
26
|
+
const repository_1 = require("@loopback/repository");
|
27
|
+
const rest_1 = require("@loopback/rest");
|
28
|
+
const common_1 = require("../../common");
|
29
|
+
const security_1 = require("@loopback/security");
|
30
|
+
const common_2 = require("./common");
|
31
|
+
// --------------------------------------------------------------------------------------------------------------
|
32
|
+
const defineServiceCrudController = (opts) => {
|
33
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
34
|
+
const { entity: entityOptions, service: serviceOptions, controller: controllerOptions, schema: schemaOptions, doInjectCurrentUser = true, } = opts;
|
35
|
+
const idPathParam = {
|
36
|
+
name: 'id',
|
37
|
+
in: 'path',
|
38
|
+
schema: (0, common_2.getIdSchema)(entityOptions),
|
39
|
+
};
|
40
|
+
class ReadController {
|
41
|
+
constructor(service, getCurrentUser) {
|
42
|
+
var _a;
|
43
|
+
this.service = service;
|
44
|
+
this.getCurrentUser = getCurrentUser;
|
45
|
+
this.defaultLimit = (_a = controllerOptions === null || controllerOptions === void 0 ? void 0 : controllerOptions.defaultLimit) !== null && _a !== void 0 ? _a : common_1.App.DEFAULT_QUERY_LIMIT;
|
46
|
+
}
|
47
|
+
// ----------------------------------------------------------------------------------------------------------
|
48
|
+
_getContextUser() {
|
49
|
+
return new Promise((resolve, reject) => {
|
50
|
+
if (!this.getCurrentUser) {
|
51
|
+
resolve(null);
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
this.getCurrentUser().then(resolve).catch(reject);
|
55
|
+
});
|
56
|
+
}
|
57
|
+
// ----------------------------------------------------------------------------------------------------------
|
58
|
+
find(filter) {
|
59
|
+
return new Promise((resolve, reject) => {
|
60
|
+
this._getContextUser().then(currentUser => {
|
61
|
+
this.service
|
62
|
+
.find((0, common_2.applyLimit)(filter), {
|
63
|
+
currentUser,
|
64
|
+
})
|
65
|
+
.then(resolve)
|
66
|
+
.catch(reject);
|
67
|
+
});
|
68
|
+
});
|
69
|
+
}
|
70
|
+
// ----------------------------------------------------------------------------------------------------------
|
71
|
+
findById(id, filter) {
|
72
|
+
return new Promise((resolve, reject) => {
|
73
|
+
this._getContextUser().then(currentUser => {
|
74
|
+
this.service
|
75
|
+
.findById(id, (0, common_2.applyLimit)(filter), {
|
76
|
+
currentUser,
|
77
|
+
})
|
78
|
+
.then(resolve)
|
79
|
+
.catch(reject);
|
80
|
+
});
|
81
|
+
});
|
82
|
+
}
|
83
|
+
// ----------------------------------------------------------------------------------------------------------
|
84
|
+
findOne(filter) {
|
85
|
+
return new Promise((resolve, reject) => {
|
86
|
+
this._getContextUser().then(currentUser => {
|
87
|
+
this.service
|
88
|
+
.findOne((0, common_2.applyLimit)(filter), {
|
89
|
+
currentUser,
|
90
|
+
})
|
91
|
+
.then(resolve)
|
92
|
+
.catch(reject);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
}
|
96
|
+
// ----------------------------------------------------------------------------------------------------------
|
97
|
+
count(where) {
|
98
|
+
return new Promise((resolve, reject) => {
|
99
|
+
this._getContextUser().then(currentUser => {
|
100
|
+
this.service
|
101
|
+
.count(where !== null && where !== void 0 ? where : {}, {
|
102
|
+
currentUser,
|
103
|
+
})
|
104
|
+
.then(resolve)
|
105
|
+
.catch(reject);
|
106
|
+
});
|
107
|
+
});
|
108
|
+
}
|
109
|
+
}
|
110
|
+
__decorate([
|
111
|
+
(0, rest_1.get)('/', {
|
112
|
+
responses: {
|
113
|
+
'200': {
|
114
|
+
description: `Array of ${entityOptions.name} model instances`,
|
115
|
+
content: {
|
116
|
+
'application/json': {
|
117
|
+
schema: {
|
118
|
+
type: 'array',
|
119
|
+
items: (_a = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.find) !== null && _a !== void 0 ? _a : (0, rest_1.getModelSchemaRef)(entityOptions, { includeRelations: true }),
|
120
|
+
},
|
121
|
+
},
|
122
|
+
},
|
123
|
+
},
|
124
|
+
},
|
125
|
+
}),
|
126
|
+
__param(0, rest_1.param.filter(entityOptions)),
|
127
|
+
__metadata("design:type", Function),
|
128
|
+
__metadata("design:paramtypes", [Object]),
|
129
|
+
__metadata("design:returntype", Promise)
|
130
|
+
], ReadController.prototype, "find", null);
|
131
|
+
__decorate([
|
132
|
+
(0, rest_1.get)('/{id}', {
|
133
|
+
responses: {
|
134
|
+
'200': {
|
135
|
+
description: `Find ${entityOptions.name} model instance`,
|
136
|
+
content: {
|
137
|
+
'application/json': {
|
138
|
+
schema: (_b = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.findById) !== null && _b !== void 0 ? _b : (0, rest_1.getModelSchemaRef)(entityOptions, { includeRelations: true }),
|
139
|
+
},
|
140
|
+
},
|
141
|
+
},
|
142
|
+
},
|
143
|
+
}),
|
144
|
+
__param(0, (0, rest_1.param)(idPathParam)),
|
145
|
+
__param(1, rest_1.param.query.object('filter', (0, rest_1.getFilterSchemaFor)(entityOptions, { exclude: 'where' }))),
|
146
|
+
__metadata("design:type", Function),
|
147
|
+
__metadata("design:paramtypes", [Object, Object]),
|
148
|
+
__metadata("design:returntype", Promise)
|
149
|
+
], ReadController.prototype, "findById", null);
|
150
|
+
__decorate([
|
151
|
+
(0, rest_1.get)('/find-one', {
|
152
|
+
responses: {
|
153
|
+
'200': {
|
154
|
+
description: `Find one ${entityOptions.name} model instance`,
|
155
|
+
content: {
|
156
|
+
'application/json': {
|
157
|
+
schema: (_c = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.findOne) !== null && _c !== void 0 ? _c : (0, rest_1.getModelSchemaRef)(entityOptions, { includeRelations: true }),
|
158
|
+
},
|
159
|
+
},
|
160
|
+
},
|
161
|
+
},
|
162
|
+
}),
|
163
|
+
__param(0, rest_1.param.query.object('filter', (0, rest_1.getFilterSchemaFor)(entityOptions))),
|
164
|
+
__metadata("design:type", Function),
|
165
|
+
__metadata("design:paramtypes", [Object]),
|
166
|
+
__metadata("design:returntype", Promise)
|
167
|
+
], ReadController.prototype, "findOne", null);
|
168
|
+
__decorate([
|
169
|
+
(0, rest_1.get)('/count', {
|
170
|
+
responses: {
|
171
|
+
'200': {
|
172
|
+
description: `Count number of ${entityOptions.name} model instance`,
|
173
|
+
content: {
|
174
|
+
'application/json': {
|
175
|
+
schema: repository_1.CountSchema,
|
176
|
+
},
|
177
|
+
},
|
178
|
+
},
|
179
|
+
},
|
180
|
+
}),
|
181
|
+
__param(0, rest_1.param.where(entityOptions)),
|
182
|
+
__metadata("design:type", Function),
|
183
|
+
__metadata("design:paramtypes", [Object]),
|
184
|
+
__metadata("design:returntype", Promise)
|
185
|
+
], ReadController.prototype, "count", null);
|
186
|
+
if (controllerOptions.readonly) {
|
187
|
+
if (serviceOptions === null || serviceOptions === void 0 ? void 0 : serviceOptions.name) {
|
188
|
+
(0, core_1.inject)(`services.${serviceOptions.name}`)(ReadController, undefined, 0);
|
189
|
+
}
|
190
|
+
if (doInjectCurrentUser) {
|
191
|
+
core_1.inject.getter(security_1.SecurityBindings.USER)(ReadController, undefined, 1);
|
192
|
+
}
|
193
|
+
return ReadController;
|
194
|
+
}
|
195
|
+
class CrudController extends ReadController {
|
196
|
+
constructor(service, getCurrentUser) {
|
197
|
+
super(service, getCurrentUser);
|
198
|
+
this.getCurrentUser = getCurrentUser;
|
199
|
+
}
|
200
|
+
// ----------------------------------------------------------------------------------------------------------
|
201
|
+
create(data) {
|
202
|
+
return new Promise((resolve, reject) => {
|
203
|
+
this._getContextUser()
|
204
|
+
.then(currentUser => {
|
205
|
+
this.service
|
206
|
+
.create(data, {
|
207
|
+
currentUser,
|
208
|
+
})
|
209
|
+
.then(resolve)
|
210
|
+
.catch(reject);
|
211
|
+
})
|
212
|
+
.catch(reject);
|
213
|
+
});
|
214
|
+
}
|
215
|
+
// ----------------------------------------------------------------------------------------------------------
|
216
|
+
updateAll(data, where) {
|
217
|
+
return new Promise((resolve, reject) => {
|
218
|
+
this._getContextUser()
|
219
|
+
.then(currentUser => {
|
220
|
+
this.service
|
221
|
+
.updateAll(data, where !== null && where !== void 0 ? where : {}, {
|
222
|
+
currentUser,
|
223
|
+
})
|
224
|
+
.then(resolve)
|
225
|
+
.catch(reject);
|
226
|
+
})
|
227
|
+
.catch(reject);
|
228
|
+
});
|
229
|
+
}
|
230
|
+
// ----------------------------------------------------------------------------------------------------------
|
231
|
+
updateById(id, data) {
|
232
|
+
return __awaiter(this, void 0, void 0, function* () {
|
233
|
+
return new Promise((resolve, reject) => {
|
234
|
+
this._getContextUser()
|
235
|
+
.then(currentUser => {
|
236
|
+
this.service
|
237
|
+
.updateWithReturn(id, data, {
|
238
|
+
currentUser,
|
239
|
+
})
|
240
|
+
.then(resolve)
|
241
|
+
.catch(reject);
|
242
|
+
})
|
243
|
+
.catch(reject);
|
244
|
+
});
|
245
|
+
});
|
246
|
+
}
|
247
|
+
// ----------------------------------------------------------------------------------------------------------
|
248
|
+
replaceById(id, data) {
|
249
|
+
return __awaiter(this, void 0, void 0, function* () {
|
250
|
+
return new Promise((resolve, reject) => {
|
251
|
+
this._getContextUser()
|
252
|
+
.then(currentUser => {
|
253
|
+
this.service
|
254
|
+
.replaceById(id, data, {
|
255
|
+
currentUser,
|
256
|
+
})
|
257
|
+
.then(resolve)
|
258
|
+
.catch(reject);
|
259
|
+
})
|
260
|
+
.catch(reject);
|
261
|
+
});
|
262
|
+
});
|
263
|
+
}
|
264
|
+
// ----------------------------------------------------------------------------------------------------------
|
265
|
+
deleteById(id) {
|
266
|
+
return new Promise((resolve, reject) => {
|
267
|
+
this._getContextUser()
|
268
|
+
.then(currentUser => {
|
269
|
+
this.service
|
270
|
+
.deleteById(id, {
|
271
|
+
currentUser,
|
272
|
+
})
|
273
|
+
.then(resolve)
|
274
|
+
.catch(reject);
|
275
|
+
})
|
276
|
+
.catch(reject);
|
277
|
+
});
|
278
|
+
}
|
279
|
+
}
|
280
|
+
__decorate([
|
281
|
+
(0, rest_1.post)('/', {
|
282
|
+
responses: {
|
283
|
+
'200': {
|
284
|
+
description: `Create ${entityOptions.name} model instance`,
|
285
|
+
content: {
|
286
|
+
'application/json': {
|
287
|
+
schema: (_d = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.create) !== null && _d !== void 0 ? _d : (0, rest_1.getModelSchemaRef)(entityOptions),
|
288
|
+
},
|
289
|
+
},
|
290
|
+
},
|
291
|
+
},
|
292
|
+
}),
|
293
|
+
__param(0, (0, rest_1.requestBody)({
|
294
|
+
content: {
|
295
|
+
'application/json': {
|
296
|
+
schema: (_e = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.createRequestBody) !== null && _e !== void 0 ? _e : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
297
|
+
title: `New ${entityOptions.name} payload`,
|
298
|
+
exclude: ['id', 'createdAt', 'modifiedAt'],
|
299
|
+
}),
|
300
|
+
},
|
301
|
+
},
|
302
|
+
})),
|
303
|
+
__metadata("design:type", Function),
|
304
|
+
__metadata("design:paramtypes", [Object]),
|
305
|
+
__metadata("design:returntype", Promise)
|
306
|
+
], CrudController.prototype, "create", null);
|
307
|
+
__decorate([
|
308
|
+
(0, rest_1.patch)('/', {
|
309
|
+
responses: {
|
310
|
+
'200': {
|
311
|
+
description: `Number of updated ${entityOptions.name} models`,
|
312
|
+
content: {
|
313
|
+
'application/json': {
|
314
|
+
schema: repository_1.CountSchema,
|
315
|
+
},
|
316
|
+
},
|
317
|
+
},
|
318
|
+
},
|
319
|
+
}),
|
320
|
+
__param(0, (0, rest_1.requestBody)({
|
321
|
+
content: {
|
322
|
+
'application/json': {
|
323
|
+
schema: (_f = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.updateAll) !== null && _f !== void 0 ? _f : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
324
|
+
title: `Partial fields of ${entityOptions.name}`,
|
325
|
+
partial: true,
|
326
|
+
}),
|
327
|
+
},
|
328
|
+
},
|
329
|
+
})),
|
330
|
+
__param(1, rest_1.param.where(entityOptions)),
|
331
|
+
__metadata("design:type", Function),
|
332
|
+
__metadata("design:paramtypes", [Object, Object]),
|
333
|
+
__metadata("design:returntype", Promise)
|
334
|
+
], CrudController.prototype, "updateAll", null);
|
335
|
+
__decorate([
|
336
|
+
(0, rest_1.patch)('/{id}', {
|
337
|
+
responses: {
|
338
|
+
'200': {
|
339
|
+
description: `Updated ${entityOptions.name} models`,
|
340
|
+
content: {
|
341
|
+
'application/json': {
|
342
|
+
schema: (_g = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.updateById) !== null && _g !== void 0 ? _g : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
343
|
+
title: `Updated ${entityOptions.name} models`,
|
344
|
+
}),
|
345
|
+
},
|
346
|
+
},
|
347
|
+
},
|
348
|
+
},
|
349
|
+
}),
|
350
|
+
__param(0, (0, rest_1.param)(idPathParam)),
|
351
|
+
__param(1, (0, rest_1.requestBody)({
|
352
|
+
content: {
|
353
|
+
'application/json': {
|
354
|
+
schema: (_h = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.updateByIdRequestBody) !== null && _h !== void 0 ? _h : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
355
|
+
title: `Partial fields of ${entityOptions.name}`,
|
356
|
+
partial: true,
|
357
|
+
}),
|
358
|
+
},
|
359
|
+
},
|
360
|
+
})),
|
361
|
+
__metadata("design:type", Function),
|
362
|
+
__metadata("design:paramtypes", [Object, Object]),
|
363
|
+
__metadata("design:returntype", Promise)
|
364
|
+
], CrudController.prototype, "updateById", null);
|
365
|
+
__decorate([
|
366
|
+
(0, rest_1.put)('/{id}', {
|
367
|
+
responses: {
|
368
|
+
'204': { description: `${entityOptions.name} was replaced` },
|
369
|
+
},
|
370
|
+
}),
|
371
|
+
__param(0, (0, rest_1.param)(idPathParam)),
|
372
|
+
__param(1, (0, rest_1.requestBody)({
|
373
|
+
content: {
|
374
|
+
'application/json': {
|
375
|
+
schema: (_j = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.replaceById) !== null && _j !== void 0 ? _j : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
376
|
+
title: `Fields of ${entityOptions.name}`,
|
377
|
+
}),
|
378
|
+
},
|
379
|
+
},
|
380
|
+
})),
|
381
|
+
__metadata("design:type", Function),
|
382
|
+
__metadata("design:paramtypes", [Object, Object]),
|
383
|
+
__metadata("design:returntype", Promise)
|
384
|
+
], CrudController.prototype, "replaceById", null);
|
385
|
+
__decorate([
|
386
|
+
(0, rest_1.del)('/{id}', {
|
387
|
+
responses: {
|
388
|
+
'200': {
|
389
|
+
description: `${entityOptions.name} was deleted`,
|
390
|
+
content: {
|
391
|
+
'application/json': {
|
392
|
+
schema: (_k = schemaOptions === null || schemaOptions === void 0 ? void 0 : schemaOptions.deleteById) !== null && _k !== void 0 ? _k : (0, rest_1.getModelSchemaRef)(entityOptions, {
|
393
|
+
partial: true,
|
394
|
+
title: `Deleted ${entityOptions.name} models`,
|
395
|
+
}),
|
396
|
+
},
|
397
|
+
},
|
398
|
+
},
|
399
|
+
},
|
400
|
+
}),
|
401
|
+
__param(0, (0, rest_1.param)(idPathParam)),
|
402
|
+
__metadata("design:type", Function),
|
403
|
+
__metadata("design:paramtypes", [Object]),
|
404
|
+
__metadata("design:returntype", Promise)
|
405
|
+
], CrudController.prototype, "deleteById", null);
|
406
|
+
if (serviceOptions === null || serviceOptions === void 0 ? void 0 : serviceOptions.name) {
|
407
|
+
(0, core_1.inject)(`services.${serviceOptions.name}`)(CrudController, undefined, 0);
|
408
|
+
}
|
409
|
+
if (doInjectCurrentUser) {
|
410
|
+
core_1.inject.getter(security_1.SecurityBindings.USER)(CrudController, undefined, 1);
|
411
|
+
}
|
412
|
+
return CrudController;
|
413
|
+
};
|
414
|
+
exports.defineServiceCrudController = defineServiceCrudController;
|
415
|
+
//# sourceMappingURL=service-crud.controller.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"service-crud.controller.js","sourceRoot":"","sources":["../../../src/base/controllers/service-crud.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAgD;AAChD,qDAA+F;AAC/F,yCAYwB;AAGxB,qCAA+B;AAG/B,iDAAsD;AAEtD,qCAAmD;AAuBnD,iHAAiH;AAC1G,MAAM,2BAA2B,GAAG,CAAyB,IAAsC,EAAE,EAAE;;IAC5G,MAAM,EACJ,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE,cAAc,EACvB,UAAU,EAA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K,EAAE,WAAW,aAAa,CAAC,IAAI,SAAS;6BAC9C,CAAC;yBACL;qBACF;iBACF;aACF;SACF,CAAC;QACU,WAAA,IAAA,YAAK,EAAC,WAAW,CAAC,CAAA;;;;oDAa7B;IAGH,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,EAAE,CAAC;QACzB,IAAA,aAAM,EAAC,YAAY,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,mBAAmB,EAAE,CAAC;QACxB,aAAM,CAAC,MAAM,CAAC,2BAAgB,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,cAAc,CAAC;AACxB,CAAC,CAAC;AApYW,QAAA,2BAA2B,+BAoYtC"}
|
package/dist/base/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
export * from './applications';
|
2
2
|
export * from './controllers';
|
3
3
|
export * from './repositories';
|
4
|
+
export * from './services';
|
4
5
|
export * from './base.component';
|
5
6
|
export * from './base.datasource';
|
6
7
|
export * from './base.helper';
|
7
8
|
export * from './base.model';
|
8
9
|
export * from './base.provider';
|
9
10
|
export * from './base.sequence';
|
10
|
-
export * from './base.service';
|
package/dist/base/index.js
CHANGED
@@ -17,11 +17,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./applications"), exports);
|
18
18
|
__exportStar(require("./controllers"), exports);
|
19
19
|
__exportStar(require("./repositories"), exports);
|
20
|
+
__exportStar(require("./services"), exports);
|
20
21
|
__exportStar(require("./base.component"), exports);
|
21
22
|
__exportStar(require("./base.datasource"), exports);
|
22
23
|
__exportStar(require("./base.helper"), exports);
|
23
24
|
__exportStar(require("./base.model"), exports);
|
24
25
|
__exportStar(require("./base.provider"), exports);
|
25
26
|
__exportStar(require("./base.sequence"), exports);
|
26
|
-
__exportStar(require("./base.service"), exports);
|
27
27
|
//# sourceMappingURL=index.js.map
|
package/dist/base/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,iDAA+B;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,gDAA8B;AAC9B,iDAA+B;AAC/B,6CAA2B;AAE3B,mDAAiC;AACjC,oDAAkC;AAClC,gDAA8B;AAC9B,+CAA6B;AAC7B,kDAAgC;AAChC,kDAAgC"}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { EntityRelationType, ICrudMethodOptions, ICrudService, IdType } from '../../common';
|
2
|
+
import { Count, Filter, Where } from '@loopback/repository';
|
3
|
+
import { BaseTzEntity } from '../base.model';
|
4
|
+
import { BaseService } from './base.service';
|
5
|
+
import { AbstractTzRepository } from '../repositories';
|
6
|
+
export declare abstract class BaseCrudService<E extends BaseTzEntity> extends BaseService implements ICrudService<E> {
|
7
|
+
repository: AbstractTzRepository<E, EntityRelationType>;
|
8
|
+
constructor(opts: {
|
9
|
+
scope: string;
|
10
|
+
repository: AbstractTzRepository<E, EntityRelationType>;
|
11
|
+
});
|
12
|
+
find(filter: Filter<E>, _options: ICrudMethodOptions): Promise<(E & EntityRelationType)[]>;
|
13
|
+
findById(id: IdType, filter: Filter<E>, _options: ICrudMethodOptions): Promise<E & EntityRelationType>;
|
14
|
+
findOne(filter: Filter<E>, _options: ICrudMethodOptions): Promise<(E & EntityRelationType) | null>;
|
15
|
+
count(where: Where<E>, _options: ICrudMethodOptions): Promise<Count>;
|
16
|
+
create(data: Omit<E, 'id'>, options: ICrudMethodOptions): Promise<E>;
|
17
|
+
updateAll(data: Partial<E>, where: Where<E>, options: ICrudMethodOptions): Promise<Count>;
|
18
|
+
updateWithReturn(id: IdType, data: Partial<E>, options: ICrudMethodOptions): Promise<E>;
|
19
|
+
replaceById(id: IdType, data: E, options: ICrudMethodOptions): Promise<E>;
|
20
|
+
deleteById(id: IdType, _options: ICrudMethodOptions): Promise<{
|
21
|
+
id: IdType;
|
22
|
+
}>;
|
23
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.BaseCrudService = void 0;
|
4
|
+
const base_service_1 = require("./base.service");
|
5
|
+
const common_1 = require("../controllers/common");
|
6
|
+
class BaseCrudService extends base_service_1.BaseService {
|
7
|
+
constructor(opts) {
|
8
|
+
const { scope, repository } = opts;
|
9
|
+
super({ scope });
|
10
|
+
this.repository = repository;
|
11
|
+
}
|
12
|
+
find(filter, _options) {
|
13
|
+
return this.repository.find((0, common_1.applyLimit)(filter));
|
14
|
+
}
|
15
|
+
findById(id, filter, _options) {
|
16
|
+
return this.repository.findById(id, (0, common_1.applyLimit)(filter));
|
17
|
+
}
|
18
|
+
findOne(filter, _options) {
|
19
|
+
return this.repository.findOne(filter);
|
20
|
+
}
|
21
|
+
count(where, _options) {
|
22
|
+
return this.repository.count(where);
|
23
|
+
}
|
24
|
+
create(data, options) {
|
25
|
+
var _a;
|
26
|
+
return this.repository.create(data, {
|
27
|
+
authorId: (_a = options.currentUser) === null || _a === void 0 ? void 0 : _a.userId,
|
28
|
+
});
|
29
|
+
}
|
30
|
+
updateAll(data, where, options) {
|
31
|
+
var _a;
|
32
|
+
return this.repository.updateAll(data, where, {
|
33
|
+
authorId: (_a = options.currentUser) === null || _a === void 0 ? void 0 : _a.userId,
|
34
|
+
});
|
35
|
+
}
|
36
|
+
updateWithReturn(id, data, options) {
|
37
|
+
var _a;
|
38
|
+
return this.repository.updateWithReturn(id, data, {
|
39
|
+
authorId: (_a = options.currentUser) === null || _a === void 0 ? void 0 : _a.userId,
|
40
|
+
});
|
41
|
+
}
|
42
|
+
replaceById(id, data, options) {
|
43
|
+
return new Promise((resolve, reject) => {
|
44
|
+
var _a;
|
45
|
+
this.repository
|
46
|
+
.replaceById(id, data, {
|
47
|
+
authorId: (_a = options.currentUser) === null || _a === void 0 ? void 0 : _a.userId,
|
48
|
+
})
|
49
|
+
.then(() => {
|
50
|
+
resolve(Object.assign(Object.assign({}, data), { id }));
|
51
|
+
})
|
52
|
+
.catch(reject);
|
53
|
+
});
|
54
|
+
}
|
55
|
+
deleteById(id, _options) {
|
56
|
+
return new Promise((resolve, reject) => {
|
57
|
+
this.repository
|
58
|
+
.deleteById(id)
|
59
|
+
.then(() => {
|
60
|
+
resolve({ id });
|
61
|
+
})
|
62
|
+
.catch(reject);
|
63
|
+
});
|
64
|
+
}
|
65
|
+
}
|
66
|
+
exports.BaseCrudService = BaseCrudService;
|
67
|
+
//# sourceMappingURL=base-crud.service.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base-crud.service.js","sourceRoot":"","sources":["../../../src/base/services/base-crud.service.ts"],"names":[],"mappings":";;;AAGA,iDAA6C;AAC7C,kDAAmD;AAGnD,MAAsB,eAAwC,SAAQ,0BAAW;IAG/E,YAAY,IAAgF;QAC1F,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QACnC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,IAAI,CAAC,MAAiB,EAAE,QAA4B;QAClD,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,MAAiB,EAAE,QAA4B;QAClE,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,EAAE,IAAA,mBAAU,EAAC,MAAM,CAAC,CAAC,CAAC;IAC1D,CAAC;IAED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AAC,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,EAAU,EAAE,QAA4B;QACjD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,UAAU;iBACZ,UAAU,CAAC,EAAE,CAAC;iBACd,IAAI,CAAC,GAAG,EAAE;gBACT,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAClB,CAAC,CAAC;iBACD,KAAK,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlED,0CAkEC"}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { IService } from '
|
2
|
-
import { ApplicationLogger } from '
|
1
|
+
import { IService } from '../../common/types';
|
2
|
+
import { ApplicationLogger } from '../../helpers';
|
3
3
|
export declare abstract class BaseService implements IService {
|
4
4
|
protected logger: ApplicationLogger;
|
5
5
|
constructor(opts: {
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base.service.js","sourceRoot":"","sources":["../../../src/base/services/base.service.ts"],"names":[],"mappings":";;;AACA,uCAA6D;AAE7D,MAAsB,WAAW;IAG/B,YAAY,IAAuB;;QACjC,IAAI,CAAC,MAAM,GAAG,uBAAa,CAAC,SAAS,CAAC,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,mCAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3E,CAAC;CACF;AAND,kCAMC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./base.service"), exports);
|
18
|
+
__exportStar(require("./base-crud.service"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/base/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,sDAAoC"}
|
package/dist/common/types.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { AbstractTzRepository } from '../base';
|
1
2
|
import { BaseIdEntity, BaseTzEntity } from '../base/base.model';
|
2
3
|
import { BindingKey } from '@loopback/core';
|
3
4
|
import { Count, DataObject, Entity, Filter, Options, Where } from '@loopback/repository';
|
@@ -62,9 +63,34 @@ export interface IDangerFilter extends Omit<Filter, 'order'> {
|
|
62
63
|
}
|
63
64
|
export interface IService {
|
64
65
|
}
|
66
|
+
export interface ICrudMethodOptions {
|
67
|
+
currentUser: {
|
68
|
+
userId: IdType;
|
69
|
+
roles: Array<{
|
70
|
+
id: IdType;
|
71
|
+
identifier: string;
|
72
|
+
priority: number;
|
73
|
+
}>;
|
74
|
+
[extra: string | symbol]: any;
|
75
|
+
} | null;
|
76
|
+
}
|
77
|
+
export interface ICrudService<E extends BaseTzEntity> extends IService {
|
78
|
+
repository: AbstractTzRepository<E, EntityRelationType>;
|
79
|
+
find(filter: Filter<E>, options: ICrudMethodOptions): Promise<Array<E & EntityRelationType>>;
|
80
|
+
findById(id: IdType, filter: Filter<E>, options: ICrudMethodOptions): Promise<E & EntityRelationType>;
|
81
|
+
findOne(filter: Filter<E>, options: ICrudMethodOptions): Promise<(E & EntityRelationType) | null>;
|
82
|
+
count(where: Where<E>, options: ICrudMethodOptions): Promise<Count>;
|
83
|
+
create(data: Omit<E, 'id'>, options: ICrudMethodOptions): Promise<E>;
|
84
|
+
updateAll(data: Partial<E>, where: Where<E>, options: ICrudMethodOptions): Promise<Count>;
|
85
|
+
updateWithReturn(id: IdType, data: Partial<E>, options: ICrudMethodOptions): Promise<E>;
|
86
|
+
replaceById(id: IdType, data: E, options: ICrudMethodOptions): Promise<E>;
|
87
|
+
deleteById(id: IdType, options: ICrudMethodOptions): Promise<{
|
88
|
+
id: IdType;
|
89
|
+
}>;
|
90
|
+
}
|
65
91
|
export interface IController {
|
66
92
|
}
|
67
|
-
export interface
|
93
|
+
export interface ICrudController extends IController {
|
68
94
|
defaultLimit: number;
|
69
95
|
relation?: {
|
70
96
|
name: string;
|