@isardsat/editorial-server 6.20.0 → 6.21.0
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.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {} from "@isardsat/editorial-common";
|
|
2
|
+
import pkg from "../../../package.json" with { type: "json" };
|
|
3
|
+
const CURRENT_VERSION = pkg.version;
|
|
4
|
+
let latestVersionCache = null;
|
|
5
|
+
let lastChecked = 0;
|
|
6
|
+
export async function getCurrentAndLatestVersion() {
|
|
7
|
+
const now = Date.now();
|
|
8
|
+
if (latestVersionCache && now - lastChecked < 60_000 * 10) {
|
|
9
|
+
// cache 10 min
|
|
10
|
+
return { current: CURRENT_VERSION, latest: latestVersionCache };
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const res = await fetch("https://registry.npmjs.org/@isardsat/editorial-admin", { headers: { Accept: "application/vnd.npm.install-v1+json" } });
|
|
14
|
+
const data = (await res.json());
|
|
15
|
+
latestVersionCache = data["dist-tags"].latest;
|
|
16
|
+
lastChecked = now;
|
|
17
|
+
return { current: CURRENT_VERSION, latest: latestVersionCache };
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
throw new Error("Failed to fetch latest version from npm registry");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/routes/data.js
CHANGED
|
@@ -551,7 +551,7 @@ export function createDataRoutes(config, storage) {
|
|
|
551
551
|
if (singletonKey) {
|
|
552
552
|
const previewItem = previewCollection[singletonKey];
|
|
553
553
|
const productionItem = productionCollection[singletonKey];
|
|
554
|
-
if (previewItem && !productionItem) {
|
|
554
|
+
if (previewItem && !previewItem.isDraft && !productionItem) {
|
|
555
555
|
// Singleton exists in preview but not in production = added
|
|
556
556
|
result.singles[itemType] = {
|
|
557
557
|
status: "added",
|
|
@@ -567,7 +567,8 @@ export function createDataRoutes(config, storage) {
|
|
|
567
567
|
production: productionItem,
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
|
-
else if (
|
|
570
|
+
else if (productionItem &&
|
|
571
|
+
previewItem?.updatedAt !== productionItem?.updatedAt) {
|
|
571
572
|
// Singleton has different updatedAt = modified
|
|
572
573
|
const changedFields = getChangedFields(previewItem, productionItem);
|
|
573
574
|
if (changedFields.length === 0) {
|
|
@@ -592,7 +593,7 @@ export function createDataRoutes(config, storage) {
|
|
|
592
593
|
// Find added and modified items
|
|
593
594
|
for (const [id, previewItem] of Object.entries(previewCollection)) {
|
|
594
595
|
const productionItem = productionCollection[id];
|
|
595
|
-
if (!productionItem) {
|
|
596
|
+
if (!previewItem.isDraft && !productionItem) {
|
|
596
597
|
// Item exists in preview but not in production = added
|
|
597
598
|
added.push({
|
|
598
599
|
id,
|
|
@@ -600,7 +601,8 @@ export function createDataRoutes(config, storage) {
|
|
|
600
601
|
updatedAt: previewItem.updatedAt,
|
|
601
602
|
});
|
|
602
603
|
}
|
|
603
|
-
else if (
|
|
604
|
+
else if (productionItem &&
|
|
605
|
+
previewItem.updatedAt !== productionItem.updatedAt) {
|
|
604
606
|
// Item has different updatedAt = modified (not yet published)
|
|
605
607
|
const changedFields = getChangedFields(previewItem, productionItem);
|
|
606
608
|
if (changedFields.length === 0) {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { OpenAPIHono, z } from "@hono/zod-openapi";
|
|
2
|
+
import { EditorialVersionResponseSchema } from "@isardsat/editorial-common";
|
|
3
|
+
import { getCurrentAndLatestVersion } from "../lib/utils/version.js";
|
|
4
|
+
export function createVersionRoutes(hooks) {
|
|
5
|
+
const app = new OpenAPIHono();
|
|
6
|
+
app.openapi({
|
|
7
|
+
method: "get",
|
|
8
|
+
path: "/version",
|
|
9
|
+
summary: "Get Editorial version",
|
|
10
|
+
responses: {
|
|
11
|
+
200: {
|
|
12
|
+
content: {
|
|
13
|
+
"application/json": {
|
|
14
|
+
schema: EditorialVersionResponseSchema,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
description: "Editorial version",
|
|
18
|
+
},
|
|
19
|
+
500: {
|
|
20
|
+
content: {
|
|
21
|
+
"application/json": { schema: z.object({ error: z.string() }) },
|
|
22
|
+
},
|
|
23
|
+
description: "Server error",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
tags: ["Version"],
|
|
27
|
+
}, async (c) => {
|
|
28
|
+
try {
|
|
29
|
+
const { current, latest } = await getCurrentAndLatestVersion();
|
|
30
|
+
return c.json({ current, latest }, 200);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return c.json({ error: "Failed to fetch latest version from npm registry" }, 500);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
app.openapi({
|
|
37
|
+
method: "post",
|
|
38
|
+
path: "/version/upgrade",
|
|
39
|
+
summary: "Trigger Editorial upgrade hook",
|
|
40
|
+
description: "Triggers a placeholder hook to start upgrade flow. Replace hook implementation with real deployment/migration logic.",
|
|
41
|
+
responses: {
|
|
42
|
+
202: {
|
|
43
|
+
content: {
|
|
44
|
+
"application/json": {
|
|
45
|
+
schema: z.boolean(),
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
description: "Upgrade request accepted",
|
|
49
|
+
},
|
|
50
|
+
500: {
|
|
51
|
+
content: {
|
|
52
|
+
"application/json": { schema: z.object({ error: z.string() }) },
|
|
53
|
+
},
|
|
54
|
+
description: "Server error",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
tags: ["Version"],
|
|
58
|
+
}, async (c) => {
|
|
59
|
+
try {
|
|
60
|
+
await hooks.onUpgrade();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
console.error("Error executing onUpgrade script:", error);
|
|
64
|
+
return c.json({ error: "Failed upgrade Editorial version" }, 500);
|
|
65
|
+
}
|
|
66
|
+
return c.json(true, 202);
|
|
67
|
+
});
|
|
68
|
+
return app;
|
|
69
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isardsat/editorial-server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.21.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"jose": "^6.1.3",
|
|
16
16
|
"yaml": "^2.8.1",
|
|
17
17
|
"zod": "^4.1.11",
|
|
18
|
-
"@isardsat/editorial-admin": "^6.
|
|
19
|
-
"@isardsat/editorial-common": "^6.
|
|
18
|
+
"@isardsat/editorial-admin": "^6.21.0",
|
|
19
|
+
"@isardsat/editorial-common": "^6.21.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@tsconfig/node22": "^22.0.0",
|