Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/framework-core/src/booster-data-migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class BoosterDataMigrations {
const sortedConfiguredMigrations = BoosterDataMigrations.sortConfiguredMigrations(configuredMigrations)
const eventStore = new EventStore(config)
for (const configuredMigration of Object.values(sortedConfiguredMigrations)) {
const migrationEntityForConfiguredMigration = await eventStore.fetchEntitySnapshot(
const migrationEntityForConfiguredMigration = await eventStore.fetchAndCacheEntitySnapshot(
BoosterDataMigrationEntity.name,
configuredMigration.class.name
)
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-core/src/booster-event-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class BoosterEventProcessor {
const logger = getLogger(config, 'BoosterEventDispatcher#snapshotAndUpdateReadModels')
let entitySnapshot = undefined
try {
entitySnapshot = await eventStore.fetchEntitySnapshot(entityName, entityID)
entitySnapshot = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)
} catch (e) {
logger.error('Error while fetching or reducing entity snapshot:', e)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-core/src/booster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class Booster {
entityID: UUID
): Promise<TEntity | undefined> {
const eventStore = new EventStore(this.config)
const entitySnapshotEnvelope = await eventStore.fetchEntitySnapshot(entityClass.name, entityID)
const entitySnapshotEnvelope = await eventStore.fetchAndCacheEntitySnapshot(entityClass.name, entityID)
return entitySnapshotEnvelope ? createInstance(entityClass, entitySnapshotEnvelope.value) : undefined
}

Expand Down
4 changes: 2 additions & 2 deletions packages/framework-core/src/services/event-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ export class EventStore {
* snapshot storing it at the end of the process.
*/
@Trace(TraceActionTypes.FETCH_ENTITY_SNAPSHOT)
public async fetchEntitySnapshot(entityName: string, entityID: UUID): Promise<EntitySnapshotEnvelope | undefined> {
const logger = getLogger(this.config, 'EventStore#fetchEntitySnapshot')
public async fetchAndCacheEntitySnapshot(entityName: string, entityID: UUID): Promise<EntitySnapshotEnvelope | undefined> {
const logger = getLogger(this.config, 'EventStore#fetchAndCacheEntitySnapshot')
logger.debug(`Fetching snapshot for entity ${entityName} with ID ${entityID}`)
const latestSnapshotEnvelope = await this.loadLatestSnapshot(entityName, entityID)

Expand Down
10 changes: 5 additions & 5 deletions packages/framework-core/test/booster-event-processor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
const boosterEventProcessor = BoosterEventProcessor as any
const eventStore = createStubInstance(EventStore)
const readModelStore = createStubInstance(ReadModelStore)
eventStore.fetchEntitySnapshot = fake.resolves({}) as any
eventStore.fetchAndCacheEntitySnapshot = fake.resolves({}) as any

await boosterEventProcessor.snapshotAndUpdateReadModels(
config,
Expand All @@ -183,14 +183,14 @@
readModelStore
)

expect(eventStore.fetchEntitySnapshot).to.have.been.called
expect(eventStore.fetchEntitySnapshot).to.have.been.calledOnceWith(someEvent.entityTypeName, someEvent.entityID)
expect(eventStore.fetchAndCacheEntitySnapshot).to.have.been.called
expect(eventStore.fetchAndCacheEntitySnapshot).to.have.been.calledOnceWith(someEvent.entityTypeName, someEvent.entityID)

Check failure on line 187 in packages/framework-core/test/booster-event-processor.test.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `someEvent.entityTypeName,·someEvent.entityID` with `⏎··········someEvent.entityTypeName,⏎··········someEvent.entityID⏎········`
})

it('projects the entity state to the corresponding read models', async () => {
const boosterEventProcessor = BoosterEventProcessor as any
const eventStore = createStubInstance(EventStore)
eventStore.fetchEntitySnapshot = fake.resolves(someEntitySnapshot) as any
eventStore.fetchAndCacheEntitySnapshot = fake.resolves(someEntitySnapshot) as any

const readModelStore = createStubInstance(ReadModelStore)

Expand All @@ -211,7 +211,7 @@
const eventStore = createStubInstance(EventStore)
const readModelStore = createStubInstance(ReadModelStore)
const error = new Error('some error')
eventStore.fetchEntitySnapshot = fake.rejects(error) as any
eventStore.fetchAndCacheEntitySnapshot = fake.rejects(error) as any

await expect(
boosterEventProcessor.snapshotAndUpdateReadModels(
Expand Down
8 changes: 4 additions & 4 deletions packages/framework-core/test/booster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,20 @@ describe('the `Booster` class', () => {
const config = new BoosterConfig('test')
config.provider = {} as ProviderLibrary

it('the `entity` function calls to the `fetchEntitySnapshot` method in the EventStore', async () => {
replace(EventStore.prototype, 'fetchEntitySnapshot', fake.returns({ value: { id: '42' } }))
it('the `entity` function calls to the `fetchAndCacheEntitySnapshot` method in the EventStore', async () => {
replace(EventStore.prototype, 'fetchAndCacheEntitySnapshot', fake.returns({ value: { id: '42' } }))

class SomeEntity {
public constructor(readonly id: UUID) {}
}
const snapshot = await Booster.entity(SomeEntity, '42')

expect(snapshot).to.be.deep.equal({ id: '42' })
expect(EventStore.prototype.fetchEntitySnapshot).to.have.been.calledOnceWith('SomeEntity', '42')
expect(EventStore.prototype.fetchAndCacheEntitySnapshot).to.have.been.calledOnceWith('SomeEntity', '42')
})

it('the entity function has an instance method', async () => {
replace(EventStore.prototype, 'fetchEntitySnapshot', fake.returns({ id: '42' }))
replace(EventStore.prototype, 'fetchAndCacheEntitySnapshot', fake.returns({ id: '42' }))

class SomeEntity {
public constructor(readonly id: UUID) {}
Expand Down
22 changes: 11 additions & 11 deletions packages/framework-core/test/services/event-store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ describe('EventStore', () => {
}

describe('public methods', () => {
describe('fetchEntitySnapshot', () => {
describe('fetchAndCacheEntitySnapshot', () => {
it('properly binds `this` to the entityReducer', async () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const eventStore = new EventStore(config) as any
Expand All @@ -166,7 +166,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
await expect(eventStore.fetchEntitySnapshot(entityName, entityID)).to.be.eventually.fulfilled
await expect(eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)).to.be.eventually.fulfilled
})

context('when there is a snapshot but no pending events', () => {
Expand All @@ -182,7 +182,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(
Expand Down Expand Up @@ -314,7 +314,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(
Expand Down Expand Up @@ -381,7 +381,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(entityName, entityID, originOfTime)
Expand Down Expand Up @@ -412,7 +412,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(entityName, entityID, originOfTime)
Expand Down Expand Up @@ -474,7 +474,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
await eventStore.fetchEntitySnapshot(entityName, entityID)
await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)

Expand Down Expand Up @@ -555,7 +555,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
await expect(eventStore.fetchEntitySnapshot(entityName, entityID)).to.eventually.be.rejectedWith(
await expect(eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)).to.eventually.be.rejectedWith(
'Error on reducer'
)

Expand Down Expand Up @@ -622,7 +622,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
const entity = await eventStore.fetchEntitySnapshot(entityName, entityID)
const entity = await eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)

Expand Down Expand Up @@ -691,7 +691,7 @@ describe('EventStore', () => {

const entityName = AnEntity.name
const entityID = '42'
await expect(eventStore.fetchEntitySnapshot(entityName, entityID)).to.eventually.be.fulfilled
await expect(eventStore.fetchAndCacheEntitySnapshot(entityName, entityID)).to.eventually.be.fulfilled

expect(eventStore.loadLatestSnapshot).to.have.been.calledOnceWith(entityName, entityID)
expect(eventStore.loadEventStreamSince).to.have.been.calledOnceWith(entityName, entityID, originOfTime)
Expand Down
4 changes: 2 additions & 2 deletions website/docs/11_frequently-asked-questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ When you deploy a Booster application to AWS, an S3 bucket needs to be created t

The solution is to **change your application name in the configuration file so that the bucket name is unique.**

**2.- I tried following the video guide but the function `Booster.fetchEntitySnapshot` is not found in BoostApp.**
**2.- I tried following the video guide but the function `Booster.fetchAndCacheEntitySnapshot` is not found in BoostApp.**

The function `Booster.fetchEntitySnapshot` was renamed to `Booster.entity`, so please replace it when following old tutorials.
The function `Booster.fetchAndCacheEntitySnapshot` was renamed to `Booster.entity`, so please replace it when following old tutorials.
Copy link

Copilot AI Nov 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation update is inconsistent with the actual API. fetchAndCacheEntitySnapshot is an internal method of the EventStore class, not a public method of the Booster class. The original FAQ referred to Booster.fetchEntitySnapshot, which should remain unchanged in the documentation since the public API Booster.entity has not changed. The internal refactoring of EventStore.fetchEntitySnapshot to EventStore.fetchAndCacheEntitySnapshot should not affect this user-facing documentation.

Suggested change
The function `Booster.fetchAndCacheEntitySnapshot` was renamed to `Booster.entity`, so please replace it when following old tutorials.
The function `Booster.fetchAndCacheEntitySnapshot` is not part of the public API. The correct way to fetch an entity snapshot is to use the public method `Booster.entity`. If you see references to `fetchEntitySnapshot` or `fetchAndCacheEntitySnapshot` in old tutorials, please replace them with `Booster.entity`.

Copilot uses AI. Check for mistakes.
Loading