@coffer-org/plugin-transit 1.3.0 → 1.3.2
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/runtime/index.js +3 -1
- package/dist/runtime/sync.js +5 -3
- package/package.json +4 -4
package/dist/runtime/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { startSync, stopSync } from "./sync.js";
|
|
2
|
+
import { getLogger } from '@coffer-org/sdk/logger';
|
|
3
|
+
const log = getLogger('transit');
|
|
2
4
|
export { startSync, stopSync } from "./sync.js";
|
|
3
5
|
export const serverHooks = {
|
|
4
6
|
init: () => {
|
|
5
|
-
void startSync().catch((e) =>
|
|
7
|
+
void startSync().catch((e) => log.warn(`sync failed to start: ${e.message}`));
|
|
6
8
|
},
|
|
7
9
|
teardown: () => {
|
|
8
10
|
stopSync();
|
package/dist/runtime/sync.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getEm } from '@coffer-org/server/db';
|
|
2
2
|
import { getPluginSettings } from '@coffer-org/server/plugin-runtime';
|
|
3
3
|
import { resolveDavSettings, WebDavClient, CalDavCollection, buildVEvent, buildRRule, } from '@coffer-org/dav';
|
|
4
|
+
import { getLogger } from '@coffer-org/sdk/logger';
|
|
5
|
+
const log = getLogger('transit');
|
|
4
6
|
const REF_DATE = { weekday: '20240101', saturday: '20240106', sunday: '20240107' };
|
|
5
7
|
const BYDAY = {
|
|
6
8
|
weekday: ['MO', 'TU', 'WE', 'TH', 'FR'],
|
|
@@ -82,7 +84,7 @@ async function runOnce() {
|
|
|
82
84
|
});
|
|
83
85
|
const coll = new CalDavCollection(ops);
|
|
84
86
|
const result = await coll.syncEvents('bus-route-', icsFiles);
|
|
85
|
-
|
|
87
|
+
log.debug(`synced: ${result.written.length} written, ${result.deleted.length} deleted, ${result.failed.length} failed`);
|
|
86
88
|
}
|
|
87
89
|
const INTERVAL_MS = Number(process.env['TRANSIT_SYNC_INTERVAL_MS'] ?? 0) || 6 * 60 * 60 * 1000;
|
|
88
90
|
let timer;
|
|
@@ -91,10 +93,10 @@ export async function startSync() {
|
|
|
91
93
|
await runOnce();
|
|
92
94
|
}
|
|
93
95
|
catch (e) {
|
|
94
|
-
|
|
96
|
+
log.error(`initial sync failed: ${e.message}`);
|
|
95
97
|
}
|
|
96
98
|
timer = setInterval(() => {
|
|
97
|
-
void runOnce().catch((e) =>
|
|
99
|
+
void runOnce().catch((e) => log.error(`sync error: ${e.message}`));
|
|
98
100
|
}, INTERVAL_MS);
|
|
99
101
|
}
|
|
100
102
|
export function stopSync() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coffer-org/plugin-transit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"test": "node --import tsx/esm --test 'src/runtime/*.test.ts'"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@coffer-org/sdk": "^1.
|
|
29
|
-
"@coffer-org/server": "^1.
|
|
30
|
-
"@coffer-org/dav": "^1.
|
|
28
|
+
"@coffer-org/sdk": "^1.4.0",
|
|
29
|
+
"@coffer-org/server": "^1.4.0",
|
|
30
|
+
"@coffer-org/dav": "^1.4.0"
|
|
31
31
|
},
|
|
32
32
|
"coffer": {
|
|
33
33
|
"schema": "dist/schema.js"
|