@things-factory/dataset 9.1.18 → 9.1.19
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/EXPLORATION_INDEX.md +252 -0
- package/FRONTEND_ARCHITECTURE.md +732 -0
- package/QUICK_REFERENCE.md +365 -0
- package/dist-client/pages/data-set/data-item-list.js +15 -1
- package/dist-client/pages/data-set/data-item-list.js.map +1 -1
- package/dist-client/pages/data-set/data-set-list-page.js +0 -1
- package/dist-client/pages/data-set/data-set-list-page.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/controllers/create-data-sample.js +57 -5
- package/dist-server/controllers/create-data-sample.js.map +1 -1
- package/dist-server/service/data-set/data-item-type.d.ts +259 -0
- package/dist-server/service/data-set/data-item-type.js +259 -0
- package/dist-server/service/data-set/data-item-type.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/dist-server/utils/index.d.ts +1 -0
- package/dist-server/utils/index.js +1 -0
- package/dist-server/utils/index.js.map +1 -1
- package/dist-server/utils/media-validation.d.ts +51 -0
- package/dist-server/utils/media-validation.js +148 -0
- package/dist-server/utils/media-validation.js.map +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# Frontend Architecture Exploration - Document Index
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
This package contains comprehensive documentation of the Things-Factory dataset client-side frontend architecture, specifically focused on understanding how data entry forms are structured and how to implement media input components (image, video, audio).
|
|
5
|
+
|
|
6
|
+
## Generated Documents
|
|
7
|
+
|
|
8
|
+
### 1. FRONTEND_ARCHITECTURE.md (COMPREHENSIVE)
|
|
9
|
+
- **Purpose**: Complete technical reference
|
|
10
|
+
- **Contents**:
|
|
11
|
+
- Input component architecture and patterns
|
|
12
|
+
- Data entry form system deep dive
|
|
13
|
+
- DataItemType enumeration and structures
|
|
14
|
+
- Component hierarchy and integration
|
|
15
|
+
- File upload handling (client + server)
|
|
16
|
+
- Media validation utilities
|
|
17
|
+
- Component registration and bootstrap
|
|
18
|
+
- Subgroup form system (Grist tables)
|
|
19
|
+
- File/media options schema with examples
|
|
20
|
+
- Implementation guide for new media components
|
|
21
|
+
- Complete usage flow with diagrams
|
|
22
|
+
- Directory structure summary
|
|
23
|
+
- **Best for**: Understanding the complete architecture, implementing new components, architecture decisions
|
|
24
|
+
|
|
25
|
+
### 2. QUICK_REFERENCE.md (CONCISE)
|
|
26
|
+
- **Purpose**: Quick lookup and checklists
|
|
27
|
+
- **Contents**:
|
|
28
|
+
- File location quick lookup
|
|
29
|
+
- 5-step data entry flow
|
|
30
|
+
- Type mapping reference
|
|
31
|
+
- Key functions and classes
|
|
32
|
+
- Component creation checklist
|
|
33
|
+
- Value extraction mechanisms
|
|
34
|
+
- DataItem configuration examples
|
|
35
|
+
- GraphQL context explanation
|
|
36
|
+
- Common gotchas and pitfalls
|
|
37
|
+
- Testing checklist
|
|
38
|
+
- **Best for**: Quick lookups during implementation, finding specific functions, remembering patterns
|
|
39
|
+
|
|
40
|
+
### 3. EXPLORATION_SUMMARY.txt (THIS FILE)
|
|
41
|
+
- **Purpose**: High-level findings and absolute paths
|
|
42
|
+
- **Contents**:
|
|
43
|
+
- Key findings summary
|
|
44
|
+
- Critical file paths with absolute paths
|
|
45
|
+
- Component architecture flow
|
|
46
|
+
- Type-to-component mapping
|
|
47
|
+
- Key methods to understand
|
|
48
|
+
- DataItemType enum definition
|
|
49
|
+
- Media validation function reference
|
|
50
|
+
- File upload flow end-to-end
|
|
51
|
+
- Implementation requirements
|
|
52
|
+
- **Best for**: Getting oriented, understanding what needs to be implemented, seeing the big picture
|
|
53
|
+
|
|
54
|
+
## File Locations Reference
|
|
55
|
+
|
|
56
|
+
### In This Package
|
|
57
|
+
```
|
|
58
|
+
/Users/super/Documents/GitHub/things-factory/packages/dataset/
|
|
59
|
+
├── FRONTEND_ARCHITECTURE.md (Comprehensive reference)
|
|
60
|
+
├── QUICK_REFERENCE.md (Quick lookup guide)
|
|
61
|
+
├── EXPLORATION_INDEX.md (This file)
|
|
62
|
+
├── client/
|
|
63
|
+
│ ├── components/
|
|
64
|
+
│ │ ├── data-entry-form.ts
|
|
65
|
+
│ │ └── checklist-entry-form.ts
|
|
66
|
+
│ ├── activities/
|
|
67
|
+
│ │ └── activity-data-collect-edit.ts
|
|
68
|
+
│ └── bootstrap.ts
|
|
69
|
+
└── server/
|
|
70
|
+
├── service/data-set/
|
|
71
|
+
│ └── data-item-type.ts
|
|
72
|
+
├── utils/
|
|
73
|
+
│ └── media-validation.ts
|
|
74
|
+
└── controllers/
|
|
75
|
+
└── create-data-sample.ts
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Node Modules (Dependencies)
|
|
79
|
+
```
|
|
80
|
+
node_modules/@operato/dataset/dist/src/
|
|
81
|
+
├── ox-data-entry-form.js
|
|
82
|
+
├── ox-data-entry-subgroup-form.js
|
|
83
|
+
└── ox-data-input-factory.js
|
|
84
|
+
|
|
85
|
+
node_modules/@operato/input/dist/src/
|
|
86
|
+
├── ox-form-field.d.ts|.js
|
|
87
|
+
├── ox-input-file.d.ts|.js
|
|
88
|
+
├── ox-input-image.d.ts|.js
|
|
89
|
+
└── ox-input-signature.d.ts|.js
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## How to Use These Documents
|
|
93
|
+
|
|
94
|
+
### For Understanding the Architecture
|
|
95
|
+
1. Start with: **EXPLORATION_SUMMARY.txt** - High-level overview
|
|
96
|
+
2. Then read: **FRONTEND_ARCHITECTURE.md** - Deep technical details
|
|
97
|
+
3. Reference: **QUICK_REFERENCE.md** - For specific lookups
|
|
98
|
+
|
|
99
|
+
### For Implementation
|
|
100
|
+
1. Check: **QUICK_REFERENCE.md** - "Adding New Media Components - Checklist"
|
|
101
|
+
2. Reference: **FRONTEND_ARCHITECTURE.md** - "Implementation Guide: Adding Media Components"
|
|
102
|
+
3. Look at: **QUICK_REFERENCE.md** - DataItem configuration examples
|
|
103
|
+
|
|
104
|
+
### For Debugging
|
|
105
|
+
1. Consult: **QUICK_REFERENCE.md** - "Common Gotchas" section
|
|
106
|
+
2. Trace: **FRONTEND_ARCHITECTURE.md** - "Current Usage Flow" section
|
|
107
|
+
3. Check: **QUICK_REFERENCE.md** - "Testing Checklist"
|
|
108
|
+
|
|
109
|
+
## Key Findings Summary
|
|
110
|
+
|
|
111
|
+
### Current State
|
|
112
|
+
- Input components for file and signature types exist
|
|
113
|
+
- Media types (image, video, audio) are defined in enum but not rendered
|
|
114
|
+
- OxDataInputFactory uses switch statement to map types to components
|
|
115
|
+
- Factory is missing 'image', 'video', and 'audio' cases
|
|
116
|
+
- Server-side validation and file handling fully implemented
|
|
117
|
+
|
|
118
|
+
### What's Missing
|
|
119
|
+
- OxInputImage component
|
|
120
|
+
- OxInputVideo component
|
|
121
|
+
- OxInputAudio component
|
|
122
|
+
- Factory mappings for these three types
|
|
123
|
+
- Component imports in appropriate locations
|
|
124
|
+
|
|
125
|
+
### Implementation Effort
|
|
126
|
+
- Create three components: 2-3 hours
|
|
127
|
+
- Update factory: 30 minutes
|
|
128
|
+
- Add imports: 15 minutes
|
|
129
|
+
- End-to-end testing: 1-2 hours
|
|
130
|
+
- **Total**: ~4-6 hours for complete implementation
|
|
131
|
+
|
|
132
|
+
## Architecture Patterns
|
|
133
|
+
|
|
134
|
+
### Component Creation Pattern
|
|
135
|
+
All input components:
|
|
136
|
+
1. Extend OxFormField (from @operato/input)
|
|
137
|
+
2. Use @customElement decorator for registration
|
|
138
|
+
3. Implement required methods: render, updated, firstUpdated, _onChangeValue, _notifyChange
|
|
139
|
+
4. Set `name` attribute on native input for form extraction
|
|
140
|
+
5. Handle FormDataEvent for form submission integration
|
|
141
|
+
|
|
142
|
+
### Data Flow Pattern
|
|
143
|
+
1. Activity receives dataSetId
|
|
144
|
+
2. DataSet fetched with dataItems
|
|
145
|
+
3. OxDataEntryForm renders per dataItems
|
|
146
|
+
4. OxDataInputFactory.createInputElement() maps type to component
|
|
147
|
+
5. Form collects values via name attribute
|
|
148
|
+
6. GraphQL mutation with hasUpload context
|
|
149
|
+
7. Server validates and creates attachments
|
|
150
|
+
8. File paths stored in DataSample.data
|
|
151
|
+
|
|
152
|
+
### Factory Pattern
|
|
153
|
+
OxDataInputFactory uses static methods:
|
|
154
|
+
1. createInputElement(type, tag, value, options, idx) - Routes to correct component
|
|
155
|
+
2. mapGristType(type) - Maps to Grist column types
|
|
156
|
+
3. getGristRecordOptions(type, options) - Grid cell configuration
|
|
157
|
+
|
|
158
|
+
## Critical Code Snippets
|
|
159
|
+
|
|
160
|
+
### How Form Extracts Values
|
|
161
|
+
```typescript
|
|
162
|
+
// Location: ox-data-entry-form.js line ~89
|
|
163
|
+
const editors = Array.from(
|
|
164
|
+
this.renderRoot.querySelectorAll(`[name=${tag}]`)
|
|
165
|
+
)
|
|
166
|
+
// Looks for elements with name="product_image", etc.
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### How Types are Mapped
|
|
170
|
+
```javascript
|
|
171
|
+
// Location: ox-data-input-factory.js
|
|
172
|
+
static createInputElement(type, tag, value, options = {}, idx = 0) {
|
|
173
|
+
switch (type) {
|
|
174
|
+
case 'image':
|
|
175
|
+
// TO BE ADDED
|
|
176
|
+
case 'video':
|
|
177
|
+
// TO BE ADDED
|
|
178
|
+
case 'audio':
|
|
179
|
+
// TO BE ADDED
|
|
180
|
+
// ... existing cases ...
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Server File Upload Handling
|
|
186
|
+
```typescript
|
|
187
|
+
// Location: create-data-sample.ts line ~122
|
|
188
|
+
if (isFileOrMediaType(dataItem.type)) {
|
|
189
|
+
const filesArray = data[tag]
|
|
190
|
+
// Process and validate files
|
|
191
|
+
// Create attachments
|
|
192
|
+
// Replace data[tag] with path info
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Next Steps
|
|
197
|
+
|
|
198
|
+
### For Implementation
|
|
199
|
+
1. Read **QUICK_REFERENCE.md** - "Adding New Media Components - Checklist"
|
|
200
|
+
2. Create three component files based on OxInputFile pattern
|
|
201
|
+
3. Update OxDataInputFactory in @operato/dataset (or create wrapper)
|
|
202
|
+
4. Add component imports to wrapper components
|
|
203
|
+
5. Test end-to-end with example DataSet
|
|
204
|
+
|
|
205
|
+
### For Maintenance
|
|
206
|
+
1. Keep documentation in sync with code changes
|
|
207
|
+
2. Update type mappings when new types added
|
|
208
|
+
3. Document new media options in data-item-type.ts
|
|
209
|
+
4. Maintain backward compatibility with existing components
|
|
210
|
+
|
|
211
|
+
### For Learning
|
|
212
|
+
1. Study OxInputFile implementation for pattern
|
|
213
|
+
2. Review ox-data-entry-form.js rendering logic
|
|
214
|
+
3. Trace complete user flow in activity component
|
|
215
|
+
4. Understand FormDataEvent integration
|
|
216
|
+
5. Review GraphQL multipart/form-data setup
|
|
217
|
+
|
|
218
|
+
## Questions and Clarifications
|
|
219
|
+
|
|
220
|
+
### Q: Why does OxInputImage exist but isn't used?
|
|
221
|
+
A: OxInputImage exists in @operato/input but the factory doesn't route to it. Need to add the mapping in OxDataInputFactory.
|
|
222
|
+
|
|
223
|
+
### Q: How are values extracted from complex components?
|
|
224
|
+
A: Via the `name` attribute in DOM queries. All OxInput* components must set name on their native input.
|
|
225
|
+
|
|
226
|
+
### Q: Why `hasUpload: true` in GraphQL context?
|
|
227
|
+
A: Tells Apollo Client to use multipart/form-data encoding instead of JSON for file streaming.
|
|
228
|
+
|
|
229
|
+
### Q: Where do file paths get stored?
|
|
230
|
+
A: In DataSample.data[tag] as array of { id, mimetype, name, fullpath } objects, not the actual files.
|
|
231
|
+
|
|
232
|
+
### Q: How are media validations handled?
|
|
233
|
+
A: Server-side in create-data-sample.ts using validateMediaFile() utility before attachment creation.
|
|
234
|
+
|
|
235
|
+
## Document Versions
|
|
236
|
+
|
|
237
|
+
- **Created**: 2024-11-09
|
|
238
|
+
- **Exploration Scope**: Very Thorough
|
|
239
|
+
- **Focus Area**: Things-Factory Dataset Client Frontend Architecture
|
|
240
|
+
- **Specific Goal**: Understanding media component implementation requirements
|
|
241
|
+
|
|
242
|
+
## Additional Resources
|
|
243
|
+
|
|
244
|
+
- @operato/input package documentation
|
|
245
|
+
- @operato/dataset package documentation
|
|
246
|
+
- Lit web components documentation
|
|
247
|
+
- GraphQL upload specifications
|
|
248
|
+
- Material Design components (md-icon usage)
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
**Navigation**: Start with the executive summary, then dive into detailed docs as needed. Use QUICK_REFERENCE.md during active development.
|