@leadcms/sdk 1.2.87-pre → 1.2.88-pre
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.
|
@@ -355,7 +355,5 @@ async function main() {
|
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
357
|
|
|
358
|
-
main
|
|
359
|
-
|
|
360
|
-
process.exit(1)
|
|
361
|
-
})
|
|
358
|
+
// Export the main function so it can be imported by other modules
|
|
359
|
+
export { main as fetchLeadCMSContent }
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import "dotenv/config"
|
|
2
2
|
import { EventSource } from "eventsource"
|
|
3
|
-
import { exec } from "child_process"
|
|
4
3
|
import {
|
|
5
4
|
saveContentFile,
|
|
6
5
|
leadCMSUrl,
|
|
@@ -9,6 +8,7 @@ import {
|
|
|
9
8
|
CONTENT_DIR,
|
|
10
9
|
} from "./leadcms-helpers.mjs"
|
|
11
10
|
import { fetchContentTypes } from "./leadcms-helpers.mjs"
|
|
11
|
+
import { fetchLeadCMSContent } from "./fetch-leadcms-content.mjs"
|
|
12
12
|
|
|
13
13
|
// Log environment configuration for debugging
|
|
14
14
|
console.log(`[SSE ENV] LeadCMS URL: ${leadCMSUrl}`)
|
|
@@ -18,6 +18,17 @@ console.log(
|
|
|
18
18
|
console.log(`[SSE ENV] Default Language: ${defaultLanguage}`)
|
|
19
19
|
console.log(`[SSE ENV] Content Dir: ${CONTENT_DIR}`)
|
|
20
20
|
|
|
21
|
+
// Helper function to trigger content fetch
|
|
22
|
+
async function triggerContentFetch() {
|
|
23
|
+
try {
|
|
24
|
+
console.log("[SSE] Starting content fetch...")
|
|
25
|
+
await fetchLeadCMSContent()
|
|
26
|
+
console.log("[SSE] Content fetch completed successfully")
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error("[SSE] Content fetch failed:", error.message)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
21
32
|
function buildSSEUrl() {
|
|
22
33
|
console.log(`[SSE URL] Building SSE URL with base: ${leadCMSUrl}`)
|
|
23
34
|
const url = new URL("/api/sse/stream", leadCMSUrl)
|
|
@@ -95,16 +106,7 @@ async function startSSEWatcher() {
|
|
|
95
106
|
if (data.entityType === "Content") {
|
|
96
107
|
console.log(`[SSE] Content message - Operation: ${data.operation}`)
|
|
97
108
|
console.log(`[SSE] Content change detected - triggering full fetch`)
|
|
98
|
-
|
|
99
|
-
if (err) {
|
|
100
|
-
console.error("[SSE] fetch:leadcms failed:", err.message)
|
|
101
|
-
console.error("[SSE] fetch:leadcms stderr:", stderr)
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
console.log("[SSE] fetch:leadcms completed successfully")
|
|
105
|
-
console.log("[SSE] fetch:leadcms output:\n", stdout)
|
|
106
|
-
if (stderr) console.warn("[SSE] fetch:leadcms stderr:", stderr)
|
|
107
|
-
})
|
|
109
|
+
triggerContentFetch()
|
|
108
110
|
} else {
|
|
109
111
|
console.log(`[SSE] Non-content message - Entity type: ${data.entityType}`)
|
|
110
112
|
}
|
|
@@ -163,16 +165,7 @@ async function startSSEWatcher() {
|
|
|
163
165
|
}
|
|
164
166
|
|
|
165
167
|
console.log(`[SSE] Draft updated - triggering full fetch`)
|
|
166
|
-
|
|
167
|
-
if (err) {
|
|
168
|
-
console.error("[SSE] fetch:leadcms failed:", err.message)
|
|
169
|
-
console.error("[SSE] fetch:leadcms stderr:", stderr)
|
|
170
|
-
return
|
|
171
|
-
}
|
|
172
|
-
console.log("[SSE] fetch:leadcms completed successfully")
|
|
173
|
-
console.log("[SSE] fetch:leadcms output:\n", stdout)
|
|
174
|
-
if (stderr) console.warn("[SSE] fetch:leadcms stderr:", stderr)
|
|
175
|
-
})
|
|
168
|
+
triggerContentFetch()
|
|
176
169
|
|
|
177
170
|
if (contentType === "MDX" || contentType === "JSON") {
|
|
178
171
|
if (contentData && typeof contentData === "object") {
|
|
@@ -227,16 +220,7 @@ async function startSSEWatcher() {
|
|
|
227
220
|
}
|
|
228
221
|
|
|
229
222
|
console.log(`[SSE] Legacy draft modified - triggering full fetch`)
|
|
230
|
-
|
|
231
|
-
if (err) {
|
|
232
|
-
console.error("[SSE] fetch:leadcms failed:", err.message)
|
|
233
|
-
console.error("[SSE] fetch:leadcms stderr:", stderr)
|
|
234
|
-
return
|
|
235
|
-
}
|
|
236
|
-
console.log("[SSE] fetch:leadcms completed successfully")
|
|
237
|
-
console.log("[SSE] fetch:leadcms output:\n", stdout)
|
|
238
|
-
if (stderr) console.warn("[SSE] fetch:leadcms stderr:", stderr)
|
|
239
|
-
})
|
|
223
|
+
triggerContentFetch()
|
|
240
224
|
|
|
241
225
|
if (contentType === "MDX" || contentType === "JSON") {
|
|
242
226
|
if (contentData && typeof contentData === "object") {
|
|
@@ -272,16 +256,7 @@ async function startSSEWatcher() {
|
|
|
272
256
|
console.log(`[SSE] Content updated data:`, JSON.stringify(data, null, 2))
|
|
273
257
|
|
|
274
258
|
console.log(`[SSE] Content updated - triggering full fetch`)
|
|
275
|
-
|
|
276
|
-
if (err) {
|
|
277
|
-
console.error("[SSE] fetch:leadcms failed:", err.message)
|
|
278
|
-
console.error("[SSE] fetch:leadcms stderr:", stderr)
|
|
279
|
-
return
|
|
280
|
-
}
|
|
281
|
-
console.log("[SSE] fetch:leadcms completed successfully")
|
|
282
|
-
console.log("[SSE] fetch:leadcms output:\n", stdout)
|
|
283
|
-
if (stderr) console.warn("[SSE] fetch:leadcms stderr:", stderr)
|
|
284
|
-
})
|
|
259
|
+
triggerContentFetch()
|
|
285
260
|
} catch (e) {
|
|
286
261
|
console.warn("[SSE] Failed to parse content-updated event:", e.message)
|
|
287
262
|
console.warn("[SSE] Raw content-updated event data:", event.data)
|
package/package.json
CHANGED