nicot 1.2.3 → 1.2.5
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/README-CN.md +799 -0
- package/README.md +816 -870
- package/api-cn.md +749 -0
- package/api.md +767 -0
- package/dist/index.cjs +307 -26
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +304 -26
- package/dist/index.mjs.map +3 -3
- package/dist/src/crud-base.d.ts +31 -0
- package/dist/src/decorators/binding.d.ts +7 -0
- package/dist/src/decorators/index.d.ts +1 -0
- package/dist/src/restful.d.ts +30 -1
- package/dist/src/utility/metadata.d.ts +3 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -783,6 +783,18 @@ var QueryOr = (...decs) => {
|
|
|
783
783
|
});
|
|
784
784
|
};
|
|
785
785
|
|
|
786
|
+
// src/decorators/binding.ts
|
|
787
|
+
var DefaultBindingKey = "default";
|
|
788
|
+
var BindingColumn = (bindingKey = DefaultBindingKey) => Metadata.set("bindingColumn", bindingKey, "bindingColumnFields");
|
|
789
|
+
var BindingValue = (bindingKey = DefaultBindingKey) => (obj, key, des) => {
|
|
790
|
+
const isMethod = !!des && typeof des.value === "function";
|
|
791
|
+
Metadata.set(
|
|
792
|
+
"bindingValue",
|
|
793
|
+
{ bindingKey, isMethod },
|
|
794
|
+
"bindingValueFields"
|
|
795
|
+
)(obj, key);
|
|
796
|
+
};
|
|
797
|
+
|
|
786
798
|
// src/dto/cursor-pagination.ts
|
|
787
799
|
var CursorPaginationDto = class {
|
|
788
800
|
};
|
|
@@ -796,7 +808,8 @@ __decorateClass([
|
|
|
796
808
|
required: false,
|
|
797
809
|
type: String
|
|
798
810
|
}),
|
|
799
|
-
NotInResult()
|
|
811
|
+
NotInResult(),
|
|
812
|
+
QueryManual()
|
|
800
813
|
], CursorPaginationDto.prototype, "paginationCursor", 2);
|
|
801
814
|
__decorateClass([
|
|
802
815
|
NotWritable(),
|
|
@@ -808,7 +821,8 @@ __decorateClass([
|
|
|
808
821
|
type: Number,
|
|
809
822
|
minimum: 1
|
|
810
823
|
}),
|
|
811
|
-
NotInResult()
|
|
824
|
+
NotInResult(),
|
|
825
|
+
QueryManual()
|
|
812
826
|
], CursorPaginationDto.prototype, "recordsPerPage", 2);
|
|
813
827
|
var BlankCursorPaginationReturnMessageDto = class extends BlankReturnMessageDto {
|
|
814
828
|
constructor(statusCode, message, cursorResponse) {
|
|
@@ -900,7 +914,8 @@ __decorateClass([
|
|
|
900
914
|
minimum: 1
|
|
901
915
|
}),
|
|
902
916
|
NotInResult(),
|
|
903
|
-
Reflect.metadata("design:type", Number)
|
|
917
|
+
Reflect.metadata("design:type", Number),
|
|
918
|
+
QueryManual()
|
|
904
919
|
], PageSettingsDto.prototype, "pageCount", 2);
|
|
905
920
|
__decorateClass([
|
|
906
921
|
NotWritable(),
|
|
@@ -912,6 +927,7 @@ __decorateClass([
|
|
|
912
927
|
minimum: 1
|
|
913
928
|
}),
|
|
914
929
|
NotInResult(),
|
|
930
|
+
QueryManual(),
|
|
915
931
|
Reflect.metadata("design:type", Number)
|
|
916
932
|
], PageSettingsDto.prototype, "recordsPerPage", 2);
|
|
917
933
|
|
|
@@ -1410,7 +1426,11 @@ var CrudBase = class {
|
|
|
1410
1426
|
});
|
|
1411
1427
|
this.log = new ConsoleLogger(`${this.entityClass.name}Service`);
|
|
1412
1428
|
this._typeormRelations = getTypeormRelations(this.entityClass);
|
|
1429
|
+
// binding things
|
|
1430
|
+
this._tmpBindingMap = /* @__PURE__ */ new Map();
|
|
1431
|
+
this._bindingCache = /* @__PURE__ */ new Map();
|
|
1413
1432
|
}
|
|
1433
|
+
// cleaning entities
|
|
1414
1434
|
_cleanEntityNotInResultFields(ent) {
|
|
1415
1435
|
const visited = /* @__PURE__ */ new Set();
|
|
1416
1436
|
const runSingleObject = (o, cl) => {
|
|
@@ -1454,6 +1474,105 @@ var CrudBase = class {
|
|
|
1454
1474
|
return this._cleanEntityNotInResultFields(ents);
|
|
1455
1475
|
}
|
|
1456
1476
|
}
|
|
1477
|
+
_lookForBindingValueField(bindingKey) {
|
|
1478
|
+
if (this._bindingCache.has(bindingKey)) {
|
|
1479
|
+
return this._bindingCache.get(bindingKey);
|
|
1480
|
+
}
|
|
1481
|
+
const bindingServiceFields = getSpecificFields(this, "bindingValue");
|
|
1482
|
+
const useField = bindingServiceFields.find((f) => {
|
|
1483
|
+
const meta = reflector.get("bindingValue", this, f);
|
|
1484
|
+
return meta?.bindingKey === bindingKey;
|
|
1485
|
+
});
|
|
1486
|
+
if (useField) {
|
|
1487
|
+
const meta = reflector.get("bindingValue", this, useField);
|
|
1488
|
+
const res = {
|
|
1489
|
+
...meta,
|
|
1490
|
+
field: useField
|
|
1491
|
+
};
|
|
1492
|
+
this._bindingCache.set(bindingKey, res);
|
|
1493
|
+
return res;
|
|
1494
|
+
}
|
|
1495
|
+
return void 0;
|
|
1496
|
+
}
|
|
1497
|
+
_resolveBindingValue(entityField) {
|
|
1498
|
+
const bindingKey = reflector.get(
|
|
1499
|
+
"bindingColumn",
|
|
1500
|
+
this.entityClass,
|
|
1501
|
+
entityField
|
|
1502
|
+
);
|
|
1503
|
+
if (!bindingKey) {
|
|
1504
|
+
return void 0;
|
|
1505
|
+
}
|
|
1506
|
+
if (this._tmpBindingMap.has(bindingKey)) {
|
|
1507
|
+
return this._tmpBindingMap.get(bindingKey);
|
|
1508
|
+
}
|
|
1509
|
+
const bindingValueField = this._lookForBindingValueField(bindingKey);
|
|
1510
|
+
if (!bindingValueField) {
|
|
1511
|
+
return void 0;
|
|
1512
|
+
}
|
|
1513
|
+
if (bindingValueField.isMethod) {
|
|
1514
|
+
return this[bindingValueField.field]();
|
|
1515
|
+
} else {
|
|
1516
|
+
return this[bindingValueField.field];
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
// MUST be called 1st on every CRUD operation
|
|
1520
|
+
async getBindingPartialEntity() {
|
|
1521
|
+
const bindingFields = getSpecificFields(this.entityClass, "bindingColumn");
|
|
1522
|
+
if (!bindingFields.length) {
|
|
1523
|
+
return {};
|
|
1524
|
+
}
|
|
1525
|
+
const values = bindingFields.map((field, i) => {
|
|
1526
|
+
return {
|
|
1527
|
+
field,
|
|
1528
|
+
value: this._resolveBindingValue(field),
|
|
1529
|
+
i
|
|
1530
|
+
};
|
|
1531
|
+
});
|
|
1532
|
+
this._tmpBindingMap.clear();
|
|
1533
|
+
const containingPromiseValues = values.filter(
|
|
1534
|
+
(v) => v.value instanceof Promise
|
|
1535
|
+
);
|
|
1536
|
+
if (containingPromiseValues.length) {
|
|
1537
|
+
await Promise.all(
|
|
1538
|
+
containingPromiseValues.map(async (v) => {
|
|
1539
|
+
v.value = await v.value;
|
|
1540
|
+
})
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
const res = {};
|
|
1544
|
+
for (const v of values) {
|
|
1545
|
+
if (v.value != null) {
|
|
1546
|
+
res[v.field] = v.value;
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
return res;
|
|
1550
|
+
}
|
|
1551
|
+
useBinding(value, bindngKey = DefaultBindingKey) {
|
|
1552
|
+
this._tmpBindingMap.set(bindngKey, value);
|
|
1553
|
+
return this;
|
|
1554
|
+
}
|
|
1555
|
+
_freezeBindings() {
|
|
1556
|
+
const res = {};
|
|
1557
|
+
for (const [key, value] of this._tmpBindingMap.entries()) {
|
|
1558
|
+
res[key] = value;
|
|
1559
|
+
}
|
|
1560
|
+
this._tmpBindingMap.clear();
|
|
1561
|
+
return res;
|
|
1562
|
+
}
|
|
1563
|
+
_restoreBindings(frozen) {
|
|
1564
|
+
this._tmpBindingMap.clear();
|
|
1565
|
+
for (const key of Object.keys(frozen)) {
|
|
1566
|
+
this._tmpBindingMap.set(key, frozen[key]);
|
|
1567
|
+
}
|
|
1568
|
+
return this;
|
|
1569
|
+
}
|
|
1570
|
+
async beforeSuper(fn) {
|
|
1571
|
+
const snap = this._freezeBindings();
|
|
1572
|
+
const res = await fn();
|
|
1573
|
+
this._restoreBindings(snap);
|
|
1574
|
+
return res;
|
|
1575
|
+
}
|
|
1457
1576
|
async _batchCreate(ents, beforeCreate, skipErrors = false) {
|
|
1458
1577
|
const entsWithId = ents.filter((ent) => ent.id != null);
|
|
1459
1578
|
return this.repo.manager.transaction(async (mdb) => {
|
|
@@ -1559,6 +1678,7 @@ var CrudBase = class {
|
|
|
1559
1678
|
});
|
|
1560
1679
|
}
|
|
1561
1680
|
async create(_ent, beforeCreate) {
|
|
1681
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1562
1682
|
if (!_ent) {
|
|
1563
1683
|
throw new BlankReturnMessageDto2(400, "Invalid entity").toException();
|
|
1564
1684
|
}
|
|
@@ -1593,6 +1713,7 @@ var CrudBase = class {
|
|
|
1593
1713
|
}
|
|
1594
1714
|
}
|
|
1595
1715
|
}
|
|
1716
|
+
Object.assign(ent, bindingEnt);
|
|
1596
1717
|
if (beforeCreate) {
|
|
1597
1718
|
await beforeCreate(repo);
|
|
1598
1719
|
}
|
|
@@ -1658,10 +1779,20 @@ var CrudBase = class {
|
|
|
1658
1779
|
queryBuilder() {
|
|
1659
1780
|
return this.repo.createQueryBuilder(this.entityAliasName);
|
|
1660
1781
|
}
|
|
1782
|
+
_applyQueryFromBinding(bindingEnt, qb) {
|
|
1783
|
+
for (const [key, value] of Object.entries(bindingEnt)) {
|
|
1784
|
+
const typeormKey = `_binding_${key}`;
|
|
1785
|
+
qb.andWhere(`${this.entityAliasName}.${key} = :${typeormKey}`, {
|
|
1786
|
+
[typeormKey]: value
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
}
|
|
1661
1790
|
async findOne(id, extraQuery = () => {
|
|
1662
1791
|
}) {
|
|
1792
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1663
1793
|
const query = this.queryBuilder().where(`${this.entityAliasName}.id = :id`, { id }).take(1);
|
|
1664
1794
|
this._applyQueryRelations(query);
|
|
1795
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1665
1796
|
this.extraGetQuery(query);
|
|
1666
1797
|
extraQuery(query);
|
|
1667
1798
|
query.take(1);
|
|
@@ -1692,6 +1823,7 @@ var CrudBase = class {
|
|
|
1692
1823
|
}
|
|
1693
1824
|
async _preFindAll(ent, extraQuery = () => {
|
|
1694
1825
|
}) {
|
|
1826
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1695
1827
|
const query = this.queryBuilder().where("1 = 1");
|
|
1696
1828
|
const newEnt = new this.entityClass();
|
|
1697
1829
|
if (ent) {
|
|
@@ -1701,6 +1833,7 @@ var CrudBase = class {
|
|
|
1701
1833
|
}
|
|
1702
1834
|
this._applyQueryRelations(query);
|
|
1703
1835
|
this._applyQueryFilters(query, newEnt);
|
|
1836
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1704
1837
|
const pageSettings = newEnt instanceof PageSettingsDto ? newEnt : Object.assign(new PageSettingsDto(), newEnt);
|
|
1705
1838
|
this.extraGetQuery(query);
|
|
1706
1839
|
extraQuery(query);
|
|
@@ -1759,6 +1892,7 @@ var CrudBase = class {
|
|
|
1759
1892
|
}
|
|
1760
1893
|
}
|
|
1761
1894
|
async update(id, entPart, cond = {}) {
|
|
1895
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1762
1896
|
let result;
|
|
1763
1897
|
const ent = new this.entityClass();
|
|
1764
1898
|
Object.assign(ent, entPart);
|
|
@@ -1771,6 +1905,7 @@ var CrudBase = class {
|
|
|
1771
1905
|
result = await this.repo.update(
|
|
1772
1906
|
{
|
|
1773
1907
|
id,
|
|
1908
|
+
...bindingEnt,
|
|
1774
1909
|
...cond
|
|
1775
1910
|
},
|
|
1776
1911
|
ent
|
|
@@ -1792,9 +1927,11 @@ var CrudBase = class {
|
|
|
1792
1927
|
return new BlankReturnMessageDto2(200, "success");
|
|
1793
1928
|
}
|
|
1794
1929
|
async delete(id, cond = {}) {
|
|
1930
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1795
1931
|
let result;
|
|
1796
1932
|
const searchCond = {
|
|
1797
1933
|
id,
|
|
1934
|
+
...bindingEnt,
|
|
1798
1935
|
...cond
|
|
1799
1936
|
};
|
|
1800
1937
|
try {
|
|
@@ -1812,6 +1949,7 @@ var CrudBase = class {
|
|
|
1812
1949
|
return new BlankReturnMessageDto2(200, "success");
|
|
1813
1950
|
}
|
|
1814
1951
|
async importEntities(_ents, extraChecking) {
|
|
1952
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1815
1953
|
const ents = _ents.map((ent) => {
|
|
1816
1954
|
const newEnt = new this.entityClass();
|
|
1817
1955
|
Object.assign(
|
|
@@ -1839,6 +1977,9 @@ var CrudBase = class {
|
|
|
1839
1977
|
const remainingEnts = ents.filter(
|
|
1840
1978
|
(ent) => !invalidResults.find((result) => result.entry === ent)
|
|
1841
1979
|
);
|
|
1980
|
+
for (const ent of remainingEnts) {
|
|
1981
|
+
Object.assign(ent, bindingEnt);
|
|
1982
|
+
}
|
|
1842
1983
|
await Promise.all(remainingEnts.map((ent) => ent.beforeCreate?.()));
|
|
1843
1984
|
const data = await this._batchCreate(remainingEnts, void 0, true);
|
|
1844
1985
|
await Promise.all(data.results.map((e) => e.afterCreate?.()));
|
|
@@ -1859,7 +2000,11 @@ var CrudBase = class {
|
|
|
1859
2000
|
);
|
|
1860
2001
|
}
|
|
1861
2002
|
async exists(id) {
|
|
1862
|
-
const
|
|
2003
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
2004
|
+
const ent = await this.repo.findOne({
|
|
2005
|
+
where: { id, ...bindingEnt },
|
|
2006
|
+
select: ["id"]
|
|
2007
|
+
});
|
|
1863
2008
|
return !!ent;
|
|
1864
2009
|
}
|
|
1865
2010
|
async _loadFullTextIndex() {
|
|
@@ -2111,7 +2256,132 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2111
2256
|
filterRelations(entityClass, options.relations);
|
|
2112
2257
|
}
|
|
2113
2258
|
}
|
|
2114
|
-
|
|
2259
|
+
omitInput(...fields) {
|
|
2260
|
+
return new _RestfulFactory(
|
|
2261
|
+
this.entityClass,
|
|
2262
|
+
{
|
|
2263
|
+
...this.options,
|
|
2264
|
+
fieldsToOmit: _5.uniq([...this.options.fieldsToOmit || [], ...fields])
|
|
2265
|
+
},
|
|
2266
|
+
this.__resolveVisited
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
omitWrite(...fields) {
|
|
2270
|
+
return new _RestfulFactory(
|
|
2271
|
+
this.entityClass,
|
|
2272
|
+
{
|
|
2273
|
+
...this.options,
|
|
2274
|
+
writeFieldsToOmit: _5.uniq([
|
|
2275
|
+
...this.options.writeFieldsToOmit || [],
|
|
2276
|
+
...fields
|
|
2277
|
+
])
|
|
2278
|
+
},
|
|
2279
|
+
this.__resolveVisited
|
|
2280
|
+
);
|
|
2281
|
+
}
|
|
2282
|
+
omitCreate(...fields) {
|
|
2283
|
+
return new _RestfulFactory(
|
|
2284
|
+
this.entityClass,
|
|
2285
|
+
{
|
|
2286
|
+
...this.options,
|
|
2287
|
+
createFieldsToOmit: _5.uniq([
|
|
2288
|
+
...this.options.createFieldsToOmit || [],
|
|
2289
|
+
...fields
|
|
2290
|
+
])
|
|
2291
|
+
},
|
|
2292
|
+
this.__resolveVisited
|
|
2293
|
+
);
|
|
2294
|
+
}
|
|
2295
|
+
omitUpdate(...fields) {
|
|
2296
|
+
return new _RestfulFactory(
|
|
2297
|
+
this.entityClass,
|
|
2298
|
+
{
|
|
2299
|
+
...this.options,
|
|
2300
|
+
updateFieldsToOmit: _5.uniq([
|
|
2301
|
+
...this.options.updateFieldsToOmit || [],
|
|
2302
|
+
...fields
|
|
2303
|
+
])
|
|
2304
|
+
},
|
|
2305
|
+
this.__resolveVisited
|
|
2306
|
+
);
|
|
2307
|
+
}
|
|
2308
|
+
omitFindAll(...fields) {
|
|
2309
|
+
return new _RestfulFactory(
|
|
2310
|
+
this.entityClass,
|
|
2311
|
+
{
|
|
2312
|
+
...this.options,
|
|
2313
|
+
findAllFieldsToOmit: _5.uniq([
|
|
2314
|
+
...this.options.findAllFieldsToOmit || [],
|
|
2315
|
+
...fields
|
|
2316
|
+
])
|
|
2317
|
+
},
|
|
2318
|
+
this.__resolveVisited
|
|
2319
|
+
);
|
|
2320
|
+
}
|
|
2321
|
+
omitOutput(...fields) {
|
|
2322
|
+
return new _RestfulFactory(
|
|
2323
|
+
this.entityClass,
|
|
2324
|
+
{
|
|
2325
|
+
...this.options,
|
|
2326
|
+
outputFieldsToOmit: _5.uniq([
|
|
2327
|
+
...this.options.outputFieldsToOmit || [],
|
|
2328
|
+
...fields
|
|
2329
|
+
])
|
|
2330
|
+
},
|
|
2331
|
+
this.__resolveVisited
|
|
2332
|
+
);
|
|
2333
|
+
}
|
|
2334
|
+
pathPrefix(prefix) {
|
|
2335
|
+
return new _RestfulFactory(
|
|
2336
|
+
this.entityClass,
|
|
2337
|
+
{
|
|
2338
|
+
...this.options,
|
|
2339
|
+
prefix
|
|
2340
|
+
},
|
|
2341
|
+
this.__resolveVisited
|
|
2342
|
+
);
|
|
2343
|
+
}
|
|
2344
|
+
keepEntityVersioningDates(enable = true) {
|
|
2345
|
+
return new _RestfulFactory(
|
|
2346
|
+
this.entityClass,
|
|
2347
|
+
{
|
|
2348
|
+
...this.options,
|
|
2349
|
+
keepEntityVersioningDates: enable
|
|
2350
|
+
},
|
|
2351
|
+
this.__resolveVisited
|
|
2352
|
+
);
|
|
2353
|
+
}
|
|
2354
|
+
skipNonQueryableFields(enable = true) {
|
|
2355
|
+
return new _RestfulFactory(
|
|
2356
|
+
this.entityClass,
|
|
2357
|
+
{
|
|
2358
|
+
...this.options,
|
|
2359
|
+
skipNonQueryableFields: enable
|
|
2360
|
+
},
|
|
2361
|
+
this.__resolveVisited
|
|
2362
|
+
);
|
|
2363
|
+
}
|
|
2364
|
+
renameEntityClass(name) {
|
|
2365
|
+
return new _RestfulFactory(
|
|
2366
|
+
this.entityClass,
|
|
2367
|
+
{
|
|
2368
|
+
...this.options,
|
|
2369
|
+
entityClassName: name
|
|
2370
|
+
},
|
|
2371
|
+
this.__resolveVisited
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
useRelations(...relations) {
|
|
2375
|
+
return new _RestfulFactory(
|
|
2376
|
+
this.entityClass,
|
|
2377
|
+
{
|
|
2378
|
+
...this.options,
|
|
2379
|
+
relations: [...this.options.relations || [], ...relations]
|
|
2380
|
+
},
|
|
2381
|
+
this.__resolveVisited
|
|
2382
|
+
);
|
|
2383
|
+
}
|
|
2384
|
+
get entityClassName() {
|
|
2115
2385
|
return this.options.entityClassName || this.entityClass.name;
|
|
2116
2386
|
}
|
|
2117
2387
|
get fieldsToOmit() {
|
|
@@ -2135,7 +2405,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2135
2405
|
get createDto() {
|
|
2136
2406
|
return RenameClass(
|
|
2137
2407
|
OmitTypeExclude(this.entityClass, this.fieldsInCreateToOmit),
|
|
2138
|
-
`Create${this.
|
|
2408
|
+
`Create${this.entityClassName}Dto`
|
|
2139
2409
|
);
|
|
2140
2410
|
}
|
|
2141
2411
|
get fieldsInUpdateToOmit() {
|
|
@@ -2150,7 +2420,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2150
2420
|
get updateDto() {
|
|
2151
2421
|
return RenameClass(
|
|
2152
2422
|
PartialType(OmitTypeExclude(this.entityClass, this.fieldsInUpdateToOmit)),
|
|
2153
|
-
`Update${this.
|
|
2423
|
+
`Update${this.entityClassName}Dto`
|
|
2154
2424
|
);
|
|
2155
2425
|
}
|
|
2156
2426
|
get importDto() {
|
|
@@ -2168,7 +2438,12 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2168
2438
|
}
|
|
2169
2439
|
get queryableFields() {
|
|
2170
2440
|
return _5.difference(
|
|
2171
|
-
|
|
2441
|
+
[
|
|
2442
|
+
...getSpecificFields(this.entityClass, "queryCondition"),
|
|
2443
|
+
"pageCount",
|
|
2444
|
+
"recordsPerPage",
|
|
2445
|
+
"paginationCursor"
|
|
2446
|
+
],
|
|
2172
2447
|
this.fieldsInGetToOmit
|
|
2173
2448
|
);
|
|
2174
2449
|
}
|
|
@@ -2189,7 +2464,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2189
2464
|
if (this.options.skipNonQueryableFields) {
|
|
2190
2465
|
cl = PickTypeExpose(cl, this.queryableFields);
|
|
2191
2466
|
}
|
|
2192
|
-
return RenameClass(cl, `Find${this.
|
|
2467
|
+
return RenameClass(cl, `Find${this.entityClassName}Dto`);
|
|
2193
2468
|
}
|
|
2194
2469
|
get findAllCursorPaginatedDto() {
|
|
2195
2470
|
return RenameClass(
|
|
@@ -2197,7 +2472,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2197
2472
|
OmitTypeExclude(this.findAllDto, ["pageCount"]),
|
|
2198
2473
|
CursorPaginationDto
|
|
2199
2474
|
),
|
|
2200
|
-
`Find${this.
|
|
2475
|
+
`Find${this.entityClassName}CursorPaginatedDto`
|
|
2201
2476
|
);
|
|
2202
2477
|
}
|
|
2203
2478
|
get entityResultDto() {
|
|
@@ -2240,7 +2515,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2240
2515
|
const relationFactory = new _RestfulFactory(
|
|
2241
2516
|
relation.propertyClass,
|
|
2242
2517
|
{
|
|
2243
|
-
entityClassName: `${this.
|
|
2518
|
+
entityClassName: `${this.entityClassName}${this.options.relations ? upperFirst(relation.propertyName) : relation.propertyClass.name}`,
|
|
2244
2519
|
relations: this.options.relations && getNextLevelRelations(
|
|
2245
2520
|
this.options.relations.map(extractRelationName),
|
|
2246
2521
|
relation.propertyName
|
|
@@ -2271,7 +2546,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2271
2546
|
}
|
|
2272
2547
|
const res = RenameClass(
|
|
2273
2548
|
resultDto,
|
|
2274
|
-
`${this.
|
|
2549
|
+
`${this.entityClassName}ResultDto`
|
|
2275
2550
|
);
|
|
2276
2551
|
const currentContainer = this.__resolveVisited.get(this.entityClass);
|
|
2277
2552
|
if (currentContainer) {
|
|
@@ -2291,7 +2566,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2291
2566
|
(m) => !m.keepInCreate
|
|
2292
2567
|
)
|
|
2293
2568
|
]),
|
|
2294
|
-
`${this.
|
|
2569
|
+
`${this.entityClassName}CreateResultDto`
|
|
2295
2570
|
);
|
|
2296
2571
|
}
|
|
2297
2572
|
get entityReturnMessageDto() {
|
|
@@ -2333,14 +2608,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2333
2608
|
this.usePrefix(Post),
|
|
2334
2609
|
HttpCode(200),
|
|
2335
2610
|
ApiOperation({
|
|
2336
|
-
summary: `Create a new ${this.
|
|
2611
|
+
summary: `Create a new ${this.entityClassName}`,
|
|
2337
2612
|
...extras
|
|
2338
2613
|
}),
|
|
2339
2614
|
ApiBody({ type: this.createDto }),
|
|
2340
2615
|
ApiOkResponse({ type: this.entityCreateReturnMessageDto }),
|
|
2341
2616
|
ApiBadRequestResponse({
|
|
2342
2617
|
type: BlankReturnMessageDto3,
|
|
2343
|
-
description: `The ${this.
|
|
2618
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2344
2619
|
})
|
|
2345
2620
|
]);
|
|
2346
2621
|
}
|
|
@@ -2351,14 +2626,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2351
2626
|
return MergeMethodDecorators([
|
|
2352
2627
|
this.usePrefix(Get, ":id"),
|
|
2353
2628
|
ApiOperation({
|
|
2354
|
-
summary: `Find a ${this.
|
|
2629
|
+
summary: `Find a ${this.entityClassName} by id`,
|
|
2355
2630
|
...extras
|
|
2356
2631
|
}),
|
|
2357
2632
|
ApiParam({ name: "id", type: this.idType, required: true }),
|
|
2358
2633
|
ApiOkResponse({ type: this.entityReturnMessageDto }),
|
|
2359
2634
|
ApiNotFoundResponse({
|
|
2360
2635
|
type: BlankReturnMessageDto3,
|
|
2361
|
-
description: `The ${this.
|
|
2636
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2362
2637
|
})
|
|
2363
2638
|
]);
|
|
2364
2639
|
}
|
|
@@ -2373,7 +2648,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2373
2648
|
return MergeMethodDecorators([
|
|
2374
2649
|
this.usePrefix(Get),
|
|
2375
2650
|
ApiOperation({
|
|
2376
|
-
summary: `Find all ${this.
|
|
2651
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2377
2652
|
...extras
|
|
2378
2653
|
}),
|
|
2379
2654
|
ApiOkResponse({ type: this.entityArrayReturnMessageDto })
|
|
@@ -2383,7 +2658,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2383
2658
|
return MergeMethodDecorators([
|
|
2384
2659
|
this.usePrefix(Get),
|
|
2385
2660
|
ApiOperation({
|
|
2386
|
-
summary: `Find all ${this.
|
|
2661
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2387
2662
|
...extras
|
|
2388
2663
|
}),
|
|
2389
2664
|
ApiOkResponse({ type: this.entityCursorPaginationReturnMessageDto })
|
|
@@ -2410,7 +2685,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2410
2685
|
this.usePrefix(Patch, ":id"),
|
|
2411
2686
|
HttpCode(200),
|
|
2412
2687
|
ApiOperation({
|
|
2413
|
-
summary: `Update a ${this.
|
|
2688
|
+
summary: `Update a ${this.entityClassName} by id`,
|
|
2414
2689
|
...extras
|
|
2415
2690
|
}),
|
|
2416
2691
|
ApiParam({ name: "id", type: this.idType, required: true }),
|
|
@@ -2418,11 +2693,11 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2418
2693
|
ApiOkResponse({ type: BlankReturnMessageDto3 }),
|
|
2419
2694
|
ApiNotFoundResponse({
|
|
2420
2695
|
type: BlankReturnMessageDto3,
|
|
2421
|
-
description: `The ${this.
|
|
2696
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2422
2697
|
}),
|
|
2423
2698
|
ApiBadRequestResponse({
|
|
2424
2699
|
type: BlankReturnMessageDto3,
|
|
2425
|
-
description: `The ${this.
|
|
2700
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2426
2701
|
}),
|
|
2427
2702
|
ApiInternalServerErrorResponse({
|
|
2428
2703
|
type: BlankReturnMessageDto3,
|
|
@@ -2438,14 +2713,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2438
2713
|
this.usePrefix(Delete, ":id"),
|
|
2439
2714
|
HttpCode(200),
|
|
2440
2715
|
ApiOperation({
|
|
2441
|
-
summary: `Delete a ${this.
|
|
2716
|
+
summary: `Delete a ${this.entityClassName} by id`,
|
|
2442
2717
|
...extras
|
|
2443
2718
|
}),
|
|
2444
2719
|
ApiParam({ name: "id", type: this.idType, required: true }),
|
|
2445
2720
|
ApiOkResponse({ type: BlankReturnMessageDto3 }),
|
|
2446
2721
|
ApiNotFoundResponse({
|
|
2447
2722
|
type: BlankReturnMessageDto3,
|
|
2448
|
-
description: `The ${this.
|
|
2723
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2449
2724
|
}),
|
|
2450
2725
|
ApiInternalServerErrorResponse({
|
|
2451
2726
|
type: BlankReturnMessageDto3,
|
|
@@ -2458,7 +2733,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2458
2733
|
Post("import"),
|
|
2459
2734
|
HttpCode(200),
|
|
2460
2735
|
ApiOperation({
|
|
2461
|
-
summary: `Import ${this.
|
|
2736
|
+
summary: `Import ${this.entityClassName}`,
|
|
2462
2737
|
...extras
|
|
2463
2738
|
}),
|
|
2464
2739
|
ApiBody({ type: this.importDto }),
|
|
@@ -2580,7 +2855,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2580
2855
|
Object.defineProperty(cl.prototype, method, descriptor);
|
|
2581
2856
|
});
|
|
2582
2857
|
}
|
|
2583
|
-
return RenameClass(cl, `${this.
|
|
2858
|
+
return RenameClass(cl, `${this.entityClassName}Controller`);
|
|
2584
2859
|
}
|
|
2585
2860
|
crudService(options = {}) {
|
|
2586
2861
|
return CrudService(this.entityClass, {
|
|
@@ -2711,6 +2986,8 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
2711
2986
|
}
|
|
2712
2987
|
);
|
|
2713
2988
|
export {
|
|
2989
|
+
BindingColumn,
|
|
2990
|
+
BindingValue,
|
|
2714
2991
|
BlankCursorPaginationReturnMessageDto,
|
|
2715
2992
|
BoolColumn,
|
|
2716
2993
|
CrudBase,
|
|
@@ -2718,6 +2995,7 @@ export {
|
|
|
2718
2995
|
CursorPaginationDto,
|
|
2719
2996
|
CursorPaginationReturnMessageDto,
|
|
2720
2997
|
DateColumn,
|
|
2998
|
+
DefaultBindingKey,
|
|
2721
2999
|
EnumColumn,
|
|
2722
3000
|
FloatColumn,
|
|
2723
3001
|
GenericCursorPaginationReturnMessageDto,
|