Skip to content

AsSystem

AsSystem<TGrant>(options): DualMethodDecorator

Defined in: packages/pipeline-job-context/src/decorators/as-system.decorator.ts:44

Runs system-started work, such as a cron job, once per configured tenant. Each run has its own tenant, a new correlation id, and the declared service principal and grants, bound through the registered IJobPrincipal. Grants come only from this declaration, never from data.

Tenants run one after another. A failing tenant does not stop the others; the method then rejects with an AggregateError of the failures. Its return values are discarded. Place it under the scheduling decorator.

TGrant

AsSystemOptions<TGrant>

DualMethodDecorator

class Maintenance {
@AsSystem({
principal: { id: 'session-cleanup', type: 'service' },
grants: [{ action: 'delete', subject: 'Auth' }],
})
async purgeSessions() {
await purgeExpiredSessions();
}
}
cron.schedule('0 3 * * *', () => maintenance.purgeSessions());