-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed685f5
commit 4643b75
Showing
11 changed files
with
131 additions
and
77 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
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
7 changes: 6 additions & 1 deletion
7
src/core/useCases/car/query/retrieveCarsPlanning/types/query.ts
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
type Actor = { | ||
id: string; | ||
} | ||
|
||
type RetrieveCarsPlanningQuery = { | ||
startDate: Date; | ||
endDate: Date; | ||
limit: number; | ||
cursor: null | string; | ||
cursor: string; | ||
actor: Actor; | ||
}; | ||
|
||
export default RetrieveCarsPlanningQuery; |
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,30 @@ | ||
import DecodedCursor from "src/core/domain/common/types/cursor"; | ||
|
||
/** | ||
* Encodes a cursor address to a base64 format. | ||
* | ||
* @param cursor The cursor address to encode | ||
* @param order The order of the cursor (gte for next, lte for prev) | ||
*/ | ||
export const encodeCursor = (cursor: string, order: string): string => { | ||
if (cursor === ''){ | ||
return ''; | ||
} | ||
return btoa(`${order == 'gte' ? 'next' : 'prev'}___${cursor}`); | ||
} | ||
|
||
export const decodeCursor = (cursor: string): DecodedCursor => { | ||
if (cursor === '') { | ||
return { | ||
order: 'gte', | ||
address: '' | ||
} | ||
} | ||
const cursorMatch = atob(cursor).match(new RegExp('^(?<order>(next|prev))___(?<address>[\\w\'-]+)$')) as RegExpMatchArray; | ||
const groups = cursorMatch.groups as any; | ||
|
||
return { | ||
order: groups.order == 'next' ? 'gte' : 'lte', | ||
address: groups.address as string, | ||
} | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import UserPermissionsProfile from "src/core/useCases/common/permissions/types/userPermissionsProfile"; | ||
|
||
export default interface PermissionsGatewayInterface { | ||
getUserPermissions(): Promise<UserPermissionsProfile[]>; | ||
getUserPermissions({userId}: { userId: string }): Promise<UserPermissionsProfile[]>; | ||
} |
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
Oops, something went wrong.