Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into rocket_health_sensors
Browse files Browse the repository at this point in the history
# Conflicts:
#	common/config/rush/pnpm-lock.yaml
  • Loading branch information
Castro, Mario committed Aug 19, 2024
2 parents 89abb5d + 8adf2ee commit aae4aef
Show file tree
Hide file tree
Showing 75 changed files with 2,714 additions and 1,048 deletions.
470 changes: 239 additions & 231 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common/config/rush/version-policies.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@
"definitionName": "lockStepVersion",
"policyName": "booster",
"mainProject": "@boostercloud/framework-core",
"version": "2.13.1"
"version": "2.16.0"
}
]
6 changes: 3 additions & 3 deletions packages/application-tester/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boostercloud/application-tester",
"version": "2.13.1",
"version": "2.16.0",
"description": "Contains Booster types related to the information extracted from the user project",
"keywords": [
"application-tester"
Expand Down Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@apollo/client": "3.7.13",
"@boostercloud/framework-types": "workspace:^2.13.1",
"@boostercloud/framework-types": "workspace:^2.16.0",
"cross-fetch": "3.1.5",
"graphql": "^16.6.0",
"jsonwebtoken": "9.0.1",
Expand All @@ -48,7 +48,7 @@
"@effect-ts/core": "^0.60.4"
},
"devDependencies": {
"@boostercloud/eslint-config": "workspace:^2.13.1",
"@boostercloud/eslint-config": "workspace:^2.16.0",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.23.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@boostercloud/cli",
"description": "CLI of the Booster Framework, the next level of abstraction for cloud-native applications",
"version": "2.13.1",
"version": "2.16.0",
"author": "Boosterin Labs SLU",
"homepage": "https://boosterframework.com",
"publishConfig": {
Expand All @@ -12,8 +12,8 @@
},
"bugs": "https://github.com/boostercloud/booster/issues",
"dependencies": {
"@boostercloud/framework-core": "workspace:^2.13.1",
"@boostercloud/framework-types": "workspace:^2.13.1",
"@boostercloud/framework-core": "workspace:^2.16.0",
"@boostercloud/framework-types": "workspace:^2.16.0",
"@oclif/core": "3.15.0",
"@oclif/plugin-help": "^5",
"chalk": "^2.4.2",
Expand All @@ -30,8 +30,8 @@
"@effect-ts/core": "^0.60.4"
},
"devDependencies": {
"@boostercloud/eslint-config": "workspace:^2.13.1",
"@boostercloud/application-tester": "workspace:^2.13.1",
"@boostercloud/eslint-config": "workspace:^2.16.0",
"@boostercloud/application-tester": "workspace:^2.16.0",
"@oclif/test": "^3.0.3",
"@types/chai": "4.2.18",
"@types/chai-as-promised": "7.1.4",
Expand Down
6 changes: 3 additions & 3 deletions packages/framework-common-helpers/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boostercloud/framework-common-helpers",
"version": "2.13.1",
"version": "2.16.0",
"description": "Contains Booster common helpers used by the core and provider packages",
"keywords": [
"framework-common-helpers"
Expand Down Expand Up @@ -36,14 +36,14 @@
"node": ">=18.0.0 <19.0.0"
},
"dependencies": {
"@boostercloud/framework-types": "workspace:^2.13.1",
"@boostercloud/framework-types": "workspace:^2.16.0",
"child-process-promise": "^2.2.1",
"tslib": "^2.4.0",
"@effect-ts/core": "^0.60.4",
"class-transformer": "~0.5.1"
},
"devDependencies": {
"@boostercloud/eslint-config": "workspace:^2.13.1",
"@boostercloud/eslint-config": "workspace:^2.16.0",
"@types/chai": "4.2.18",
"@types/chai-as-promised": "7.1.4",
"@types/child-process-promise": "^2.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/framework-common-helpers/src/retrier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Class, Logger } from '@boostercloud/framework-types'
* @returns The result of the first successful retry.
*/
export async function retryIfError<TReturn>(
logicToRetry: () => Promise<TReturn>,
logicToRetry: (tryNumber?: number) => Promise<TReturn>,
errorClassThatRetries: Class<Error>,
logger?: Logger,
maxRetries = 1000
Expand All @@ -20,7 +20,7 @@ export async function retryIfError<TReturn>(
for (tryNumber = 1; tryNumber <= maxRetries; tryNumber++) {
try {
logger?.debug(`[retryIfError] Try number ${tryNumber}`)
const result = await logicToRetry()
const result = await logicToRetry(tryNumber)
logger?.debug(`[retryIfError] Succeeded after ${tryNumber} retries`)
return result
} catch (e) {
Expand Down
84 changes: 84 additions & 0 deletions packages/framework-core/CHANGELOG.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,90 @@
{
"name": "@boostercloud/framework-core",
"entries": [
{
"version": "2.16.0",
"tag": "@boostercloud/framework-core_v2.16.0",
"date": "Tue, 06 Aug 2024 20:59:53 GMT",
"comments": {
"minor": [
{
"comment": "Improve GlobalErrorHandler",
"author": "gonzalojaubert <[email protected]>",
"commit": "84b93bc513693f326b766678e423c2d669d18b94"
}
],
"dependency": [
{
"comment": "Updating dependency \"@boostercloud/framework-common-helpers\" from `^2.15.0` to `^2.16.0`"
},
{
"comment": "Updating dependency \"@boostercloud/framework-types\" from `^2.15.0` to `^2.16.0`"
},
{
"comment": "Updating dependency \"@boostercloud/metadata-booster\" from `^2.15.0` to `^2.16.0`"
},
{
"comment": "Updating dependency \"@boostercloud/eslint-config\" from `^2.15.0` to `^2.16.0`"
}
]
}
},
{
"version": "2.15.0",
"tag": "@boostercloud/framework-core_v2.15.0",
"date": "Wed, 31 Jul 2024 14:54:27 GMT",
"comments": {
"minor": [
{
"comment": "Handle non-found events with global error handler",
"author": "gonzalojaubert <[email protected]>",
"commit": "c474f64af3439b15339cd2a6cef31969f568d52c"
}
],
"dependency": [
{
"comment": "Updating dependency \"@boostercloud/framework-common-helpers\" from `^2.14.0` to `^2.15.0`"
},
{
"comment": "Updating dependency \"@boostercloud/framework-types\" from `^2.14.0` to `^2.15.0`"
},
{
"comment": "Updating dependency \"@boostercloud/metadata-booster\" from `^2.14.0` to `^2.15.0`"
},
{
"comment": "Updating dependency \"@boostercloud/eslint-config\" from `^2.14.0` to `^2.15.0`"
}
]
}
},
{
"version": "2.14.0",
"tag": "@boostercloud/framework-core_v2.14.0",
"date": "Tue, 30 Jul 2024 18:43:55 GMT",
"comments": {
"minor": [
{
"comment": "Read Models projections by ReadModel query",
"author": "gonzalojaubert <[email protected]>",
"commit": "2abba631c47a71d6b886f752ade48c0efe57accf"
}
],
"dependency": [
{
"comment": "Updating dependency \"@boostercloud/framework-common-helpers\" from `^2.13.1` to `^2.14.0`"
},
{
"comment": "Updating dependency \"@boostercloud/framework-types\" from `^2.13.1` to `^2.14.0`"
},
{
"comment": "Updating dependency \"@boostercloud/metadata-booster\" from `^2.13.1` to `^2.14.0`"
},
{
"comment": "Updating dependency \"@boostercloud/eslint-config\" from `^2.13.1` to `^2.14.0`"
}
]
}
},
{
"version": "2.13.1",
"tag": "@boostercloud/framework-core_v2.13.1",
Expand Down
23 changes: 22 additions & 1 deletion packages/framework-core/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# Change Log - @boostercloud/framework-core

This log was last generated on Fri, 26 Jul 2024 09:36:18 GMT and should not be manually modified.
This log was last generated on Tue, 06 Aug 2024 20:59:53 GMT and should not be manually modified.

## 2.16.0
Tue, 06 Aug 2024 20:59:53 GMT

### Minor changes

- Improve GlobalErrorHandler

## 2.15.0
Wed, 31 Jul 2024 14:54:27 GMT

### Minor changes

- Handle non-found events with global error handler

## 2.14.0
Tue, 30 Jul 2024 18:43:55 GMT

### Minor changes

- Read Models projections by ReadModel query

## 2.13.1
Fri, 26 Jul 2024 09:36:18 GMT
Expand Down
10 changes: 5 additions & 5 deletions packages/framework-core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@boostercloud/framework-core",
"version": "2.13.1",
"version": "2.16.0",
"description": "Library for your Booster apps",
"author": "Boosterin Labs SLU",
"homepage": "https://boosterframework.com",
Expand Down Expand Up @@ -37,8 +37,8 @@
"graphql": "^16.6.0"
},
"dependencies": {
"@boostercloud/framework-common-helpers": "workspace:^2.13.1",
"@boostercloud/framework-types": "workspace:^2.13.1",
"@boostercloud/framework-common-helpers": "workspace:^2.16.0",
"@boostercloud/framework-types": "workspace:^2.16.0",
"fp-ts": "^2.11.0",
"graphql-scalars": "^1.17.0",
"graphql-subscriptions": "2.0.0",
Expand All @@ -61,8 +61,8 @@
"ws": "8.17.1"
},
"devDependencies": {
"@boostercloud/metadata-booster": "workspace:^2.13.1",
"@boostercloud/eslint-config": "workspace:^2.13.1",
"@boostercloud/metadata-booster": "workspace:^2.16.0",
"@boostercloud/eslint-config": "workspace:^2.16.0",
"@types/chai": "4.2.18",
"@types/chai-as-promised": "7.1.4",
"@types/faker": "5.1.5",
Expand Down
4 changes: 3 additions & 1 deletion packages/framework-core/src/booster-command-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export class BoosterCommandDispatcher {
result = await commandClass.handle(commandInstance, register)
} catch (err) {
const e = err as Error
const error = await this.globalErrorDispatcher.dispatch(new CommandHandlerGlobalError(migratedCommandEnvelope, e))
const error = await this.globalErrorDispatcher.dispatch(
new CommandHandlerGlobalError(migratedCommandEnvelope, commandMetadata, e)
)
if (error) throw error
}
logger.debug('Command dispatched with register: ', register)
Expand Down
2 changes: 1 addition & 1 deletion packages/framework-core/src/booster-event-dispatcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BoosterConfig, TraceActionTypes } from '@boostercloud/framework-types'
import { EventStore } from './services/event-store'
import { RawEventsParser } from './services/raw-events-parser'
import { ReadModelStore } from './services/read-model-store'
import { getLogger } from '@boostercloud/framework-common-helpers'
import { ReadModelStore } from './services/read-model-store'
import { Trace } from './instrumentation'
import { BoosterEventProcessor } from './booster-event-processor'

Expand Down
4 changes: 3 additions & 1 deletion packages/framework-core/src/booster-event-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,9 @@ export class BoosterEventProcessor {
await eventHandler.handle(eventInstance, register)
} catch (e) {
const globalErrorDispatcher = new BoosterGlobalErrorDispatcher(config)
const error = await globalErrorDispatcher.dispatch(new EventHandlerGlobalError(eventInstance, e))
const error = await globalErrorDispatcher.dispatch(
new EventHandlerGlobalError(eventEnvelope, eventInstance, e.eventHandlerMetadata, e)
)
if (error) throw error
}
await RegisterHandler.handle(config, register)
Expand Down
40 changes: 32 additions & 8 deletions packages/framework-core/src/booster-global-error-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
ProjectionGlobalError,
SnapshotPersistHandlerGlobalError,
QueryHandlerGlobalError,
EventGlobalError,
} from '@boostercloud/framework-types'
import { getLogger } from '@boostercloud/framework-common-helpers'

Expand Down Expand Up @@ -48,14 +49,14 @@ export class BoosterGlobalErrorDispatcher {
case SnapshotPersistHandlerGlobalError:
newError = await this.handleSnapshotPersistError(error)
break
case EventGlobalError:
newError = await this.handleEventError(error)
break
}

newError = await this.handleGenericError(newError)
} catch (e) {
logger.error(
`Unhandled error inside the global error handler. When handling error ${error.originalError}, another error occurred`,
e
)
logger.error(`Unhandled error inside the global error handler. When handling error ${error.originalError}`, e)
return e
}
if (newError) return newError
Expand All @@ -65,7 +66,11 @@ export class BoosterGlobalErrorDispatcher {
private async handleCommandError(error: GlobalErrorContainer): Promise<Error | undefined> {
if (!this.errorHandler || !this.errorHandler.onCommandHandlerError) throw error.originalError
const currentError = error as CommandHandlerGlobalError
return await this.errorHandler.onCommandHandlerError(currentError.originalError, currentError.command)
return await this.errorHandler.onCommandHandlerError(
currentError.originalError,
currentError.commandEnvelope,
currentError.commandMetadata
)
}

private async handleQueryError(error: GlobalErrorContainer): Promise<Error | undefined> {
Expand All @@ -77,20 +82,31 @@ export class BoosterGlobalErrorDispatcher {
private async handleScheduleError(error: GlobalErrorContainer): Promise<Error | undefined> {
if (!this.errorHandler || !this.errorHandler.onScheduledCommandHandlerError) throw error.originalError
const currentError = error as ScheduleCommandGlobalError
return await this.errorHandler.onScheduledCommandHandlerError(currentError.originalError)
return await this.errorHandler.onScheduledCommandHandlerError(
currentError.originalError,
currentError.scheduleCommandEnvelope,
currentError.scheduleCommandMetadata
)
}

private async handleEventHandlerError(error: GlobalErrorContainer): Promise<Error | undefined> {
if (!this.errorHandler || !this.errorHandler.onDispatchEventHandlerError) throw error.originalError
const currentError = error as EventHandlerGlobalError
return await this.errorHandler.onDispatchEventHandlerError(currentError.originalError, currentError.eventInstance)
return await this.errorHandler.onDispatchEventHandlerError(
currentError.originalError,
currentError.eventEnvelope,
currentError.eventHandlerMetadata,
currentError.eventInstance
)
}

private async handleReducerError(error: GlobalErrorContainer): Promise<Error | undefined> {
private async handleReducerError(error: GlobalErrorContainer): Promise<Error> {
if (!this.errorHandler || !this.errorHandler.onReducerError) throw error.originalError
const currentError = error as ReducerGlobalError
return await this.errorHandler.onReducerError(
currentError.originalError,
currentError.eventEnvelope,
currentError.reducerMetadata,
currentError.eventInstance,
currentError.snapshotInstance
)
Expand All @@ -101,6 +117,8 @@ export class BoosterGlobalErrorDispatcher {
const currentError = error as ProjectionGlobalError
return await this.errorHandler.onProjectionError(
currentError.originalError,
currentError.entityEnvelope,
currentError.projectionMetadata,
currentError.entity,
currentError.readModel
)
Expand All @@ -112,6 +130,12 @@ export class BoosterGlobalErrorDispatcher {
return this.errorHandler.onSnapshotPersistError(currentError.originalError, currentError.snapshot)
}

private async handleEventError(error: GlobalErrorContainer): Promise<Error | undefined> {
if (!this.errorHandler || !this.errorHandler.onEventError) throw error.originalError
const currentError = error as EventGlobalError
return await this.errorHandler.onEventError(currentError.originalError, currentError.eventEnvelope)
}

private async handleGenericError(error: Error | undefined): Promise<Error | undefined> {
if (!error) return undefined
if (!this.errorHandler || !this.errorHandler.onError) throw error
Expand Down
Loading

0 comments on commit aae4aef

Please sign in to comment.