Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
nicot
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
3rdeye
nicot
Commits
1f569dca
Commit
1f569dca
authored
Jan 14, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix class name conflict
parent
ad54ab9d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
+22
-8
src/decorators/restful.ts
src/decorators/restful.ts
+18
-8
src/utility/rename-class.ts
src/utility/rename-class.ts
+4
-0
No files found.
src/decorators/restful.ts
View file @
1f569dca
...
...
@@ -31,6 +31,7 @@ import { CreatePipe, GetPipe, UpdatePipe } from './pipes';
import
{
OperationObject
}
from
'
@nestjs/swagger/dist/interfaces/open-api-spec.interface
'
;
import
_
from
'
lodash
'
;
import
{
getSpecificFields
}
from
'
../utility/metadata
'
;
import
{
RenameClass
}
from
'
../utility/rename-class
'
;
export
interface
RestfulFactoryOptions
<
T
>
{
fieldsToOmit
?:
(
keyof
T
)[];
...
...
@@ -52,17 +53,26 @@ export class RestfulFactory<T> {
this
.
entityClass
,
this
.
fieldsToOmit
,
)
as
ClassType
<
T
>
;
readonly
createDto
=
OmitType
(
readonly
createDto
=
RenameClass
(
OmitType
(
this
.
basicDto
,
getSpecificFields
(
this
.
entityClass
,
'
notWritable
'
)
as
(
keyof
T
)[],
),
`Create
${
this
.
entityClass
.
name
}
Dto`
,
)
as
ClassType
<
T
>
;
readonly
importDto
=
ImportDataDto
(
this
.
entityClass
);
readonly
findAllDto
=
PartialType
(
this
.
basicDto
)
as
ClassType
<
T
>
;
readonly
updateDto
=
PartialType
(
readonly
findAllDto
=
RenameClass
(
PartialType
(
this
.
basicDto
),
`Find
${
this
.
entityClass
.
name
}
Dto`
,
)
as
ClassType
<
T
>
;
readonly
updateDto
=
RenameClass
(
PartialType
(
OmitType
(
this
.
createDto
,
getSpecificFields
(
this
.
entityClass
,
'
notChangeable
'
)
as
(
keyof
T
)[],
),
),
`Update
${
this
.
entityClass
.
name
}
Dto`
,
)
as
ClassType
<
T
>
;
// eslint-disable-next-line @typescript-eslint/ban-types
readonly
idType
:
Function
=
Reflect
.
getMetadata
(
...
...
src/utility/rename-class.ts
0 → 100644
View file @
1f569dca
export
function
RenameClass
<
T
>
(
cls
:
T
,
name
:
string
)
{
Object
.
defineProperty
(
cls
,
'
name
'
,
{
value
:
name
});
return
cls
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment