@domain-first/project-structure 5.0.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -49,12 +49,20 @@ It exits with 1 when anything is found. Checks turned off in the config (`rules.
|
|
|
49
49
|
|
|
50
50
|
```ts
|
|
51
51
|
export class Order extends domainType(
|
|
52
|
-
z.object({
|
|
52
|
+
z.object({
|
|
53
|
+
id: z.instanceof(OrderId),
|
|
54
|
+
lines: z.array(z.instanceof(OrderLine)),
|
|
55
|
+
status: z.enum(["open", "paid"]),
|
|
56
|
+
}),
|
|
53
57
|
) {
|
|
54
|
-
|
|
55
|
-
if (this.status ===
|
|
56
|
-
|
|
57
|
-
|
|
58
|
+
withPayment = () => {
|
|
59
|
+
if (this.status === "paid") {
|
|
60
|
+
throw new AlreadyPaidOrderSalesError({
|
|
61
|
+
id: this.id.snapshot,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
return this.with({ status: "paid" });
|
|
65
|
+
};
|
|
58
66
|
}
|
|
59
67
|
```
|
|
60
68
|
|
|
@@ -76,7 +84,10 @@ export class Order extends domainType(
|
|
|
76
84
|
Dependencies (constructor parameters and their wires) are added only by `df-ps` (`df-ps-scaffold`, rule 3): the generator's `Dependencies:` step or `Wire dependency`. It keeps each `wireClass(X, [...])` in the order of the constructor, which TypeScript checks:
|
|
77
85
|
|
|
78
86
|
```ts
|
|
79
|
-
export const wirePlaceOrderUseCase = wireClass(PlaceOrderUseCase, [
|
|
87
|
+
export const wirePlaceOrderUseCase = wireClass(PlaceOrderUseCase, [
|
|
88
|
+
wireOrderRepository,
|
|
89
|
+
wirePaymentGateway,
|
|
90
|
+
]);
|
|
80
91
|
```
|
|
81
92
|
|
|
82
93
|
- Use the injected dependencies in the class body; don't edit the parameter list or the wire list.
|