Skip to content

Commit

Permalink
format & lint
Browse files Browse the repository at this point in the history
  • Loading branch information
idugalic committed Oct 6, 2024
1 parent ab0e1f5 commit 41298a2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
14 changes: 7 additions & 7 deletions lib/application.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EventSourcingAggregate, MaterializedView } from "fmodel";
import { Order, Restaurant, RestaurantView } from "./domain.ts";
import { StreamVersion } from "./infrastructure.ts";
import { CommandMetadata } from "./infrastructure.ts";
import { EventMetadata } from "./infrastructure.ts";
import { OrderView } from "./domain.ts";
import { Command, Event } from "./api.ts";
import type { EventSourcingAggregate, MaterializedView } from "fmodel";
import type { Order, Restaurant, RestaurantView } from "./domain.ts";
import type { StreamVersion } from "./infrastructure.ts";
import type { CommandMetadata } from "./infrastructure.ts";
import type { EventMetadata } from "./infrastructure.ts";
import type { OrderView } from "./domain.ts";
import type { Command, Event } from "./api.ts";

/**
* An aggregate that handles the command and produces new events / A convenient type alias for the Fmodel's `EventSourcingLockingAggregate`
Expand Down
21 changes: 13 additions & 8 deletions lib/domain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// deno-lint-ignore-file no-case-declarations
import { Decider, View } from "fmodel";
import {
import type {
MenuItem,
OrderCommand,
OrderEvent,
Expand Down Expand Up @@ -119,10 +118,11 @@ export const restaurantDecider: Decider<
final: false,
},
];
default:
default: {
// Exhaustive matching of the command type
const _: never = command;
return [];
}
}
},
(currentState, event) => {
Expand All @@ -145,10 +145,11 @@ export const restaurantDecider: Decider<
return currentState;
case "RestaurantOrderNotPlacedEvent":
return currentState;
default:
default: {
// Exhaustive matching of the event type
const _: never = event;
return currentState;
}
}
},
null,
Expand Down Expand Up @@ -197,10 +198,11 @@ export const restaurantView: View<RestaurantView | null, RestaurantEvent> =
return currentState;
case "RestaurantOrderNotPlacedEvent":
return currentState;
default:
default: {
// Exhaustive matching of the event type
const _: never = event;
return currentState;
}
}
},
null,
Expand Down Expand Up @@ -280,10 +282,11 @@ export const orderDecider: Decider<OrderCommand, Order | null, OrderEvent> =
final: false,
},
];
default:
default: {
// Exhaustive matching of the command type
const _: never = command;
return [];
}
}
},
(currentState, event) => {
Expand All @@ -308,10 +311,11 @@ export const orderDecider: Decider<OrderCommand, Order | null, OrderEvent> =
: currentState;
case "OrderNotPreparedEvent":
return currentState;
default:
default: {
// Exhaustive matching of the event type
const _: never = event;
return currentState;
}
}
},
null,
Expand Down Expand Up @@ -365,10 +369,11 @@ export const orderView: View<OrderView | null, OrderEvent> = new View<
: currentState;
case "OrderNotPreparedEvent":
return currentState;
default:
default: {
// Exhaustive matching of the event type
const _: never = event;
return currentState;
}
}
},
null,
Expand Down
2 changes: 1 addition & 1 deletion lib/domain_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from "./api_schema.ts";
import { ViewSpecification } from "../test_specification.ts";
import { DeciderSpecification } from "../test_specification.ts";
import { RestaurantCommand, RestaurantEvent } from "./api.ts";
import type { RestaurantCommand, RestaurantEvent } from "./api.ts";

// A convinient testing specififcation for the Decider - GIVEN / WHEN / THEN

Expand Down
4 changes: 2 additions & 2 deletions lib/infrastructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* These classes are used in the infrastructure layer of the application.
*/

import { IEventRepository } from "fmodel";
import { Command, Event } from "./api.ts";
import type { IEventRepository } from "fmodel";
import type { Command, Event } from "./api.ts";
import { monotonicFactory } from "ulid";

// Be precise and explicit about the types
Expand Down
15 changes: 9 additions & 6 deletions server.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { blue } from "std/fmt/colors.ts";
import {
Order,
type Order,
orderDecider,
Restaurant,
type Restaurant,
restaurantDecider,
} from "./lib/domain.ts";
import { Decider, EventSourcingAggregate } from "fmodel";
import { CommandMetadata, DenoEventRepository } from "./lib/infrastructure.ts";
import { ApplicationAggregate } from "./lib/application.ts";
import { type Decider, EventSourcingAggregate } from "fmodel";
import {
type CommandMetadata,
DenoEventRepository,
} from "./lib/infrastructure.ts";
import type { ApplicationAggregate } from "./lib/application.ts";
import { commandAndMetadataSchema } from "./lib/api_schema.ts";
import { Command, Event } from "./lib/api.ts";
import type { Command, Event } from "./lib/api.ts";

// A simple HTTP server that handles commands of all types
Deno.serve(async (request: Request) => {
Expand Down
4 changes: 3 additions & 1 deletion test_specification.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assert, assertEquals } from "std/assert/mod.ts";
import { IDecider, IView } from "fmodel";
import type { IDecider, IView } from "fmodel";

export type DeciderSpecification<C, E> = {
given: (events: E[]) => {
Expand Down Expand Up @@ -44,6 +44,7 @@ export const DeciderSpecification = {
};

return {
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: (expectedEvents: E[]) => {
const resultEvents = handle();
assertEquals(resultEvents, expectedEvents);
Expand Down Expand Up @@ -99,6 +100,7 @@ export const ViewSpecification = {
);
};
return {
// biome-ignore lint/suspicious/noThenProperty: <explanation>
then: (expectedState: S) => {
const resultState = handle();
assertEquals(resultState, expectedState);
Expand Down

0 comments on commit 41298a2

Please sign in to comment.