Skip to content

Commit

Permalink
Release 0.33.10
Browse files Browse the repository at this point in the history
Release 0.33.10
  • Loading branch information
resolve-bot authored Jan 17, 2022
2 parents a970d84 + 6750e41 commit 23f20fd
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 30 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [Upcoming](https://github.com/reimagined/resolve/tree/HEAD)

[Full Changelog](https://github.com/reimagined/resolve/compare/V0.33.9...HEAD)

**Enhancements:**

- Optimize loadevents for postgresql eventstore adapter [\#2196](https://github.com/reimagined/resolve/pull/2196)

**Bug fixes:**

- Resetting saga in hacker-news example generates redundant events [\#2163](https://github.com/reimagined/resolve/issues/2163)

**Other changes:**

- Fix issue with event.timestamp and +/-1 in @resolve-js/testing-tools [\#2198](https://github.com/reimagined/resolve/pull/2198)

## [V0.33.9](https://github.com/reimagined/resolve/tree/V0.33.9) (2022-01-12)

[Full Changelog](https://github.com/reimagined/resolve/compare/V0.33.8...V0.33.9)
Expand Down
8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ description: Full stack CQRS, DDD, Event Sourcing framework for Node.js
- [Custom Read Model Connectors](custom-read-model-connectors.md)
- [File Upload](file-upload.md)
- [Event Export and Import](export-import.md)
- [Preparing to Production](preparing-to-production.md)
- [Configuration Options](preparing-to-production.md#configuration-options)
- [Configuring Adapters](preparing-to-production.md#configuring-adapters)
- [Using Environment Variables](preparing-to-production.md#using-environment-variables)
- [Preparing for Production](preparing-for-production.md)
- [Configuration Options](preparing-for-production.md#configuration-options)
- [Configuring Adapters](preparing-for-production.md#configuring-adapters)
- [Using Environment Variables](preparing-for-production.md#using-environment-variables)
- [Code Splitting](code-splitting.md)
- [Debugging](debugging.md)
- [Debug ReSolve](debugging.md#debug-resolve)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: preparing-to-production
title: Preparing to Production
id: preparing-for-production
title: Preparing for Production
description: This document describes how to prepare a reSolve application for deployment to a production server environment.
---

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ A command handler returns an **event** object. This object should contain the fo

The reSolve framework saves produced events to a persistent **[event store](write-side.md#event-store)**. A newly created application is configured to use a SQLite event store. We suggest that you keep this configuration throughout the tutorial. For information on how to use other storage types, see the following documentation topics:

- [Adapters](https://github.com/reimagined/resolve/blob/master/docs/advanced-techniques.md#adapters)
- [Configuring Adapters](https://github.com/reimagined/resolve/blob/master/docs/preparing-to-production.md#configuring-adapters)
- [Adapters](adapters.md)
- [Configuring Adapters](preparing-for-production.md#configuring-adapters)

The last step is to register the implemented aggregate in the application's configuration file. To do this, open the **config.app.js** file and specify the following settings in the **aggregates** configuration section:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const createLoadQuery = (
const injectString = (value: any): string => `${escape(value)}`
const injectNumber = (value: any): string => `${+value}`

const queryConditions: string[] = []
const queryConditions: string[] = ['1 = 1']
if (eventTypes != null) {
if (eventTypes.length === 0) {
return null
Expand All @@ -29,28 +29,44 @@ const createLoadQuery = (
queryConditions.push(`"aggregateId" IN (${aggregateIds.map(injectString)})`)
}

const resultQueryCondition = `WHERE ${
queryConditions.length > 0 ? `${queryConditions.join(' AND ')} AND (` : ''
}
${vectorConditions
const resultQueryCondition = queryConditions.join(' AND ')

const databaseNameAsId: string = escapeId(databaseName)
const eventsTableAsId: string = escapeId(eventsTableName)

if (limit !== undefined) {
return [
`SELECT "unitedEvents".* FROM (
${vectorConditions
.map(
(threadCounter, threadId) =>
`(${[
`SELECT * FROM ${databaseNameAsId}.${eventsTableAsId}`,
`WHERE (${resultQueryCondition}) AND "threadId" = ${threadId} AND "threadCounter" >= ${threadCounter}::${INT8_SQL_TYPE}`,
`LIMIT ${limit}`,
].join(' ')})`
)
.join(' UNION ALL \n')}
) "unitedEvents"`,
`ORDER BY "unitedEvents"."timestamp" ASC, "unitedEvents"."threadCounter" ASC, "unitedEvents"."threadId" ASC`,
`LIMIT ${+limit}`,
].join('\n')
} else {
const resultVectorConditions = `${vectorConditions
.map(
(threadCounter, threadId) =>
`"threadId" = ${injectNumber(
threadId
)} AND "threadCounter" >= ${threadCounter}::${INT8_SQL_TYPE} `
)
.join(' OR ')}
${queryConditions.length > 0 ? ')' : ''}`
.join(' OR ')}`

const databaseNameAsId: string = escapeId(databaseName)
const eventsTableAsId: string = escapeId(eventsTableName)

return [
`SELECT * FROM ${databaseNameAsId}.${eventsTableAsId}`,
`${resultQueryCondition}`,
`ORDER BY "timestamp" ASC, "threadCounter" ASC, "threadId" ASC`,
limit !== undefined ? `LIMIT ${+limit}` : '',
].join('\n')
return [
`SELECT * FROM ${databaseNameAsId}.${eventsTableAsId}`,
`WHERE (${resultVectorConditions}) AND (${resultQueryCondition})`,
`ORDER BY "timestamp" ASC, "threadCounter" ASC, "threadId" ASC`,
].join('\n')
}
}

export default createLoadQuery
4 changes: 2 additions & 2 deletions packages/tools/testing-tools/src/runtime/get-event-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export const getEventStore = async (
const event = events[timestampIndex]

event.timestamp =
(eventByAggregateIdVersion.get(
eventByAggregateIdVersion.get(
`${event.aggregateId}:${event.aggregateVersion}`
)?.timestamp ?? timestampIndex) + 1
)?.timestamp ?? timestampIndex + 1
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ Array [
exports[`givenEvents tests should match snapshot with specified timestamp 1`] = `
Array [
Object {
"timestamp": 11,
"timestamp": 10,
"value": "test-1",
},
Object {
"timestamp": 21,
"timestamp": 20,
"value": "test-2",
},
Object {
"timestamp": 31,
"timestamp": 30,
"value": "test-3",
},
]
Expand Down
14 changes: 14 additions & 0 deletions packages/tools/testing-tools/test/read-model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,20 @@ describe('givenEvents tests', () => {
.readModel(readModel)
.query('all', {})

expect(result?.items).toEqual([
{
value: 'test-1',
timestamp: 10,
},
{
value: 'test-2',
timestamp: 20,
},
{
value: 'test-3',
timestamp: 30,
},
])
expect(result?.items).toMatchSnapshot()
})

Expand Down
2 changes: 1 addition & 1 deletion website/sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"custom-read-model-connectors",
"file-upload",
"export-import",
"preparing-to-production",
"preparing-for-production",
"code-splitting",
"debugging",
"testing",
Expand Down

0 comments on commit 23f20fd

Please sign in to comment.