Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
generic-client-layer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Applications
Sargasso
generic-client-layer
Commits
44b3bc33
Commit
44b3bc33
authored
1 year ago
by
Ajay Nishad
Browse files
Options
Downloads
Patches
Plain Diff
feat: add the remove empty object keys sanitization
parent
ddcee14f
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/mapper.service.ts
+6
-2
6 additions, 2 deletions
src/common/mapper.service.ts
src/common/utils.ts
+11
-0
11 additions, 0 deletions
src/common/utils.ts
with
17 additions
and
2 deletions
src/common/mapper.service.ts
+
6
−
2
View file @
44b3bc33
...
...
@@ -2,8 +2,12 @@ import fs from "fs";
import
path
from
"
path
"
;
import
appRootPath
from
'
app-root-path
'
;
import
jsonata
from
'
jsonata
'
;
import
{
removeEmptyObjectKeys
}
from
'
./utils
'
export
const
map
=
(
data
:
any
,
action
?:
string
)
=>
{
export
const
map
=
async
(
data
:
any
,
action
?:
string
)
=>
{
const
expression
=
jsonata
(
fs
.
readFileSync
(
path
.
join
(
appRootPath
.
toString
(),
`/mappings/
${
action
}
.jsonata`
),
"
utf8
"
));
return
expression
.
evaluate
(
data
);
let
mapped
=
await
expression
.
evaluate
(
data
);
mapped
=
removeEmptyObjectKeys
(
mapped
);
return
mapped
;
};
This diff is collapsed.
Click to expand it.
src/common/utils.ts
+
11
−
0
View file @
44b3bc33
export
function
removeEmptyObjectKeys
(
obj
:
any
)
{
for
(
const
key
in
obj
)
{
if
(
typeof
obj
[
key
]
===
'
object
'
&&
obj
[
key
]
!==
null
)
{
removeEmptyObjectKeys
(
obj
[
key
]);
if
(
Object
.
keys
(
obj
[
key
]).
length
===
0
)
{
delete
obj
[
key
];
}
}
}
return
obj
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment