Skip to content

Commit 796e9a3

Browse files
committed
Rename autoConvert to converter-auto, add converter-default setting
- autoConvert-{item} → converter-auto-{item} (display conversion preference) - converter-default-{item} (default input method for forms, hides method selector) - Both use dynamic settings with prefix pattern
1 parent b303054 commit 796e9a3

4 files changed

Lines changed: 39 additions & 38 deletions

File tree

tests/HDSSettings.test.js

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -209,57 +209,57 @@ describe('[HDSD] HDSSettings dynamic settings', function () {
209209
});
210210

211211
it('[HDSD1] _testInject and get work for dynamic keys', () => {
212-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'billings');
213-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), 'billings');
212+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'billings');
213+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), 'billings');
214214
assert.strictEqual(HDSSettings.isHooked, true);
215215
});
216216

217217
it('[HDSD2] _testClear removes dynamic key', () => {
218-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'mira');
219-
HDSSettings._testClear('autoConvert-wellbeing-mood');
220-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), undefined);
218+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'mira');
219+
HDSSettings._testClear('converter-auto-wellbeing-mood');
220+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), undefined);
221221
});
222222

223223
it('[HDSD3] getDynamic returns all settings with prefix', () => {
224-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'billings');
225-
HDSSettings._testInject('autoConvert-body-vulva-mucus-inspect', 'appleHealth');
226-
const all = HDSSettings.getDynamic('autoConvert-');
224+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'billings');
225+
HDSSettings._testInject('converter-auto-body-vulva-mucus-inspect', 'appleHealth');
226+
const all = HDSSettings.getDynamic('converter-auto-');
227227
assert.strictEqual(all['wellbeing-mood'], 'billings');
228228
assert.strictEqual(all['body-vulva-mucus-inspect'], 'appleHealth');
229229
});
230230

231231
it('[HDSD4] unhook clears dynamic settings', () => {
232-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'billings');
232+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'billings');
233233
HDSSettings.unhook();
234-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), undefined);
235-
assert.deepStrictEqual(HDSSettings.getDynamic('autoConvert-'), {});
234+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), undefined);
235+
assert.deepStrictEqual(HDSSettings.getDynamic('converter-auto-'), {});
236236
});
237237

238238
it('[HDSD5] load reads dynamic settings from server events', async () => {
239239
const conn = createMockConnection({
240240
'events.get': () => ({
241241
events: [
242-
{ id: 'ev-ac1', type: 'settings/auto-convert', content: { itemKey: 'wellbeing-mood', method: 'billings' } },
243-
{ id: 'ev-ac2', type: 'settings/auto-convert', content: { itemKey: 'body-vulva-mucus-inspect', method: 'appleHealth' } },
242+
{ id: 'ev-ac1', type: 'settings/converter-auto', content: { itemKey: 'wellbeing-mood', method: 'billings' } },
243+
{ id: 'ev-ac2', type: 'settings/converter-auto', content: { itemKey: 'body-vulva-mucus-inspect', method: 'appleHealth' } },
244244
{ id: 'ev-t', type: 'settings/theme', content: 'dark' },
245245
]
246246
})
247247
});
248248
await HDSSettings.hookToConnection(conn, 'test-stream');
249-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), 'billings');
250-
assert.strictEqual(HDSSettings.get('autoConvert-body-vulva-mucus-inspect'), 'appleHealth');
249+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), 'billings');
250+
assert.strictEqual(HDSSettings.get('converter-auto-body-vulva-mucus-inspect'), 'appleHealth');
251251
assert.strictEqual(HDSSettings.get('theme'), 'dark');
252252
});
253253

254254
it('[HDSD6] setDynamic creates new event', async () => {
255255
const conn = createMockConnection();
256256
await HDSSettings.hookToConnection(conn, 'test-stream');
257257

258-
await HDSSettings.setDynamic('autoConvert-wellbeing-mood', 'billings');
259-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), 'billings');
258+
await HDSSettings.setDynamic('converter-auto-wellbeing-mood', 'billings');
259+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), 'billings');
260260

261261
const createCall = conn.apiCalls.find(c =>
262-
c.method === 'events.create' && c.params.type === 'settings/auto-convert'
262+
c.method === 'events.create' && c.params.type === 'settings/converter-auto'
263263
);
264264
assert.ok(createCall, 'Should have called events.create');
265265
assert.strictEqual(createCall.params.content.itemKey, 'wellbeing-mood');
@@ -270,15 +270,15 @@ describe('[HDSD] HDSSettings dynamic settings', function () {
270270
const conn = createMockConnection({
271271
'events.get': () => ({
272272
events: [
273-
{ id: 'ev-ac-mood', type: 'settings/auto-convert', content: { itemKey: 'wellbeing-mood', method: 'billings' } }
273+
{ id: 'ev-ac-mood', type: 'settings/converter-auto', content: { itemKey: 'wellbeing-mood', method: 'billings' } }
274274
]
275275
})
276276
});
277277
await HDSSettings.hookToConnection(conn, 'test-stream');
278-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), 'billings');
278+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), 'billings');
279279

280-
await HDSSettings.setDynamic('autoConvert-wellbeing-mood', 'mira');
281-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), 'mira');
280+
await HDSSettings.setDynamic('converter-auto-wellbeing-mood', 'mira');
281+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), 'mira');
282282

283283
const updateCall = conn.apiCalls.find(c => c.method === 'events.update');
284284
assert.ok(updateCall, 'Should have called events.update');
@@ -290,14 +290,14 @@ describe('[HDSD] HDSSettings dynamic settings', function () {
290290
const conn = createMockConnection({
291291
'events.get': () => ({
292292
events: [
293-
{ id: 'ev-ac-mood', type: 'settings/auto-convert', content: { itemKey: 'wellbeing-mood', method: 'billings' } }
293+
{ id: 'ev-ac-mood', type: 'settings/converter-auto', content: { itemKey: 'wellbeing-mood', method: 'billings' } }
294294
]
295295
})
296296
});
297297
await HDSSettings.hookToConnection(conn, 'test-stream');
298298

299-
await HDSSettings.setDynamic('autoConvert-wellbeing-mood', null);
300-
assert.strictEqual(HDSSettings.get('autoConvert-wellbeing-mood'), undefined);
299+
await HDSSettings.setDynamic('converter-auto-wellbeing-mood', null);
300+
assert.strictEqual(HDSSettings.get('converter-auto-wellbeing-mood'), undefined);
301301

302302
const deleteCall = conn.apiCalls.find(c => c.method === 'events.delete');
303303
assert.ok(deleteCall, 'Should have called events.delete');
@@ -315,7 +315,7 @@ describe('[HDSD] HDSSettings dynamic settings', function () {
315315

316316
it('[HDSD10] setDynamic throws when not hooked', async () => {
317317
await assert.rejects(
318-
() => HDSSettings.setDynamic('autoConvert-wellbeing-mood', 'billings'),
318+
() => HDSSettings.setDynamic('converter-auto-wellbeing-mood', 'billings'),
319319
/hookToApplication|hookToConnection/
320320
);
321321
});

tests/eventToShortText.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,14 +419,14 @@ describe('[ESTX] eventToShortText', () => {
419419
});
420420

421421
it('[EST22b] autoConvert same method — shows sourceData + method name (no conversion)', async () => {
422-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'mira');
422+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'mira');
423423
const event = await model.converters.convertMethodToEvent('mood', 'mira', 'Happy');
424424
event.time = Date.now() / 1000;
425425
assert.equal(eventToShortText(event), 'Happy (Mira)');
426426
});
427427

428428
it('[EST22c] autoConvert mood mira→hds — shows stop labels with target <- source', async () => {
429-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'hds');
429+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'hds');
430430
const event = await model.converters.convertMethodToEvent('mood', 'mira', 'Happy');
431431
event.time = Date.now() / 1000;
432432
const result = eventToShortText(event);
@@ -436,15 +436,15 @@ describe('[ESTX] eventToShortText', () => {
436436
});
437437

438438
it('[EST22d] autoConvert cervical fluid mira→appleHealth — localized label + perfect match', async () => {
439-
HDSSettings._testInject('autoConvert-body-vulva-mucus-inspect', 'appleHealth');
439+
HDSSettings._testInject('converter-auto-body-vulva-mucus-inspect', 'appleHealth');
440440
const event = await model.converters.convertMethodToEvent('cervical-fluid', 'mira', 'Creamy');
441441
event.time = Date.now() / 1000;
442442
// "creamy" value should resolve to "Creamy" label from appleHealth method
443443
assert.equal(eventToShortText(event), 'Creamy (Apple Health <- Mira)');
444444
});
445445

446446
it('[EST22e] autoConvert cervical fluid mira→billings — localized label + partial match', async () => {
447-
HDSSettings._testInject('autoConvert-body-vulva-mucus-inspect', 'billings');
447+
HDSSettings._testInject('converter-auto-body-vulva-mucus-inspect', 'billings');
448448
const event = await model.converters.convertMethodToEvent('cervical-fluid', 'mira', 'Watery');
449449
event.time = Date.now() / 1000;
450450
const result = eventToShortText(event);
@@ -455,7 +455,7 @@ describe('[ESTX] eventToShortText', () => {
455455
});
456456

457457
it('[EST22f] autoConvert raw vector (no source) — shows result + target name', async () => {
458-
HDSSettings._testInject('autoConvert-wellbeing-mood', 'mira');
458+
HDSSettings._testInject('converter-auto-wellbeing-mood', 'mira');
459459
const event = {
460460
content: { vectors: { valence: 0.8, arousal: 0.2, dominance: 0.7, socialOrientation: 0.5, temporalFocus: 0.3 } },
461461
streamIds: ['wellbeing-mood'],
@@ -468,7 +468,7 @@ describe('[ESTX] eventToShortText', () => {
468468
});
469469

470470
it('[EST22g] all cervical fluid mira→appleHealth labels are capitalized', async () => {
471-
HDSSettings._testInject('autoConvert-body-vulva-mucus-inspect', 'appleHealth');
471+
HDSSettings._testInject('converter-auto-body-vulva-mucus-inspect', 'appleHealth');
472472
const pairs = [
473473
['No discharge', 'Dry'], ['Dry', 'Dry'], ['Sticky', 'Sticky'],
474474
['Creamy', 'Creamy'], ['Watery', 'Watery'], ['Raw Egg White', 'Egg White'],

ts/HDSModel/eventToShortText.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ function formatConvertible (_event: any, content: any, itemDef: any, model: any)
272272
// Check for autoConvert setting
273273
if (HDSSettings.isHooked && vectors) {
274274
try {
275-
const settingKey = `autoConvert-${itemDef.key}`;
275+
const settingKey = `converter-auto-${itemDef.key}`;
276276
const targetMethod = HDSSettings.get(settingKey);
277277
if (targetMethod && typeof targetMethod === 'string') {
278278
// Skip conversion if target method equals source method

ts/settings/HDSSettings.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export const SETTING_TYPES = {
1919
* Event type is shared for all settings with the same prefix.
2020
*/
2121
const DYNAMIC_PREFIXES: Record<string, { eventType: string; contentKey: string; contentValue: string }> = {
22-
'autoConvert-': { eventType: 'settings/auto-convert', contentKey: 'itemKey', contentValue: 'method' },
22+
'converter-auto-': { eventType: 'settings/converter-auto', contentKey: 'itemKey', contentValue: 'method' },
23+
'converter-default-': { eventType: 'settings/converter-default', contentKey: 'itemKey', contentValue: 'method' },
2324
};
2425

2526
export type SettingKey = keyof typeof SETTING_TYPES;
@@ -153,14 +154,14 @@ async function load (): Promise<void> {
153154
*
154155
* Supports two kinds of settings:
155156
* - **Typed settings**: fixed keys (theme, dateFormat, etc.) with specific event types.
156-
* - **Dynamic settings**: prefix-based keys (autoConvert-{itemKey}) stored as events
157+
* - **Dynamic settings**: prefix-based keys (converter-auto-{itemKey}) stored as events
157158
* with a shared event type and keyed by content field.
158159
*
159160
* Usage:
160161
* await HDSSettings.hookToApplication(app);
161162
* const locale = HDSSettings.get('preferredLocales');
162163
* await HDSSettings.set('theme', 'dark');
163-
* await HDSSettings.setDynamic('autoConvert-wellbeing-mood', 'billings');
164+
* await HDSSettings.setDynamic('converter-auto-wellbeing-mood', 'billings');
164165
*/
165166
const HDSSettings = {
166167

@@ -185,7 +186,7 @@ const HDSSettings = {
185186

186187
/**
187188
* Get the current value for a typed setting.
188-
* Also checks dynamic settings for prefix-based keys (e.g. 'autoConvert-wellbeing-mood').
189+
* Also checks dynamic settings for prefix-based keys (e.g. 'converter-auto-wellbeing-mood').
189190
*/
190191
get (key: string): any {
191192
if (key in _dynamicValues) return _dynamicValues[key];
@@ -246,7 +247,7 @@ const HDSSettings = {
246247

247248
/**
248249
* Set a dynamic setting value — persists to HDS server.
249-
* Key must match a known prefix (e.g. 'autoConvert-wellbeing-mood').
250+
* Key must match a known prefix (e.g. 'converter-auto-wellbeing-mood').
250251
* Pass null to delete the setting.
251252
*/
252253
async setDynamic (key: string, value: any): Promise<void> {

0 commit comments

Comments
 (0)