Skip to content

SudoSOS Back-end API / internal/user-user-service / UserSyncService

Abstract Class: UserSyncService ​

UserSyncService interface.

Specific sync service for users.

Extends ​

Extended by ​

Constructors ​

Constructor ​

ts
new UserSyncService(manager?): UserSyncService;

Parameters ​

ParameterType
manager?EntityManager

Returns ​

UserSyncService

Inherited from ​

SyncService.constructor

Properties ​

PropertyModifierTypeInherited from
managerprotectedEntityManagerSyncService.manager
targetspublicUserType[]-

Methods ​

down() ​

ts
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 ​

ParameterTypeDescription
userUser-
isDryRun?booleanWhether this is a dry run (no actual changes)

Returns ​

Promise<void>

Overrides ​

SyncService.down


fetch() ​

ts
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 ​

SyncService.fetch


guard() ​

ts
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 ​

ParameterType
userUser

Returns ​

Promise<boolean>

True if the entity should be synced, false otherwise.

Overrides ​

SyncService.guard


post() ​

ts
post(): Promise<void>;

Called after a sync batch is finished.

Returns ​

Promise<void>

Inherited from ​

SyncService.post


pre() ​

ts
pre(): Promise<void>;

Called before a sync batch is started.

Returns ​

Promise<void>

Inherited from ​

SyncService.pre


sync() ​

ts
abstract protected sync(user, isDryRun?): Promise<boolean>;

Synchronizes the user data with the external data source.

Parameters ​

ParameterTypeDescription
userUser-
isDryRun?booleanWhether this is a dry run (no actual changes)

Returns ​

Promise<boolean>

True if the user was synchronized, false otherwise.

Overrides ​

SyncService.sync


up() ​

ts
up(entity, isDryRun?): Promise<SyncResult>;

Up is a wrapper around sync that handles the guard.

Parameters ​

ParameterTypeDefault valueDescription
entityUserundefined-
isDryRunbooleanfalseWhether this is a dry run (no actual changes)

Returns ​

Promise<SyncResult>

The result of the sync.

Inherited from ​

SyncService.up