Skip to main content

@idpass/data-collect-core / SelfServiceManager

Class: SelfServiceManager

Defined in: services/SelfServiceManager.ts:87

Manages self-service interactions where beneficiaries can view and update their own records. Provides a restricted API surface compared to the full EntityDataManager, ensuring beneficiaries can only access their own data.

All submissions through this manager generate standard events that flow through the same event sourcing pipeline as field worker submissions.

Constructors​

Constructor​

new SelfServiceManager(entityStore, eventStore, eventApplierService): SelfServiceManager

Defined in: services/SelfServiceManager.ts:88

Parameters​

entityStore​

EntityStore

eventStore​

EventStore

eventApplierService​

EventApplierService

Returns​

SelfServiceManager

Methods​

getOwnEntity()​

getOwnEntity(entityGuid): Promise<EntityDoc | null>

Defined in: services/SelfServiceManager.ts:100

Get the authenticated beneficiary's own entity.

Parameters​

entityGuid​

string

The GUID of the entity (from the self-service JWT claims)

Returns​

Promise<EntityDoc | null>

The entity document, or null if not found


submitSelfServiceForm()​

submitSelfServiceForm(entityGuid, formData, userId): Promise<void>

Defined in: services/SelfServiceManager.ts:116

Submit a self-service form that updates the beneficiary's own record. Creates an "update-individual" event targeting the entity.

Parameters​

entityGuid​

string

The GUID of the entity to update

formData​

Record<string, unknown>

The data fields to update

userId​

string

The self-service user identifier (from JWT)

Returns​

Promise<void>


getAvailableForms()​

getAvailableForms(config): FormConfig[]

Defined in: services/SelfServiceManager.ts:150

Get forms available for self-service based on tenant configuration.

Parameters​

config​

SelfServiceConfig

The self-service configuration for the tenant

Returns​

FormConfig[]

Array of form configurations available to beneficiaries


getSubmissionHistory()​

getSubmissionHistory(entityGuid): Promise<FormSubmission[]>

Defined in: services/SelfServiceManager.ts:168

Get submission history for an entity. Returns all events targeting the specified entity, providing a complete change history.

Parameters​

entityGuid​

string

The GUID of the entity

Returns​

Promise<FormSubmission[]>

Array of form submissions for this entity