-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into deploy_script
- Loading branch information
Showing
61 changed files
with
1,565 additions
and
1,054 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dist | |
src/package.json | ||
.eslintcache | ||
.DS_Store | ||
upload-docs* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Config, ContactType } from '../config'; | ||
import SessionCache from '../services/session-cache'; | ||
import { stringify } from 'csv/sync'; | ||
|
||
type File = { | ||
filename: string; | ||
content: string; | ||
}; | ||
|
||
export default function getCredentialsFiles(sessionCache: SessionCache, contactTypes: ContactType[]): File[] { | ||
const files: File[] = []; | ||
for (const contactType of contactTypes) { | ||
const places = sessionCache.getPlaces({ type: contactType.name }); | ||
if (!places.length) { | ||
continue; | ||
} | ||
|
||
const rows = places.map((place) => [ | ||
...Object.values(place.hierarchyProperties).map(prop => prop.formatted), | ||
place.name, | ||
place.contact.properties.name?.formatted, | ||
place.contact.properties.phone?.formatted, | ||
place.userRoles.join(' '), | ||
place.creationDetails.username, | ||
place.creationDetails.password, | ||
]); | ||
|
||
const constraints = Config.getHierarchyWithReplacement(contactType); | ||
const props = Object.keys(places[0].hierarchyProperties) | ||
.map(prop => constraints.find(c => c.property_name === prop)!.friendly_name); | ||
const columns = [ | ||
...props, | ||
contactType.friendly, | ||
'name', | ||
'phone', | ||
'role', | ||
'username', | ||
'password', | ||
]; | ||
|
||
const content = stringify(rows, { | ||
columns, | ||
header: true, | ||
}); | ||
files.push({ | ||
filename: `${contactType.name}.csv`, | ||
content, | ||
}); | ||
} | ||
|
||
return files; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.