archstone 1.1.1 → 1.2.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.
package/README.md CHANGED
@@ -275,7 +275,7 @@ bun x skills add joao-coimbra/archstone
275
275
  **Or copy from the installed package:**
276
276
 
277
277
  ```bash
278
- cp -r node_modules/archstone/skills/archstone .claude/skills/
278
+ cp -r node_modules/archstone/skills/use-archstone .claude/skills/
279
279
  ```
280
280
 
281
281
  ---
@@ -1,17 +1,2 @@
1
1
  // @bun
2
- import {
3
- ValueObject,
4
- WatchedList,
5
- left,
6
- right
7
- } from "../shared/chunk-833sxwt1.js";
8
- import {
9
- UniqueEntityId
10
- } from "../shared/chunk-wzqmg7ms.js";
11
- export {
12
- right,
13
- left,
14
- WatchedList,
15
- ValueObject,
16
- UniqueEntityId
17
- };
2
+ import{a,b,c as d,d as e}from"../shared/chunk-kybhb7j0.js";import{h as c}from"../shared/chunk-27pwj1j1.js";export{b as right,a as left,e as WatchedList,d as ValueObject,c as UniqueEntityId};
@@ -1,12 +1,2 @@
1
1
  // @bun
2
- import {
3
- AggregateRoot,
4
- DomainEvents,
5
- Entity
6
- } from "../../shared/chunk-9cq8r162.js";
7
- import"../../shared/chunk-wzqmg7ms.js";
8
- export {
9
- Entity,
10
- DomainEvents,
11
- AggregateRoot
12
- };
2
+ import{e as a,f as b,g as c}from"../../shared/chunk-mmsp4fty.js";import"../../shared/chunk-27pwj1j1.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
@@ -1,14 +1,2 @@
1
1
  // @bun
2
- import"../shared/chunk-x296z7h1.js";
3
- import"../shared/chunk-wsjyhnpq.js";
4
- import {
5
- AggregateRoot,
6
- DomainEvents,
7
- Entity
8
- } from "../shared/chunk-9cq8r162.js";
9
- import"../shared/chunk-wzqmg7ms.js";
10
- export {
11
- Entity,
12
- DomainEvents,
13
- AggregateRoot
14
- };
2
+ import"../shared/chunk-x296z7h1.js";import"../shared/chunk-wsjyhnpq.js";import{e as a,f as b,g as c}from"../shared/chunk-mmsp4fty.js";import"../shared/chunk-27pwj1j1.js";export{b as Entity,a as DomainEvents,c as AggregateRoot};
package/dist/index.js CHANGED
@@ -1,27 +1,2 @@
1
1
  // @bun
2
- import {
3
- ValueObject,
4
- WatchedList,
5
- left,
6
- right
7
- } from "./shared/chunk-833sxwt1.js";
8
- import"./shared/chunk-x296z7h1.js";
9
- import"./shared/chunk-wsjyhnpq.js";
10
- import {
11
- AggregateRoot,
12
- DomainEvents,
13
- Entity
14
- } from "./shared/chunk-9cq8r162.js";
15
- import {
16
- UniqueEntityId
17
- } from "./shared/chunk-wzqmg7ms.js";
18
- export {
19
- right,
20
- left,
21
- WatchedList,
22
- ValueObject,
23
- UniqueEntityId,
24
- Entity,
25
- DomainEvents,
26
- AggregateRoot
27
- };
2
+ import{a as f,b as m,c as t,d as x}from"./shared/chunk-kybhb7j0.js";import"./shared/chunk-x296z7h1.js";import"./shared/chunk-wsjyhnpq.js";import{e as a,f as b,g as c}from"./shared/chunk-mmsp4fty.js";import{h as p}from"./shared/chunk-27pwj1j1.js";export{m as right,f as left,x as WatchedList,t as ValueObject,p as UniqueEntityId,b as Entity,a as DomainEvents,c as AggregateRoot};
@@ -0,0 +1,3 @@
1
+ // @bun
2
+ var{randomUUIDv7:k}=globalThis.Bun;class x{value;constructor(j){this.value=j??k()}toValue(){return this.value}toString(){return this.value}equals(j){return j.toValue()===this.value}}
3
+ export{x as h};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ class f{value;constructor(x){this.value=x}isRight(){return!1}isLeft(){return!0}}class U{value;constructor(x){this.value=x}isRight(){return!0}isLeft(){return!1}}var z=(x)=>new f(x),A=(x)=>new U(x);class V{props;constructor(x){this.props=x}equals(x){return JSON.stringify(this.props)===JSON.stringify(x.props)}}class W{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{z as a,A as b,V as c,W as d};
@@ -0,0 +1,2 @@
1
+ // @bun
2
+ import{h as j}from"./chunk-27pwj1j1.js";class R{handlersMap=new Map;markedAggregates=new Set;markAggregateForDispatch(x){if(!this.findMarkedAggregateByID(x.id))this.markedAggregates.add(x)}dispatchEventsForAggregate(x){let f=this.findMarkedAggregateByID(x);if(f)this.dispatchAggregateEvents(f),f.clearEvents(),this.removeAggregateFromMarkedDispatchList(f)}register(x,f){if(!this.handlersMap.has(f))this.handlersMap.set(f,[]);this.handlersMap.get(f)?.push(x)}clearHandlers(){this.handlersMap.clear()}clearMarkedAggregates(){this.markedAggregates.clear()}dispatchAggregateEvents(x){for(let f of x.domainEvents)this.dispatch(f)}removeAggregateFromMarkedDispatchList(x){this.markedAggregates.delete(x)}findMarkedAggregateByID(x){return[...this.markedAggregates].find((f)=>f.id.equals(x))}dispatch(x){let f=this.handlersMap.get(x.constructor.name)??[];for(let B of f)B(x)}}var H=new R;class A{_id;props;get id(){return this._id}constructor(x,f){this._id=f??new j,this.props=x}equals(x){if(x===this)return!0;return x.id.equals(this._id)}}class z extends A{_domainEvents=new Set;get domainEvents(){return Array.from(this._domainEvents)}addDomainEvent(x){this._domainEvents.add(x),H.markAggregateForDispatch(this)}clearEvents(){this._domainEvents.clear()}}export{H as e,A as f,z as g};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "archstone",
3
3
  "description": "TypeScript architecture foundation for backend services based on Domain-Driven Design and Clean Architecture",
4
- "version": "1.1.1",
4
+ "version": "1.2.0",
5
5
  "type": "module",
6
6
  "private": false,
7
7
  "files": [
@@ -1,112 +0,0 @@
1
- // @bun
2
- // src/core/either.ts
3
- class Left {
4
- value;
5
- constructor(value) {
6
- this.value = value;
7
- }
8
- isRight() {
9
- return false;
10
- }
11
- isLeft() {
12
- return true;
13
- }
14
- }
15
-
16
- class Right {
17
- value;
18
- constructor(value) {
19
- this.value = value;
20
- }
21
- isRight() {
22
- return true;
23
- }
24
- isLeft() {
25
- return false;
26
- }
27
- }
28
- var left = (value) => new Left(value);
29
- var right = (value) => new Right(value);
30
- // src/core/value-object.ts
31
- class ValueObject {
32
- props;
33
- constructor(props) {
34
- this.props = props;
35
- }
36
- equals(other) {
37
- return JSON.stringify(this.props) === JSON.stringify(other.props);
38
- }
39
- }
40
- // src/core/watched-list.ts
41
- class WatchedList {
42
- currentItems;
43
- initial;
44
- new;
45
- removed;
46
- constructor(initialItems) {
47
- this.currentItems = initialItems ?? [];
48
- this.initial = initialItems ?? [];
49
- this.new = [];
50
- this.removed = [];
51
- }
52
- getItems() {
53
- return this.currentItems;
54
- }
55
- getNewItems() {
56
- return this.new;
57
- }
58
- getRemovedItems() {
59
- return this.removed;
60
- }
61
- exists(item) {
62
- return this.isCurrentItem(item);
63
- }
64
- add(item) {
65
- if (this.isRemovedItem(item)) {
66
- this.removeFromRemoved(item);
67
- }
68
- if (!(this.isNewItem(item) || this.wasAddedInitially(item))) {
69
- this.new.push(item);
70
- }
71
- if (!this.isCurrentItem(item)) {
72
- this.currentItems.push(item);
73
- }
74
- }
75
- remove(item) {
76
- this.removeFromCurrent(item);
77
- if (this.isNewItem(item)) {
78
- this.removeFromNew(item);
79
- return;
80
- }
81
- if (!this.isRemovedItem(item)) {
82
- this.removed.push(item);
83
- }
84
- }
85
- update(items) {
86
- this.new = items.filter((a) => !this.getItems().some((b) => this.compareItems(a, b)));
87
- this.removed = this.getItems().filter((a) => !items.some((b) => this.compareItems(a, b)));
88
- this.currentItems = items;
89
- }
90
- isCurrentItem(item) {
91
- return this.currentItems.some((v) => this.compareItems(item, v));
92
- }
93
- isNewItem(item) {
94
- return this.new.some((v) => this.compareItems(item, v));
95
- }
96
- isRemovedItem(item) {
97
- return this.removed.some((v) => this.compareItems(item, v));
98
- }
99
- removeFromNew(item) {
100
- this.new = this.new.filter((v) => !this.compareItems(v, item));
101
- }
102
- removeFromCurrent(item) {
103
- this.currentItems = this.currentItems.filter((v) => !this.compareItems(item, v));
104
- }
105
- removeFromRemoved(item) {
106
- this.removed = this.removed.filter((v) => !this.compareItems(item, v));
107
- }
108
- wasAddedInitially(item) {
109
- return this.initial.some((v) => this.compareItems(item, v));
110
- }
111
- }
112
- export { left, right, ValueObject, WatchedList };
@@ -1,88 +0,0 @@
1
- // @bun
2
- import {
3
- UniqueEntityId
4
- } from "./chunk-wzqmg7ms.js";
5
-
6
- // src/domain/enterprise/events/domain-events.ts
7
- class DomainEventsImplementation {
8
- handlersMap = new Map;
9
- markedAggregates = new Set;
10
- markAggregateForDispatch(aggregate) {
11
- if (!this.findMarkedAggregateByID(aggregate.id)) {
12
- this.markedAggregates.add(aggregate);
13
- }
14
- }
15
- dispatchEventsForAggregate(id) {
16
- const aggregate = this.findMarkedAggregateByID(id);
17
- if (aggregate) {
18
- this.dispatchAggregateEvents(aggregate);
19
- aggregate.clearEvents();
20
- this.removeAggregateFromMarkedDispatchList(aggregate);
21
- }
22
- }
23
- register(callback, eventClassName) {
24
- if (!this.handlersMap.has(eventClassName)) {
25
- this.handlersMap.set(eventClassName, []);
26
- }
27
- this.handlersMap.get(eventClassName)?.push(callback);
28
- }
29
- clearHandlers() {
30
- this.handlersMap.clear();
31
- }
32
- clearMarkedAggregates() {
33
- this.markedAggregates.clear();
34
- }
35
- dispatchAggregateEvents(aggregate) {
36
- for (const event of aggregate.domainEvents) {
37
- this.dispatch(event);
38
- }
39
- }
40
- removeAggregateFromMarkedDispatchList(aggregate) {
41
- this.markedAggregates.delete(aggregate);
42
- }
43
- findMarkedAggregateByID(id) {
44
- return [...this.markedAggregates].find((a) => a.id.equals(id));
45
- }
46
- dispatch(event) {
47
- const handlers = this.handlersMap.get(event.constructor.name) ?? [];
48
- for (const handler of handlers) {
49
- handler(event);
50
- }
51
- }
52
- }
53
- var DomainEvents = new DomainEventsImplementation;
54
-
55
- // src/domain/enterprise/entities/entity.ts
56
- class Entity {
57
- _id;
58
- props;
59
- get id() {
60
- return this._id;
61
- }
62
- constructor(props, id) {
63
- this._id = id ?? new UniqueEntityId;
64
- this.props = props;
65
- }
66
- equals(entity) {
67
- if (entity === this) {
68
- return true;
69
- }
70
- return entity.id.equals(this._id);
71
- }
72
- }
73
-
74
- // src/domain/enterprise/entities/aggregate-root.ts
75
- class AggregateRoot extends Entity {
76
- _domainEvents = new Set;
77
- get domainEvents() {
78
- return Array.from(this._domainEvents);
79
- }
80
- addDomainEvent(domainEvent) {
81
- this._domainEvents.add(domainEvent);
82
- DomainEvents.markAggregateForDispatch(this);
83
- }
84
- clearEvents() {
85
- this._domainEvents.clear();
86
- }
87
- }
88
- export { DomainEvents, Entity, AggregateRoot };
@@ -1,21 +0,0 @@
1
- // @bun
2
- // src/core/unique-entity-id.ts
3
- var {randomUUIDv7 } = globalThis.Bun;
4
-
5
- class UniqueEntityId {
6
- value;
7
- constructor(value) {
8
- this.value = value ?? randomUUIDv7();
9
- }
10
- toValue() {
11
- return this.value;
12
- }
13
- toString() {
14
- return this.value;
15
- }
16
- equals(id) {
17
- return id.toValue() === this.value;
18
- }
19
- }
20
-
21
- export { UniqueEntityId };
File without changes