nicot 1.2.4 → 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 +234 -0
- package/README.md +258 -0
- package/dist/index.cjs +294 -22
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +291 -22
- 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.cjs
CHANGED
|
@@ -38,6 +38,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
38
38
|
// index.ts
|
|
39
39
|
var index_exports = {};
|
|
40
40
|
__export(index_exports, {
|
|
41
|
+
BindingColumn: () => BindingColumn,
|
|
42
|
+
BindingValue: () => BindingValue,
|
|
41
43
|
BlankCursorPaginationReturnMessageDto: () => BlankCursorPaginationReturnMessageDto,
|
|
42
44
|
BoolColumn: () => BoolColumn,
|
|
43
45
|
CrudBase: () => CrudBase,
|
|
@@ -45,6 +47,7 @@ __export(index_exports, {
|
|
|
45
47
|
CursorPaginationDto: () => CursorPaginationDto,
|
|
46
48
|
CursorPaginationReturnMessageDto: () => CursorPaginationReturnMessageDto,
|
|
47
49
|
DateColumn: () => DateColumn,
|
|
50
|
+
DefaultBindingKey: () => DefaultBindingKey,
|
|
48
51
|
EnumColumn: () => EnumColumn,
|
|
49
52
|
FloatColumn: () => FloatColumn,
|
|
50
53
|
GenericCursorPaginationReturnMessageDto: () => GenericCursorPaginationReturnMessageDto,
|
|
@@ -870,6 +873,18 @@ var QueryOr = (...decs) => {
|
|
|
870
873
|
});
|
|
871
874
|
};
|
|
872
875
|
|
|
876
|
+
// src/decorators/binding.ts
|
|
877
|
+
var DefaultBindingKey = "default";
|
|
878
|
+
var BindingColumn = (bindingKey = DefaultBindingKey) => Metadata.set("bindingColumn", bindingKey, "bindingColumnFields");
|
|
879
|
+
var BindingValue = (bindingKey = DefaultBindingKey) => (obj, key, des) => {
|
|
880
|
+
const isMethod = !!des && typeof des.value === "function";
|
|
881
|
+
Metadata.set(
|
|
882
|
+
"bindingValue",
|
|
883
|
+
{ bindingKey, isMethod },
|
|
884
|
+
"bindingValueFields"
|
|
885
|
+
)(obj, key);
|
|
886
|
+
};
|
|
887
|
+
|
|
873
888
|
// src/dto/cursor-pagination.ts
|
|
874
889
|
var CursorPaginationDto = class {
|
|
875
890
|
};
|
|
@@ -1491,7 +1506,11 @@ var CrudBase = class {
|
|
|
1491
1506
|
});
|
|
1492
1507
|
this.log = new import_common2.ConsoleLogger(`${this.entityClass.name}Service`);
|
|
1493
1508
|
this._typeormRelations = getTypeormRelations(this.entityClass);
|
|
1509
|
+
// binding things
|
|
1510
|
+
this._tmpBindingMap = /* @__PURE__ */ new Map();
|
|
1511
|
+
this._bindingCache = /* @__PURE__ */ new Map();
|
|
1494
1512
|
}
|
|
1513
|
+
// cleaning entities
|
|
1495
1514
|
_cleanEntityNotInResultFields(ent) {
|
|
1496
1515
|
const visited = /* @__PURE__ */ new Set();
|
|
1497
1516
|
const runSingleObject = (o, cl) => {
|
|
@@ -1535,6 +1554,105 @@ var CrudBase = class {
|
|
|
1535
1554
|
return this._cleanEntityNotInResultFields(ents);
|
|
1536
1555
|
}
|
|
1537
1556
|
}
|
|
1557
|
+
_lookForBindingValueField(bindingKey) {
|
|
1558
|
+
if (this._bindingCache.has(bindingKey)) {
|
|
1559
|
+
return this._bindingCache.get(bindingKey);
|
|
1560
|
+
}
|
|
1561
|
+
const bindingServiceFields = getSpecificFields(this, "bindingValue");
|
|
1562
|
+
const useField = bindingServiceFields.find((f) => {
|
|
1563
|
+
const meta = reflector.get("bindingValue", this, f);
|
|
1564
|
+
return meta?.bindingKey === bindingKey;
|
|
1565
|
+
});
|
|
1566
|
+
if (useField) {
|
|
1567
|
+
const meta = reflector.get("bindingValue", this, useField);
|
|
1568
|
+
const res = {
|
|
1569
|
+
...meta,
|
|
1570
|
+
field: useField
|
|
1571
|
+
};
|
|
1572
|
+
this._bindingCache.set(bindingKey, res);
|
|
1573
|
+
return res;
|
|
1574
|
+
}
|
|
1575
|
+
return void 0;
|
|
1576
|
+
}
|
|
1577
|
+
_resolveBindingValue(entityField) {
|
|
1578
|
+
const bindingKey = reflector.get(
|
|
1579
|
+
"bindingColumn",
|
|
1580
|
+
this.entityClass,
|
|
1581
|
+
entityField
|
|
1582
|
+
);
|
|
1583
|
+
if (!bindingKey) {
|
|
1584
|
+
return void 0;
|
|
1585
|
+
}
|
|
1586
|
+
if (this._tmpBindingMap.has(bindingKey)) {
|
|
1587
|
+
return this._tmpBindingMap.get(bindingKey);
|
|
1588
|
+
}
|
|
1589
|
+
const bindingValueField = this._lookForBindingValueField(bindingKey);
|
|
1590
|
+
if (!bindingValueField) {
|
|
1591
|
+
return void 0;
|
|
1592
|
+
}
|
|
1593
|
+
if (bindingValueField.isMethod) {
|
|
1594
|
+
return this[bindingValueField.field]();
|
|
1595
|
+
} else {
|
|
1596
|
+
return this[bindingValueField.field];
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
// MUST be called 1st on every CRUD operation
|
|
1600
|
+
async getBindingPartialEntity() {
|
|
1601
|
+
const bindingFields = getSpecificFields(this.entityClass, "bindingColumn");
|
|
1602
|
+
if (!bindingFields.length) {
|
|
1603
|
+
return {};
|
|
1604
|
+
}
|
|
1605
|
+
const values = bindingFields.map((field, i) => {
|
|
1606
|
+
return {
|
|
1607
|
+
field,
|
|
1608
|
+
value: this._resolveBindingValue(field),
|
|
1609
|
+
i
|
|
1610
|
+
};
|
|
1611
|
+
});
|
|
1612
|
+
this._tmpBindingMap.clear();
|
|
1613
|
+
const containingPromiseValues = values.filter(
|
|
1614
|
+
(v) => v.value instanceof Promise
|
|
1615
|
+
);
|
|
1616
|
+
if (containingPromiseValues.length) {
|
|
1617
|
+
await Promise.all(
|
|
1618
|
+
containingPromiseValues.map(async (v) => {
|
|
1619
|
+
v.value = await v.value;
|
|
1620
|
+
})
|
|
1621
|
+
);
|
|
1622
|
+
}
|
|
1623
|
+
const res = {};
|
|
1624
|
+
for (const v of values) {
|
|
1625
|
+
if (v.value != null) {
|
|
1626
|
+
res[v.field] = v.value;
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
return res;
|
|
1630
|
+
}
|
|
1631
|
+
useBinding(value, bindngKey = DefaultBindingKey) {
|
|
1632
|
+
this._tmpBindingMap.set(bindngKey, value);
|
|
1633
|
+
return this;
|
|
1634
|
+
}
|
|
1635
|
+
_freezeBindings() {
|
|
1636
|
+
const res = {};
|
|
1637
|
+
for (const [key, value] of this._tmpBindingMap.entries()) {
|
|
1638
|
+
res[key] = value;
|
|
1639
|
+
}
|
|
1640
|
+
this._tmpBindingMap.clear();
|
|
1641
|
+
return res;
|
|
1642
|
+
}
|
|
1643
|
+
_restoreBindings(frozen) {
|
|
1644
|
+
this._tmpBindingMap.clear();
|
|
1645
|
+
for (const key of Object.keys(frozen)) {
|
|
1646
|
+
this._tmpBindingMap.set(key, frozen[key]);
|
|
1647
|
+
}
|
|
1648
|
+
return this;
|
|
1649
|
+
}
|
|
1650
|
+
async beforeSuper(fn) {
|
|
1651
|
+
const snap = this._freezeBindings();
|
|
1652
|
+
const res = await fn();
|
|
1653
|
+
this._restoreBindings(snap);
|
|
1654
|
+
return res;
|
|
1655
|
+
}
|
|
1538
1656
|
async _batchCreate(ents, beforeCreate, skipErrors = false) {
|
|
1539
1657
|
const entsWithId = ents.filter((ent) => ent.id != null);
|
|
1540
1658
|
return this.repo.manager.transaction(async (mdb) => {
|
|
@@ -1640,6 +1758,7 @@ var CrudBase = class {
|
|
|
1640
1758
|
});
|
|
1641
1759
|
}
|
|
1642
1760
|
async create(_ent, beforeCreate) {
|
|
1761
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1643
1762
|
if (!_ent) {
|
|
1644
1763
|
throw new import_nesties8.BlankReturnMessageDto(400, "Invalid entity").toException();
|
|
1645
1764
|
}
|
|
@@ -1674,6 +1793,7 @@ var CrudBase = class {
|
|
|
1674
1793
|
}
|
|
1675
1794
|
}
|
|
1676
1795
|
}
|
|
1796
|
+
Object.assign(ent, bindingEnt);
|
|
1677
1797
|
if (beforeCreate) {
|
|
1678
1798
|
await beforeCreate(repo);
|
|
1679
1799
|
}
|
|
@@ -1739,10 +1859,20 @@ var CrudBase = class {
|
|
|
1739
1859
|
queryBuilder() {
|
|
1740
1860
|
return this.repo.createQueryBuilder(this.entityAliasName);
|
|
1741
1861
|
}
|
|
1862
|
+
_applyQueryFromBinding(bindingEnt, qb) {
|
|
1863
|
+
for (const [key, value] of Object.entries(bindingEnt)) {
|
|
1864
|
+
const typeormKey = `_binding_${key}`;
|
|
1865
|
+
qb.andWhere(`${this.entityAliasName}.${key} = :${typeormKey}`, {
|
|
1866
|
+
[typeormKey]: value
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
}
|
|
1742
1870
|
async findOne(id, extraQuery = () => {
|
|
1743
1871
|
}) {
|
|
1872
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1744
1873
|
const query = this.queryBuilder().where(`${this.entityAliasName}.id = :id`, { id }).take(1);
|
|
1745
1874
|
this._applyQueryRelations(query);
|
|
1875
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1746
1876
|
this.extraGetQuery(query);
|
|
1747
1877
|
extraQuery(query);
|
|
1748
1878
|
query.take(1);
|
|
@@ -1773,6 +1903,7 @@ var CrudBase = class {
|
|
|
1773
1903
|
}
|
|
1774
1904
|
async _preFindAll(ent, extraQuery = () => {
|
|
1775
1905
|
}) {
|
|
1906
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1776
1907
|
const query = this.queryBuilder().where("1 = 1");
|
|
1777
1908
|
const newEnt = new this.entityClass();
|
|
1778
1909
|
if (ent) {
|
|
@@ -1782,6 +1913,7 @@ var CrudBase = class {
|
|
|
1782
1913
|
}
|
|
1783
1914
|
this._applyQueryRelations(query);
|
|
1784
1915
|
this._applyQueryFilters(query, newEnt);
|
|
1916
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1785
1917
|
const pageSettings = newEnt instanceof PageSettingsDto ? newEnt : Object.assign(new PageSettingsDto(), newEnt);
|
|
1786
1918
|
this.extraGetQuery(query);
|
|
1787
1919
|
extraQuery(query);
|
|
@@ -1840,6 +1972,7 @@ var CrudBase = class {
|
|
|
1840
1972
|
}
|
|
1841
1973
|
}
|
|
1842
1974
|
async update(id, entPart, cond = {}) {
|
|
1975
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1843
1976
|
let result;
|
|
1844
1977
|
const ent = new this.entityClass();
|
|
1845
1978
|
Object.assign(ent, entPart);
|
|
@@ -1852,6 +1985,7 @@ var CrudBase = class {
|
|
|
1852
1985
|
result = await this.repo.update(
|
|
1853
1986
|
{
|
|
1854
1987
|
id,
|
|
1988
|
+
...bindingEnt,
|
|
1855
1989
|
...cond
|
|
1856
1990
|
},
|
|
1857
1991
|
ent
|
|
@@ -1873,9 +2007,11 @@ var CrudBase = class {
|
|
|
1873
2007
|
return new import_nesties8.BlankReturnMessageDto(200, "success");
|
|
1874
2008
|
}
|
|
1875
2009
|
async delete(id, cond = {}) {
|
|
2010
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1876
2011
|
let result;
|
|
1877
2012
|
const searchCond = {
|
|
1878
2013
|
id,
|
|
2014
|
+
...bindingEnt,
|
|
1879
2015
|
...cond
|
|
1880
2016
|
};
|
|
1881
2017
|
try {
|
|
@@ -1893,6 +2029,7 @@ var CrudBase = class {
|
|
|
1893
2029
|
return new import_nesties8.BlankReturnMessageDto(200, "success");
|
|
1894
2030
|
}
|
|
1895
2031
|
async importEntities(_ents, extraChecking) {
|
|
2032
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1896
2033
|
const ents = _ents.map((ent) => {
|
|
1897
2034
|
const newEnt = new this.entityClass();
|
|
1898
2035
|
Object.assign(
|
|
@@ -1920,6 +2057,9 @@ var CrudBase = class {
|
|
|
1920
2057
|
const remainingEnts = ents.filter(
|
|
1921
2058
|
(ent) => !invalidResults.find((result) => result.entry === ent)
|
|
1922
2059
|
);
|
|
2060
|
+
for (const ent of remainingEnts) {
|
|
2061
|
+
Object.assign(ent, bindingEnt);
|
|
2062
|
+
}
|
|
1923
2063
|
await Promise.all(remainingEnts.map((ent) => ent.beforeCreate?.()));
|
|
1924
2064
|
const data = await this._batchCreate(remainingEnts, void 0, true);
|
|
1925
2065
|
await Promise.all(data.results.map((e) => e.afterCreate?.()));
|
|
@@ -1940,7 +2080,11 @@ var CrudBase = class {
|
|
|
1940
2080
|
);
|
|
1941
2081
|
}
|
|
1942
2082
|
async exists(id) {
|
|
1943
|
-
const
|
|
2083
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
2084
|
+
const ent = await this.repo.findOne({
|
|
2085
|
+
where: { id, ...bindingEnt },
|
|
2086
|
+
select: ["id"]
|
|
2087
|
+
});
|
|
1944
2088
|
return !!ent;
|
|
1945
2089
|
}
|
|
1946
2090
|
async _loadFullTextIndex() {
|
|
@@ -2163,7 +2307,132 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2163
2307
|
filterRelations(entityClass, options.relations);
|
|
2164
2308
|
}
|
|
2165
2309
|
}
|
|
2166
|
-
|
|
2310
|
+
omitInput(...fields) {
|
|
2311
|
+
return new _RestfulFactory(
|
|
2312
|
+
this.entityClass,
|
|
2313
|
+
{
|
|
2314
|
+
...this.options,
|
|
2315
|
+
fieldsToOmit: import_lodash5.default.uniq([...this.options.fieldsToOmit || [], ...fields])
|
|
2316
|
+
},
|
|
2317
|
+
this.__resolveVisited
|
|
2318
|
+
);
|
|
2319
|
+
}
|
|
2320
|
+
omitWrite(...fields) {
|
|
2321
|
+
return new _RestfulFactory(
|
|
2322
|
+
this.entityClass,
|
|
2323
|
+
{
|
|
2324
|
+
...this.options,
|
|
2325
|
+
writeFieldsToOmit: import_lodash5.default.uniq([
|
|
2326
|
+
...this.options.writeFieldsToOmit || [],
|
|
2327
|
+
...fields
|
|
2328
|
+
])
|
|
2329
|
+
},
|
|
2330
|
+
this.__resolveVisited
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2333
|
+
omitCreate(...fields) {
|
|
2334
|
+
return new _RestfulFactory(
|
|
2335
|
+
this.entityClass,
|
|
2336
|
+
{
|
|
2337
|
+
...this.options,
|
|
2338
|
+
createFieldsToOmit: import_lodash5.default.uniq([
|
|
2339
|
+
...this.options.createFieldsToOmit || [],
|
|
2340
|
+
...fields
|
|
2341
|
+
])
|
|
2342
|
+
},
|
|
2343
|
+
this.__resolveVisited
|
|
2344
|
+
);
|
|
2345
|
+
}
|
|
2346
|
+
omitUpdate(...fields) {
|
|
2347
|
+
return new _RestfulFactory(
|
|
2348
|
+
this.entityClass,
|
|
2349
|
+
{
|
|
2350
|
+
...this.options,
|
|
2351
|
+
updateFieldsToOmit: import_lodash5.default.uniq([
|
|
2352
|
+
...this.options.updateFieldsToOmit || [],
|
|
2353
|
+
...fields
|
|
2354
|
+
])
|
|
2355
|
+
},
|
|
2356
|
+
this.__resolveVisited
|
|
2357
|
+
);
|
|
2358
|
+
}
|
|
2359
|
+
omitFindAll(...fields) {
|
|
2360
|
+
return new _RestfulFactory(
|
|
2361
|
+
this.entityClass,
|
|
2362
|
+
{
|
|
2363
|
+
...this.options,
|
|
2364
|
+
findAllFieldsToOmit: import_lodash5.default.uniq([
|
|
2365
|
+
...this.options.findAllFieldsToOmit || [],
|
|
2366
|
+
...fields
|
|
2367
|
+
])
|
|
2368
|
+
},
|
|
2369
|
+
this.__resolveVisited
|
|
2370
|
+
);
|
|
2371
|
+
}
|
|
2372
|
+
omitOutput(...fields) {
|
|
2373
|
+
return new _RestfulFactory(
|
|
2374
|
+
this.entityClass,
|
|
2375
|
+
{
|
|
2376
|
+
...this.options,
|
|
2377
|
+
outputFieldsToOmit: import_lodash5.default.uniq([
|
|
2378
|
+
...this.options.outputFieldsToOmit || [],
|
|
2379
|
+
...fields
|
|
2380
|
+
])
|
|
2381
|
+
},
|
|
2382
|
+
this.__resolveVisited
|
|
2383
|
+
);
|
|
2384
|
+
}
|
|
2385
|
+
pathPrefix(prefix) {
|
|
2386
|
+
return new _RestfulFactory(
|
|
2387
|
+
this.entityClass,
|
|
2388
|
+
{
|
|
2389
|
+
...this.options,
|
|
2390
|
+
prefix
|
|
2391
|
+
},
|
|
2392
|
+
this.__resolveVisited
|
|
2393
|
+
);
|
|
2394
|
+
}
|
|
2395
|
+
keepEntityVersioningDates(enable = true) {
|
|
2396
|
+
return new _RestfulFactory(
|
|
2397
|
+
this.entityClass,
|
|
2398
|
+
{
|
|
2399
|
+
...this.options,
|
|
2400
|
+
keepEntityVersioningDates: enable
|
|
2401
|
+
},
|
|
2402
|
+
this.__resolveVisited
|
|
2403
|
+
);
|
|
2404
|
+
}
|
|
2405
|
+
skipNonQueryableFields(enable = true) {
|
|
2406
|
+
return new _RestfulFactory(
|
|
2407
|
+
this.entityClass,
|
|
2408
|
+
{
|
|
2409
|
+
...this.options,
|
|
2410
|
+
skipNonQueryableFields: enable
|
|
2411
|
+
},
|
|
2412
|
+
this.__resolveVisited
|
|
2413
|
+
);
|
|
2414
|
+
}
|
|
2415
|
+
renameEntityClass(name) {
|
|
2416
|
+
return new _RestfulFactory(
|
|
2417
|
+
this.entityClass,
|
|
2418
|
+
{
|
|
2419
|
+
...this.options,
|
|
2420
|
+
entityClassName: name
|
|
2421
|
+
},
|
|
2422
|
+
this.__resolveVisited
|
|
2423
|
+
);
|
|
2424
|
+
}
|
|
2425
|
+
useRelations(...relations) {
|
|
2426
|
+
return new _RestfulFactory(
|
|
2427
|
+
this.entityClass,
|
|
2428
|
+
{
|
|
2429
|
+
...this.options,
|
|
2430
|
+
relations: [...this.options.relations || [], ...relations]
|
|
2431
|
+
},
|
|
2432
|
+
this.__resolveVisited
|
|
2433
|
+
);
|
|
2434
|
+
}
|
|
2435
|
+
get entityClassName() {
|
|
2167
2436
|
return this.options.entityClassName || this.entityClass.name;
|
|
2168
2437
|
}
|
|
2169
2438
|
get fieldsToOmit() {
|
|
@@ -2187,7 +2456,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2187
2456
|
get createDto() {
|
|
2188
2457
|
return (0, import_nesties11.RenameClass)(
|
|
2189
2458
|
OmitTypeExclude(this.entityClass, this.fieldsInCreateToOmit),
|
|
2190
|
-
`Create${this.
|
|
2459
|
+
`Create${this.entityClassName}Dto`
|
|
2191
2460
|
);
|
|
2192
2461
|
}
|
|
2193
2462
|
get fieldsInUpdateToOmit() {
|
|
@@ -2202,7 +2471,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2202
2471
|
get updateDto() {
|
|
2203
2472
|
return (0, import_nesties11.RenameClass)(
|
|
2204
2473
|
(0, import_swagger6.PartialType)(OmitTypeExclude(this.entityClass, this.fieldsInUpdateToOmit)),
|
|
2205
|
-
`Update${this.
|
|
2474
|
+
`Update${this.entityClassName}Dto`
|
|
2206
2475
|
);
|
|
2207
2476
|
}
|
|
2208
2477
|
get importDto() {
|
|
@@ -2246,7 +2515,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2246
2515
|
if (this.options.skipNonQueryableFields) {
|
|
2247
2516
|
cl = PickTypeExpose(cl, this.queryableFields);
|
|
2248
2517
|
}
|
|
2249
|
-
return (0, import_nesties11.RenameClass)(cl, `Find${this.
|
|
2518
|
+
return (0, import_nesties11.RenameClass)(cl, `Find${this.entityClassName}Dto`);
|
|
2250
2519
|
}
|
|
2251
2520
|
get findAllCursorPaginatedDto() {
|
|
2252
2521
|
return (0, import_nesties11.RenameClass)(
|
|
@@ -2254,7 +2523,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2254
2523
|
OmitTypeExclude(this.findAllDto, ["pageCount"]),
|
|
2255
2524
|
CursorPaginationDto
|
|
2256
2525
|
),
|
|
2257
|
-
`Find${this.
|
|
2526
|
+
`Find${this.entityClassName}CursorPaginatedDto`
|
|
2258
2527
|
);
|
|
2259
2528
|
}
|
|
2260
2529
|
get entityResultDto() {
|
|
@@ -2297,7 +2566,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2297
2566
|
const relationFactory = new _RestfulFactory(
|
|
2298
2567
|
relation.propertyClass,
|
|
2299
2568
|
{
|
|
2300
|
-
entityClassName: `${this.
|
|
2569
|
+
entityClassName: `${this.entityClassName}${this.options.relations ? (0, import_lodash5.upperFirst)(relation.propertyName) : relation.propertyClass.name}`,
|
|
2301
2570
|
relations: this.options.relations && getNextLevelRelations(
|
|
2302
2571
|
this.options.relations.map(extractRelationName),
|
|
2303
2572
|
relation.propertyName
|
|
@@ -2328,7 +2597,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2328
2597
|
}
|
|
2329
2598
|
const res = (0, import_nesties11.RenameClass)(
|
|
2330
2599
|
resultDto,
|
|
2331
|
-
`${this.
|
|
2600
|
+
`${this.entityClassName}ResultDto`
|
|
2332
2601
|
);
|
|
2333
2602
|
const currentContainer = this.__resolveVisited.get(this.entityClass);
|
|
2334
2603
|
if (currentContainer) {
|
|
@@ -2348,7 +2617,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2348
2617
|
(m) => !m.keepInCreate
|
|
2349
2618
|
)
|
|
2350
2619
|
]),
|
|
2351
|
-
`${this.
|
|
2620
|
+
`${this.entityClassName}CreateResultDto`
|
|
2352
2621
|
);
|
|
2353
2622
|
}
|
|
2354
2623
|
get entityReturnMessageDto() {
|
|
@@ -2390,14 +2659,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2390
2659
|
this.usePrefix(import_common3.Post),
|
|
2391
2660
|
(0, import_common3.HttpCode)(200),
|
|
2392
2661
|
(0, import_swagger6.ApiOperation)({
|
|
2393
|
-
summary: `Create a new ${this.
|
|
2662
|
+
summary: `Create a new ${this.entityClassName}`,
|
|
2394
2663
|
...extras
|
|
2395
2664
|
}),
|
|
2396
2665
|
(0, import_swagger6.ApiBody)({ type: this.createDto }),
|
|
2397
2666
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityCreateReturnMessageDto }),
|
|
2398
2667
|
(0, import_swagger6.ApiBadRequestResponse)({
|
|
2399
2668
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2400
|
-
description: `The ${this.
|
|
2669
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2401
2670
|
})
|
|
2402
2671
|
]);
|
|
2403
2672
|
}
|
|
@@ -2408,14 +2677,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2408
2677
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2409
2678
|
this.usePrefix(import_common3.Get, ":id"),
|
|
2410
2679
|
(0, import_swagger6.ApiOperation)({
|
|
2411
|
-
summary: `Find a ${this.
|
|
2680
|
+
summary: `Find a ${this.entityClassName} by id`,
|
|
2412
2681
|
...extras
|
|
2413
2682
|
}),
|
|
2414
2683
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
2415
2684
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityReturnMessageDto }),
|
|
2416
2685
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2417
2686
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2418
|
-
description: `The ${this.
|
|
2687
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2419
2688
|
})
|
|
2420
2689
|
]);
|
|
2421
2690
|
}
|
|
@@ -2430,7 +2699,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2430
2699
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2431
2700
|
this.usePrefix(import_common3.Get),
|
|
2432
2701
|
(0, import_swagger6.ApiOperation)({
|
|
2433
|
-
summary: `Find all ${this.
|
|
2702
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2434
2703
|
...extras
|
|
2435
2704
|
}),
|
|
2436
2705
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityArrayReturnMessageDto })
|
|
@@ -2440,7 +2709,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2440
2709
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2441
2710
|
this.usePrefix(import_common3.Get),
|
|
2442
2711
|
(0, import_swagger6.ApiOperation)({
|
|
2443
|
-
summary: `Find all ${this.
|
|
2712
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2444
2713
|
...extras
|
|
2445
2714
|
}),
|
|
2446
2715
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityCursorPaginationReturnMessageDto })
|
|
@@ -2467,7 +2736,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2467
2736
|
this.usePrefix(import_common3.Patch, ":id"),
|
|
2468
2737
|
(0, import_common3.HttpCode)(200),
|
|
2469
2738
|
(0, import_swagger6.ApiOperation)({
|
|
2470
|
-
summary: `Update a ${this.
|
|
2739
|
+
summary: `Update a ${this.entityClassName} by id`,
|
|
2471
2740
|
...extras
|
|
2472
2741
|
}),
|
|
2473
2742
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
@@ -2475,11 +2744,11 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2475
2744
|
(0, import_swagger6.ApiOkResponse)({ type: import_nesties10.BlankReturnMessageDto }),
|
|
2476
2745
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2477
2746
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2478
|
-
description: `The ${this.
|
|
2747
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2479
2748
|
}),
|
|
2480
2749
|
(0, import_swagger6.ApiBadRequestResponse)({
|
|
2481
2750
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2482
|
-
description: `The ${this.
|
|
2751
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2483
2752
|
}),
|
|
2484
2753
|
(0, import_swagger6.ApiInternalServerErrorResponse)({
|
|
2485
2754
|
type: import_nesties10.BlankReturnMessageDto,
|
|
@@ -2495,14 +2764,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2495
2764
|
this.usePrefix(import_common3.Delete, ":id"),
|
|
2496
2765
|
(0, import_common3.HttpCode)(200),
|
|
2497
2766
|
(0, import_swagger6.ApiOperation)({
|
|
2498
|
-
summary: `Delete a ${this.
|
|
2767
|
+
summary: `Delete a ${this.entityClassName} by id`,
|
|
2499
2768
|
...extras
|
|
2500
2769
|
}),
|
|
2501
2770
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
2502
2771
|
(0, import_swagger6.ApiOkResponse)({ type: import_nesties10.BlankReturnMessageDto }),
|
|
2503
2772
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2504
2773
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2505
|
-
description: `The ${this.
|
|
2774
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2506
2775
|
}),
|
|
2507
2776
|
(0, import_swagger6.ApiInternalServerErrorResponse)({
|
|
2508
2777
|
type: import_nesties10.BlankReturnMessageDto,
|
|
@@ -2515,7 +2784,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2515
2784
|
(0, import_common3.Post)("import"),
|
|
2516
2785
|
(0, import_common3.HttpCode)(200),
|
|
2517
2786
|
(0, import_swagger6.ApiOperation)({
|
|
2518
|
-
summary: `Import ${this.
|
|
2787
|
+
summary: `Import ${this.entityClassName}`,
|
|
2519
2788
|
...extras
|
|
2520
2789
|
}),
|
|
2521
2790
|
(0, import_swagger6.ApiBody)({ type: this.importDto }),
|
|
@@ -2637,7 +2906,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2637
2906
|
Object.defineProperty(cl.prototype, method, descriptor);
|
|
2638
2907
|
});
|
|
2639
2908
|
}
|
|
2640
|
-
return (0, import_nesties11.RenameClass)(cl, `${this.
|
|
2909
|
+
return (0, import_nesties11.RenameClass)(cl, `${this.entityClassName}Controller`);
|
|
2641
2910
|
}
|
|
2642
2911
|
crudService(options = {}) {
|
|
2643
2912
|
return CrudService(this.entityClass, {
|
|
@@ -2769,6 +3038,8 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
2769
3038
|
);
|
|
2770
3039
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2771
3040
|
0 && (module.exports = {
|
|
3041
|
+
BindingColumn,
|
|
3042
|
+
BindingValue,
|
|
2772
3043
|
BlankCursorPaginationReturnMessageDto,
|
|
2773
3044
|
BoolColumn,
|
|
2774
3045
|
CrudBase,
|
|
@@ -2776,6 +3047,7 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
2776
3047
|
CursorPaginationDto,
|
|
2777
3048
|
CursorPaginationReturnMessageDto,
|
|
2778
3049
|
DateColumn,
|
|
3050
|
+
DefaultBindingKey,
|
|
2779
3051
|
EnumColumn,
|
|
2780
3052
|
FloatColumn,
|
|
2781
3053
|
GenericCursorPaginationReturnMessageDto,
|