archstone 1.3.1 → 1.4.0

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.
@@ -1,2 +1,2 @@
1
- import { DomainEvent, DomainEvents, Either, EventHandler1 as EventHandler, Optional, UniqueEntityId, ValueObject, WatchedList, left, right } from "../shared/chunk-ghvxv2w6.js";
2
- export { right, left, WatchedList, ValueObject, UniqueEntityId, Optional, EventHandler, Either, DomainEvents, DomainEvent };
1
+ import { DomainEvent, DomainEvents, Either, EventHandler1 as EventHandler, Maybe, Optional, UniqueEntityId, ValueObject, WatchedList, just, left, maybe, nothing, right } from "../shared/chunk-w9w4akh1.js";
2
+ export { right, nothing, maybe, left, just, WatchedList, ValueObject, UniqueEntityId, Optional, Maybe, EventHandler, Either, DomainEvents, DomainEvent };
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{c as a,d as b,e as c,f as d,g as e,h as f}from"../shared/chunk-k4yvnajk.js";export{b as right,a as left,f as WatchedList,e as ValueObject,d as UniqueEntityId,c as DomainEvents};
2
+ import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i}from"../shared/chunk-q4ayz844.js";export{i as right,h as nothing,g as maybe,f as left,e as just,d as WatchedList,c as ValueObject,b as UniqueEntityId,a as DomainEvents};
@@ -1,2 +1,2 @@
1
- import { Creatable, Deletable, Findable, Repository, Saveable, UseCase, UseCaseError } from "../../shared/chunk-ghvxv2w6.js";
1
+ import { Creatable, Deletable, Findable, Repository, Saveable, UseCase, UseCaseError } from "../../shared/chunk-w9w4akh1.js";
2
2
  export { UseCaseError, UseCase, Saveable, Repository, Findable, Deletable, Creatable };
@@ -1,2 +1,2 @@
1
- import { AggregateRoot, DomainEvent, DomainEvents, Entity, EventHandler } from "../../shared/chunk-ghvxv2w6.js";
1
+ import { AggregateRoot, DomainEvent, DomainEvents, Entity, EventHandler } from "../../shared/chunk-w9w4akh1.js";
2
2
  export { EventHandler, Entity, DomainEvents, DomainEvent, AggregateRoot };
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{a as b,b as c}from"../../shared/chunk-ph10w7xb.js";import{e as a}from"../../shared/chunk-k4yvnajk.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
2
+ import{a as b,b as c}from"../../shared/chunk-whqnrgyf.js";import{c as a}from"../../shared/chunk-q4ayz844.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
@@ -1,2 +1,2 @@
1
- import { AggregateRoot, Creatable, Deletable, DomainEvent, DomainEvents, Entity, EventHandler, Findable, Repository, Saveable, UseCase, UseCaseError } from "../shared/chunk-ghvxv2w6.js";
1
+ import { AggregateRoot, Creatable, Deletable, DomainEvent, DomainEvents, Entity, EventHandler, Findable, Repository, Saveable, UseCase, UseCaseError } from "../shared/chunk-w9w4akh1.js";
2
2
  export { UseCaseError, UseCase, Saveable, Repository, Findable, EventHandler, Entity, DomainEvents, DomainEvent, Deletable, Creatable, AggregateRoot };
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../shared/chunk-x296z7h1.js";import"../shared/chunk-wsjyhnpq.js";import{a as b,b as c}from"../shared/chunk-ph10w7xb.js";import{e as a}from"../shared/chunk-k4yvnajk.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
2
+ import"../shared/chunk-x296z7h1.js";import"../shared/chunk-wsjyhnpq.js";import{a as b,b as c}from"../shared/chunk-whqnrgyf.js";import{c as a}from"../shared/chunk-q4ayz844.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { AggregateRoot, Creatable, Deletable, DomainEvent, DomainEvents, Either, Entity, Findable, Optional, Repository, Saveable, UniqueEntityId, UseCase, UseCaseError, ValueObject, WatchedList, left, right } from "./shared/chunk-ghvxv2w6.js";
2
- export { right, left, WatchedList, ValueObject, UseCaseError, UseCase, UniqueEntityId, Saveable, Repository, Optional, Findable, Entity, Either, DomainEvents, DomainEvent, Deletable, Creatable, AggregateRoot };
1
+ import { AggregateRoot, Creatable, Deletable, DomainEvent, DomainEvents, Either, Entity, Findable, Maybe, Optional, Repository, Saveable, UniqueEntityId, UseCase, UseCaseError, ValueObject, WatchedList, just, left, maybe, nothing, right } from "./shared/chunk-w9w4akh1.js";
2
+ export { right, nothing, maybe, left, just, WatchedList, ValueObject, UseCaseError, UseCase, UniqueEntityId, Saveable, Repository, Optional, Maybe, Findable, Entity, Either, DomainEvents, DomainEvent, Deletable, Creatable, AggregateRoot };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"./shared/chunk-x296z7h1.js";import"./shared/chunk-wsjyhnpq.js";import{a as b,b as c}from"./shared/chunk-ph10w7xb.js";import{c as f,d as m,e as p,f as t,g as x,h as a}from"./shared/chunk-k4yvnajk.js";export{m as right,f as left,a as WatchedList,x as ValueObject,t as UniqueEntityId,b as Entity,p as DomainEvents,c as AggregateRoot};
2
+ import"./shared/chunk-x296z7h1.js";import"./shared/chunk-wsjyhnpq.js";import{a as g,b as h}from"./shared/chunk-whqnrgyf.js";import{c as f,d as m,e as p,f as t,g as x,h as a,i as b,j as c,k as d}from"./shared/chunk-q4ayz844.js";export{d as right,c as nothing,b as maybe,a as left,x as just,t as WatchedList,p as ValueObject,m as UniqueEntityId,g as Entity,f as DomainEvents,h as AggregateRoot};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{just as Q,left as X,maybe as Y,nothing as Z,right as _}from"failcraft";class O{handlersMap=new Map;markedAggregates=new Set;shouldRun=!0;markAggregateForDispatch(x){if(!this.findMarkedAggregateByID(x.id))this.markedAggregates.add(x)}dispatchEventsForAggregate(x){let E=this.findMarkedAggregateByID(x);if(E)this.dispatchAggregateEvents(E),E.clearEvents(),this.removeAggregateFromMarkedDispatchList(E)}register(x,E){if(!this.handlersMap.has(E))this.handlersMap.set(E,[]);this.handlersMap.get(E)?.push(x)}clearHandlers(){this.handlersMap.clear()}clearMarkedAggregates(){this.markedAggregates.clear()}dispatchAggregateEvents(x){for(let E of x.domainEvents)this.dispatch(E)}removeAggregateFromMarkedDispatchList(x){this.markedAggregates.delete(x)}findMarkedAggregateByID(x){return[...this.markedAggregates].find((E)=>E.id.equals(x))}dispatch(x){if(!this.shouldRun)return;let E=this.handlersMap.get(x.constructor.name)??[];for(let f of E)f(x)}}var M=new O;var{randomUUIDv7:V}=globalThis.Bun;class y{value;constructor(x){this.value=x??V()}toValue(){return this.value}toString(){return this.value}equals(x){return x.toValue()===this.value}}class H{props;constructor(x){this.props=x}equals(x){return JSON.stringify(this.props)===JSON.stringify(x.props)}}class L{currentItems;initial;new;removed;constructor(x){this.currentItems=x??[],this.initial=x??[],this.new=[],this.removed=[]}getItems(){return this.currentItems}getNewItems(){return this.new}getRemovedItems(){return this.removed}exists(x){return this.isCurrentItem(x)}add(x){if(this.isRemovedItem(x))this.removeFromRemoved(x);if(!(this.isNewItem(x)||this.wasAddedInitially(x)))this.new.push(x);if(!this.isCurrentItem(x))this.currentItems.push(x)}remove(x){if(this.removeFromCurrent(x),this.isNewItem(x)){this.removeFromNew(x);return}if(!this.isRemovedItem(x))this.removed.push(x)}update(x){this.new=x.filter((E)=>!this.getItems().some((f)=>this.compareItems(E,f))),this.removed=this.getItems().filter((E)=>!x.some((f)=>this.compareItems(E,f))),this.currentItems=x}isCurrentItem(x){return this.currentItems.some((E)=>this.compareItems(x,E))}isNewItem(x){return this.new.some((E)=>this.compareItems(x,E))}isRemovedItem(x){return this.removed.some((E)=>this.compareItems(x,E))}removeFromNew(x){this.new=this.new.filter((E)=>!this.compareItems(E,x))}removeFromCurrent(x){this.currentItems=this.currentItems.filter((E)=>!this.compareItems(x,E))}removeFromRemoved(x){this.removed=this.removed.filter((E)=>!this.compareItems(x,E))}wasAddedInitially(x){return this.initial.some((E)=>this.compareItems(x,E))}}export{M as c,y as d,H as e,L as f,Q as g,X as h,Y as i,Z as j,_ as k};
@@ -76,109 +76,7 @@ interface Saveable<T> {
76
76
  * ```
77
77
  */
78
78
  interface Repository<T> extends Findable<T>, Saveable<T>, Creatable<T>, Deletable<T> {}
79
- /**
80
- * Base contract for all use case errors.
81
- *
82
- * Implement this interface to define semantic, domain-aware errors
83
- * that can be returned as the left side of an {@link Either}.
84
- *
85
- * @example
86
- * ```ts
87
- * class UserNotFoundError implements UseCaseError {
88
- * message = "User not found."
89
- * }
90
- *
91
- * type FindUserResult = Either<UserNotFoundError, User>
92
- * ```
93
- */
94
- interface UseCaseError {
95
- message: string;
96
- }
97
- /**
98
- * Represents the left side of an {@link Either} — conventionally used for
99
- * failure or error values.
100
- *
101
- * @template L - The type of the failure value
102
- * @template R - The type of the success value
103
- */
104
- declare class Left<
105
- L,
106
- R
107
- > {
108
- readonly value: L;
109
- constructor(value: L);
110
- isRight(): this is Right<L, R>;
111
- isLeft(): this is Left<L, R>;
112
- }
113
- /**
114
- * Represents the right side of an {@link Either} — conventionally used for
115
- * success values.
116
- *
117
- * @template L - The type of the failure value
118
- * @template R - The type of the success value
119
- */
120
- declare class Right<
121
- L,
122
- R
123
- > {
124
- readonly value: R;
125
- constructor(value: R);
126
- isRight(): this is Right<L, R>;
127
- isLeft(): this is Left<L, R>;
128
- }
129
- /**
130
- * A discriminated union that represents a value of one of two possible types.
131
- *
132
- * Commonly used as a type-safe alternative to throwing exceptions — the left
133
- * side carries an error, and the right side carries a success value.
134
- *
135
- * Use the {@link left} and {@link right} helper functions to construct values,
136
- * and `isLeft()` / `isRight()` to narrow the type.
137
- *
138
- * @template L - The type of the failure value
139
- * @template R - The type of the success value
140
- *
141
- * @example
142
- * ```ts
143
- * type FindUserResult = Either<NotFoundError, User>
144
- *
145
- * function findUser(id: string): FindUserResult {
146
- * const user = db.find(id)
147
- * if (!user) return left(new NotFoundError("User", id))
148
- * return right(user)
149
- * }
150
- *
151
- * const result = findUser("123")
152
- *
153
- * if (result.isLeft()) {
154
- * console.error(result.value) // NotFoundError
155
- * } else {
156
- * console.log(result.value) // User
157
- * }
158
- * ```
159
- */
160
- type Either<
161
- L,
162
- R
163
- > = Left<L, R> | Right<L, R>;
164
- /**
165
- * Constructs a {@link Left} value, representing a failure.
166
- *
167
- * @param value - The error or failure value
168
- */
169
- declare const left: <
170
- L,
171
- R
172
- >(value: L) => Either<L, R>;
173
- /**
174
- * Constructs a {@link Right} value, representing a success.
175
- *
176
- * @param value - The success value
177
- */
178
- declare const right: <
179
- L,
180
- R
181
- >(value: R) => Either<L, R>;
79
+ import { Either, just, left, Maybe, maybe, nothing, right } from "failcraft";
182
80
  /**
183
81
  * Base contract for all domain events.
184
82
  *
@@ -632,6 +530,24 @@ declare abstract class WatchedList<T> {
632
530
  private wasAddedInitially;
633
531
  }
634
532
  /**
533
+ * Base contract for all use case errors.
534
+ *
535
+ * Implement this interface to define semantic, domain-aware errors
536
+ * that can be returned as the left side of an {@link Either}.
537
+ *
538
+ * @example
539
+ * ```ts
540
+ * class UserNotFoundError implements UseCaseError {
541
+ * message = "User not found."
542
+ * }
543
+ *
544
+ * type FindUserResult = Either<UserNotFoundError, User>
545
+ * ```
546
+ */
547
+ interface UseCaseError {
548
+ message: string;
549
+ }
550
+ /**
635
551
  * Represents the expected output shape of any use case.
636
552
  * Always an {@link Either} — left for errors, right for success.
637
553
  */
@@ -671,4 +587,4 @@ interface UseCase<
671
587
  > {
672
588
  execute(input: Input): Promise<Output>;
673
589
  }
674
- export { Either, left, right, DomainEvent, Creatable, Deletable, Findable, Saveable, Repository, UseCaseError, UseCase, Entity, AggregateRoot, EventHandler, DomainEvents, EventHandler2 as EventHandler1, Optional, UniqueEntityId, ValueObject, WatchedList };
590
+ export { DomainEvent, Creatable, Deletable, Findable, Saveable, Repository, UseCaseError, UseCase, Entity, AggregateRoot, EventHandler, DomainEvents, EventHandler2 as EventHandler1, Optional, UniqueEntityId, ValueObject, WatchedList, Either, just, left, Maybe, maybe, nothing, right };
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{e as j,f as k}from"./chunk-k4yvnajk.js";class R{_id;props;get id(){return this._id}constructor(A,B){this._id=B??new k,this.props=A}equals(A){if(A===this)return!0;return A.id.equals(this._id)}}class z extends R{_domainEvents=new Set;get domainEvents(){return Array.from(this._domainEvents)}addDomainEvent(A){this._domainEvents.add(A),j.markAggregateForDispatch(this)}clearEvents(){this._domainEvents.clear()}}export{R as a,z as b};
2
+ import{c as j,d as k}from"./chunk-q4ayz844.js";class R{_id;props;get id(){return this._id}constructor(A,B){this._id=B??new k,this.props=A}equals(A){if(A===this)return!0;return A.id.equals(this._id)}}class z extends R{_domainEvents=new Set;get domainEvents(){return Array.from(this._domainEvents)}addDomainEvent(A){this._domainEvents.add(A),j.markAggregateForDispatch(this)}clearEvents(){this._domainEvents.clear()}}export{R as a,z as b};
package/package.json CHANGED
@@ -1,15 +1,25 @@
1
1
  {
2
2
  "name": "archstone",
3
- "description": "TypeScript architecture foundation for backend services based on Domain-Driven Design and Clean Architecture",
4
- "version": "1.3.1",
5
- "type": "module",
6
- "private": false,
7
- "files": [
8
- "dist",
9
- "skills"
10
- ],
3
+ "version": "1.4.0",
4
+ "author": {
5
+ "name": "João Henrique Benatti Coimbra",
6
+ "url": "https://github.com/joao-coimbra"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/joao-coimbra/archstone.git"
11
+ },
11
12
  "module": "./dist/index.js",
12
- "types": "./dist/index.d.ts",
13
+ "devDependencies": {
14
+ "@biomejs/biome": "2.4.5",
15
+ "@types/bun": "latest",
16
+ "bunup": "^0.16.31",
17
+ "husky": "^9.1.7",
18
+ "ultracite": "7.3.0"
19
+ },
20
+ "peerDependencies": {
21
+ "typescript": "^5"
22
+ },
13
23
  "exports": {
14
24
  ".": {
15
25
  "import": {
@@ -43,6 +53,15 @@
43
53
  },
44
54
  "./package.json": "./package.json"
45
55
  },
56
+ "bugs": {
57
+ "url": "https://github.com/joao-coimbra/archstone/issues"
58
+ },
59
+ "description": "TypeScript architecture foundation for backend services based on Domain-Driven Design and Clean Architecture",
60
+ "files": [
61
+ "dist",
62
+ "skills"
63
+ ],
64
+ "homepage": "https://github.com/joao-coimbra/archstone#readme",
46
65
  "keywords": [
47
66
  "ddd",
48
67
  "domain-driven-design",
@@ -57,19 +76,8 @@
57
76
  "use-case",
58
77
  "bun"
59
78
  ],
60
- "author": {
61
- "name": "João Henrique Benatti Coimbra",
62
- "url": "https://github.com/joao-coimbra"
63
- },
64
79
  "license": "MIT",
65
- "homepage": "https://github.com/joao-coimbra/archstone#readme",
66
- "repository": {
67
- "type": "git",
68
- "url": "git+https://github.com/joao-coimbra/archstone.git"
69
- },
70
- "bugs": {
71
- "url": "https://github.com/joao-coimbra/archstone/issues"
72
- },
80
+ "private": false,
73
81
  "scripts": {
74
82
  "build": "bunup",
75
83
  "dev": "bunup --watch",
@@ -80,14 +88,9 @@
80
88
  "prepublishOnly": "bun run build",
81
89
  "prepare": "bunx husky"
82
90
  },
83
- "devDependencies": {
84
- "@biomejs/biome": "2.4.5",
85
- "@types/bun": "latest",
86
- "bunup": "^0.16.31",
87
- "husky": "^9.1.7",
88
- "ultracite": "7.3.0"
89
- },
90
- "peerDependencies": {
91
- "typescript": "^5"
91
+ "type": "module",
92
+ "types": "./dist/index.d.ts",
93
+ "dependencies": {
94
+ "failcraft": "^1.3.1"
92
95
  }
93
96
  }
@@ -1,2 +0,0 @@
1
- // @bun
2
- class H{value;constructor(x){this.value=x}isRight(){return!1}isLeft(){return!0}}class V{value;constructor(x){this.value=x}isRight(){return!0}isLeft(){return!1}}var B=(x)=>new H(x),F=(x)=>new V(x);class W{handlersMap=new Map;markedAggregates=new Set;shouldRun=!0;markAggregateForDispatch(x){if(!this.findMarkedAggregateByID(x.id))this.markedAggregates.add(x)}dispatchEventsForAggregate(x){let E=this.findMarkedAggregateByID(x);if(E)this.dispatchAggregateEvents(E),E.clearEvents(),this.removeAggregateFromMarkedDispatchList(E)}register(x,E){if(!this.handlersMap.has(E))this.handlersMap.set(E,[]);this.handlersMap.get(E)?.push(x)}clearHandlers(){this.handlersMap.clear()}clearMarkedAggregates(){this.markedAggregates.clear()}dispatchAggregateEvents(x){for(let E of x.domainEvents)this.dispatch(E)}removeAggregateFromMarkedDispatchList(x){this.markedAggregates.delete(x)}findMarkedAggregateByID(x){return[...this.markedAggregates].find((E)=>E.id.equals(x))}dispatch(x){if(!this.shouldRun)return;let E=this.handlersMap.get(x.constructor.name)??[];for(let O of E)O(x)}}var G=new W;var{randomUUIDv7:J}=globalThis.Bun;class f{value;constructor(x){this.value=x??J()}toValue(){return this.value}toString(){return this.value}equals(x){return x.toValue()===this.value}}class z{props;constructor(x){this.props=x}equals(x){return JSON.stringify(this.props)===JSON.stringify(x.props)}}class A{currentItems;initial;new;removed;constructor(x){this.currentItems=x??[],this.initial=x??[],this.new=[],this.removed=[]}getItems(){return this.currentItems}getNewItems(){return this.new}getRemovedItems(){return this.removed}exists(x){return this.isCurrentItem(x)}add(x){if(this.isRemovedItem(x))this.removeFromRemoved(x);if(!(this.isNewItem(x)||this.wasAddedInitially(x)))this.new.push(x);if(!this.isCurrentItem(x))this.currentItems.push(x)}remove(x){if(this.removeFromCurrent(x),this.isNewItem(x)){this.removeFromNew(x);return}if(!this.isRemovedItem(x))this.removed.push(x)}update(x){this.new=x.filter((E)=>!this.getItems().some((O)=>this.compareItems(E,O))),this.removed=this.getItems().filter((E)=>!x.some((O)=>this.compareItems(E,O))),this.currentItems=x}isCurrentItem(x){return this.currentItems.some((E)=>this.compareItems(x,E))}isNewItem(x){return this.new.some((E)=>this.compareItems(x,E))}isRemovedItem(x){return this.removed.some((E)=>this.compareItems(x,E))}removeFromNew(x){this.new=this.new.filter((E)=>!this.compareItems(E,x))}removeFromCurrent(x){this.currentItems=this.currentItems.filter((E)=>!this.compareItems(x,E))}removeFromRemoved(x){this.removed=this.removed.filter((E)=>!this.compareItems(x,E))}wasAddedInitially(x){return this.initial.some((E)=>this.compareItems(x,E))}}export{B as c,F as d,G as e,f,z as g,A as h};