Commit graph

142 commits

Author SHA1 Message Date
David Mehren
e09cdd5162
style(note-metadata): remove unused imports
Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:58:23 +01:00
David Mehren
f63c15c1ab
refactor(note-metadata): do not embed User objects
This is part of an effort to consistently not embed User objects
in API responses. Usernames are returned instead.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:56:58 +01:00
David Mehren
cdd4f58746
refactor(note-group-permission-update-dto): rename attribute groupName
For consistency with NoteGroupPermissionEntryDto

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:56:09 +01:00
David Mehren
fe4e3d5657
refactor(note-group-permission-entry-dto): do not embed Group objects
This is part of an effort to consistently not embed Group objects
in API responses. Names are returned instead.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:56:09 +01:00
David Mehren
93301d84c7
refactor(note-user-permission-entry-dto): do not embed User objects
This is part of an effort to consistently not embed User objects
in API responses. Usernames are returned instead.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:56:09 +01:00
David Mehren
acaefb3996
refactor(note-permissions-dto): do not embed User objects
This is part of an effort to consistently not embed User objects
in API responses. Usernames are returned instead.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-17 11:56:09 +01:00
David Mehren
05e534a7d6
refactor(note-metadata): rename date attributes
This is part of an effort to name all date attributes
consistently.

Signed-off-by: David Mehren <git@herrmehren.de>
2022-01-16 22:04:53 +01:00
David Mehren
2da6faa4b4
refactor(revision): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
e73bd7c030
refactor(edit): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
f164e84081
refactor(tag): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
3c0c11e3d4
refactor(note): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
9e608c75d3
refactor(alias): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-13 21:45:03 +01:00
David Mehren
244e3f76ea
refactor(author): lazy-load relations
Signed-off-by: David Mehren <git@herrmehren.de>
2021-12-05 19:40:25 +01:00
Philip Molares
4b3c726101 chore: move get-note-pipe to api utils
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-30 19:48:47 +01:00
David Mehren
9c08ff94fe
fix(note): fix type for owner param
To make the create method easier to use in conjunction
with the authentication framework, this commit changes the type of
the `owner` parameter from `User | undefined` to `User | null`.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
01b53d3858
fix(alias): remove default for primary
To make the create method more consistent with the
guidelines,
this commit removes the default value from the `primary` parameter.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
David Mehren
5ba6b4ab67
fix(group): add special flag to create method
To make the create method more consistent with the
guidelines, this commit adds the `special` flag to
the parameters.
As this function will only be used to create the two hard-coded groups
and to handle API requests at one or two places, adding the parameter
should not be too problematic.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-11-14 21:46:04 +01:00
Philip Molares
58d8ff71fe fix: the tests use the new typing from create methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
d18d23cb16 fix: services use the new typings from create methods
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Philip Molares
b896f954b9 feat: consolidate entities create
This was done to give better typings to the function signatures of entities `create` methods.
It also ensures that each field that should be set to `null` is set to `null` and doesn't leave that up to the typeorm handlers.

See: #1641
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-11-11 22:07:20 +01:00
Yannick Bungers
d33cfa4541 fix username spelling from userName
Signed-off-by: Yannick Bungers <git@innay.de>
2021-10-13 22:54:00 +02:00
Philip Molares
b95a6f56b6 test: fix service tests to handle the new aliases
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-22 20:43:45 +02:00
Philip Molares
3b7a06913b feat: add aliases to service files
This commit makes it possible to identifier notes via any alias in the note and history service.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-22 20:43:44 +02:00
Philip Molares
10ed40f9f1 chore: create getPrimaryAlias utility function
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-22 20:43:44 +02:00
Philip Molares
0db7a41d1a feat: add alias service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-22 20:43:44 +02:00
Philip Molares
aaef0f72ba feat: add list of aliases to note entity
One of the aliases can be primary for each note, but all can be used to get information from the apis.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-21 15:14:00 +02:00
Philip Molares
dd2667b523 chore: add alias dtos
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-21 15:14:00 +02:00
Philip Molares
b2da8a2b95 chore: move identity entity in its own folder
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-09-16 23:59:59 +02:00
David Mehren
0dc472bba8
RevisionsService: Refactor getFirst/LastRevision
The functions now expect a `Note` object instead of a noteId to
make it more consistent with other functions.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-09-04 22:40:15 +02:00
David Mehren
1e3c08b3df
Implement GetNotePipe
This pipe transforms a note ID or alias to a Note object
by loading it from the database.
It also performs error handling

Signed-off-by: David Mehren <git@herrmehren.de>
2021-09-04 21:42:54 +02:00
David Mehren
3658204acb
Cleanup some imports
Signed-off-by: David Mehren <git@herrmehren.de>
2021-08-29 18:57:00 +02:00
David Mehren
bcc9ec9c75
Enforce import order with prettier
Signed-off-by: David Mehren <git@herrmehren.de>
2021-08-29 18:45:46 +02:00
Philip Molares
eea0e410d3 test(generatePublicId): test if with a given random buffer a correct encoding is generated
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-06-17 21:45:28 +02:00
Philip Molares
b636afc4bd fix(publicId): generate 128-bit instead of 128-byte value
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-06-17 21:45:28 +02:00
David Mehren
09329ae360
Rename NoteAuthorshipDto to EditDto
After Authorship was renamed to Edit, the DTO should follow.
The file is also moved to the revisions folder, where the entity
already is.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 22:02:32 +02:00
David Mehren
62e0530d2b
Rename Authorship entity to Edit
As we now have a separate Author entity, which holds information
about an author (the color), the Authorship name became confusing.
Edit seems to be a better name, as the entity saves information
about a change in a note.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 21:46:41 +02:00
David Mehren
4d0205a61f
NotesService: Implement getAuthorUsers
This reimplements logic to get all Users that ever edited a note
and fixes the empty `editedBy` property of `toNoteMetadataDto`
introduced in 81cc092e.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 21:14:06 +02:00
David Mehren
b2b3849300
Adjust tests to new Session and Author entities
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 18:44:00 +02:00
David Mehren
20006df82f
AuthorshipEntity: Adjust to DB schema
This commit replaces the user property with a author property,
in accordance with the DB schema updated in 0d6c3002.

It also adjusts the NoteService accordingly.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 18:42:57 +02:00
David Mehren
81cc092e51
Remove AuthorColor entity
It will be replaced with the Author entity,
that will save the color

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-31 17:38:58 +02:00
David Mehren
a2e8c3d031
Move publicID creation to Note.create
Before this commit, `Note.create()` did not return a complete object,
as the `publicId` property was missing.
This adds the generation of the property to the `create` method and
moves the actual generation code from the `NotesService`
to a utility method.

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-19 22:19:04 +02:00
Philip Molares
fb79f44b1f chore(test): Change test to work with publicId
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-17 20:27:44 +02:00
Philip Molares
430e75ef44 feat(notes): Use publicId in notes service
Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-17 20:27:43 +02:00
Philip Molares
072c2b6a59 feat(note): Add publicId field
This field is a randomly generated 128-bit value encoded with base32-encode using the crockford variant and converted to lowercase.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-17 20:27:43 +02:00
Philip Molares
8c562016ab Refactor(note): Remove shortid from note
This is a 1.x relict and isn't used anymore in 2.x. All 1.x shortids will be converted to aliases on migration of 1.x to 2.x.

Signed-off-by: Philip Molares <philip.molares@udo.edu>
2021-05-11 22:49:44 +02:00
David Mehren
980da1fa43
Fix nullable property types in Note DTOs
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
d1e352d56c
Add explicit type annotations to nullable columns
TypeORM can't correctly infer the data type on properties with a `| null` type.
This commit adds explicit type annotations.

See also https://github.com/typeorm/typeorm/issues/2567#issuecomment-408599335

Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
f9a0353748
NotesService.toNoteMetadataDto: Handle undefined updateUser
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
f8efb9717e
NotesService: Fix type errors
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00
David Mehren
3b0ffaca30
Consistently type properties as optional
Signed-off-by: David Mehren <git@herrmehren.de>
2021-05-09 20:59:31 +02:00