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.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
|
};
|
|
@@ -883,7 +898,8 @@ __decorateClass([
|
|
|
883
898
|
required: false,
|
|
884
899
|
type: String
|
|
885
900
|
}),
|
|
886
|
-
NotInResult()
|
|
901
|
+
NotInResult(),
|
|
902
|
+
QueryManual()
|
|
887
903
|
], CursorPaginationDto.prototype, "paginationCursor", 2);
|
|
888
904
|
__decorateClass([
|
|
889
905
|
NotWritable(),
|
|
@@ -895,7 +911,8 @@ __decorateClass([
|
|
|
895
911
|
type: Number,
|
|
896
912
|
minimum: 1
|
|
897
913
|
}),
|
|
898
|
-
NotInResult()
|
|
914
|
+
NotInResult(),
|
|
915
|
+
QueryManual()
|
|
899
916
|
], CursorPaginationDto.prototype, "recordsPerPage", 2);
|
|
900
917
|
var BlankCursorPaginationReturnMessageDto = class extends import_nesties6.BlankReturnMessageDto {
|
|
901
918
|
constructor(statusCode, message, cursorResponse) {
|
|
@@ -981,7 +998,8 @@ __decorateClass([
|
|
|
981
998
|
minimum: 1
|
|
982
999
|
}),
|
|
983
1000
|
NotInResult(),
|
|
984
|
-
Reflect.metadata("design:type", Number)
|
|
1001
|
+
Reflect.metadata("design:type", Number),
|
|
1002
|
+
QueryManual()
|
|
985
1003
|
], PageSettingsDto.prototype, "pageCount", 2);
|
|
986
1004
|
__decorateClass([
|
|
987
1005
|
NotWritable(),
|
|
@@ -993,6 +1011,7 @@ __decorateClass([
|
|
|
993
1011
|
minimum: 1
|
|
994
1012
|
}),
|
|
995
1013
|
NotInResult(),
|
|
1014
|
+
QueryManual(),
|
|
996
1015
|
Reflect.metadata("design:type", Number)
|
|
997
1016
|
], PageSettingsDto.prototype, "recordsPerPage", 2);
|
|
998
1017
|
|
|
@@ -1487,7 +1506,11 @@ var CrudBase = class {
|
|
|
1487
1506
|
});
|
|
1488
1507
|
this.log = new import_common2.ConsoleLogger(`${this.entityClass.name}Service`);
|
|
1489
1508
|
this._typeormRelations = getTypeormRelations(this.entityClass);
|
|
1509
|
+
// binding things
|
|
1510
|
+
this._tmpBindingMap = /* @__PURE__ */ new Map();
|
|
1511
|
+
this._bindingCache = /* @__PURE__ */ new Map();
|
|
1490
1512
|
}
|
|
1513
|
+
// cleaning entities
|
|
1491
1514
|
_cleanEntityNotInResultFields(ent) {
|
|
1492
1515
|
const visited = /* @__PURE__ */ new Set();
|
|
1493
1516
|
const runSingleObject = (o, cl) => {
|
|
@@ -1531,6 +1554,105 @@ var CrudBase = class {
|
|
|
1531
1554
|
return this._cleanEntityNotInResultFields(ents);
|
|
1532
1555
|
}
|
|
1533
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
|
+
}
|
|
1534
1656
|
async _batchCreate(ents, beforeCreate, skipErrors = false) {
|
|
1535
1657
|
const entsWithId = ents.filter((ent) => ent.id != null);
|
|
1536
1658
|
return this.repo.manager.transaction(async (mdb) => {
|
|
@@ -1636,6 +1758,7 @@ var CrudBase = class {
|
|
|
1636
1758
|
});
|
|
1637
1759
|
}
|
|
1638
1760
|
async create(_ent, beforeCreate) {
|
|
1761
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1639
1762
|
if (!_ent) {
|
|
1640
1763
|
throw new import_nesties8.BlankReturnMessageDto(400, "Invalid entity").toException();
|
|
1641
1764
|
}
|
|
@@ -1670,6 +1793,7 @@ var CrudBase = class {
|
|
|
1670
1793
|
}
|
|
1671
1794
|
}
|
|
1672
1795
|
}
|
|
1796
|
+
Object.assign(ent, bindingEnt);
|
|
1673
1797
|
if (beforeCreate) {
|
|
1674
1798
|
await beforeCreate(repo);
|
|
1675
1799
|
}
|
|
@@ -1735,10 +1859,20 @@ var CrudBase = class {
|
|
|
1735
1859
|
queryBuilder() {
|
|
1736
1860
|
return this.repo.createQueryBuilder(this.entityAliasName);
|
|
1737
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
|
+
}
|
|
1738
1870
|
async findOne(id, extraQuery = () => {
|
|
1739
1871
|
}) {
|
|
1872
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1740
1873
|
const query = this.queryBuilder().where(`${this.entityAliasName}.id = :id`, { id }).take(1);
|
|
1741
1874
|
this._applyQueryRelations(query);
|
|
1875
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1742
1876
|
this.extraGetQuery(query);
|
|
1743
1877
|
extraQuery(query);
|
|
1744
1878
|
query.take(1);
|
|
@@ -1769,6 +1903,7 @@ var CrudBase = class {
|
|
|
1769
1903
|
}
|
|
1770
1904
|
async _preFindAll(ent, extraQuery = () => {
|
|
1771
1905
|
}) {
|
|
1906
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1772
1907
|
const query = this.queryBuilder().where("1 = 1");
|
|
1773
1908
|
const newEnt = new this.entityClass();
|
|
1774
1909
|
if (ent) {
|
|
@@ -1778,6 +1913,7 @@ var CrudBase = class {
|
|
|
1778
1913
|
}
|
|
1779
1914
|
this._applyQueryRelations(query);
|
|
1780
1915
|
this._applyQueryFilters(query, newEnt);
|
|
1916
|
+
this._applyQueryFromBinding(bindingEnt, query);
|
|
1781
1917
|
const pageSettings = newEnt instanceof PageSettingsDto ? newEnt : Object.assign(new PageSettingsDto(), newEnt);
|
|
1782
1918
|
this.extraGetQuery(query);
|
|
1783
1919
|
extraQuery(query);
|
|
@@ -1836,6 +1972,7 @@ var CrudBase = class {
|
|
|
1836
1972
|
}
|
|
1837
1973
|
}
|
|
1838
1974
|
async update(id, entPart, cond = {}) {
|
|
1975
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1839
1976
|
let result;
|
|
1840
1977
|
const ent = new this.entityClass();
|
|
1841
1978
|
Object.assign(ent, entPart);
|
|
@@ -1848,6 +1985,7 @@ var CrudBase = class {
|
|
|
1848
1985
|
result = await this.repo.update(
|
|
1849
1986
|
{
|
|
1850
1987
|
id,
|
|
1988
|
+
...bindingEnt,
|
|
1851
1989
|
...cond
|
|
1852
1990
|
},
|
|
1853
1991
|
ent
|
|
@@ -1869,9 +2007,11 @@ var CrudBase = class {
|
|
|
1869
2007
|
return new import_nesties8.BlankReturnMessageDto(200, "success");
|
|
1870
2008
|
}
|
|
1871
2009
|
async delete(id, cond = {}) {
|
|
2010
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1872
2011
|
let result;
|
|
1873
2012
|
const searchCond = {
|
|
1874
2013
|
id,
|
|
2014
|
+
...bindingEnt,
|
|
1875
2015
|
...cond
|
|
1876
2016
|
};
|
|
1877
2017
|
try {
|
|
@@ -1889,6 +2029,7 @@ var CrudBase = class {
|
|
|
1889
2029
|
return new import_nesties8.BlankReturnMessageDto(200, "success");
|
|
1890
2030
|
}
|
|
1891
2031
|
async importEntities(_ents, extraChecking) {
|
|
2032
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
1892
2033
|
const ents = _ents.map((ent) => {
|
|
1893
2034
|
const newEnt = new this.entityClass();
|
|
1894
2035
|
Object.assign(
|
|
@@ -1916,6 +2057,9 @@ var CrudBase = class {
|
|
|
1916
2057
|
const remainingEnts = ents.filter(
|
|
1917
2058
|
(ent) => !invalidResults.find((result) => result.entry === ent)
|
|
1918
2059
|
);
|
|
2060
|
+
for (const ent of remainingEnts) {
|
|
2061
|
+
Object.assign(ent, bindingEnt);
|
|
2062
|
+
}
|
|
1919
2063
|
await Promise.all(remainingEnts.map((ent) => ent.beforeCreate?.()));
|
|
1920
2064
|
const data = await this._batchCreate(remainingEnts, void 0, true);
|
|
1921
2065
|
await Promise.all(data.results.map((e) => e.afterCreate?.()));
|
|
@@ -1936,7 +2080,11 @@ var CrudBase = class {
|
|
|
1936
2080
|
);
|
|
1937
2081
|
}
|
|
1938
2082
|
async exists(id) {
|
|
1939
|
-
const
|
|
2083
|
+
const bindingEnt = await this.getBindingPartialEntity();
|
|
2084
|
+
const ent = await this.repo.findOne({
|
|
2085
|
+
where: { id, ...bindingEnt },
|
|
2086
|
+
select: ["id"]
|
|
2087
|
+
});
|
|
1940
2088
|
return !!ent;
|
|
1941
2089
|
}
|
|
1942
2090
|
async _loadFullTextIndex() {
|
|
@@ -2159,7 +2307,132 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2159
2307
|
filterRelations(entityClass, options.relations);
|
|
2160
2308
|
}
|
|
2161
2309
|
}
|
|
2162
|
-
|
|
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() {
|
|
2163
2436
|
return this.options.entityClassName || this.entityClass.name;
|
|
2164
2437
|
}
|
|
2165
2438
|
get fieldsToOmit() {
|
|
@@ -2183,7 +2456,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2183
2456
|
get createDto() {
|
|
2184
2457
|
return (0, import_nesties11.RenameClass)(
|
|
2185
2458
|
OmitTypeExclude(this.entityClass, this.fieldsInCreateToOmit),
|
|
2186
|
-
`Create${this.
|
|
2459
|
+
`Create${this.entityClassName}Dto`
|
|
2187
2460
|
);
|
|
2188
2461
|
}
|
|
2189
2462
|
get fieldsInUpdateToOmit() {
|
|
@@ -2198,7 +2471,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2198
2471
|
get updateDto() {
|
|
2199
2472
|
return (0, import_nesties11.RenameClass)(
|
|
2200
2473
|
(0, import_swagger6.PartialType)(OmitTypeExclude(this.entityClass, this.fieldsInUpdateToOmit)),
|
|
2201
|
-
`Update${this.
|
|
2474
|
+
`Update${this.entityClassName}Dto`
|
|
2202
2475
|
);
|
|
2203
2476
|
}
|
|
2204
2477
|
get importDto() {
|
|
@@ -2216,7 +2489,12 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2216
2489
|
}
|
|
2217
2490
|
get queryableFields() {
|
|
2218
2491
|
return import_lodash5.default.difference(
|
|
2219
|
-
|
|
2492
|
+
[
|
|
2493
|
+
...getSpecificFields(this.entityClass, "queryCondition"),
|
|
2494
|
+
"pageCount",
|
|
2495
|
+
"recordsPerPage",
|
|
2496
|
+
"paginationCursor"
|
|
2497
|
+
],
|
|
2220
2498
|
this.fieldsInGetToOmit
|
|
2221
2499
|
);
|
|
2222
2500
|
}
|
|
@@ -2237,7 +2515,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2237
2515
|
if (this.options.skipNonQueryableFields) {
|
|
2238
2516
|
cl = PickTypeExpose(cl, this.queryableFields);
|
|
2239
2517
|
}
|
|
2240
|
-
return (0, import_nesties11.RenameClass)(cl, `Find${this.
|
|
2518
|
+
return (0, import_nesties11.RenameClass)(cl, `Find${this.entityClassName}Dto`);
|
|
2241
2519
|
}
|
|
2242
2520
|
get findAllCursorPaginatedDto() {
|
|
2243
2521
|
return (0, import_nesties11.RenameClass)(
|
|
@@ -2245,7 +2523,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2245
2523
|
OmitTypeExclude(this.findAllDto, ["pageCount"]),
|
|
2246
2524
|
CursorPaginationDto
|
|
2247
2525
|
),
|
|
2248
|
-
`Find${this.
|
|
2526
|
+
`Find${this.entityClassName}CursorPaginatedDto`
|
|
2249
2527
|
);
|
|
2250
2528
|
}
|
|
2251
2529
|
get entityResultDto() {
|
|
@@ -2288,7 +2566,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2288
2566
|
const relationFactory = new _RestfulFactory(
|
|
2289
2567
|
relation.propertyClass,
|
|
2290
2568
|
{
|
|
2291
|
-
entityClassName: `${this.
|
|
2569
|
+
entityClassName: `${this.entityClassName}${this.options.relations ? (0, import_lodash5.upperFirst)(relation.propertyName) : relation.propertyClass.name}`,
|
|
2292
2570
|
relations: this.options.relations && getNextLevelRelations(
|
|
2293
2571
|
this.options.relations.map(extractRelationName),
|
|
2294
2572
|
relation.propertyName
|
|
@@ -2319,7 +2597,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2319
2597
|
}
|
|
2320
2598
|
const res = (0, import_nesties11.RenameClass)(
|
|
2321
2599
|
resultDto,
|
|
2322
|
-
`${this.
|
|
2600
|
+
`${this.entityClassName}ResultDto`
|
|
2323
2601
|
);
|
|
2324
2602
|
const currentContainer = this.__resolveVisited.get(this.entityClass);
|
|
2325
2603
|
if (currentContainer) {
|
|
@@ -2339,7 +2617,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2339
2617
|
(m) => !m.keepInCreate
|
|
2340
2618
|
)
|
|
2341
2619
|
]),
|
|
2342
|
-
`${this.
|
|
2620
|
+
`${this.entityClassName}CreateResultDto`
|
|
2343
2621
|
);
|
|
2344
2622
|
}
|
|
2345
2623
|
get entityReturnMessageDto() {
|
|
@@ -2381,14 +2659,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2381
2659
|
this.usePrefix(import_common3.Post),
|
|
2382
2660
|
(0, import_common3.HttpCode)(200),
|
|
2383
2661
|
(0, import_swagger6.ApiOperation)({
|
|
2384
|
-
summary: `Create a new ${this.
|
|
2662
|
+
summary: `Create a new ${this.entityClassName}`,
|
|
2385
2663
|
...extras
|
|
2386
2664
|
}),
|
|
2387
2665
|
(0, import_swagger6.ApiBody)({ type: this.createDto }),
|
|
2388
2666
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityCreateReturnMessageDto }),
|
|
2389
2667
|
(0, import_swagger6.ApiBadRequestResponse)({
|
|
2390
2668
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2391
|
-
description: `The ${this.
|
|
2669
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2392
2670
|
})
|
|
2393
2671
|
]);
|
|
2394
2672
|
}
|
|
@@ -2399,14 +2677,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2399
2677
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2400
2678
|
this.usePrefix(import_common3.Get, ":id"),
|
|
2401
2679
|
(0, import_swagger6.ApiOperation)({
|
|
2402
|
-
summary: `Find a ${this.
|
|
2680
|
+
summary: `Find a ${this.entityClassName} by id`,
|
|
2403
2681
|
...extras
|
|
2404
2682
|
}),
|
|
2405
2683
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
2406
2684
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityReturnMessageDto }),
|
|
2407
2685
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2408
2686
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2409
|
-
description: `The ${this.
|
|
2687
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2410
2688
|
})
|
|
2411
2689
|
]);
|
|
2412
2690
|
}
|
|
@@ -2421,7 +2699,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2421
2699
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2422
2700
|
this.usePrefix(import_common3.Get),
|
|
2423
2701
|
(0, import_swagger6.ApiOperation)({
|
|
2424
|
-
summary: `Find all ${this.
|
|
2702
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2425
2703
|
...extras
|
|
2426
2704
|
}),
|
|
2427
2705
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityArrayReturnMessageDto })
|
|
@@ -2431,7 +2709,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2431
2709
|
return (0, import_nesties10.MergeMethodDecorators)([
|
|
2432
2710
|
this.usePrefix(import_common3.Get),
|
|
2433
2711
|
(0, import_swagger6.ApiOperation)({
|
|
2434
|
-
summary: `Find all ${this.
|
|
2712
|
+
summary: `Find all ${this.entityClassName}`,
|
|
2435
2713
|
...extras
|
|
2436
2714
|
}),
|
|
2437
2715
|
(0, import_swagger6.ApiOkResponse)({ type: this.entityCursorPaginationReturnMessageDto })
|
|
@@ -2458,7 +2736,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2458
2736
|
this.usePrefix(import_common3.Patch, ":id"),
|
|
2459
2737
|
(0, import_common3.HttpCode)(200),
|
|
2460
2738
|
(0, import_swagger6.ApiOperation)({
|
|
2461
|
-
summary: `Update a ${this.
|
|
2739
|
+
summary: `Update a ${this.entityClassName} by id`,
|
|
2462
2740
|
...extras
|
|
2463
2741
|
}),
|
|
2464
2742
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
@@ -2466,11 +2744,11 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2466
2744
|
(0, import_swagger6.ApiOkResponse)({ type: import_nesties10.BlankReturnMessageDto }),
|
|
2467
2745
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2468
2746
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2469
|
-
description: `The ${this.
|
|
2747
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2470
2748
|
}),
|
|
2471
2749
|
(0, import_swagger6.ApiBadRequestResponse)({
|
|
2472
2750
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2473
|
-
description: `The ${this.
|
|
2751
|
+
description: `The ${this.entityClassName} is not valid`
|
|
2474
2752
|
}),
|
|
2475
2753
|
(0, import_swagger6.ApiInternalServerErrorResponse)({
|
|
2476
2754
|
type: import_nesties10.BlankReturnMessageDto,
|
|
@@ -2486,14 +2764,14 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2486
2764
|
this.usePrefix(import_common3.Delete, ":id"),
|
|
2487
2765
|
(0, import_common3.HttpCode)(200),
|
|
2488
2766
|
(0, import_swagger6.ApiOperation)({
|
|
2489
|
-
summary: `Delete a ${this.
|
|
2767
|
+
summary: `Delete a ${this.entityClassName} by id`,
|
|
2490
2768
|
...extras
|
|
2491
2769
|
}),
|
|
2492
2770
|
(0, import_swagger6.ApiParam)({ name: "id", type: this.idType, required: true }),
|
|
2493
2771
|
(0, import_swagger6.ApiOkResponse)({ type: import_nesties10.BlankReturnMessageDto }),
|
|
2494
2772
|
(0, import_swagger6.ApiNotFoundResponse)({
|
|
2495
2773
|
type: import_nesties10.BlankReturnMessageDto,
|
|
2496
|
-
description: `The ${this.
|
|
2774
|
+
description: `The ${this.entityClassName} with the given id was not found`
|
|
2497
2775
|
}),
|
|
2498
2776
|
(0, import_swagger6.ApiInternalServerErrorResponse)({
|
|
2499
2777
|
type: import_nesties10.BlankReturnMessageDto,
|
|
@@ -2506,7 +2784,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2506
2784
|
(0, import_common3.Post)("import"),
|
|
2507
2785
|
(0, import_common3.HttpCode)(200),
|
|
2508
2786
|
(0, import_swagger6.ApiOperation)({
|
|
2509
|
-
summary: `Import ${this.
|
|
2787
|
+
summary: `Import ${this.entityClassName}`,
|
|
2510
2788
|
...extras
|
|
2511
2789
|
}),
|
|
2512
2790
|
(0, import_swagger6.ApiBody)({ type: this.importDto }),
|
|
@@ -2628,7 +2906,7 @@ var _RestfulFactory = class _RestfulFactory {
|
|
|
2628
2906
|
Object.defineProperty(cl.prototype, method, descriptor);
|
|
2629
2907
|
});
|
|
2630
2908
|
}
|
|
2631
|
-
return (0, import_nesties11.RenameClass)(cl, `${this.
|
|
2909
|
+
return (0, import_nesties11.RenameClass)(cl, `${this.entityClassName}Controller`);
|
|
2632
2910
|
}
|
|
2633
2911
|
crudService(options = {}) {
|
|
2634
2912
|
return CrudService(this.entityClass, {
|
|
@@ -2760,6 +3038,8 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
2760
3038
|
);
|
|
2761
3039
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2762
3040
|
0 && (module.exports = {
|
|
3041
|
+
BindingColumn,
|
|
3042
|
+
BindingValue,
|
|
2763
3043
|
BlankCursorPaginationReturnMessageDto,
|
|
2764
3044
|
BoolColumn,
|
|
2765
3045
|
CrudBase,
|
|
@@ -2767,6 +3047,7 @@ var applyQueryMatchBooleanMySQL = createQueryCondition(
|
|
|
2767
3047
|
CursorPaginationDto,
|
|
2768
3048
|
CursorPaginationReturnMessageDto,
|
|
2769
3049
|
DateColumn,
|
|
3050
|
+
DefaultBindingKey,
|
|
2770
3051
|
EnumColumn,
|
|
2771
3052
|
FloatColumn,
|
|
2772
3053
|
GenericCursorPaginationReturnMessageDto,
|