@ik-firewall/core 1.0.0 → 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/dist/index.cjs +22 -2
- package/dist/index.js +22 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -47,6 +47,8 @@ if (typeof window === "undefined") {
|
|
|
47
47
|
var Registry = class _Registry {
|
|
48
48
|
static instance;
|
|
49
49
|
registryPath;
|
|
50
|
+
hasWarnedNoFs = false;
|
|
51
|
+
hasWarnedSaveError = false;
|
|
50
52
|
constructor() {
|
|
51
53
|
this.registryPath = "";
|
|
52
54
|
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
@@ -56,7 +58,12 @@ var Registry = class _Registry {
|
|
|
56
58
|
this.registryPath = path.join(process.cwd(), ".ik-adapter", "registry.json");
|
|
57
59
|
this.ensureDirectory();
|
|
58
60
|
} catch (e) {
|
|
59
|
-
|
|
61
|
+
if (!this.hasWarnedNoFs) {
|
|
62
|
+
console.warn("\n[IK_REGISTRY] \u26A0\uFE0F WARNING: Node.js environment detected but fs/path modules failed to load. Falling back to in-memory mode.");
|
|
63
|
+
console.warn("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Custom configurations (metaprompts, instances) will be LOST upon server restart or lambda spin-down.");
|
|
64
|
+
console.warn("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: Host on a traditional VPS (Node/Docker) or migrate settings to your database if you need persistence on Serverless runtimes.\n");
|
|
65
|
+
this.hasWarnedNoFs = true;
|
|
66
|
+
}
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
}
|
|
@@ -93,13 +100,26 @@ var Registry = class _Registry {
|
|
|
93
100
|
}
|
|
94
101
|
save(data) {
|
|
95
102
|
if (!fs || !this.registryPath) {
|
|
103
|
+
if (!this.hasWarnedNoFs) {
|
|
104
|
+
console.warn("\n[IK_REGISTRY] \u26A0\uFE0F WARNING: No File System (fs) detected. Running in in-memory mode.");
|
|
105
|
+
console.warn("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Custom configurations (metaprompts, instances) will be LOST upon server restart or lambda spin-down.");
|
|
106
|
+
console.warn("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: If hosting on Vercel/Serverless or Edge runtimes, do not rely on local JSON for dynamic config changes.");
|
|
107
|
+
console.warn("[IK_REGISTRY] \u{1F449} Consider migrating user-generated adapter settings to your database or host on a traditional VPS (Node/Docker) to ensure persistence.\n");
|
|
108
|
+
this.hasWarnedNoFs = true;
|
|
109
|
+
}
|
|
96
110
|
return;
|
|
97
111
|
}
|
|
98
112
|
try {
|
|
99
113
|
this.ensureDirectory();
|
|
100
114
|
fs.writeFileSync(this.registryPath, JSON.stringify(data, null, 2), "utf8");
|
|
101
115
|
} catch (error) {
|
|
102
|
-
|
|
116
|
+
if (!this.hasWarnedSaveError) {
|
|
117
|
+
console.error("\n[IK_REGISTRY] \u{1F6A8} ERROR saving registry.json. Your environment likely has a read-only filesystem (e.g. Vercel Serverless).");
|
|
118
|
+
console.error("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Serverless environments wipe or restrict file writes!");
|
|
119
|
+
console.error("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: Host on a traditional VPS (Node/Docker) or intercept state changes via Events/Database to ensure persistence.");
|
|
120
|
+
console.error("[IK_REGISTRY] Actual Error:", error.message, "\n");
|
|
121
|
+
this.hasWarnedSaveError = true;
|
|
122
|
+
}
|
|
103
123
|
}
|
|
104
124
|
}
|
|
105
125
|
/**
|
package/dist/index.js
CHANGED
|
@@ -16,6 +16,8 @@ if (typeof window === "undefined") {
|
|
|
16
16
|
var Registry = class _Registry {
|
|
17
17
|
static instance;
|
|
18
18
|
registryPath;
|
|
19
|
+
hasWarnedNoFs = false;
|
|
20
|
+
hasWarnedSaveError = false;
|
|
19
21
|
constructor() {
|
|
20
22
|
this.registryPath = "";
|
|
21
23
|
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
@@ -25,7 +27,12 @@ var Registry = class _Registry {
|
|
|
25
27
|
this.registryPath = path.join(process.cwd(), ".ik-adapter", "registry.json");
|
|
26
28
|
this.ensureDirectory();
|
|
27
29
|
} catch (e) {
|
|
28
|
-
|
|
30
|
+
if (!this.hasWarnedNoFs) {
|
|
31
|
+
console.warn("\n[IK_REGISTRY] \u26A0\uFE0F WARNING: Node.js environment detected but fs/path modules failed to load. Falling back to in-memory mode.");
|
|
32
|
+
console.warn("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Custom configurations (metaprompts, instances) will be LOST upon server restart or lambda spin-down.");
|
|
33
|
+
console.warn("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: Host on a traditional VPS (Node/Docker) or migrate settings to your database if you need persistence on Serverless runtimes.\n");
|
|
34
|
+
this.hasWarnedNoFs = true;
|
|
35
|
+
}
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
}
|
|
@@ -62,13 +69,26 @@ var Registry = class _Registry {
|
|
|
62
69
|
}
|
|
63
70
|
save(data) {
|
|
64
71
|
if (!fs || !this.registryPath) {
|
|
72
|
+
if (!this.hasWarnedNoFs) {
|
|
73
|
+
console.warn("\n[IK_REGISTRY] \u26A0\uFE0F WARNING: No File System (fs) detected. Running in in-memory mode.");
|
|
74
|
+
console.warn("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Custom configurations (metaprompts, instances) will be LOST upon server restart or lambda spin-down.");
|
|
75
|
+
console.warn("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: If hosting on Vercel/Serverless or Edge runtimes, do not rely on local JSON for dynamic config changes.");
|
|
76
|
+
console.warn("[IK_REGISTRY] \u{1F449} Consider migrating user-generated adapter settings to your database or host on a traditional VPS (Node/Docker) to ensure persistence.\n");
|
|
77
|
+
this.hasWarnedNoFs = true;
|
|
78
|
+
}
|
|
65
79
|
return;
|
|
66
80
|
}
|
|
67
81
|
try {
|
|
68
82
|
this.ensureDirectory();
|
|
69
83
|
fs.writeFileSync(this.registryPath, JSON.stringify(data, null, 2), "utf8");
|
|
70
84
|
} catch (error) {
|
|
71
|
-
|
|
85
|
+
if (!this.hasWarnedSaveError) {
|
|
86
|
+
console.error("\n[IK_REGISTRY] \u{1F6A8} ERROR saving registry.json. Your environment likely has a read-only filesystem (e.g. Vercel Serverless).");
|
|
87
|
+
console.error("[IK_REGISTRY] \u{1F4DD} INTEGRATOR NOTICE: Serverless environments wipe or restrict file writes!");
|
|
88
|
+
console.error("[IK_REGISTRY] \u{1F4A1} BEST PRACTICE: Host on a traditional VPS (Node/Docker) or intercept state changes via Events/Database to ensure persistence.");
|
|
89
|
+
console.error("[IK_REGISTRY] Actual Error:", error.message, "\n");
|
|
90
|
+
this.hasWarnedSaveError = true;
|
|
91
|
+
}
|
|
72
92
|
}
|
|
73
93
|
}
|
|
74
94
|
/**
|