SudoSOS Back-end API / internal/user-user-service / UserSyncService
Abstract Class: UserSyncService ​
UserSyncService interface.
Specific sync service for users.
Extends ​
Extended by ​
Constructors ​
Constructor ​
new UserSyncService(manager?): UserSyncService;Parameters ​
| Parameter | Type |
|---|---|
manager? | EntityManager |
Returns ​
UserSyncService
Inherited from ​
Properties ​
| Property | Modifier | Type | Inherited from |
|---|---|---|---|
manager | protected | EntityManager | SyncService.manager |
targets | public | UserType[] | - |
Methods ​
down() ​
abstract down(user, isDryRun?): Promise<void>;Down is called when the SyncService decides that the entity is no longer connected to this sync service be removed. This can be used to remove the entity from the database or clean up entities.
This should be revertible and idempotent!
Parameters ​
| Parameter | Type | Description |
|---|---|---|
user | User | - |
isDryRun? | boolean | Whether this is a dry run (no actual changes) |
Returns ​
Promise<void>
Overrides ​
fetch() ​
abstract fetch(): Promise<void>;Fetches the user data from the external data source. sync can be seen as a push and fetch as a pull.
Returns ​
Promise<void>
Inherited from ​
guard() ​
guard(user): Promise<boolean>;Guard determines whether the entity should be synced using this sync service.
Not passing the guard will result in the user being skipped. A skipped sync does not count as a failure.
Parameters ​
| Parameter | Type |
|---|---|
user | User |
Returns ​
Promise<boolean>
True if the entity should be synced, false otherwise.
Overrides ​
post() ​
post(): Promise<void>;Called after a sync batch is finished.
Returns ​
Promise<void>
Inherited from ​
pre() ​
pre(): Promise<void>;Called before a sync batch is started.
Returns ​
Promise<void>
Inherited from ​
sync() ​
abstract protected sync(user, isDryRun?): Promise<boolean>;Synchronizes the user data with the external data source.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
user | User | - |
isDryRun? | boolean | Whether this is a dry run (no actual changes) |
Returns ​
Promise<boolean>
True if the user was synchronized, false otherwise.
Overrides ​
up() ​
up(entity, isDryRun?): Promise<SyncResult>;Up is a wrapper around sync that handles the guard.
Parameters ​
| Parameter | Type | Default value | Description |
|---|---|---|---|
entity | User | undefined | - |
isDryRun | boolean | false | Whether this is a dry run (no actual changes) |
Returns ​
Promise<SyncResult>
The result of the sync.