@goodgamestudios/cxf-webshop 7.0.0-qa.6 → 7.0.0-qa.8
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/dist/webshop-cxf.js +1 -1
- package/dist/webshop-cxf.js.map +2 -2
- package/package.json +3 -2
- package/.prettierignore +0 -6
- package/.prettierrc.js +0 -10
- package/REFACTORING_README.md +0 -265
- package/TEST_MIGRATION.md +0 -441
- package/TYPES_REFACTORING.md +0 -308
- package/esbuild.build.js +0 -13
- package/esbuild.serve.js +0 -25
package/TYPES_REFACTORING.md
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
# Types Refactoring Summary
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
All exported types and interfaces in the `/src` folder have been reviewed and reorganized for better maintainability and clarity.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## What Was Done
|
|
10
|
-
|
|
11
|
-
### 1. Created `types.ts` - Central Type Repository
|
|
12
|
-
A new file consolidating all cross-cutting types and interfaces:
|
|
13
|
-
|
|
14
|
-
**Moved into `types.ts`:**
|
|
15
|
-
- ✅ **Handler Types** (from `handlers/postMessageHandlers.ts`, `handlers/pushHandlers.ts`, `handlers/reducers.ts`)
|
|
16
|
-
- `Handler` - Generic handler function type
|
|
17
|
-
- `Handlers` - Dictionary of handlers
|
|
18
|
-
- `PushHandler` - Push notification handler type
|
|
19
|
-
- `PushHandlers` - Dictionary of push handlers
|
|
20
|
-
- `CxfReducers` - CXF event reducers map
|
|
21
|
-
|
|
22
|
-
- ✅ **Event Payload Types** (from various handler files)
|
|
23
|
-
- `OpenIGSPayload` - From `handlers/eventHandlers.ts`
|
|
24
|
-
- `OnRewardProperties` - From `handlers/pushHandlers.ts`
|
|
25
|
-
- `OnLemonstandCategoryUpdateProperties` - From `handlers/pushHandlers.ts`
|
|
26
|
-
- `OnLemonstandNotificationsCreatedProperties` - From `handlers/pushHandlers.ts`
|
|
27
|
-
|
|
28
|
-
- ✅ **Tracking Types** (from `track.ts`)
|
|
29
|
-
- `ITrackPayload` - Base tracking payload interface
|
|
30
|
-
- `IRanchWebShopCallProperties` - Specific tracking properties
|
|
31
|
-
|
|
32
|
-
- ✅ **URL Types** (from `url.ts`)
|
|
33
|
-
- `ICreateCatalogUrlProperties` - URL generation properties
|
|
34
|
-
|
|
35
|
-
- ✅ **Events Enum** (from `common.ts`)
|
|
36
|
-
- `WebshopEvents` - Webshop event names enum
|
|
37
|
-
|
|
38
|
-
### 2. Updated `common.ts`
|
|
39
|
-
Kept only generic, reusable utility types:
|
|
40
|
-
- ❌ Removed: `WebshopEvents` enum (moved to `types.ts`)
|
|
41
|
-
- ✅ Kept: `IDictionary`, `AnyVoidFn`, `Fn`, `PromiseFn`, `IPushMessageData`, `IPushMessage`
|
|
42
|
-
|
|
43
|
-
### 3. Domain-Specific Types Remain in Place
|
|
44
|
-
These types stayed in their original files as they're domain-specific:
|
|
45
|
-
|
|
46
|
-
| File | Types Kept | Rationale |
|
|
47
|
-
|------|-----------|-----------|
|
|
48
|
-
| `cxf.ts` | `IGameApi`, `ICXF` | CXF integration domain |
|
|
49
|
-
| `config.ts` | `GameSpecificConfig`, `Config` | Configuration domain |
|
|
50
|
-
| `store.ts` | `IStore` | State management domain |
|
|
51
|
-
| `storage.ts` | `IStorageData` | Local storage domain |
|
|
52
|
-
| `ping.ts` | `PingProperties` | Ping utility domain |
|
|
53
|
-
| `globalState.ts` | `IProvider<T>` | Internal to global state |
|
|
54
|
-
| `messages/IShopMessageBus.ts` | `IShopMessageBus` | Message bus interface |
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Files Modified
|
|
59
|
-
|
|
60
|
-
### Created (1)
|
|
61
|
-
- ✨ `src/types.ts` - 129 lines of consolidated type definitions
|
|
62
|
-
|
|
63
|
-
### Updated (10)
|
|
64
|
-
1. `src/common.ts` - Removed WebshopEvents enum
|
|
65
|
-
2. `src/config.ts` - Import WebshopEvents from types.ts
|
|
66
|
-
3. `src/handlers/eventHandlers.ts` - Import OpenIGSPayload from types.ts
|
|
67
|
-
4. `src/handlers/postMessageHandlers.ts` - Import Handlers, WebshopEvents from types.ts
|
|
68
|
-
5. `src/handlers/pushHandlers.ts` - Import all payload types from types.ts
|
|
69
|
-
6. `src/handlers/reducers.ts` - Import CxfReducers, WebshopEvents from types.ts
|
|
70
|
-
7. `src/track.ts` - Import tracking types from types.ts
|
|
71
|
-
8. `src/url.ts` - Import ICreateCatalogUrlProperties from types.ts
|
|
72
|
-
9. `src/README.md` - Added types organization section
|
|
73
|
-
10. `src/FILE_LIST.md` - Updated file count and structure
|
|
74
|
-
|
|
75
|
-
### Documentation (1)
|
|
76
|
-
- 📖 `src/TYPES_ORGANIZATION.md` - Comprehensive guide (267 lines)
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Before & After
|
|
81
|
-
|
|
82
|
-
### Before: Types Scattered Across Files
|
|
83
|
-
|
|
84
|
-
```typescript
|
|
85
|
-
// handlers/eventHandlers.ts
|
|
86
|
-
export interface OpenIGSPayload { ... }
|
|
87
|
-
|
|
88
|
-
// handlers/postMessageHandlers.ts
|
|
89
|
-
export type Handler = (...args: any[]) => void
|
|
90
|
-
export type Handlers = IDictionary<Handler>
|
|
91
|
-
|
|
92
|
-
// handlers/pushHandlers.ts
|
|
93
|
-
export type PushHandler = (...args: any[]) => void
|
|
94
|
-
export type PushHandlers = IDictionary<PushHandler>
|
|
95
|
-
export interface OnRewardProperties { ... }
|
|
96
|
-
export interface OnLemonstandCategoryUpdateProperties { ... }
|
|
97
|
-
|
|
98
|
-
// track.ts
|
|
99
|
-
export interface IRanchWebShopCallProperties { ... }
|
|
100
|
-
export interface ITrackPayload { ... }
|
|
101
|
-
|
|
102
|
-
// url.ts
|
|
103
|
-
export interface ICreateCatalogUrlProperties { ... }
|
|
104
|
-
|
|
105
|
-
// common.ts
|
|
106
|
-
export enum WebshopEvents { ... }
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### After: Consolidated in `types.ts`
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
// types.ts - Single source of truth
|
|
113
|
-
export type Handler = (...args: any[]) => void
|
|
114
|
-
export type Handlers = IDictionary<Handler>
|
|
115
|
-
export type PushHandler = (...args: any[]) => void
|
|
116
|
-
export type PushHandlers = IDictionary<PushHandler>
|
|
117
|
-
export type CxfReducers = IDictionary<() => void>
|
|
118
|
-
|
|
119
|
-
export interface OpenIGSPayload { ... }
|
|
120
|
-
export interface OnRewardProperties { ... }
|
|
121
|
-
export interface OnLemonstandCategoryUpdateProperties { ... }
|
|
122
|
-
export interface OnLemonstandNotificationsCreatedProperties { ... }
|
|
123
|
-
|
|
124
|
-
export interface ITrackPayload { ... }
|
|
125
|
-
export interface IRanchWebShopCallProperties extends ITrackPayload { ... }
|
|
126
|
-
|
|
127
|
-
export interface ICreateCatalogUrlProperties { ... }
|
|
128
|
-
|
|
129
|
-
export enum WebshopEvents { ... }
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
## Import Pattern Changes
|
|
135
|
-
|
|
136
|
-
### Before
|
|
137
|
-
```typescript
|
|
138
|
-
// Multiple imports from different files
|
|
139
|
-
import { WebshopEvents } from '../common'
|
|
140
|
-
import { Handler, Handlers } from '../handlers/postMessageHandlers'
|
|
141
|
-
import { OpenIGSPayload } from '../handlers/eventHandlers'
|
|
142
|
-
import { PushHandler, PushHandlers } from '../handlers/pushHandlers'
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### After
|
|
146
|
-
```typescript
|
|
147
|
-
// Single import for all shared types
|
|
148
|
-
import {
|
|
149
|
-
Handler,
|
|
150
|
-
Handlers,
|
|
151
|
-
PushHandlers,
|
|
152
|
-
OpenIGSPayload,
|
|
153
|
-
WebshopEvents
|
|
154
|
-
} from '../types'
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## Benefits Achieved
|
|
160
|
-
|
|
161
|
-
### ✅ Organization
|
|
162
|
-
- Single source of truth for cross-cutting types
|
|
163
|
-
- Clear separation between generic utils and shared types
|
|
164
|
-
- Related types grouped together logically
|
|
165
|
-
|
|
166
|
-
### ✅ Maintainability
|
|
167
|
-
- Easier to find type definitions
|
|
168
|
-
- Reduced duplication risk
|
|
169
|
-
- Clear naming conventions with JSDoc comments
|
|
170
|
-
|
|
171
|
-
### ✅ Developer Experience
|
|
172
|
-
- Fewer import statements
|
|
173
|
-
- Clearer module dependencies
|
|
174
|
-
- Better IDE autocomplete and navigation
|
|
175
|
-
|
|
176
|
-
### ✅ Scalability
|
|
177
|
-
- Established pattern for future type additions
|
|
178
|
-
- Clear decision tree for type placement
|
|
179
|
-
- Documentation for onboarding
|
|
180
|
-
|
|
181
|
-
---
|
|
182
|
-
|
|
183
|
-
## Organization Principles
|
|
184
|
-
|
|
185
|
-
### Types go in `types.ts` when:
|
|
186
|
-
1. ✅ Used by multiple modules
|
|
187
|
-
2. ✅ Defines handler signatures
|
|
188
|
-
3. ✅ Represents event payloads/properties
|
|
189
|
-
4. ✅ Cross-cutting concerns (tracking, URLs, etc.)
|
|
190
|
-
5. ✅ Application-specific enums
|
|
191
|
-
|
|
192
|
-
### Types stay in domain files when:
|
|
193
|
-
1. ✅ Specific to a single domain (Config, Store, CXF)
|
|
194
|
-
2. ✅ Only used within one module
|
|
195
|
-
3. ✅ Represents core domain concepts
|
|
196
|
-
4. ✅ Implementation details
|
|
197
|
-
|
|
198
|
-
### Types stay in `common.ts` when:
|
|
199
|
-
1. ✅ Generic utility types
|
|
200
|
-
2. ✅ Could be used in any TypeScript project
|
|
201
|
-
3. ✅ No application-specific logic
|
|
202
|
-
|
|
203
|
-
---
|
|
204
|
-
|
|
205
|
-
## Statistics
|
|
206
|
-
|
|
207
|
-
| Metric | Count |
|
|
208
|
-
|--------|-------|
|
|
209
|
-
| Types consolidated into types.ts | 12+ |
|
|
210
|
-
| Files updated | 10 |
|
|
211
|
-
| New documentation files | 1 |
|
|
212
|
-
| Lines of documentation added | 267 |
|
|
213
|
-
| Import statements simplified | 8+ |
|
|
214
|
-
| Removed duplicate type exports | 12+ |
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## Type Distribution
|
|
219
|
-
|
|
220
|
-
```
|
|
221
|
-
Total Exported Types: ~45
|
|
222
|
-
|
|
223
|
-
types.ts (new): 12 types (26%) - Shared/cross-cutting
|
|
224
|
-
common.ts: 6 types (13%) - Generic utilities
|
|
225
|
-
Domain files: 27 types (61%) - Domain-specific
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
---
|
|
229
|
-
|
|
230
|
-
## Documentation
|
|
231
|
-
|
|
232
|
-
### New Documentation Created
|
|
233
|
-
- **TYPES_ORGANIZATION.md** - Comprehensive guide
|
|
234
|
-
- Where to find types
|
|
235
|
-
- When to add new types
|
|
236
|
-
- Decision tree for type placement
|
|
237
|
-
- Import patterns
|
|
238
|
-
- Best practices
|
|
239
|
-
|
|
240
|
-
### Updated Documentation
|
|
241
|
-
- **README.md** - Added types organization section
|
|
242
|
-
- **FILE_LIST.md** - Updated file inventory
|
|
243
|
-
- **INDEX.md** - Added types documentation link
|
|
244
|
-
|
|
245
|
-
---
|
|
246
|
-
|
|
247
|
-
## Migration Guide
|
|
248
|
-
|
|
249
|
-
### For Developers
|
|
250
|
-
|
|
251
|
-
**Finding a type:**
|
|
252
|
-
1. Check `types.ts` for handler/payload/event types
|
|
253
|
-
2. Check `common.ts` for generic utility types
|
|
254
|
-
3. Check domain files (`config.ts`, `store.ts`, etc.) for domain types
|
|
255
|
-
|
|
256
|
-
**Adding a new type:**
|
|
257
|
-
1. Is it used by multiple modules? → Consider `types.ts`
|
|
258
|
-
2. Is it a generic utility? → Consider `common.ts`
|
|
259
|
-
3. Is it domain-specific? → Keep in domain file
|
|
260
|
-
|
|
261
|
-
**See [TYPES_ORGANIZATION.md](./src/TYPES_ORGANIZATION.md) for detailed guidance**
|
|
262
|
-
|
|
263
|
-
---
|
|
264
|
-
|
|
265
|
-
## Validation
|
|
266
|
-
|
|
267
|
-
### All Imports Updated ✅
|
|
268
|
-
- Zero circular dependencies
|
|
269
|
-
- All type references resolved
|
|
270
|
-
- TypeScript compilation successful
|
|
271
|
-
- No runtime errors introduced
|
|
272
|
-
|
|
273
|
-
### Code Quality ✅
|
|
274
|
-
- JSDoc comments added to all types in types.ts
|
|
275
|
-
- Consistent naming conventions
|
|
276
|
-
- Logical grouping with section headers
|
|
277
|
-
- Clear type relationships (extends, implements)
|
|
278
|
-
|
|
279
|
-
---
|
|
280
|
-
|
|
281
|
-
## Future Considerations
|
|
282
|
-
|
|
283
|
-
As the codebase grows:
|
|
284
|
-
- Consider splitting `types.ts` by category (handlers/, payloads/, etc.)
|
|
285
|
-
- Create `types/` directory with categorized files
|
|
286
|
-
- Use TypeScript namespaces for grouping
|
|
287
|
-
- Consider a `contracts/` folder for cross-module interfaces
|
|
288
|
-
|
|
289
|
-
---
|
|
290
|
-
|
|
291
|
-
## Conclusion
|
|
292
|
-
|
|
293
|
-
The types refactoring successfully:
|
|
294
|
-
- ✅ Consolidated 12+ scattered type definitions into a single `types.ts` file
|
|
295
|
-
- ✅ Established clear organization principles
|
|
296
|
-
- ✅ Improved developer experience with simpler imports
|
|
297
|
-
- ✅ Created comprehensive documentation
|
|
298
|
-
- ✅ Maintained 100% backward compatibility
|
|
299
|
-
- ✅ Zero breaking changes to functionality
|
|
300
|
-
|
|
301
|
-
**Result**: Better organized, more maintainable type system with clear patterns for future growth.
|
|
302
|
-
|
|
303
|
-
---
|
|
304
|
-
|
|
305
|
-
**Completed**: 2024
|
|
306
|
-
**Status**: Production Ready ✅
|
|
307
|
-
**Breaking Changes**: None
|
|
308
|
-
**Documentation**: Complete
|
package/esbuild.build.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as esbuild from 'esbuild'
|
|
2
|
-
import * as env from './env.js'
|
|
3
|
-
|
|
4
|
-
const STAGE = process.env.STAGE || 'development'
|
|
5
|
-
|
|
6
|
-
await esbuild.build({
|
|
7
|
-
entryPoints: ['src/index.ts'],
|
|
8
|
-
bundle: true,
|
|
9
|
-
minify: true,
|
|
10
|
-
sourcemap: STAGE === 'live' ? false : true,
|
|
11
|
-
define: { process: JSON.stringify({ env: env[STAGE] }) },
|
|
12
|
-
outfile: 'dist/webshop-cxf.js',
|
|
13
|
-
})
|
package/esbuild.serve.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as esbuild from 'esbuild'
|
|
2
|
-
import * as env from './env.js'
|
|
3
|
-
|
|
4
|
-
const STAGE = process.env.STAGE || 'development'
|
|
5
|
-
const PORT = 1101
|
|
6
|
-
|
|
7
|
-
process.title = 'esbuild-serve' // required for shutdown process after tests are finished
|
|
8
|
-
|
|
9
|
-
let ctx = await esbuild.context({
|
|
10
|
-
entryPoints: ['bdd/src/index.ts'],
|
|
11
|
-
bundle: true,
|
|
12
|
-
minify: true,
|
|
13
|
-
sourcemap: true,
|
|
14
|
-
define: { process: JSON.stringify({ env: env[STAGE] }) },
|
|
15
|
-
outdir: 'bdd/src',
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
await ctx.watch()
|
|
19
|
-
|
|
20
|
-
let { port } = await ctx.serve({
|
|
21
|
-
port: PORT,
|
|
22
|
-
servedir: 'bdd/src',
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
console.log(`Project is running at http://localhost:${port}/`)
|