Skip to content

Commit

Permalink
Updated packages in Events Versioning samples
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Jan 4, 2024
1 parent 4bad59b commit 26959ce
Show file tree
Hide file tree
Showing 15 changed files with 5,350 additions and 5,843 deletions.
3 changes: 1 addition & 2 deletions samples/eventsVersioning/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
"error",
{ "varsIgnorePattern": "^_", "argsIgnorePattern": "^_" }
],
"@typescript-eslint/no-misused-promises": ["off"],
"@typescript-eslint/prefer-namespace-keyword": "off"
"@typescript-eslint/no-misused-promises": ["off"]
},
"settings": {
"import/resolver": {
Expand Down
4 changes: 1 addition & 3 deletions samples/eventsVersioning/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,

"editor.codeActionsOnSave": {
// For ESLint
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},

"editor.tabSize": 2,
Expand Down
1 change: 0 additions & 1 deletion samples/eventsVersioning/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module.exports = {
setupFilesAfterEnv: ['./jest.setup.js'],
moduleNameMapper: {
'#core/(.*)': '<rootDir>/src/core/$1',
'#config': '<rootDir>/config.ts',
'#testing/(.*)': '<rootDir>/src/testing/$1',
},
globals: {
Expand Down
11,080 changes: 5,299 additions & 5,781 deletions samples/eventsVersioning/package-lock.json

Large diffs are not rendered by default.

56 changes: 22 additions & 34 deletions samples/eventsVersioning/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eventsourcing.nodejs",
"version": "1.0.0",
"version": "6.0.0",
"description": "Samples of Event Sourcing in JavaScript and TypeScript",
"scripts": {
"setup": "cat .nvmrc | nvm install; nvm use",
Expand All @@ -11,14 +11,11 @@
"lint": "npm run lint:eslint && npm run lint:prettier",
"lint:prettier": "prettier --check \"**/**/!(*.d).{ts,json,md}\"",
"lint:eslint": "eslint **/*.ts",
"fix": "run-s fix:eslint fix:prettier",
"fix": "npm run fix:eslint && npm run fix:prettier",
"fix:prettier": "prettier --write \"**/**/!(*.d).{ts,json,md}\"",
"fix:eslint": "eslint **/*.ts --fix",
"test": "run-s test:unit test:infr",
"test:unit": "jest unit --passWithNoTests --forceExit",
"test:infr": "jest infr --passWithNoTests --forceExit",
"test:watch": "jest test --passWithNoTests",
"test:unit:watch": "jest exercise --passWithNoTests --forceExit --watch"
"test": "run-s test:unit",
"test:unit": "jest unit --passWithNoTests"
},
"repository": {
"type": "git",
Expand All @@ -34,36 +31,27 @@
},
"homepage": "https://github.com/oskardudycz/EventSourcing.NodeJS#readme",
"dependencies": {
"@eventstore/db-client": "5.0.0",
"@faker-js/faker": "7.6.0",
"convict": "6.2.4",
"dotenv": "16.0.3",
"dotenv-cli": "7.0.0",
"@eventstore/db-client": "6.1.0",
"express": "4.18.2",
"immutable": "4.2.2",
"mongodb": "4.13.0"
"mongodb": "6.3.0"
},
"devDependencies": {
"@types/convict": "6.1.1",
"@types/express": "4.17.16",
"@types/jest": "29.4.0",
"@types/node": "18.11.18",
"@types/supertest": "2.0.12",
"@types/uuid": "9.0.0",
"@typescript-eslint/eslint-plugin": "5.49.0",
"@typescript-eslint/parser": "5.49.0",
"docker-compose": "0.23.19",
"eslint": "8.33.0",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-prettier": "4.2.1",
"jest": "29.4.1",
"@types/express": "4.17.21",
"@types/node": "20.10.6",
"@types/uuid": "9.0.7",
"@typescript-eslint/eslint-plugin": "6.17.0",
"@typescript-eslint/parser": "6.17.0",
"@types/jest": "29.5.11",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.1.2",
"jest": "29.7.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.3",
"supertest": "6.3.3",
"testcontainers": "9.1.1",
"ts-jest": "29.0.5",
"ts-node": "10.9.1",
"tsconfig-paths": "4.1.2",
"typescript": "4.9.4"
"prettier": "3.1.1",
"testcontainers": "10.4.0",
"ts-jest": "29.1.1",
"ts-node": "10.9.2",
"tsconfig-paths": "4.2.0",
"typescript": "5.3.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('New required property', () => {
},
};
},
}
},
);

expect(event).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('Renamed property', () => {
json,
{
map: (
value: ShoppingCartOpenedV1 | ShoppingCartOpened
value: ShoppingCartOpenedV1 | ShoppingCartOpened,
): ShoppingCartOpened => {
return {
...value,
Expand All @@ -68,7 +68,7 @@ describe('Renamed property', () => {
},
};
},
}
},
);

expect(event).toEqual({
Expand Down Expand Up @@ -135,7 +135,7 @@ describe('Renamed property', () => {
ShoppingCartOpened | ShoppingCartOpenedV1
>(json, {
map: (
value: ShoppingCartOpened
value: ShoppingCartOpened,
): ShoppingCartOpened & ShoppingCartOpenedV1 => {
return {
...value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Upcasting events', () => {
json,
{
map: upcast,
}
},
);

expect(event).toEqual({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ export class EventTransformations {
public register = {
upcaster: <From extends Event, To extends Event = From>(
eventType: string,
upcaster: (event: From) => To
upcaster: (event: From) => To,
) => {
this.#upcasters.set(eventType, (event) => upcaster(event as From));

return this.register;
},
downcaster: <From extends Event, To extends Event = From>(
eventType: string,
downcaster: (event: From) => To
downcaster: (event: From) => To,
) => {
this.#downcasters.set(eventType, (event) => downcaster(event as From));

Expand Down Expand Up @@ -139,7 +139,7 @@ export class EventParser {
type: event.type,
payload: JSONParser.stringify(
event,
downcaster ? { map: downcaster } : {}
downcaster ? { map: downcaster } : {},
),
};
}
Expand Down Expand Up @@ -192,7 +192,7 @@ describe('Multiple transformations with different event types', () => {

// When
const deserializedEvents = serializedEvents.map((e) =>
parser.parse<ShoppingCartOpenedWithStatus>(e)
parser.parse<ShoppingCartOpenedWithStatus>(e),
);

expect(deserializedEvents).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion samples/eventsVersioning/src/core/event.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export type Event<
EventType extends string = string,
EventData extends Record<string, unknown> = Record<string, unknown>
EventData extends Record<string, unknown> = Record<string, unknown>,
> = Readonly<{
type: Readonly<EventType>;
data: Readonly<EventData>;
Expand Down
6 changes: 3 additions & 3 deletions samples/eventsVersioning/src/core/jsonParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ export type MapperArgs<From, To = From> = Partial<From> &
export const JSONParser = {
stringify: <From, To = From>(
value: From,
options?: StringifyOptions<From, To>
options?: StringifyOptions<From, To>,
) => {
return JSON.stringify(
options?.map ? options.map(value as MapperArgs<From, To>) : value,
options?.replacer
options?.replacer,
);
},
parse: <From, To = From>(
text: string,
options?: ParseOptions<From, To>
options?: ParseOptions<From, To>,
): To | undefined => {
const parsed: unknown = JSON.parse(text, options?.reviver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('EventStoreDBContainer', () => {

const result = await client.appendToStream(
`test-${uuid()}`,
jsonEvent({ type: 'test-event', data: { test: 'test' } })
jsonEvent({ type: 'test-event', data: { test: 'test' } }),
);

expect(result.success).toBeTruthy();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { EventStoreDBClient } from '@eventstore/db-client';
import { GenericContainer, StartedTestContainer } from 'testcontainers';
import { Environment } from 'testcontainers/dist/docker/types';
import { AbstractStartedContainer } from 'testcontainers/dist/modules/abstract-started-container';
import {
AbstractStartedContainer,
GenericContainer,
StartedTestContainer,
} from 'testcontainers';
import { Environment } from 'testcontainers/build/types';

const EVENTSTOREDB_PORT = 2113;
const EVENTSTOREDB_TCP_PORT = 1113;
Expand All @@ -17,7 +20,7 @@ export class EventStoreDBContainer extends GenericContainer {
runProjections = true,
isInsecure = true,
emptyDatabase = true,
withoutReuse = false
withoutReuse = false,
) {
super(image);

Expand Down Expand Up @@ -63,7 +66,7 @@ export class StartedEventStoreDBContainer extends AbstractStartedContainer {

getConnectionString(): string {
return `esdb://${this.getHost()}:${this.getMappedPort(
2113
2113,
)}?tls=false&throwOnAppendFailure=false`;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
let esdbContainer: StartedEventStoreDBContainer;

export const getEventStoreDBTestClient = async (
useTestContainers = false
useTestContainers = false,
): Promise<EventStoreDBClient> => {
let connectionString;

Expand Down
6 changes: 4 additions & 2 deletions samples/eventsVersioning/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,

/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
Expand All @@ -49,6 +49,7 @@
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
"paths": {
"#core/*": ["./src/core/*"],
"#config": ["./config.ts"],
"#testing/*": ["./src/testing/*"]
} /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
Expand All @@ -59,6 +60,7 @@
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
"resolveJsonModule": true /* Enable importing .json files */,

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
Expand All @@ -73,5 +75,5 @@
"skipLibCheck": true /* Skip type checking of declaration files. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
},
"include": ["./src/**/*"]
"include": ["./src"]
}

0 comments on commit 26959ce

Please sign in to comment.