@jammysunshine/astrology-shared 1.0.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/examples/index.js +455 -0
- package/examples/serviceExamples.js +359 -0
- package/index.js +75 -0
- package/interfaces/IDataAccessService.js +70 -0
- package/interfaces/IUserContextService.js +58 -0
- package/logger/index.js +417 -0
- package/logger/test_fix.js +56 -0
- package/package.json +43 -0
- package/schemas/README.md +97 -0
- package/schemas/index.js +940 -0
- package/validation/BaseValidator.js +308 -0
- package/validation/index.js +88 -0
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example inputs for different astrology service types
|
|
3
|
+
* Demonstrating scalability for 100+ services with different requirements
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { generateRequestId } = require('../schemas');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* NUMEROLOGY SERVICE EXAMPLE
|
|
10
|
+
* Requires: personalData (name, birth date)
|
|
11
|
+
*/
|
|
12
|
+
const NUMEROLOGY_INPUT_EXAMPLE = {
|
|
13
|
+
requestId: generateRequestId(),
|
|
14
|
+
timestamp: new Date().toISOString(),
|
|
15
|
+
|
|
16
|
+
client: {
|
|
17
|
+
type: 'web',
|
|
18
|
+
version: '1.0.0',
|
|
19
|
+
sessionId: 'web_numerology_123',
|
|
20
|
+
deviceId: 'chrome_desktop_91.0.4472.124'
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// Service-specific data for numerology
|
|
24
|
+
personalData: {
|
|
25
|
+
fullName: 'John Smith',
|
|
26
|
+
birthDate: '15/01/1990',
|
|
27
|
+
preferredNumberSystem: 'pythagorean'
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
parameters: {
|
|
31
|
+
includeLifePath: true,
|
|
32
|
+
includeExpression: true,
|
|
33
|
+
includeSoulUrge: true,
|
|
34
|
+
includePersonality: true,
|
|
35
|
+
language: 'en'
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* PALMISTRY SERVICE EXAMPLE
|
|
41
|
+
* Requires: palmData (hand type, fingerprints, mounts)
|
|
42
|
+
*/
|
|
43
|
+
const PALMISTRY_INPUT_EXAMPLE = {
|
|
44
|
+
requestId: generateRequestId(),
|
|
45
|
+
timestamp: new Date().toISOString(),
|
|
46
|
+
|
|
47
|
+
client: {
|
|
48
|
+
type: 'ios',
|
|
49
|
+
version: '2.1.0',
|
|
50
|
+
sessionId: 'ios_palmistry_456',
|
|
51
|
+
deviceId: 'iPhone14,2'
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
// Service-specific data for palmistry
|
|
55
|
+
palmData: {
|
|
56
|
+
handType: 'earth',
|
|
57
|
+
fingerprints: [
|
|
58
|
+
{
|
|
59
|
+
finger: 'thumb',
|
|
60
|
+
type: 'whorl',
|
|
61
|
+
hand: 'right'
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
finger: 'index',
|
|
65
|
+
type: 'loop',
|
|
66
|
+
hand: 'right'
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
mounts: {
|
|
70
|
+
venus: 'high',
|
|
71
|
+
mars: 'medium',
|
|
72
|
+
jupiter: 'high',
|
|
73
|
+
saturn: 'flat',
|
|
74
|
+
mercury: 'medium',
|
|
75
|
+
moon: 'high'
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
parameters: {
|
|
80
|
+
includeDetailedAnalysis: true,
|
|
81
|
+
includeHealthIndicators: true,
|
|
82
|
+
language: 'en'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* CHINESE ASTROLOGY SERVICE EXAMPLE
|
|
88
|
+
* Requires: birthData with Chinese calendar options
|
|
89
|
+
*/
|
|
90
|
+
const CHINESE_ASTROLOGY_INPUT_EXAMPLE = {
|
|
91
|
+
requestId: generateRequestId(),
|
|
92
|
+
timestamp: new Date().toISOString(),
|
|
93
|
+
|
|
94
|
+
client: {
|
|
95
|
+
type: 'android',
|
|
96
|
+
version: '1.5.0',
|
|
97
|
+
sessionId: 'android_chinese_789',
|
|
98
|
+
deviceId: 'SM-G998B'
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
// Enhanced birth data for Chinese astrology
|
|
102
|
+
birthData: {
|
|
103
|
+
date: '15/01/1990',
|
|
104
|
+
time: '14:30',
|
|
105
|
+
place: 'Beijing, China',
|
|
106
|
+
chineseCalendar: true,
|
|
107
|
+
includeBaZi: true,
|
|
108
|
+
includeFengShui: true
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
parameters: {
|
|
112
|
+
calendarType: 'lunar',
|
|
113
|
+
includeAnimalSign: true,
|
|
114
|
+
includeElement: true,
|
|
115
|
+
includeYinYang: true,
|
|
116
|
+
language: 'zh'
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* KABBALISTIC ASTROLOGY SERVICE EXAMPLE
|
|
122
|
+
* Requires: kabbalisticData (Hebrew name, birth data)
|
|
123
|
+
*/
|
|
124
|
+
const KABBALISTIC_INPUT_EXAMPLE = {
|
|
125
|
+
requestId: generateRequestId(),
|
|
126
|
+
timestamp: new Date().toISOString(),
|
|
127
|
+
|
|
128
|
+
client: {
|
|
129
|
+
type: 'web',
|
|
130
|
+
version: '1.0.0',
|
|
131
|
+
sessionId: 'web_kabbalah_101',
|
|
132
|
+
deviceId: 'firefox_desktop_89.0'
|
|
133
|
+
},
|
|
134
|
+
|
|
135
|
+
// Service-specific data for Kabbalistic astrology
|
|
136
|
+
kabbalisticData: {
|
|
137
|
+
hebrewName: 'יוחנן', // Hebrew characters only
|
|
138
|
+
birthData: {
|
|
139
|
+
date: '15/01/1990',
|
|
140
|
+
time: '14:30',
|
|
141
|
+
place: 'Jerusalem, Israel'
|
|
142
|
+
},
|
|
143
|
+
includeGematria: true,
|
|
144
|
+
includeTreeOfLife: true,
|
|
145
|
+
includeSephiroth: true
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
parameters: {
|
|
149
|
+
gematriaMethod: 'standard',
|
|
150
|
+
includePaths: true,
|
|
151
|
+
includeArchetypes: true,
|
|
152
|
+
language: 'he'
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* TAROT SERVICE EXAMPLE
|
|
158
|
+
* Requires: tarotQuery (question, spread type)
|
|
159
|
+
*/
|
|
160
|
+
const TAROT_INPUT_EXAMPLE = {
|
|
161
|
+
requestId: generateRequestId(),
|
|
162
|
+
timestamp: new Date().toISOString(),
|
|
163
|
+
|
|
164
|
+
client: {
|
|
165
|
+
type: 'pwa',
|
|
166
|
+
version: '1.2.0',
|
|
167
|
+
sessionId: 'pwa_tarot_202',
|
|
168
|
+
deviceId: 'chrome_mobile_91.0.4472.124'
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
// Service-specific data for tarot
|
|
172
|
+
tarotQuery: {
|
|
173
|
+
question: 'What should I focus on in my career this year?',
|
|
174
|
+
spreadType: 'celtic_cross',
|
|
175
|
+
includeAstrologicalCorrelation: true
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
parameters: {
|
|
179
|
+
deckType: 'rider_waite',
|
|
180
|
+
includeReversed: true,
|
|
181
|
+
includeInterpretation: true,
|
|
182
|
+
language: 'en'
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* I-CHING SERVICE EXAMPLE
|
|
188
|
+
* Requires: ichingQuery (question, casting method)
|
|
189
|
+
*/
|
|
190
|
+
const ICHING_INPUT_EXAMPLE = {
|
|
191
|
+
requestId: generateRequestId(),
|
|
192
|
+
timestamp: new Date().toISOString(),
|
|
193
|
+
|
|
194
|
+
client: {
|
|
195
|
+
type: 'api',
|
|
196
|
+
version: '1.0.0',
|
|
197
|
+
sessionId: 'api_iching_303',
|
|
198
|
+
deviceId: 'server_node_v16'
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
// Service-specific data for I-Ching
|
|
202
|
+
ichingQuery: {
|
|
203
|
+
question: 'Should I start my own business?',
|
|
204
|
+
castingMethod: 'coins',
|
|
205
|
+
includeAstrologicalCorrelation: false
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
parameters: {
|
|
209
|
+
includeChangingLines: true,
|
|
210
|
+
includeRelatingHexagram: true,
|
|
211
|
+
includeJudgment: true,
|
|
212
|
+
includeImage: true,
|
|
213
|
+
language: 'en'
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* RUNE CASTING SERVICE EXAMPLE
|
|
219
|
+
* Requires: runeQuery (question, spread type)
|
|
220
|
+
*/
|
|
221
|
+
const RUNE_CASTING_INPUT_EXAMPLE = {
|
|
222
|
+
requestId: generateRequestId(),
|
|
223
|
+
timestamp: new Date().toISOString(),
|
|
224
|
+
|
|
225
|
+
client: {
|
|
226
|
+
type: 'whatsapp',
|
|
227
|
+
version: '2.21.22.16',
|
|
228
|
+
sessionId: 'wa_runes_404',
|
|
229
|
+
deviceId: 'iPhone12,2'
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
// Service-specific data for rune casting
|
|
233
|
+
runeQuery: {
|
|
234
|
+
question: 'What is my spiritual path?',
|
|
235
|
+
spreadType: 'celtic_cross',
|
|
236
|
+
includeAstrologicalCorrelation: true
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
parameters: {
|
|
240
|
+
runeSet: 'elder_futhark',
|
|
241
|
+
includeReversed: true,
|
|
242
|
+
includeInterpretation: true,
|
|
243
|
+
language: 'en'
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* FUTURE SERVICE TEMPLATE
|
|
249
|
+
* Template for adding new service types
|
|
250
|
+
*/
|
|
251
|
+
const FUTURE_SERVICE_TEMPLATE = {
|
|
252
|
+
requestId: generateRequestId(),
|
|
253
|
+
timestamp: new Date().toISOString(),
|
|
254
|
+
|
|
255
|
+
client: {
|
|
256
|
+
type: 'api',
|
|
257
|
+
version: '1.0.0'
|
|
258
|
+
},
|
|
259
|
+
|
|
260
|
+
// Replace with service-specific data structure
|
|
261
|
+
// serviceSpecificData: { ... },
|
|
262
|
+
|
|
263
|
+
parameters: {
|
|
264
|
+
// Service-specific parameters
|
|
265
|
+
language: 'en'
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* SERVICE REGISTRATION EXAMPLES
|
|
271
|
+
* How to register new services in the system
|
|
272
|
+
*/
|
|
273
|
+
|
|
274
|
+
// Example: Registering a new Ayurveda service
|
|
275
|
+
const AYURVEDA_SERVICE_REGISTRATION = {
|
|
276
|
+
serviceName: 'AyurvedaService',
|
|
277
|
+
category: 'ayurveda',
|
|
278
|
+
customSchema: {
|
|
279
|
+
required: ['ayurvedaData'],
|
|
280
|
+
properties: {
|
|
281
|
+
ayurvedaData: {
|
|
282
|
+
type: 'object',
|
|
283
|
+
required: ['doshaProfile', 'birthData'],
|
|
284
|
+
properties: {
|
|
285
|
+
doshaProfile: {
|
|
286
|
+
type: 'object',
|
|
287
|
+
properties: {
|
|
288
|
+
vata: { type: 'number', minimum: 0, maximum: 100 },
|
|
289
|
+
pitta: { type: 'number', minimum: 0, maximum: 100 },
|
|
290
|
+
kapha: { type: 'number', minimum: 0, maximum: 100 }
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
birthData: {} // Reference to standard birth data
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
// Example: Registering a new Crystal Healing service
|
|
301
|
+
const CRYSTAL_HEALING_REGISTRATION = {
|
|
302
|
+
serviceName: 'CrystalHealingService',
|
|
303
|
+
category: 'crystal_healing',
|
|
304
|
+
customSchema: {
|
|
305
|
+
required: ['crystalData'],
|
|
306
|
+
properties: {
|
|
307
|
+
crystalData: {
|
|
308
|
+
type: 'object',
|
|
309
|
+
required: ['selectedCrystals', 'intention'],
|
|
310
|
+
properties: {
|
|
311
|
+
selectedCrystals: {
|
|
312
|
+
type: 'array',
|
|
313
|
+
items: {
|
|
314
|
+
type: 'string',
|
|
315
|
+
enum: ['amethyst', 'rose_quartz', 'citrine', 'moonstone', 'obsidian']
|
|
316
|
+
}
|
|
317
|
+
},
|
|
318
|
+
intention: {
|
|
319
|
+
type: 'string',
|
|
320
|
+
minLength: 10,
|
|
321
|
+
maxLength: 200
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
module.exports = {
|
|
330
|
+
// Service-specific examples
|
|
331
|
+
NUMEROLOGY_INPUT_EXAMPLE,
|
|
332
|
+
PALMISTRY_INPUT_EXAMPLE,
|
|
333
|
+
CHINESE_ASTROLOGY_INPUT_EXAMPLE,
|
|
334
|
+
KABBALISTIC_INPUT_EXAMPLE,
|
|
335
|
+
TAROT_INPUT_EXAMPLE,
|
|
336
|
+
ICHING_INPUT_EXAMPLE,
|
|
337
|
+
RUNE_CASTING_INPUT_EXAMPLE,
|
|
338
|
+
|
|
339
|
+
// Templates
|
|
340
|
+
FUTURE_SERVICE_TEMPLATE,
|
|
341
|
+
|
|
342
|
+
// Registration examples
|
|
343
|
+
AYURVEDA_SERVICE_REGISTRATION,
|
|
344
|
+
CRYSTAL_HEALING_REGISTRATION,
|
|
345
|
+
|
|
346
|
+
// Helper to get example by service type
|
|
347
|
+
getExampleByServiceType: (serviceType) => {
|
|
348
|
+
const examples = {
|
|
349
|
+
numerology: NUMEROLOGY_INPUT_EXAMPLE,
|
|
350
|
+
palmistry: PALMISTRY_INPUT_EXAMPLE,
|
|
351
|
+
chinese: CHINESE_ASTROLOGY_INPUT_EXAMPLE,
|
|
352
|
+
kabbalistic: KABBALISTIC_INPUT_EXAMPLE,
|
|
353
|
+
tarot: TAROT_INPUT_EXAMPLE,
|
|
354
|
+
iching: ICHING_INPUT_EXAMPLE,
|
|
355
|
+
runes: RUNE_CASTING_INPUT_EXAMPLE
|
|
356
|
+
};
|
|
357
|
+
return examples[serviceType] || FUTURE_SERVICE_TEMPLATE;
|
|
358
|
+
}
|
|
359
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for astrology applications
|
|
3
|
+
* Works in both Node.js (backend) and browser (frontend) environments
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Logger
|
|
7
|
+
const { getLogger, createNamedLogger } = require('./logger');
|
|
8
|
+
|
|
9
|
+
// Validation
|
|
10
|
+
const {
|
|
11
|
+
validateBirthData,
|
|
12
|
+
// Other specific validation functions from './validation' that might use Joi,
|
|
13
|
+
// these need to be refactored later to use the AJV system if desired.
|
|
14
|
+
validateDateFormat,
|
|
15
|
+
validateTimeFormat,
|
|
16
|
+
validateBirthPlace,
|
|
17
|
+
validateClientContext,
|
|
18
|
+
validatePreferences,
|
|
19
|
+
createValidationError
|
|
20
|
+
} = require('./validation');
|
|
21
|
+
|
|
22
|
+
// Core AJV Schema Management API from schemas/index.js
|
|
23
|
+
const {
|
|
24
|
+
loadSchema,
|
|
25
|
+
getVersionMetadata,
|
|
26
|
+
validateInput, // Generic validate function for any schema by name
|
|
27
|
+
validateOutput, // Generic validate function for any schema by name
|
|
28
|
+
registerSchema, // Renamed from registerServiceSchema in schemas/index.js
|
|
29
|
+
getRegistry,
|
|
30
|
+
clearCache,
|
|
31
|
+
} = require('./schemas'); // This is schemas/index.js
|
|
32
|
+
|
|
33
|
+
// Schema system using new JSON Schema architecture (imported above)
|
|
34
|
+
|
|
35
|
+
// Export everything
|
|
36
|
+
module.exports = {
|
|
37
|
+
// Logger
|
|
38
|
+
getLogger,
|
|
39
|
+
createNamedLogger,
|
|
40
|
+
|
|
41
|
+
// Validation (still contains Joi-based functions, to be refactored)
|
|
42
|
+
validateBirthData,
|
|
43
|
+
validateDateFormat,
|
|
44
|
+
validateTimeFormat,
|
|
45
|
+
validateBirthPlace,
|
|
46
|
+
validateClientContext,
|
|
47
|
+
validatePreferences,
|
|
48
|
+
createValidationError,
|
|
49
|
+
|
|
50
|
+
// Core AJV Schema Management API
|
|
51
|
+
loadSchema,
|
|
52
|
+
getVersionMetadata,
|
|
53
|
+
validateInput,
|
|
54
|
+
validateOutput,
|
|
55
|
+
registerSchema,
|
|
56
|
+
getRegistry,
|
|
57
|
+
clearCache,
|
|
58
|
+
|
|
59
|
+
// Schema System API (New JSON Schema Architecture)
|
|
60
|
+
loadSchema,
|
|
61
|
+
validateInput,
|
|
62
|
+
validateOutput,
|
|
63
|
+
registerSchema,
|
|
64
|
+
getRegistry,
|
|
65
|
+
|
|
66
|
+
// Legacy compatibility (deprecated - use new schema system)
|
|
67
|
+
astrologyInputSchema: () => loadSchema('astrology/birth-chart/service'),
|
|
68
|
+
astrologyOutputSchema: () => loadSchema('astrology/birth-chart/service'),
|
|
69
|
+
getServiceInputSchema: validateInput,
|
|
70
|
+
validateServiceInput: validateInput,
|
|
71
|
+
|
|
72
|
+
// Version info
|
|
73
|
+
version: '1.0.0',
|
|
74
|
+
name: '@astrology/shared'
|
|
75
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IDataAccessService Interface
|
|
3
|
+
* Abstract interface for all data persistence operations
|
|
4
|
+
* Provides unified access to Redis caching and MongoDB persistence
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
class IDataAccessService {
|
|
8
|
+
/**
|
|
9
|
+
* Store a calculation result
|
|
10
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
11
|
+
* @param {string} calculationType - Type of calculation (birth-chart, dasha, etc.)
|
|
12
|
+
* @param {Object} data - Calculation result data
|
|
13
|
+
* @param {Object} metadata - Additional metadata for the calculation
|
|
14
|
+
* @returns {Promise<Object>} Storage result with operation details
|
|
15
|
+
*/
|
|
16
|
+
async storeCalculation(unifiedUserId, calculationType, data, metadata) {
|
|
17
|
+
throw new Error('storeCalculation method must be implemented by concrete class');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve a calculation result
|
|
22
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
23
|
+
* @param {string} calculationType - Type of calculation
|
|
24
|
+
* @param {string} calculationId - Unique calculation identifier
|
|
25
|
+
* @returns {Promise<Object>} Retrieved calculation data with metadata
|
|
26
|
+
*/
|
|
27
|
+
async retrieveCalculation(unifiedUserId, calculationType, calculationId) {
|
|
28
|
+
throw new Error('retrieveCalculation method must be implemented by concrete class');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Store user preferences
|
|
33
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
34
|
+
* @param {Object} preferences - User preference data
|
|
35
|
+
* @returns {Promise<Object>} Storage result
|
|
36
|
+
*/
|
|
37
|
+
async storeUserPreferences(unifiedUserId, preferences) {
|
|
38
|
+
throw new Error('storeUserPreferences method must be implemented by concrete class');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get user preferences
|
|
43
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
44
|
+
* @returns {Promise<Object>} User preferences data
|
|
45
|
+
*/
|
|
46
|
+
async getUserPreferences(unifiedUserId) {
|
|
47
|
+
throw new Error('getUserPreferences method must be implemented by concrete class');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Log an analytics event
|
|
52
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
53
|
+
* @param {string} event - Event type/name
|
|
54
|
+
* @param {Object} data - Event data
|
|
55
|
+
* @returns {Promise<Object>} Logging result
|
|
56
|
+
*/
|
|
57
|
+
async logAnalyticsEvent(unifiedUserId, event, data) {
|
|
58
|
+
throw new Error('logAnalyticsEvent method must be implemented by concrete class');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Health check for the data access service
|
|
63
|
+
* @returns {Promise<Object>} Health status
|
|
64
|
+
*/
|
|
65
|
+
async healthCheck() {
|
|
66
|
+
throw new Error('healthCheck method must be implemented by concrete class');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = IDataAccessService;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IUserContextService Interface
|
|
3
|
+
* Abstract interface for all user identity and session operations
|
|
4
|
+
* Provides unified access to user context across platforms
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
class IUserContextService {
|
|
8
|
+
/**
|
|
9
|
+
* Resolve unified user ID from platform-specific user ID
|
|
10
|
+
* @param {string} platform - Platform identifier (whatsapp, web, ios, android)
|
|
11
|
+
* @param {string} platformUserId - Platform-specific user identifier
|
|
12
|
+
* @returns {Promise<string>} Unified user identifier
|
|
13
|
+
*/
|
|
14
|
+
async resolveUserId(platform, platformUserId) {
|
|
15
|
+
throw new Error('resolveUserId method must be implemented by concrete class');
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get session state for a user
|
|
20
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
21
|
+
* @param {string} sessionId - Session identifier
|
|
22
|
+
* @returns {Promise<Object>} Session state data
|
|
23
|
+
*/
|
|
24
|
+
async getSessionState(unifiedUserId, sessionId) {
|
|
25
|
+
throw new Error('getSessionState method must be implemented by concrete class');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Update session state for a user
|
|
30
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
31
|
+
* @param {string} sessionId - Session identifier
|
|
32
|
+
* @param {Object} partialState - Partial state update
|
|
33
|
+
* @returns {Promise<Object>} Update result
|
|
34
|
+
*/
|
|
35
|
+
async updateSessionState(unifiedUserId, sessionId, partialState) {
|
|
36
|
+
throw new Error('updateSessionState method must be implemented by concrete class');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Get user profile data
|
|
41
|
+
* @param {string} unifiedUserId - Unified user identifier
|
|
42
|
+
* @param {Object} [projection=null] - Optional field projection
|
|
43
|
+
* @returns {Promise<Object>} User profile data
|
|
44
|
+
*/
|
|
45
|
+
async getUserProfile(unifiedUserId, projection = null) {
|
|
46
|
+
throw new Error('getUserProfile method must be implemented by concrete class');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Health check for the user context service
|
|
51
|
+
* @returns {Promise<Object>} Health status
|
|
52
|
+
*/
|
|
53
|
+
async healthCheck() {
|
|
54
|
+
throw new Error('healthCheck method must be implemented by concrete class');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
module.exports = IUserContextService;
|