daeda-mcp 1.0.2 → 1.0.3
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readInitState, writeInitState, createInitialState, isFullySynced, getSyncedCount, ALL_EXPORTS, } from "./init-state.js";
|
|
1
|
+
import { readInitState, writeInitState, createInitialState, isFullySynced, getSyncedCount, readExportOverride, ALL_EXPORTS, } from "./init-state.js";
|
|
2
2
|
import { validateToken, startObjectExport, startAssociationExport, getExportStatus, downloadExportCsvToFile, fetchObjectProperties, findReusableExports, } from "./export-api.js";
|
|
3
3
|
import { loadContactsCsvFromFile, loadCompaniesCsvFromFile, loadDealsCsvFromFile, loadAssociationsCsvFromFile, } from "./csv-loader.js";
|
|
4
4
|
import { runSeeding } from "./seeder.js";
|
|
@@ -74,6 +74,21 @@ export async function startInitialization(force = false) {
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
async function fireAllExportRequests(token, state) {
|
|
77
|
+
const override = readExportOverride();
|
|
78
|
+
if (override) {
|
|
79
|
+
console.error("[init-manager] Using export override file");
|
|
80
|
+
for (const exportName of ALL_EXPORTS) {
|
|
81
|
+
const overrideExport = override[exportName];
|
|
82
|
+
if (overrideExport?.exportId) {
|
|
83
|
+
state.exports[exportName].exportId = overrideExport.exportId;
|
|
84
|
+
state.exports[exportName].status = overrideExport.status;
|
|
85
|
+
state.exports[exportName].error = overrideExport.error;
|
|
86
|
+
console.error(`[init-manager] Override ${exportName}: ${overrideExport.exportId}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
writeInitState(state);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
77
92
|
console.error("[init-manager] Checking for reusable exports from the past week...");
|
|
78
93
|
let reusableExports;
|
|
79
94
|
try {
|
|
@@ -29,3 +29,4 @@ export declare function resetInitState(): void;
|
|
|
29
29
|
export declare function getSyncedCount(state: InitState): number;
|
|
30
30
|
export declare function isFullySynced(state: InitState): boolean;
|
|
31
31
|
export declare function getStateFilePath(): string;
|
|
32
|
+
export declare function readExportOverride(): Record<ExportName, ExportState> | null;
|
package/dist/sync/init-state.js
CHANGED
|
@@ -4,6 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
5
5
|
const DATA_DIR = join(__dirname, "..", "..", "data");
|
|
6
6
|
const STATE_FILE = join(DATA_DIR, "init_state.json");
|
|
7
|
+
const OVERRIDE_FILE = join(DATA_DIR, "export_override.json");
|
|
7
8
|
export const ALL_EXPORTS = [
|
|
8
9
|
"contacts",
|
|
9
10
|
"companies",
|
|
@@ -62,3 +63,15 @@ export function isFullySynced(state) {
|
|
|
62
63
|
export function getStateFilePath() {
|
|
63
64
|
return STATE_FILE;
|
|
64
65
|
}
|
|
66
|
+
export function readExportOverride() {
|
|
67
|
+
try {
|
|
68
|
+
if (!existsSync(OVERRIDE_FILE)) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
const content = readFileSync(OVERRIDE_FILE, "utf-8");
|
|
72
|
+
return JSON.parse(content);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|