@technomoron/mail-magic 1.0.37 → 1.0.38
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/CHANGES +9 -0
- package/dist/esm/store/store.js +32 -12
- package/package.json +1 -1
package/CHANGES
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
Version 1.0.38 (2026-02-17)
|
|
2
|
+
|
|
3
|
+
- Prefer `fs.watch` for init-data auto-reload with automatic fallback to
|
|
4
|
+
`fs.watchFile` when native file watching is unavailable.
|
|
5
|
+
- Add regression tests for auto-reload watcher behavior (`watch`, fallback,
|
|
6
|
+
disabled mode).
|
|
7
|
+
- Add schema-drift regression tests that assert Zod schema keys match Sequelize
|
|
8
|
+
model attributes for core API models.
|
|
9
|
+
|
|
1
10
|
Version 1.0.37 (2026-02-17)
|
|
2
11
|
|
|
3
12
|
- Remove stale commented-out debug code from server mailer/store paths.
|
package/dist/esm/store/store.js
CHANGED
|
@@ -27,6 +27,35 @@ function create_mail_transport(vars) {
|
|
|
27
27
|
});
|
|
28
28
|
return mailer;
|
|
29
29
|
}
|
|
30
|
+
export function enableInitDataAutoReload(ctx, reload) {
|
|
31
|
+
if (!ctx.vars.DB_AUTO_RELOAD) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const initDataPath = ctx.config_filename('init-data.json');
|
|
35
|
+
ctx.print_debug('Enabling auto reload of init-data.json');
|
|
36
|
+
const onChange = () => {
|
|
37
|
+
ctx.print_debug('Config file changed, reloading...');
|
|
38
|
+
try {
|
|
39
|
+
reload();
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
ctx.print_debug(`Failed to reload config: ${err}`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
try {
|
|
46
|
+
const watcher = fs.watch(initDataPath, { persistent: false }, onChange);
|
|
47
|
+
return {
|
|
48
|
+
close: () => watcher.close()
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
ctx.print_debug(`fs.watch unavailable; falling back to fs.watchFile: ${err}`);
|
|
53
|
+
fs.watchFile(initDataPath, { interval: 2000 }, onChange);
|
|
54
|
+
return {
|
|
55
|
+
close: () => fs.unwatchFile(initDataPath, onChange)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
30
59
|
export class mailStore {
|
|
31
60
|
env;
|
|
32
61
|
vars;
|
|
@@ -35,6 +64,7 @@ export class mailStore {
|
|
|
35
64
|
configpath = '';
|
|
36
65
|
uploadTemplate;
|
|
37
66
|
uploadStagingPath;
|
|
67
|
+
autoReloadHandle = null;
|
|
38
68
|
print_debug(msg) {
|
|
39
69
|
if (this.vars.DEBUG) {
|
|
40
70
|
console.log(msg);
|
|
@@ -153,18 +183,8 @@ export class mailStore {
|
|
|
153
183
|
}
|
|
154
184
|
this.transport = await create_mail_transport(this.vars);
|
|
155
185
|
this.api_db = await connect_api_db(this);
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
fs.watchFile(this.config_filename('init-data.json'), { interval: 2000 }, () => {
|
|
159
|
-
this.print_debug('Config file changed, reloading...');
|
|
160
|
-
try {
|
|
161
|
-
importData(this);
|
|
162
|
-
}
|
|
163
|
-
catch (err) {
|
|
164
|
-
this.print_debug(`Failed to reload config: ${err}`);
|
|
165
|
-
}
|
|
166
|
-
});
|
|
167
|
-
}
|
|
186
|
+
this.autoReloadHandle?.close();
|
|
187
|
+
this.autoReloadHandle = enableInitDataAutoReload(this, () => importData(this));
|
|
168
188
|
return this;
|
|
169
189
|
}
|
|
170
190
|
}
|