@usecds/server 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/dist/core/content-report.d.ts +37 -0
- package/dist/core/content-report.js +306 -0
- package/dist/core/content-report.js.map +1 -0
- package/dist/core/content-types.d.ts +40 -0
- package/dist/core/content-types.js +27 -0
- package/dist/core/content-types.js.map +1 -0
- package/dist/core/jsonld.d.ts +33 -0
- package/dist/core/jsonld.js +94 -0
- package/dist/core/jsonld.js.map +1 -0
- package/dist/core/media-metadata.d.ts +20 -0
- package/dist/core/media-metadata.js +53 -0
- package/dist/core/media-metadata.js.map +1 -0
- package/dist/core/media-names.d.ts +9 -0
- package/dist/core/media-names.js +58 -0
- package/dist/core/media-names.js.map +1 -0
- package/dist/core/menu.d.ts +33 -0
- package/dist/core/menu.js +89 -0
- package/dist/core/menu.js.map +1 -0
- package/dist/core/publisher.d.ts +77 -0
- package/dist/core/publisher.js +263 -0
- package/dist/core/publisher.js.map +1 -0
- package/dist/core/report.d.ts +54 -0
- package/dist/core/report.js +132 -0
- package/dist/core/report.js.map +1 -0
- package/dist/core/settings.d.ts +12 -0
- package/dist/core/settings.js +40 -0
- package/dist/core/settings.js.map +1 -0
- package/dist/core/site.d.ts +37 -0
- package/dist/core/site.js +96 -0
- package/dist/core/site.js.map +1 -0
- package/dist/core/storage-report.d.ts +44 -0
- package/dist/core/storage-report.js +112 -0
- package/dist/core/storage-report.js.map +1 -0
- package/dist/core/targets.d.ts +63 -0
- package/dist/core/targets.js +213 -0
- package/dist/core/targets.js.map +1 -0
- package/dist/core/translations.d.ts +41 -0
- package/dist/core/translations.js +125 -0
- package/dist/core/translations.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/sources/fixture.d.ts +9 -0
- package/dist/sources/fixture.js +79 -0
- package/dist/sources/fixture.js.map +1 -0
- package/dist/storage/filesystem.d.ts +23 -0
- package/dist/storage/filesystem.js +125 -0
- package/dist/storage/filesystem.js.map +1 -0
- package/dist/types.d.ts +223 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +17 -0
- package/dist/utils.js.map +1 -0
- package/dist/validation.d.ts +23 -0
- package/dist/validation.js +102 -0
- package/dist/validation.js.map +1 -0
- package/package.json +28 -3
- package/schemas/v1/block.json +31 -0
- package/schemas/v1/channel-manifest.json +23 -0
- package/schemas/v1/collection.json +89 -0
- package/schemas/v1/jsonld.json +19 -0
- package/schemas/v1/language.json +12 -0
- package/schemas/v1/media-metadata.json +41 -0
- package/schemas/v1/menu.json +21 -0
- package/schemas/v1/page.json +12 -0
- package/schemas/v1/release-manifest.json +82 -0
- package/schemas/v1/route.json +24 -0
- package/schemas/v1/site.json +21 -0
- package/schemas/v1/target.json +98 -0
- package/README.md +0 -3
package/dist/utils.d.ts
ADDED
package/dist/utils.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
export function deterministicStringify(val) {
|
|
3
|
+
if (val === null)
|
|
4
|
+
return "null";
|
|
5
|
+
if (Array.isArray(val)) {
|
|
6
|
+
return "[" + val.map(v => deterministicStringify(v)).join(",") + "]";
|
|
7
|
+
}
|
|
8
|
+
if (typeof val === "object") {
|
|
9
|
+
const keys = Object.keys(val).sort();
|
|
10
|
+
return "{" + keys.map(k => JSON.stringify(k) + ":" + deterministicStringify(val[k])).join(",") + "}";
|
|
11
|
+
}
|
|
12
|
+
return JSON.stringify(val);
|
|
13
|
+
}
|
|
14
|
+
export function sha256(content) {
|
|
15
|
+
return crypto.createHash("sha256").update(content).digest("hex");
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,MAAM,UAAU,sBAAsB,CAAC,GAAQ;IAC7C,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAChC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACvB,OAAO,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACvE,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACrC,OAAO,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;IACvG,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,MAAM,CAAC,OAAwB;IAC7C,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare function validateChannelManifest(data: any): void;
|
|
2
|
+
export declare function validateReleaseManifest(data: any): void;
|
|
3
|
+
export declare function validateCollection(data: any): void;
|
|
4
|
+
export declare function validateTargetDefinition(data: any): void;
|
|
5
|
+
export declare function validateMediaMetadataItem(data: any): void;
|
|
6
|
+
export declare function validateJsonLdDefinition(data: any): void;
|
|
7
|
+
export declare const validateRouteItem: (data: any) => void;
|
|
8
|
+
export declare const validatePageItem: (data: any) => void;
|
|
9
|
+
export declare const validateBlockItem: (data: any) => void;
|
|
10
|
+
export declare const validateMenuItem: (data: any) => void;
|
|
11
|
+
export declare const validateSiteItem: (data: any) => void;
|
|
12
|
+
export declare const validateLanguageItem: (data: any) => void;
|
|
13
|
+
export interface ContentSchemaError {
|
|
14
|
+
keyword: string;
|
|
15
|
+
instancePath: string;
|
|
16
|
+
params: Record<string, any>;
|
|
17
|
+
message?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Compiles a JSON Schema declared in a target definition (requirements/recommendations).
|
|
21
|
+
* The returned function lists all violations; an empty list means valid.
|
|
22
|
+
*/
|
|
23
|
+
export declare function compileContentSchema(schema: object): (data: any) => ContentSchemaError[];
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import AjvModule from "ajv";
|
|
2
|
+
import addFormatsModule from "ajv-formats";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
const Ajv = AjvModule.default || AjvModule;
|
|
7
|
+
const addFormats = addFormatsModule.default || addFormatsModule;
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
// Helper to load schema files from the monorepo root
|
|
11
|
+
function loadSchema(filename) {
|
|
12
|
+
// We look for schemas first in ../../schemas/v1/ (development/test run)
|
|
13
|
+
// or inside a relative path depending on build outputs.
|
|
14
|
+
const possiblePaths = [
|
|
15
|
+
path.join(__dirname, "..", "..", "schemas", "v1", filename),
|
|
16
|
+
path.join(__dirname, "..", "schemas", "v1", filename),
|
|
17
|
+
path.join(__dirname, "schemas", "v1", filename)
|
|
18
|
+
];
|
|
19
|
+
for (const p of possiblePaths) {
|
|
20
|
+
if (fs.existsSync(p)) {
|
|
21
|
+
return JSON.parse(fs.readFileSync(p, "utf-8"));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
throw new Error(`Schema file not found: ${filename}`);
|
|
25
|
+
}
|
|
26
|
+
const channelManifestSchema = loadSchema("channel-manifest.json");
|
|
27
|
+
const releaseManifestSchema = loadSchema("release-manifest.json");
|
|
28
|
+
const collectionSchema = loadSchema("collection.json");
|
|
29
|
+
const targetSchema = loadSchema("target.json");
|
|
30
|
+
const mediaMetadataSchema = loadSchema("media-metadata.json");
|
|
31
|
+
const jsonLdSchema = loadSchema("jsonld.json");
|
|
32
|
+
const ajv = new Ajv({ allErrors: true });
|
|
33
|
+
addFormats(ajv);
|
|
34
|
+
const validateChannelManifestFn = ajv.compile(channelManifestSchema);
|
|
35
|
+
const validateReleaseManifestFn = ajv.compile(releaseManifestSchema);
|
|
36
|
+
const validateCollectionFn = ajv.compile(collectionSchema);
|
|
37
|
+
const validateTargetFn = ajv.compile(targetSchema);
|
|
38
|
+
const validateMediaMetadataFn = ajv.compile(mediaMetadataSchema);
|
|
39
|
+
const validateJsonLdFn = ajv.compile(jsonLdSchema);
|
|
40
|
+
// Target-provided schemas are often partial (e.g. only "required"), so strict-mode type hints are off
|
|
41
|
+
const contentAjv = new Ajv({ allErrors: true, strict: false });
|
|
42
|
+
addFormats(contentAjv);
|
|
43
|
+
export function validateChannelManifest(data) {
|
|
44
|
+
const valid = validateChannelManifestFn(data);
|
|
45
|
+
if (!valid) {
|
|
46
|
+
throw new Error(`Invalid Channel Manifest: ${ajv.errorsText(validateChannelManifestFn.errors)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export function validateReleaseManifest(data) {
|
|
50
|
+
const valid = validateReleaseManifestFn(data);
|
|
51
|
+
if (!valid) {
|
|
52
|
+
throw new Error(`Invalid Release Manifest: ${ajv.errorsText(validateReleaseManifestFn.errors)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function validateCollection(data) {
|
|
56
|
+
const valid = validateCollectionFn(data);
|
|
57
|
+
if (!valid) {
|
|
58
|
+
throw new Error(`Invalid Collection (${data.collection || "unknown"}): ${ajv.errorsText(validateCollectionFn.errors)}`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function validateTargetDefinition(data) {
|
|
62
|
+
const valid = validateTargetFn(data);
|
|
63
|
+
if (!valid) {
|
|
64
|
+
throw new Error(`Invalid Target Definition (${data?.id || "unknown"}): ${ajv.errorsText(validateTargetFn.errors)}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export function validateMediaMetadataItem(data) {
|
|
68
|
+
const valid = validateMediaMetadataFn(data);
|
|
69
|
+
if (!valid) {
|
|
70
|
+
throw new Error(`Invalid _media item (${data?.id || "unknown"}): ${ajv.errorsText(validateMediaMetadataFn.errors)}`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
export function validateJsonLdDefinition(data) {
|
|
74
|
+
const valid = validateJsonLdFn(data);
|
|
75
|
+
if (!valid) {
|
|
76
|
+
throw new Error(`Invalid _jsonld item (${data?.id || "unknown"}): ${ajv.errorsText(validateJsonLdFn.errors)}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
// Validators for items of the optional site-structure collections
|
|
80
|
+
function itemValidator(schemaFile, label) {
|
|
81
|
+
const validate = ajv.compile(loadSchema(schemaFile));
|
|
82
|
+
return (data) => {
|
|
83
|
+
if (!validate(data)) {
|
|
84
|
+
throw new Error(`Invalid ${label} item (${data?.id || "unknown"}): ${ajv.errorsText(validate.errors)}`);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export const validateRouteItem = itemValidator("route.json", "_routes");
|
|
89
|
+
export const validatePageItem = itemValidator("page.json", "_pages");
|
|
90
|
+
export const validateBlockItem = itemValidator("block.json", "_blocks");
|
|
91
|
+
export const validateMenuItem = itemValidator("menu.json", "_menu");
|
|
92
|
+
export const validateSiteItem = itemValidator("site.json", "_site");
|
|
93
|
+
export const validateLanguageItem = itemValidator("language.json", "_languages");
|
|
94
|
+
/**
|
|
95
|
+
* Compiles a JSON Schema declared in a target definition (requirements/recommendations).
|
|
96
|
+
* The returned function lists all violations; an empty list means valid.
|
|
97
|
+
*/
|
|
98
|
+
export function compileContentSchema(schema) {
|
|
99
|
+
const validate = contentAjv.compile(schema);
|
|
100
|
+
return (data) => (validate(data) ? [] : validate.errors);
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../src/validation.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,KAAK,CAAC;AAC5B,OAAO,gBAAgB,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,GAAG,GAAI,SAAiB,CAAC,OAAO,IAAI,SAAS,CAAC;AACpD,MAAM,UAAU,GAAI,gBAAwB,CAAC,OAAO,IAAI,gBAAgB,CAAC;AAEzE,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,qDAAqD;AACrD,SAAS,UAAU,CAAC,QAAgB;IAClC,wEAAwE;IACxE,wDAAwD;IACxD,MAAM,aAAa,GAAG;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;QAC3D,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;QACrD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,CAAC;KAChD,CAAC;IAEF,KAAK,MAAM,CAAC,IAAI,aAAa,EAA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CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC,eAAe,EAAE,YAAY,CAAC,CAAC;AASjF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAS,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAE,QAAQ,CAAC,MAA+B,CAAC,CAAC;AAC1F,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usecds/server",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"ajv": "^8.17.1",
|
|
9
|
+
"ajv-formats": "^3.0.1"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"typescript": "^5.5.4"
|
|
13
|
+
},
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/usecds/cds.git",
|
|
18
|
+
"directory": "server"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"schemas"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "tsc",
|
|
29
|
+
"clean": "rimraf dist"
|
|
30
|
+
}
|
|
6
31
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Block",
|
|
4
|
+
"description": "An item of the optional _blocks collection: one section of a page. CDS doesn't interpret type or settings.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"type": { "type": "string", "minLength": 1 },
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"description": "Explicit, ordered items",
|
|
12
|
+
"items": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": { "collection": { "type": "string" }, "id": { "type": "string" } },
|
|
15
|
+
"required": ["collection", "id"],
|
|
16
|
+
"additionalProperties": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"source": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"description": "All items of a collection, in its order",
|
|
22
|
+
"properties": { "collection": { "type": "string" } },
|
|
23
|
+
"required": ["collection"],
|
|
24
|
+
"additionalProperties": true
|
|
25
|
+
},
|
|
26
|
+
"links": { "type": "array", "items": { "type": "string" }, "description": "_menu link item ids" },
|
|
27
|
+
"settings": { "type": "object", "description": "Presentation settings for the renderer" }
|
|
28
|
+
},
|
|
29
|
+
"required": ["id", "type"],
|
|
30
|
+
"additionalProperties": true
|
|
31
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "ChannelManifest",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"schemaVersion": {
|
|
7
|
+
"type": "integer",
|
|
8
|
+
"const": 1
|
|
9
|
+
},
|
|
10
|
+
"channel": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"releaseId": {
|
|
14
|
+
"type": "string"
|
|
15
|
+
},
|
|
16
|
+
"updatedAt": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"format": "date-time"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["schemaVersion", "channel", "releaseId", "updatedAt"],
|
|
22
|
+
"additionalProperties": true
|
|
23
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Collection",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"schemaVersion": {
|
|
7
|
+
"type": "integer",
|
|
8
|
+
"const": 1
|
|
9
|
+
},
|
|
10
|
+
"collection": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"items": {
|
|
14
|
+
"type": "array",
|
|
15
|
+
"items": {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"properties": {
|
|
18
|
+
"id": { "type": "string" },
|
|
19
|
+
"key": { "type": "string" },
|
|
20
|
+
"translations": {
|
|
21
|
+
"type": "object",
|
|
22
|
+
"additionalProperties": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"media": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": { "type": "string" }
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"references": {
|
|
34
|
+
"type": "array",
|
|
35
|
+
"items": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"properties": {
|
|
38
|
+
"collection": { "type": "string" },
|
|
39
|
+
"id": { "type": "string" }
|
|
40
|
+
},
|
|
41
|
+
"required": ["collection", "id"],
|
|
42
|
+
"additionalProperties": true
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"media": {
|
|
46
|
+
"type": "array",
|
|
47
|
+
"items": {
|
|
48
|
+
"type": "string"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"_provenance": {
|
|
52
|
+
"type": "object",
|
|
53
|
+
"properties": {
|
|
54
|
+
"translations": {
|
|
55
|
+
"type": "object",
|
|
56
|
+
"additionalProperties": {
|
|
57
|
+
"type": "object",
|
|
58
|
+
"additionalProperties": { "$ref": "#/definitions/provenanceMarker" }
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"fields": {
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": { "$ref": "#/definitions/provenanceMarker" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"additionalProperties": true
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": ["id", "key", "translations"],
|
|
70
|
+
"additionalProperties": true
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"definitions": {
|
|
75
|
+
"provenanceMarker": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"properties": {
|
|
78
|
+
"status": { "enum": ["original", "human", "machine", "reviewed"] },
|
|
79
|
+
"from": { "type": "string" },
|
|
80
|
+
"sourceHash": { "type": "string" },
|
|
81
|
+
"model": { "type": "string" }
|
|
82
|
+
},
|
|
83
|
+
"required": ["status"],
|
|
84
|
+
"additionalProperties": true
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"required": ["schemaVersion", "collection", "items"],
|
|
88
|
+
"additionalProperties": true
|
|
89
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "JsonLdDefinition",
|
|
4
|
+
"description": "An item of the reserved _jsonld collection: how content items are described as schema.org JSON-LD.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"type": { "type": "string", "minLength": 1, "description": "schema.org type, e.g. Hotel" },
|
|
9
|
+
"appliesTo": { "type": "string", "description": "Collection this definition is the default for" },
|
|
10
|
+
"values": { "type": "object", "description": "Fixed values; localized ones go in translations[locale]" },
|
|
11
|
+
"map": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "schema.org property (dots for nesting, e.g. author.name) -> field path",
|
|
14
|
+
"additionalProperties": { "type": "string" }
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": ["id", "type"],
|
|
18
|
+
"additionalProperties": true
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Language",
|
|
4
|
+
"description": "An item of the optional _languages collection: a language the site is published in. The key is its locale code, as used in translations (en, de, en-GB); translations[locale].name is its name in each language.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"key": { "type": "string", "pattern": "^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$" }
|
|
9
|
+
},
|
|
10
|
+
"required": ["id", "key"],
|
|
11
|
+
"additionalProperties": true
|
|
12
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "MediaMetadataItem",
|
|
4
|
+
"description": "An item of the reserved _media collection. id = the media file's virtual path.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"name": { "type": "string", "description": "Readable output file name (slug); defaults to the original file name" },
|
|
9
|
+
"translations": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"additionalProperties": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"alt": { "type": ["string", "null"] },
|
|
15
|
+
"description": { "type": ["string", "null"] }
|
|
16
|
+
},
|
|
17
|
+
"additionalProperties": true
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"focalPoint": { "$ref": "#/definitions/point" },
|
|
21
|
+
"focalPoints": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"additionalProperties": { "$ref": "#/definitions/point" }
|
|
24
|
+
},
|
|
25
|
+
"width": { "type": "integer", "minimum": 1 },
|
|
26
|
+
"height": { "type": "integer", "minimum": 1 }
|
|
27
|
+
},
|
|
28
|
+
"definitions": {
|
|
29
|
+
"point": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"x": { "type": "number", "minimum": 0, "maximum": 1 },
|
|
33
|
+
"y": { "type": "number", "minimum": 0, "maximum": 1 }
|
|
34
|
+
},
|
|
35
|
+
"required": ["x", "y"],
|
|
36
|
+
"additionalProperties": true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": ["id"],
|
|
40
|
+
"additionalProperties": true
|
|
41
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "MenuItem",
|
|
4
|
+
"description": "An item of the optional _menu collection. Items no other item lists in children are menus (e.g. key main); entries carry a link and translations[locale].label.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"children": { "type": "array", "items": { "type": "string" }, "description": "_menu ids in order" },
|
|
9
|
+
"link": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"route": { "type": "string", "description": "_routes id" },
|
|
13
|
+
"block": { "type": "string", "description": "_blocks id on the route's page (anchor)" },
|
|
14
|
+
"url": { "type": "string", "description": "External URL" }
|
|
15
|
+
},
|
|
16
|
+
"additionalProperties": true
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["id"],
|
|
20
|
+
"additionalProperties": true
|
|
21
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Page",
|
|
4
|
+
"description": "An item of the optional _pages collection: page metadata (translations[locale].title / description) and its blocks in order.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"blocks": { "type": "array", "items": { "type": "string" } }
|
|
9
|
+
},
|
|
10
|
+
"required": ["id"],
|
|
11
|
+
"additionalProperties": true
|
|
12
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "ReleaseManifest",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"properties": {
|
|
6
|
+
"schemaVersion": {
|
|
7
|
+
"type": "integer",
|
|
8
|
+
"const": 1
|
|
9
|
+
},
|
|
10
|
+
"releaseId": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"createdAt": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"format": "date-time"
|
|
16
|
+
},
|
|
17
|
+
"sourceReadAt": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"format": "date-time",
|
|
20
|
+
"description": "When the publisher started reading the source: the content is at least this recent"
|
|
21
|
+
},
|
|
22
|
+
"collections": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"properties": {
|
|
27
|
+
"hash": { "type": "string" },
|
|
28
|
+
"itemCount": { "type": "integer", "minimum": 0 },
|
|
29
|
+
"size": { "type": "integer", "minimum": 0 }
|
|
30
|
+
},
|
|
31
|
+
"required": ["hash", "itemCount", "size"],
|
|
32
|
+
"additionalProperties": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"media": {
|
|
36
|
+
"type": "object",
|
|
37
|
+
"additionalProperties": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"hash": { "type": "string" },
|
|
41
|
+
"size": { "type": "integer", "minimum": 0 },
|
|
42
|
+
"mimeType": { "type": "string" }
|
|
43
|
+
},
|
|
44
|
+
"required": ["hash", "size", "mimeType"],
|
|
45
|
+
"additionalProperties": true
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"translations": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"properties": {
|
|
51
|
+
"sourceLocale": { "type": "string" },
|
|
52
|
+
"locales": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"additionalProperties": { "$ref": "#/definitions/translationCounts" }
|
|
55
|
+
},
|
|
56
|
+
"overall": { "$ref": "#/definitions/translationCounts" }
|
|
57
|
+
},
|
|
58
|
+
"required": ["sourceLocale", "locales", "overall"],
|
|
59
|
+
"additionalProperties": true
|
|
60
|
+
},
|
|
61
|
+
"targets": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"items": { "type": "string" }
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"definitions": {
|
|
67
|
+
"translationCounts": {
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {
|
|
70
|
+
"expected": { "type": "integer", "minimum": 0 },
|
|
71
|
+
"translated": { "type": "integer", "minimum": 0 },
|
|
72
|
+
"missing": { "type": "integer", "minimum": 0 },
|
|
73
|
+
"stale": { "type": "integer", "minimum": 0 },
|
|
74
|
+
"machine": { "type": "integer", "minimum": 0 }
|
|
75
|
+
},
|
|
76
|
+
"required": ["expected", "translated", "missing", "stale", "machine"],
|
|
77
|
+
"additionalProperties": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"required": ["schemaVersion", "releaseId", "createdAt", "collections", "media"],
|
|
81
|
+
"additionalProperties": true
|
|
82
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Route",
|
|
4
|
+
"description": "An item of the optional _routes collection: one URL, with its path per language in translations[locale].path.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"page": { "type": "string", "description": "_pages id this route shows" },
|
|
9
|
+
"redirect": { "type": "string", "description": "_routes id to redirect to, instead of a page" },
|
|
10
|
+
"status": { "enum": [301, 302], "description": "Redirect status (default 301)" },
|
|
11
|
+
"translations": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"additionalProperties": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"path": { "type": "string", "pattern": "^/" }
|
|
17
|
+
},
|
|
18
|
+
"additionalProperties": true
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"required": ["id"],
|
|
23
|
+
"additionalProperties": true
|
|
24
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"title": "Site",
|
|
4
|
+
"description": "The one item of the optional _site collection: the site's settings. translations[locale].siteName names the site in each language; defaultLanguage is a _languages key. Other fields (copyright, styles, social links) are the site's own.",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"id": { "type": "string", "minLength": 1 },
|
|
8
|
+
"defaultLanguage": { "type": "string", "minLength": 1, "description": "_languages key" },
|
|
9
|
+
"translations": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"minProperties": 1,
|
|
12
|
+
"additionalProperties": {
|
|
13
|
+
"type": "object",
|
|
14
|
+
"properties": { "siteName": { "type": "string", "minLength": 1 } },
|
|
15
|
+
"required": ["siteName"]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["id", "translations"],
|
|
20
|
+
"additionalProperties": true
|
|
21
|
+
}
|