interaqt 0.3.1 → 0.4.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/agent/.claude/agents/code-generation-handler.md +3 -3
- package/agent/.claude/agents/computation-generation-handler.md +15 -4
- package/agent/.claude/agents/implement-design-handler.md +2 -72
- package/agent/.claude/agents/requirements-analysis-handler.md +156 -9
- package/agent/agentspace/knowledge/generator/api-reference.md +538 -101
- package/agent/agentspace/knowledge/generator/computation-analysis.md +22 -20
- package/agent/agentspace/knowledge/generator/computation-implementation.md +62 -38
- package/agent/agentspace/knowledge/generator/data-analysis.md +124 -22
- package/dist/index.js +2977 -2976
- package/dist/index.js.map +1 -1
- package/dist/runtime/ComputationSourceMap.d.ts +11 -21
- package/dist/runtime/ComputationSourceMap.d.ts.map +1 -1
- package/dist/runtime/Controller.d.ts +2 -2
- package/dist/runtime/MonoSystem.d.ts.map +1 -1
- package/dist/runtime/Scheduler.d.ts +6 -6
- package/dist/runtime/Scheduler.d.ts.map +1 -1
- package/dist/runtime/System.d.ts +5 -0
- package/dist/runtime/System.d.ts.map +1 -1
- package/dist/runtime/computations/Computation.d.ts +4 -9
- package/dist/runtime/computations/Computation.d.ts.map +1 -1
- package/dist/runtime/computations/StateMachine.d.ts +4 -7
- package/dist/runtime/computations/StateMachine.d.ts.map +1 -1
- package/dist/runtime/computations/Transform.d.ts +7 -1
- package/dist/runtime/computations/Transform.d.ts.map +1 -1
- package/dist/runtime/computations/TransitionFinder.d.ts +2 -2
- package/dist/runtime/computations/TransitionFinder.d.ts.map +1 -1
- package/dist/shared/StateTransfer.d.ts +15 -5
- package/dist/shared/StateTransfer.d.ts.map +1 -1
- package/dist/shared/Transform.d.ts +17 -3
- package/dist/shared/Transform.d.ts.map +1 -1
- package/package.json +1 -1
- package/agent/.claude/agents/requirements-analysis-handler-bak.md +0 -530
|
@@ -152,7 +152,7 @@ git commit -m "feat: Task 3.1.2 - Complete entity and relation implementation"
|
|
|
152
152
|
- Clear next step
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
- [ ] Generate all interactions based on `
|
|
155
|
+
- [ ] Generate all interactions based on `requirements/interaction-designs.json`. **DO NOT define any conditions yet** - we will add permissions and business rules later in Task 3.2. No `condition` parameter in Interaction.create()
|
|
156
156
|
- [ ] Start with simple payload-only interactions (no conditions initially)
|
|
157
157
|
- [ ] Ensure all payloads match the documented fields
|
|
158
158
|
- [ ] **Type Check**: Run `npm run check` to ensure TypeScript compilation passes
|
|
@@ -380,7 +380,7 @@ git commit -m "feat: Task 3.2.0 - Create permission test file"
|
|
|
380
380
|
**📋 Create the Permission and Business Rules Implementation Plan:**
|
|
381
381
|
|
|
382
382
|
- [ ] Create `docs/business-rules-and-permission-control-implementation-plan.json` based on:
|
|
383
|
-
- `
|
|
383
|
+
- `requirements/interactions-design.json`
|
|
384
384
|
- `requirements/interaction-matrix.md` (permission requirements)
|
|
385
385
|
- `requirements/test-cases.md` (business rule scenarios)
|
|
386
386
|
|
|
@@ -511,7 +511,7 @@ git commit -m "feat: Task 3.2.2 - Complete progressive permission and business r
|
|
|
511
511
|
}
|
|
512
512
|
```
|
|
513
513
|
|
|
514
|
-
- [ ] All permissions from `
|
|
514
|
+
- [ ] All permissions from `requirements/interactions-design.json` are implemented
|
|
515
515
|
- [ ] All business rules from requirements are implemented
|
|
516
516
|
- [ ] Each rule has comprehensive test coverage (success and failure cases)
|
|
517
517
|
- [ ] All type checks pass (`npm run check`)
|
|
@@ -10,7 +10,12 @@ color: blue
|
|
|
10
10
|
|
|
11
11
|
## START: Select Next Uncompleted Item
|
|
12
12
|
|
|
13
|
-
**📖 Reference
|
|
13
|
+
**📖 Reference**
|
|
14
|
+
- `./backend/crud.example.ts` + `./tests/crud.example.test.ts` - Simple CRUD operations with state machines, relations, and permissions
|
|
15
|
+
- `./backend/versionControl.example.ts` + `./tests/versionControl.example.test.ts` - Version control with soft delete pattern
|
|
16
|
+
- `./backend/versionControlHardDelete.example.ts` + `./tests/versionControlHardDelete.example.test.ts` - Version control with hard delete pattern
|
|
17
|
+
- `./agentspace/knowledge/generator/computation-implementation.md` - Detailed computation implementation patterns and examples
|
|
18
|
+
|
|
14
19
|
|
|
15
20
|
**🔴 CRITICAL: Implement ONLY ONE computation per session, then STOP and wait for user confirmation.**
|
|
16
21
|
|
|
@@ -54,6 +59,13 @@ color: blue
|
|
|
54
59
|
1. **Implement the Computation** (following API Reference)
|
|
55
60
|
- **📖 MANDATORY FIRST STEP: Completely read `./agentspace/knowledge/generator/api-reference.md` to understand all API usage before writing any code**
|
|
56
61
|
- **📖 MANDATORY SECOND STEP: Completely read `./backend/index.ts` to understand all existing implementations from previous tasks**
|
|
62
|
+
- **📖 MANDATORY THIRD STEP: Study the reference example files above to understand the standard code structure and computation patterns**
|
|
63
|
+
- **🔴 CRITICAL: Check for existing computations** - If the target entity/relation already has computation code:
|
|
64
|
+
- **NEVER overwrite** existing computation logic
|
|
65
|
+
- **ADD branch logic** to handle the new interaction/scenario within existing Transform callback
|
|
66
|
+
- **PRESERVE all existing branches** to ensure previous test cases continue to pass
|
|
67
|
+
- Example: Add `else if` conditions or extend existing conditions in Transform callback
|
|
68
|
+
- **⚠️ Regression Prevention**: All previous tests must continue passing after adding new computation branches
|
|
57
69
|
- **🔴 SPECIAL CASE 1: `_parent:[parent]` notation**
|
|
58
70
|
- If the computation name contains `_parent:[parent]` (e.g., `_parent:[User]`), this means:
|
|
59
71
|
- You should modify the PARENT entity's computation, not the current entity
|
|
@@ -80,9 +92,7 @@ color: blue
|
|
|
80
92
|
- **🔴 SPECIAL CASE 2: `_owner` notation**
|
|
81
93
|
- If the computation decision is `_owner`, this means:
|
|
82
94
|
- The property's value is fully controlled by its owner entity/relation's computation
|
|
83
|
-
- You should modify the OWNER entity/relation's creation or derivation logic, not add a separate property computation
|
|
84
|
-
- For `controlType: "creation-only"`: Add the property assignment logic in the entity/relation's creation Transform or StateMachine
|
|
85
|
-
- For `controlType: "derived-with-parent"`: The property is part of the parent's derivation computation
|
|
95
|
+
- You should modify the OWNER entity/relation's creation or derivation logic, not add a separate property computation. Add the property assignment logic in the entity/relation's creation Transform
|
|
86
96
|
- Example: For a `createdAt` property with `_owner`, add timestamp assignment in the entity's Transform that creates it
|
|
87
97
|
- Add computation code using assignment pattern at end of file:
|
|
88
98
|
```typescript
|
|
@@ -168,6 +178,7 @@ color: blue
|
|
|
168
178
|
4. **Write Test Implementation**
|
|
169
179
|
- Add test to `tests/basic.test.ts` in 'Basic Functionality' describe group
|
|
170
180
|
- Follow the test plan created above
|
|
181
|
+
- **📖 Reference the example test files above for testing patterns and structure**
|
|
171
182
|
- For StateMachine computations, test ALL StateTransfer transitions
|
|
172
183
|
- Test all CRUD operations the computation supports
|
|
173
184
|
|
|
@@ -51,7 +51,7 @@ You are a honest software expert with the following capabilities:
|
|
|
51
51
|
}
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
## Task 2.2:
|
|
54
|
+
## Task 2.2: Computation Analysis
|
|
55
55
|
|
|
56
56
|
**🔄 Update `docs/STATUS.json`:**
|
|
57
57
|
```json
|
|
@@ -60,75 +60,6 @@ You are a honest software expert with the following capabilities:
|
|
|
60
60
|
"completed": false
|
|
61
61
|
}
|
|
62
62
|
```
|
|
63
|
-
**📖 MUST READ: `./agentspace/knowledge/generator/basic-interaction-generation.md`**
|
|
64
|
-
|
|
65
|
-
⚠️ **DO NOT proceed without reading the above reference document completely!**
|
|
66
|
-
|
|
67
|
-
**Create `docs/interaction-design.md` documenting:**
|
|
68
|
-
|
|
69
|
-
- [ ] All interactions identified from use cases
|
|
70
|
-
- [ ] For each interaction:
|
|
71
|
-
- Name and purpose
|
|
72
|
-
- Required payload fields
|
|
73
|
-
- Which entities/relations it affects
|
|
74
|
-
- Expected outcomes
|
|
75
|
-
- Permission requirements (for Stage 2)
|
|
76
|
-
- Business rules (for Stage 2)
|
|
77
|
-
- [ ] **IMPORTANT**: Design interactions for core business logic first:
|
|
78
|
-
- Basic CRUD operations
|
|
79
|
-
- State transitions
|
|
80
|
-
- Relationship management
|
|
81
|
-
- [ ] **Document but don't implement yet**:
|
|
82
|
-
- Permission checks (role-based access control)
|
|
83
|
-
- Business rule validations (e.g., quantity limits, state checks, time restrictions)
|
|
84
|
-
- Complex data validations beyond basic field requirements
|
|
85
|
-
|
|
86
|
-
**Example structure:**
|
|
87
|
-
```markdown
|
|
88
|
-
# Interaction Design
|
|
89
|
-
|
|
90
|
-
## CreateDormitory
|
|
91
|
-
- **Purpose**: Create a new dormitory
|
|
92
|
-
- **Payload**:
|
|
93
|
-
- name: string (required)
|
|
94
|
-
- capacity: number (required, 4-6)
|
|
95
|
-
- **Effects**:
|
|
96
|
-
- Creates new Dormitory entity
|
|
97
|
-
- Initializes with empty beds
|
|
98
|
-
- **Stage 2 - Permissions**: Only admin can create
|
|
99
|
-
- **Stage 2 - Business Rules**: Capacity must be 4-6
|
|
100
|
-
|
|
101
|
-
## AssignUserToDormitory
|
|
102
|
-
- **Purpose**: Assign a student to a dormitory
|
|
103
|
-
- **Payload**:
|
|
104
|
-
- userId: string
|
|
105
|
-
- dormitoryId: string
|
|
106
|
-
- **Effects**:
|
|
107
|
-
- Creates UserDormitoryRelation
|
|
108
|
-
- Updates dormitory occupancy count
|
|
109
|
-
- **Stage 2 - Permissions**: Admin or dormHead of target dormitory
|
|
110
|
-
- **Stage 2 - Business Rules**:
|
|
111
|
-
- User must not already be assigned
|
|
112
|
-
- Dormitory must have available capacity
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**✅ END Task 2.2: Update `docs/STATUS.json`:**
|
|
116
|
-
```json
|
|
117
|
-
{
|
|
118
|
-
"currentTask": "Task 2.2",
|
|
119
|
-
"completed": true
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## Task 2.3: Computation Analysis
|
|
124
|
-
|
|
125
|
-
**🔄 Update `docs/STATUS.json`:**
|
|
126
|
-
```json
|
|
127
|
-
{
|
|
128
|
-
"currentTask": "Task 2.3",
|
|
129
|
-
"completed": false
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
63
|
**📖 PRIMARY GUIDE: `./agentspace/knowledge/generator/computation-analysis.md`**
|
|
133
64
|
**📖 REFERENCE ONLY: `./agentspace/knowledge/generator/computation-implementation.md`**
|
|
134
65
|
|
|
@@ -138,7 +69,7 @@ You are a honest software expert with the following capabilities:
|
|
|
138
69
|
1. **FIRST**: Read and understand `computation-analysis.md` completely
|
|
139
70
|
2. **USE PREVIOUS OUTPUTS**: Base your analysis on:
|
|
140
71
|
- `docs/data-design.json` (from Task 2.1)
|
|
141
|
-
- `
|
|
72
|
+
- `requirements/interactions-design.json`
|
|
142
73
|
3. **ANALYZE**: For EVERY entity and EVERY property, follow the step-by-step analysis process
|
|
143
74
|
4. **DOCUMENT**: Create `docs/computation-analysis.json` documenting your analysis for each entity/property
|
|
144
75
|
5. **REFERENCE**: Use `./agentspace/knowledge/generator/computation-implementation.md` as a reference for syntax and examples
|
|
@@ -161,7 +92,6 @@ You are a honest software expert with the following capabilities:
|
|
|
161
92
|
"completed": true,
|
|
162
93
|
"completedItems": [
|
|
163
94
|
"data-design.json created",
|
|
164
|
-
"interaction-design.md created",
|
|
165
95
|
"computation-analysis.json created"
|
|
166
96
|
]
|
|
167
97
|
}
|
|
@@ -178,7 +178,7 @@ We focus on data-centric requirements. Human software usage delegates unsuitable
|
|
|
178
178
|
|
|
179
179
|
**DO NOT create "automatic system" requirements.** Our framework is reactive - avoid designing autonomous system behaviors.
|
|
180
180
|
|
|
181
|
-
**Transform "
|
|
181
|
+
**Transform "non-data-reactive" requirements into:**
|
|
182
182
|
|
|
183
183
|
1. **Reactive Data Requirements**:
|
|
184
184
|
- ❌ WRONG: "System automatically counts total books"
|
|
@@ -192,6 +192,10 @@ We focus on data-centric requirements. Human software usage delegates unsuitable
|
|
|
192
192
|
- ❌ WRONG: "System automatically creates uniform record when employee is created"
|
|
193
193
|
- ✅ CORRECT: "When creating employee, automatically create uniform record" (as data constraint)
|
|
194
194
|
|
|
195
|
+
4. **Data Replacement Operations**:
|
|
196
|
+
- ❌ WRONG: "Replace old data with new data"
|
|
197
|
+
- ✅ CORRECT: "Create new data + Delete old data" (as two separate operations)
|
|
198
|
+
|
|
195
199
|
**For unavoidable side-effect requirements** (e.g., "automatically send notification"):
|
|
196
200
|
- Design the requirement but explicitly mark as **"Currently Not Supported"**
|
|
197
201
|
- Document: "This requirement involves automatic side-effects which are not supported by the current reactive framework"
|
|
@@ -201,6 +205,7 @@ We focus on data-centric requirements. Human software usage delegates unsuitable
|
|
|
201
205
|
- "Auto-send reminders" → "Reminder needed status is computed based on due date" + "Send reminder interaction"
|
|
202
206
|
- "Auto-validate ISBN" → "Can only create books with valid ISBN format" (constraint)
|
|
203
207
|
- "Auto-update inventory" → "Available count is computed based on total copies minus borrowed copies"
|
|
208
|
+
- "Replace employee profile" → "Create new employee profile" + "Delete old employee profile" (two interactions)
|
|
204
209
|
|
|
205
210
|
### Step 1: Create Read Requirements from Goals
|
|
206
211
|
|
|
@@ -288,6 +293,20 @@ Create `requirements/requirements-analysis.json`:
|
|
|
288
293
|
},
|
|
289
294
|
"business_constraints": ["[Business rule 1]"],
|
|
290
295
|
"data_constraints": ["[Data constraint 1]"]
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
"id": "R103",
|
|
299
|
+
"type": "delete",
|
|
300
|
+
"title": "[Requirement name]",
|
|
301
|
+
"parent": "R001",
|
|
302
|
+
"role": "[Role]",
|
|
303
|
+
"data": {
|
|
304
|
+
"type": "entity|relation",
|
|
305
|
+
"description": "[Data to delete]"
|
|
306
|
+
},
|
|
307
|
+
"deletion_type": "hard",
|
|
308
|
+
"deletion_rules": ["[Rule 1: e.g., Cannot delete if has active references]", "[Rule 2]"],
|
|
309
|
+
"business_constraints": ["[Business rule 1]"]
|
|
291
310
|
}
|
|
292
311
|
],
|
|
293
312
|
"from_R101": [
|
|
@@ -367,6 +386,11 @@ For each entity property:
|
|
|
367
386
|
- **Computation Method**: For aggregated or computed values
|
|
368
387
|
- **Data Dependencies**: For computed values, list dependencies
|
|
369
388
|
|
|
389
|
+
**Hard Deletion Property**:
|
|
390
|
+
- If delete requirements in Task 1.2 specify `"deletion_type": "hard"`
|
|
391
|
+
- Add **HardDeletionProperty** to the entity/relation
|
|
392
|
+
- Document deletion rules from requirements as property metadata
|
|
393
|
+
|
|
370
394
|
### Step 3: Relation Identification and Analysis
|
|
371
395
|
|
|
372
396
|
**Relations are the ONLY way to connect entities** - they replace traditional foreign key patterns.
|
|
@@ -459,9 +483,17 @@ Create `requirements/data-concepts.json`:
|
|
|
459
483
|
"description": "Total copies minus borrowed copies",
|
|
460
484
|
"dependencies": ["BookCopy", "BorrowRecord"]
|
|
461
485
|
}
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
"name": "_hardDeletion",
|
|
489
|
+
"type": "HardDeletionProperty",
|
|
490
|
+
"required": false,
|
|
491
|
+
"computed": false,
|
|
492
|
+
"deletion_rules": ["Cannot delete if has active borrow records", "Only administrators can delete"],
|
|
493
|
+
"source_requirement": "R103"
|
|
462
494
|
}
|
|
463
495
|
],
|
|
464
|
-
"referenced_in": ["R001", "R101", "R201"],
|
|
496
|
+
"referenced_in": ["R001", "R101", "R103", "R201"],
|
|
465
497
|
"note": "No authorId or publisherId - use BookAuthorRelation and BookPublisherRelation instead"
|
|
466
498
|
},
|
|
467
499
|
{
|
|
@@ -514,9 +546,17 @@ Create `requirements/data-concepts.json`:
|
|
|
514
546
|
"name": "dueDate",
|
|
515
547
|
"type": "date",
|
|
516
548
|
"required": true
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"name": "_hardDeletion",
|
|
552
|
+
"type": "HardDeletionProperty",
|
|
553
|
+
"required": false,
|
|
554
|
+
"computed": false,
|
|
555
|
+
"deletion_rules": ["Auto-delete when book is returned"],
|
|
556
|
+
"source_requirement": "R103"
|
|
517
557
|
}
|
|
518
558
|
],
|
|
519
|
-
"lifecycle": "Created on borrow, updated on return",
|
|
559
|
+
"lifecycle": "Created on borrow, updated on return, deleted on return or book deletion",
|
|
520
560
|
"referenced_in": ["R102", "R103"]
|
|
521
561
|
},
|
|
522
562
|
{
|
|
@@ -584,11 +624,57 @@ git commit -m "feat: Task 1.3 - Complete data concept extraction"
|
|
|
584
624
|
"role": "Actor role",
|
|
585
625
|
"action": "Action name",
|
|
586
626
|
"payload": "Input data (optional)",
|
|
587
|
-
"data":
|
|
627
|
+
"data": {
|
|
628
|
+
"creates": [
|
|
629
|
+
{
|
|
630
|
+
"target": "EntityOrRelationName",
|
|
631
|
+
"description": "Detailed description of how to create using what data",
|
|
632
|
+
"dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
|
|
633
|
+
}
|
|
634
|
+
],
|
|
635
|
+
"updates": [
|
|
636
|
+
{
|
|
637
|
+
"target": "EntityOrRelationName.propertyName",
|
|
638
|
+
"description": "Detailed description of how to update using what data",
|
|
639
|
+
"dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
|
|
640
|
+
}
|
|
641
|
+
],
|
|
642
|
+
"deletes": [
|
|
643
|
+
{
|
|
644
|
+
"target": "EntityOrRelationName",
|
|
645
|
+
"description": "Detailed description of how to delete and conditions",
|
|
646
|
+
"dependencies": ["Entity.property", "OtherEntity", "Relation.property"]
|
|
647
|
+
}
|
|
648
|
+
],
|
|
649
|
+
"reads": ["Entity.property", "OtherEntity", "View"] // Only for read-type interactions
|
|
650
|
+
},
|
|
588
651
|
"dataConstraints": "Inherited data constraints from fulfilled requirement"
|
|
589
652
|
}
|
|
590
653
|
```
|
|
591
654
|
|
|
655
|
+
### Data Field Specification Details
|
|
656
|
+
|
|
657
|
+
The `data` field describes all data operations performed by the interaction:
|
|
658
|
+
|
|
659
|
+
**For Write Operations (creates/updates/deletes):**
|
|
660
|
+
- Each operation must specify:
|
|
661
|
+
- `target`: The entity/relation name (for creates/deletes) or entity/relation.property (for updates)
|
|
662
|
+
- `description`: Detailed explanation of how the operation is performed, including what data is used
|
|
663
|
+
- `dependencies`: Array of other entities/relations/properties that must be read to perform this operation
|
|
664
|
+
- Dependencies should use dot notation for specific properties (e.g., `Book.availableCount`, `Reader.status`)
|
|
665
|
+
- Dependencies include all data that needs to be read or validated during the operation
|
|
666
|
+
|
|
667
|
+
**For Read Operations:**
|
|
668
|
+
- `reads`: Array of entities/relations/properties that the user wants to retrieve through this interaction
|
|
669
|
+
- Use dot notation for specific properties (e.g., `Book.title`, `Reader.name`)
|
|
670
|
+
- Include views and aggregated values as needed
|
|
671
|
+
- This represents the data the user expects to receive, not dependencies for internal operations
|
|
672
|
+
|
|
673
|
+
**Important Notes:**
|
|
674
|
+
- Write operations should NOT include a `reads` field - use `dependencies` within each operation instead
|
|
675
|
+
- Read operations should ONLY have a `reads` field - no creates/updates/deletes
|
|
676
|
+
- All referenced entities/relations must exist in the data concepts from Task 1.3
|
|
677
|
+
|
|
592
678
|
### Output: interactions-design.json
|
|
593
679
|
|
|
594
680
|
Create `requirements/interactions-design.json`:
|
|
@@ -627,9 +713,20 @@ Create `requirements/interactions-design.json`:
|
|
|
627
713
|
}
|
|
628
714
|
},
|
|
629
715
|
"data": {
|
|
630
|
-
"creates": [
|
|
631
|
-
|
|
632
|
-
|
|
716
|
+
"creates": [
|
|
717
|
+
{
|
|
718
|
+
"target": "BorrowRecord",
|
|
719
|
+
"description": "Create new borrow record using readerId, bookId, current timestamp as borrowDate, and calculated dueDate based on loan period from SystemConfig",
|
|
720
|
+
"dependencies": ["Reader", "Book", "SystemConfig.loanPeriod"]
|
|
721
|
+
}
|
|
722
|
+
],
|
|
723
|
+
"updates": [
|
|
724
|
+
{
|
|
725
|
+
"target": "Book.availableCount",
|
|
726
|
+
"description": "Decrease available count by 1 after validating current count is greater than 0",
|
|
727
|
+
"dependencies": ["Book.availableCount"]
|
|
728
|
+
}
|
|
729
|
+
]
|
|
633
730
|
},
|
|
634
731
|
"dataConstraints": [
|
|
635
732
|
"Automatically decrease Book.availableCount by 1",
|
|
@@ -670,14 +767,64 @@ Create `requirements/interactions-design.json`:
|
|
|
670
767
|
}
|
|
671
768
|
},
|
|
672
769
|
"data": {
|
|
673
|
-
"reads": ["Book", "Book.availableCount"]
|
|
674
|
-
"returns": "BookListView"
|
|
770
|
+
"reads": ["Book.title", "Book.author", "Book.availableCount", "Book.category"]
|
|
675
771
|
},
|
|
676
772
|
"dataConstraints": [
|
|
677
773
|
"Only show books with availableCount > 0",
|
|
678
774
|
"Exclude books marked as 'restricted' for regular readers"
|
|
679
775
|
]
|
|
680
776
|
}
|
|
777
|
+
},
|
|
778
|
+
{
|
|
779
|
+
"id": "ReturnBook",
|
|
780
|
+
"fulfills_requirements": ["R102"],
|
|
781
|
+
"type": "update",
|
|
782
|
+
"specification": {
|
|
783
|
+
"role": "Librarian",
|
|
784
|
+
"action": "return",
|
|
785
|
+
"conditions": [
|
|
786
|
+
"BorrowRecord exists for the given readerId and bookId",
|
|
787
|
+
"BorrowRecord.returnDate is null"
|
|
788
|
+
],
|
|
789
|
+
"payload": {
|
|
790
|
+
"readerId": {
|
|
791
|
+
"type": "string",
|
|
792
|
+
"description": "ID of the reader returning the book",
|
|
793
|
+
"required": true
|
|
794
|
+
},
|
|
795
|
+
"bookId": {
|
|
796
|
+
"type": "string",
|
|
797
|
+
"description": "ID of the book being returned",
|
|
798
|
+
"required": true
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
"data": {
|
|
802
|
+
"updates": [
|
|
803
|
+
{
|
|
804
|
+
"target": "BorrowRecord.returnDate",
|
|
805
|
+
"description": "Set return date to current timestamp for the specific borrow record matching readerId and bookId",
|
|
806
|
+
"dependencies": ["BorrowRecord.readerId", "BorrowRecord.bookId", "BorrowRecord.returnDate"]
|
|
807
|
+
},
|
|
808
|
+
{
|
|
809
|
+
"target": "Book.availableCount",
|
|
810
|
+
"description": "Increase available count by 1 after confirming the book return",
|
|
811
|
+
"dependencies": ["Book.availableCount", "BorrowRecord"]
|
|
812
|
+
}
|
|
813
|
+
],
|
|
814
|
+
"deletes": [
|
|
815
|
+
{
|
|
816
|
+
"target": "BorrowRecord",
|
|
817
|
+
"description": "Delete the borrow record after successful return if hard deletion is enabled",
|
|
818
|
+
"dependencies": ["BorrowRecord.returnDate", "SystemConfig.enableHardDeletion"]
|
|
819
|
+
}
|
|
820
|
+
]
|
|
821
|
+
},
|
|
822
|
+
"dataConstraints": [
|
|
823
|
+
"Only update return date if it's currently null",
|
|
824
|
+
"Increase Book.availableCount only after confirming valid return",
|
|
825
|
+
"Delete BorrowRecord only if system configuration allows hard deletion"
|
|
826
|
+
]
|
|
827
|
+
}
|
|
681
828
|
}
|
|
682
829
|
],
|
|
683
830
|
"interaction_matrix": {
|