@isardsat/editorial-server 6.6.4 → 6.8.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.
- package/dist/lib/schema.d.ts +13 -19
- package/dist/lib/schema.js +6 -6
- package/dist/lib/storage.d.ts +30 -26
- package/dist/routes/data.js +10 -1
- package/package.json +8 -8
package/dist/lib/schema.d.ts
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
export declare function createSchema(configDirectory: string): Promise<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
projectId: string;
|
|
15
|
-
storageBucket: string;
|
|
16
|
-
messagingSenderId: string;
|
|
17
|
-
dbUsersPath: string;
|
|
18
|
-
} | undefined;
|
|
19
|
-
}>;
|
|
1
|
+
export declare function createSchema(configDirectory: string): Promise<Record<string, {
|
|
2
|
+
displayName: string;
|
|
3
|
+
fields: Record<string, {
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
type: "string" | "number" | "boolean" | "url" | "date" | "datetime" | "markdown" | "color" | "select";
|
|
6
|
+
displayName: string;
|
|
7
|
+
optional: boolean;
|
|
8
|
+
displayExtra?: string | undefined;
|
|
9
|
+
placeholder?: string | undefined;
|
|
10
|
+
showInSummary?: boolean | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
singleton?: boolean | undefined;
|
|
13
|
+
}>>;
|
package/dist/lib/schema.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile } from
|
|
3
|
-
import { join } from
|
|
4
|
-
import { parse } from
|
|
1
|
+
import { EditorialSchemaSchema } from "@isardsat/editorial-common";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
import { parse } from "yaml";
|
|
5
5
|
export async function createSchema(configDirectory) {
|
|
6
|
-
const configFile = await readFile(join(configDirectory,
|
|
7
|
-
const config =
|
|
6
|
+
const configFile = await readFile(join(configDirectory, "schema.yaml"), "utf-8").then((value) => parse(value));
|
|
7
|
+
const config = EditorialSchemaSchema.parse(configFile);
|
|
8
8
|
return config;
|
|
9
9
|
}
|
package/dist/lib/storage.d.ts
CHANGED
|
@@ -2,14 +2,15 @@ import type { EditorialData, EditorialDataObjectWithType } from "@isardsat/edito
|
|
|
2
2
|
export declare function createStorage(dataDirectory: string): {
|
|
3
3
|
getSchema: () => Promise<Record<string, {
|
|
4
4
|
displayName: string;
|
|
5
|
-
fields: Record<string,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
fields: Record<string, {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
type: "string" | "number" | "boolean" | "url" | "date" | "datetime" | "markdown" | "color" | "select";
|
|
8
|
+
displayName: string;
|
|
9
|
+
optional: boolean;
|
|
10
|
+
displayExtra?: string | undefined;
|
|
11
|
+
placeholder?: string | undefined;
|
|
12
|
+
showInSummary?: boolean | undefined;
|
|
13
|
+
}>;
|
|
13
14
|
singleton?: boolean | undefined;
|
|
14
15
|
}>>;
|
|
15
16
|
getContent: ({ production, }: {
|
|
@@ -17,24 +18,27 @@ export declare function createStorage(dataDirectory: string): {
|
|
|
17
18
|
}) => Promise<EditorialData>;
|
|
18
19
|
getLocalisationMessages: (langCode: string) => Promise<any>;
|
|
19
20
|
saveLocalisationMessages: (messages: any) => Promise<boolean>;
|
|
20
|
-
createItem: (item: EditorialDataObjectWithType) => Promise<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
21
|
+
createItem: (item: EditorialDataObjectWithType) => Promise<{
|
|
22
|
+
[x: string]: unknown;
|
|
23
|
+
id: string;
|
|
24
|
+
isDraft: boolean;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
updatedAt: string;
|
|
27
|
+
}>;
|
|
28
|
+
updateItem: (item: EditorialDataObjectWithType) => Promise<{
|
|
29
|
+
[x: string]: unknown;
|
|
30
|
+
id: string;
|
|
31
|
+
isDraft: boolean;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
updatedAt: string;
|
|
34
|
+
}>;
|
|
35
|
+
deleteItem: (item: EditorialDataObjectWithType) => Promise<Record<string, Record<string, {
|
|
36
|
+
[x: string]: unknown;
|
|
37
|
+
id: string;
|
|
38
|
+
isDraft: boolean;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}>>>;
|
|
38
42
|
saveContent: ({ production }: {
|
|
39
43
|
production?: boolean;
|
|
40
44
|
}) => Promise<boolean>;
|
package/dist/routes/data.js
CHANGED
|
@@ -131,6 +131,9 @@ export function createDataRoutes(config, storage) {
|
|
|
131
131
|
});
|
|
132
132
|
const schema = await cache.getSchema(storage);
|
|
133
133
|
const collection = content[itemType];
|
|
134
|
+
if (!collection && schema[itemType]) {
|
|
135
|
+
return c.json({});
|
|
136
|
+
}
|
|
134
137
|
if (!collection) {
|
|
135
138
|
return c.notFound();
|
|
136
139
|
}
|
|
@@ -178,11 +181,17 @@ export function createDataRoutes(config, storage) {
|
|
|
178
181
|
},
|
|
179
182
|
description: "Get object ids by type",
|
|
180
183
|
},
|
|
184
|
+
404: {
|
|
185
|
+
description: "Item not found",
|
|
186
|
+
},
|
|
181
187
|
},
|
|
182
188
|
}), async (c) => {
|
|
183
189
|
const { itemType } = c.req.valid("param");
|
|
184
190
|
const { preview } = c.req.valid("query");
|
|
185
191
|
const content = await cache.getContent(storage, { production: !preview });
|
|
192
|
+
if (!content[itemType]) {
|
|
193
|
+
return c.notFound();
|
|
194
|
+
}
|
|
186
195
|
return c.json(Object.keys(content[itemType]));
|
|
187
196
|
});
|
|
188
197
|
app.openapi(createRoute({
|
|
@@ -325,7 +334,7 @@ export function createDataRoutes(config, storage) {
|
|
|
325
334
|
200: {
|
|
326
335
|
content: {
|
|
327
336
|
"application/json": {
|
|
328
|
-
schema:
|
|
337
|
+
schema: EditorialDataItemSchema,
|
|
329
338
|
},
|
|
330
339
|
},
|
|
331
340
|
description: "Update object",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isardsat/editorial-server",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@hono/node-server": "^1.
|
|
11
|
+
"@hono/node-server": "^1.19.4",
|
|
12
12
|
"@hono/swagger-ui": "^0.5.0",
|
|
13
|
-
"@hono/zod-openapi": "^
|
|
14
|
-
"hono": "^4.
|
|
15
|
-
"yaml": "^2.
|
|
16
|
-
"zod": "^
|
|
17
|
-
"@isardsat/editorial-admin": "^6.
|
|
18
|
-
"@isardsat/editorial-common": "^6.
|
|
13
|
+
"@hono/zod-openapi": "^1.1.3",
|
|
14
|
+
"hono": "^4.9.8",
|
|
15
|
+
"yaml": "^2.8.1",
|
|
16
|
+
"zod": "^4.1.11",
|
|
17
|
+
"@isardsat/editorial-admin": "^6.8.0",
|
|
18
|
+
"@isardsat/editorial-common": "^6.8.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@tsconfig/node22": "^22.0.0",
|