@usecds/server 0.0.0-stage → 0.1.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/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 +261 -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/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 +17 -0
- package/dist/index.js +18 -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 +21 -0
- package/dist/validation.js +100 -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/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/target.json +98 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CollectionItem, SourceMap } from "../types.js";
|
|
2
|
+
import { ResolvedTargets } from "./targets.js";
|
|
3
|
+
import { ItemLocales, TranslationReport } from "./translations.js";
|
|
4
|
+
export type IssueSeverity = "requirement" | "recommendation";
|
|
5
|
+
export interface ContentIssue {
|
|
6
|
+
severity: IssueSeverity;
|
|
7
|
+
target?: string;
|
|
8
|
+
issue: string;
|
|
9
|
+
message: string;
|
|
10
|
+
collection?: string;
|
|
11
|
+
id?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
field?: string;
|
|
14
|
+
length?: number;
|
|
15
|
+
recommended?: string;
|
|
16
|
+
source?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface TargetResult {
|
|
19
|
+
satisfied: boolean;
|
|
20
|
+
requirements: number;
|
|
21
|
+
recommendations: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ContentReport {
|
|
24
|
+
targets: Record<string, TargetResult>;
|
|
25
|
+
issues: ContentIssue[];
|
|
26
|
+
warnings: string[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Checks every target's own declarations against the content. A named target is effectively
|
|
30
|
+
* the default plus its own rules, so evaluating each declaration once gives the merged result
|
|
31
|
+
* without duplicate issues.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildContentReport(collections: Record<string, CollectionItem[]>, translations: TranslationReport, resolved: ResolvedTargets, options?: {
|
|
34
|
+
sourceMap?: SourceMap;
|
|
35
|
+
itemLocales?: ItemLocales;
|
|
36
|
+
mediaPaths?: string[];
|
|
37
|
+
}): ContentReport;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { compileContentSchema } from "../validation.js";
|
|
2
|
+
import { deterministicStringify } from "../utils.js";
|
|
3
|
+
import { DEFAULT_TARGET_ID } from "./targets.js";
|
|
4
|
+
import { meaninglessNameReason, suggestMediaName } from "./media-names.js";
|
|
5
|
+
import { isJsonLdPathEmpty, jsonLdDefinitionFor, JSONLD_COLLECTION } from "./jsonld.js";
|
|
6
|
+
import { siteRecommendations } from "./site.js";
|
|
7
|
+
import { menuRecommendations } from "./menu.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checks every target's own declarations against the content. A named target is effectively
|
|
10
|
+
* the default plus its own rules, so evaluating each declaration once gives the merged result
|
|
11
|
+
* without duplicate issues.
|
|
12
|
+
*/
|
|
13
|
+
export function buildContentReport(collections, translations, resolved, options = {}) {
|
|
14
|
+
const { sourceMap, itemLocales } = options;
|
|
15
|
+
const allLocales = new Set();
|
|
16
|
+
for (const items of Object.values(collections)) {
|
|
17
|
+
items.forEach((item) => Object.keys(item.translations).forEach((l) => allLocales.add(l)));
|
|
18
|
+
}
|
|
19
|
+
const ctx = { collections, translations, sourceMap, allLocales: [...allLocales].sort(), itemLocales };
|
|
20
|
+
const report = { targets: {}, issues: [], warnings: [...resolved.warnings] };
|
|
21
|
+
for (const issue of translations.issues) {
|
|
22
|
+
report.issues.push({
|
|
23
|
+
severity: "recommendation",
|
|
24
|
+
issue: issue.issue === "missing" ? "untranslated" : "stale",
|
|
25
|
+
message: issue.issue === "missing"
|
|
26
|
+
? `${issue.field} is not translated to ${issue.locale}`
|
|
27
|
+
: `${issue.field} (${issue.locale}) is stale: the ${translations.sourceLocale} source changed after translation`,
|
|
28
|
+
collection: issue.collection,
|
|
29
|
+
id: issue.id,
|
|
30
|
+
locale: issue.locale,
|
|
31
|
+
field: issue.field,
|
|
32
|
+
source: sourceLink(ctx, issue.collection, issue.id)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
report.issues.push(...checkMediaNames(ctx, options.mediaPaths ?? []));
|
|
36
|
+
report.issues.push(...checkJsonLd(ctx));
|
|
37
|
+
for (const issue of [...siteRecommendations(collections), ...menuRecommendations(collections)]) {
|
|
38
|
+
report.issues.push({ severity: "recommendation", ...issue, source: sourceLink(ctx, issue.collection, issue.id) });
|
|
39
|
+
}
|
|
40
|
+
const defaultIssues = evaluateTarget(ctx, resolved.defaultTarget);
|
|
41
|
+
report.issues.push(...defaultIssues);
|
|
42
|
+
const defaultFailed = countBy(defaultIssues, "requirement");
|
|
43
|
+
report.targets[DEFAULT_TARGET_ID] = {
|
|
44
|
+
satisfied: defaultFailed === 0,
|
|
45
|
+
requirements: defaultFailed,
|
|
46
|
+
recommendations: countBy(defaultIssues, "recommendation")
|
|
47
|
+
};
|
|
48
|
+
for (const target of resolved.named) {
|
|
49
|
+
const issues = evaluateTarget(ctx, target);
|
|
50
|
+
report.issues.push(...issues);
|
|
51
|
+
const failed = countBy(issues, "requirement");
|
|
52
|
+
report.targets[target.id] = {
|
|
53
|
+
satisfied: failed === 0 && defaultFailed === 0,
|
|
54
|
+
requirements: failed,
|
|
55
|
+
recommendations: countBy(issues, "recommendation")
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return report;
|
|
59
|
+
}
|
|
60
|
+
// File names like IMG_2034.jpg or a UUID say nothing about the image; suggest a name from its alt text
|
|
61
|
+
function checkMediaNames(ctx, mediaPaths) {
|
|
62
|
+
const issues = [];
|
|
63
|
+
const sourceLocale = ctx.translations.sourceLocale;
|
|
64
|
+
for (const path of mediaPaths) {
|
|
65
|
+
const meta = ctx.collections._media?.find((m) => m.id === path);
|
|
66
|
+
const name = typeof meta?.name === "string" && meta.name ? meta.name : undefined;
|
|
67
|
+
const reason = meaninglessNameReason(name ?? path);
|
|
68
|
+
if (!reason)
|
|
69
|
+
continue;
|
|
70
|
+
const alts = meta ? [meta.translations[sourceLocale]?.alt, ...Object.values(meta.translations).map((t) => t?.alt)] : [];
|
|
71
|
+
const alt = alts.find((a) => typeof a === "string" && a.length > 0);
|
|
72
|
+
const suggestion = alt ? suggestMediaName(alt) : undefined;
|
|
73
|
+
const shown = name ?? path.split("/").pop();
|
|
74
|
+
issues.push({
|
|
75
|
+
severity: "recommendation",
|
|
76
|
+
issue: "meaningless-name",
|
|
77
|
+
message: `${name ? "_media name" : "File name"} "${shown}" doesn't describe the image (${reason}). Set a name in _media${suggestion ? `, e.g. "${suggestion}"` : ""}.`,
|
|
78
|
+
collection: "_media",
|
|
79
|
+
id: path,
|
|
80
|
+
field: "name",
|
|
81
|
+
...(suggestion ? { recommended: suggestion } : {}),
|
|
82
|
+
source: sourceLink(ctx, "_media", path)
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return issues;
|
|
86
|
+
}
|
|
87
|
+
// JSON-LD properties whose mapped field is empty for an item and locale
|
|
88
|
+
function checkJsonLd(ctx) {
|
|
89
|
+
const issues = [];
|
|
90
|
+
if (!ctx.collections[JSONLD_COLLECTION])
|
|
91
|
+
return issues;
|
|
92
|
+
for (const [collection, items] of Object.entries(ctx.collections)) {
|
|
93
|
+
if (collection === JSONLD_COLLECTION)
|
|
94
|
+
continue;
|
|
95
|
+
for (const item of items) {
|
|
96
|
+
const def = jsonLdDefinitionFor(ctx.collections, collection, item);
|
|
97
|
+
if (!def)
|
|
98
|
+
continue;
|
|
99
|
+
for (const locale of Object.keys(item.translations).sort()) {
|
|
100
|
+
for (const [property, path] of Object.entries(def.map ?? {})) {
|
|
101
|
+
if (!isJsonLdPathEmpty(ctx.collections, item, locale, path))
|
|
102
|
+
continue;
|
|
103
|
+
issues.push({
|
|
104
|
+
severity: "recommendation",
|
|
105
|
+
issue: "jsonld-empty",
|
|
106
|
+
message: `JSON-LD ${def.type}.${property} maps to ${path}, which is empty`,
|
|
107
|
+
collection,
|
|
108
|
+
id: item.id,
|
|
109
|
+
locale,
|
|
110
|
+
field: path,
|
|
111
|
+
source: sourceLink(ctx, collection, item.id)
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return issues;
|
|
118
|
+
}
|
|
119
|
+
function evaluateTarget(ctx, target) {
|
|
120
|
+
const issues = [];
|
|
121
|
+
const inScope = (collection) => !target.scope || target.scope.includes(collection);
|
|
122
|
+
const scoped = Object.keys(ctx.collections).filter(inScope);
|
|
123
|
+
const sourceLocale = ctx.translations.sourceLocale;
|
|
124
|
+
const requirement = (issue) => issues.push({ severity: "requirement", target: target.id, ...issue });
|
|
125
|
+
// Locales: presence, completeness and staleness within the target's scope
|
|
126
|
+
const required = target.locales?.required;
|
|
127
|
+
for (const locale of required ?? []) {
|
|
128
|
+
const present = scoped.some((c) => ctx.collections[c].some((item) => item.translations[locale]));
|
|
129
|
+
if (!present)
|
|
130
|
+
requirement({ issue: "missing-locale", locale, message: `Required locale ${locale} has no content` });
|
|
131
|
+
}
|
|
132
|
+
const thresholdLocales = (required ?? Object.keys(ctx.translations.locales)).filter((l) => l !== sourceLocale);
|
|
133
|
+
let stale = 0;
|
|
134
|
+
for (const locale of thresholdLocales) {
|
|
135
|
+
let expected = 0;
|
|
136
|
+
let translated = 0;
|
|
137
|
+
for (const c of scoped) {
|
|
138
|
+
const counts = ctx.translations.collections[c]?.[locale];
|
|
139
|
+
if (!counts)
|
|
140
|
+
continue;
|
|
141
|
+
expected += counts.expected;
|
|
142
|
+
translated += counts.translated;
|
|
143
|
+
stale += counts.stale;
|
|
144
|
+
}
|
|
145
|
+
const min = target.locales?.minCompleteness;
|
|
146
|
+
const completeness = expected === 0 ? 1 : translated / expected;
|
|
147
|
+
if (min !== undefined && completeness < min) {
|
|
148
|
+
requirement({
|
|
149
|
+
issue: "incomplete-locale",
|
|
150
|
+
locale,
|
|
151
|
+
message: `${locale} is ${percent(completeness)} translated, ${percent(min)} required`
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
const maxStale = target.locales?.maxStale;
|
|
156
|
+
if (maxStale !== undefined && stale > maxStale) {
|
|
157
|
+
requirement({ issue: "too-many-stale", message: `${stale} stale translations, at most ${maxStale} allowed` });
|
|
158
|
+
}
|
|
159
|
+
// Required collections and their schemas
|
|
160
|
+
const ruleLocales = required ?? [sourceLocale];
|
|
161
|
+
for (const [collection, rules] of Object.entries(target.collections ?? {})) {
|
|
162
|
+
const items = ctx.collections[collection];
|
|
163
|
+
if (!items) {
|
|
164
|
+
requirement({ issue: "missing-collection", collection, message: `Required collection ${collection} is missing` });
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
if (rules.minItems !== undefined && items.length < rules.minItems) {
|
|
168
|
+
requirement({
|
|
169
|
+
issue: "too-few-items",
|
|
170
|
+
collection,
|
|
171
|
+
message: `${collection} has ${items.length} items, at least ${rules.minItems} required`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
issues.push(...checkRules(ctx, target.id, "requirement", collection, items, rules, ruleLocales));
|
|
175
|
+
}
|
|
176
|
+
// Required named items
|
|
177
|
+
for (const { collection, key } of target.items ?? []) {
|
|
178
|
+
if (!ctx.collections[collection]?.some((item) => item.key === key)) {
|
|
179
|
+
requirement({ issue: "missing-item", collection, message: `Required item ${collection}/${key} is missing` });
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Recommendations apply to every locale in the content
|
|
183
|
+
for (const [collection, rules] of Object.entries(target.recommendations ?? {})) {
|
|
184
|
+
const items = ctx.collections[collection];
|
|
185
|
+
if (!items || !inScope(collection))
|
|
186
|
+
continue;
|
|
187
|
+
issues.push(...checkRules(ctx, target.id, "recommendation", collection, items, rules, ctx.allLocales));
|
|
188
|
+
}
|
|
189
|
+
return issues;
|
|
190
|
+
}
|
|
191
|
+
function checkRules(ctx, target, severity, collection, items, rules, locales) {
|
|
192
|
+
const issues = [];
|
|
193
|
+
const localized = rules.localized ? compiled(rules.localized) : undefined;
|
|
194
|
+
const fields = rules.fields ? compiled(rules.fields) : undefined;
|
|
195
|
+
for (const item of items) {
|
|
196
|
+
const base = { severity, target, collection, id: item.id, source: sourceLink(ctx, collection, item.id) };
|
|
197
|
+
const usedIn = ctx.itemLocales?.(collection, item);
|
|
198
|
+
if (localized) {
|
|
199
|
+
for (const locale of usedIn ? locales.filter((l) => usedIn.includes(l)) : locales) {
|
|
200
|
+
const data = withoutEmpty(item.translations[locale] ?? {});
|
|
201
|
+
for (const error of localized(data)) {
|
|
202
|
+
issues.push({ ...base, locale, ...describe(error, data, rules.localized) });
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (fields) {
|
|
207
|
+
const data = withoutEmpty(item);
|
|
208
|
+
for (const error of fields(data)) {
|
|
209
|
+
issues.push({ ...base, ...describe(error, data, rules.fields) });
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return dedupe(issues);
|
|
214
|
+
}
|
|
215
|
+
// Converts a JSON Schema violation into issue fields
|
|
216
|
+
function describe(error, data, schema) {
|
|
217
|
+
const parent = error.instancePath ? error.instancePath.slice(1).split("/") : [];
|
|
218
|
+
const fieldPath = error.keyword === "required" ? [...parent, error.params.missingProperty] : parent;
|
|
219
|
+
const field = fieldPath.join(".") || undefined;
|
|
220
|
+
const limits = field ? lengthLimits(schema, fieldPath[0]) : {};
|
|
221
|
+
const recommended = formatLimits(limits);
|
|
222
|
+
const value = fieldPath.reduce((v, k) => v?.[k], data);
|
|
223
|
+
const length = typeof value === "string" ? [...value].length : undefined;
|
|
224
|
+
const hint = recommended ? ` (recommended ${recommended})` : "";
|
|
225
|
+
switch (error.keyword) {
|
|
226
|
+
case "required":
|
|
227
|
+
return { issue: "missing", field, recommended, message: `${field} is missing${hint}` };
|
|
228
|
+
case "minLength":
|
|
229
|
+
return { issue: "too-short", field, length, recommended, message: `${field} is too short: ${length} characters${hint}` };
|
|
230
|
+
case "maxLength":
|
|
231
|
+
return { issue: "too-long", field, length, recommended, message: `${field} is too long: ${length} characters${hint}` };
|
|
232
|
+
default:
|
|
233
|
+
return { issue: "invalid", field, message: `${field ?? "item"} ${error.message ?? "is invalid"}` };
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// minLength/maxLength declared for a top-level property, across allOf branches (stricter wins)
|
|
237
|
+
function lengthLimits(schema, property) {
|
|
238
|
+
const result = {};
|
|
239
|
+
const visit = (s) => {
|
|
240
|
+
if (!s || typeof s !== "object")
|
|
241
|
+
return;
|
|
242
|
+
const prop = s.properties?.[property];
|
|
243
|
+
if (prop?.minLength !== undefined)
|
|
244
|
+
result.min = Math.max(result.min ?? 0, prop.minLength);
|
|
245
|
+
if (prop?.maxLength !== undefined)
|
|
246
|
+
result.max = Math.min(result.max ?? Infinity, prop.maxLength);
|
|
247
|
+
(s.allOf ?? []).forEach(visit);
|
|
248
|
+
};
|
|
249
|
+
visit(schema);
|
|
250
|
+
return result;
|
|
251
|
+
}
|
|
252
|
+
function formatLimits({ min, max }) {
|
|
253
|
+
if (min !== undefined && max !== undefined)
|
|
254
|
+
return `${min}–${max} characters`;
|
|
255
|
+
if (max !== undefined)
|
|
256
|
+
return `≤${max} characters`;
|
|
257
|
+
if (min !== undefined)
|
|
258
|
+
return `≥${min} characters`;
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
function sourceLink(ctx, collection, id) {
|
|
262
|
+
const map = ctx.sourceMap;
|
|
263
|
+
if (!map)
|
|
264
|
+
return undefined;
|
|
265
|
+
let adapter;
|
|
266
|
+
let ref;
|
|
267
|
+
if (collection === "_media" && map.media[id]) {
|
|
268
|
+
ref = map.media[id];
|
|
269
|
+
adapter = map.media[id].adapter;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
ref = map.collections[collection]?.items[id];
|
|
273
|
+
adapter = map.collections[collection]?.source?.adapter;
|
|
274
|
+
}
|
|
275
|
+
if (!ref?.path)
|
|
276
|
+
return undefined;
|
|
277
|
+
const baseUrl = adapter ? map.sources[adapter]?.baseUrl : undefined;
|
|
278
|
+
return baseUrl ? baseUrl.replace(/\/$/, "") + ref.path : ref.path;
|
|
279
|
+
}
|
|
280
|
+
// Empty values count as missing, so "required" catches them (consistent with translation completeness)
|
|
281
|
+
function withoutEmpty(obj) {
|
|
282
|
+
return Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined && v !== null && v !== ""));
|
|
283
|
+
}
|
|
284
|
+
const schemaCache = new Map();
|
|
285
|
+
function compiled(schema) {
|
|
286
|
+
const key = deterministicStringify(schema);
|
|
287
|
+
let fn = schemaCache.get(key);
|
|
288
|
+
if (!fn) {
|
|
289
|
+
fn = compileContentSchema(schema);
|
|
290
|
+
schemaCache.set(key, fn);
|
|
291
|
+
}
|
|
292
|
+
return fn;
|
|
293
|
+
}
|
|
294
|
+
function dedupe(issues) {
|
|
295
|
+
const seen = new Set();
|
|
296
|
+
return issues.filter((i) => {
|
|
297
|
+
const key = [i.target, i.collection, i.id, i.locale, i.field, i.issue].join("\u0000");
|
|
298
|
+
if (seen.has(key))
|
|
299
|
+
return false;
|
|
300
|
+
seen.add(key);
|
|
301
|
+
return true;
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const countBy = (issues, severity) => issues.filter((i) => i.severity === severity).length;
|
|
305
|
+
const percent = (x) => `${Math.floor(x * 1000) / 10}%`;
|
|
306
|
+
//# sourceMappingURL=content-report.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-report.js","sourceRoot":"","sources":["../../src/core/content-report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAsB,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAmB,iBAAiB,EAAqC,MAAM,cAAc,CAAC;AAErG,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAsChD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAChC,WAA6C,EAC7C,YAA+B,EAC/B,QAAyB,EACzB,UAII,EAAE;IAEN,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAC3C,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/C,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,MAAM,GAAG,GAAY,EAAE,WAAW,EAAE,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,GAAG,UAA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GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACtF,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACd,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,OAAO,GAAG,CAAC,MAAsB,EAAE,QAAuB,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,MAAM,CAAC;AAC1H,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { TargetDefinition } from "./targets.js";
|
|
2
|
+
/**
|
|
3
|
+
* A content type: a collection a consumer (e.g. a template) declares it needs, independent of the
|
|
4
|
+
* CMS. Source adapters map the CMS's records to it; the declaration also yields the publish checks
|
|
5
|
+
* (contentTypeTarget), so content that doesn't fit fails the build or shows up in the report.
|
|
6
|
+
*
|
|
7
|
+
* Field kinds and where their values go in a CDS item:
|
|
8
|
+
* text, richText translations[locale][field] (text the content is written in; richText is HTML)
|
|
9
|
+
* string, number, boolean, date, select, status, sort, slug
|
|
10
|
+
* item[field] (values; slug also becomes the item's key)
|
|
11
|
+
* file item[field] = media path
|
|
12
|
+
* reference item[field] = id of an item in `related`
|
|
13
|
+
* references item[field] = ids of items in `related`, in order (a one-to-many's children)
|
|
14
|
+
*/
|
|
15
|
+
export type ContentFieldKind = "text" | "richText" | "string" | "number" | "boolean" | "date" | "select" | "status" | "sort" | "slug" | "file" | "reference" | "references";
|
|
16
|
+
export interface ContentField {
|
|
17
|
+
field: string;
|
|
18
|
+
kind: ContentFieldKind;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/** Allowed values of a select */
|
|
21
|
+
options?: string[];
|
|
22
|
+
/** The content type a reference points to */
|
|
23
|
+
related?: string;
|
|
24
|
+
/** For references: the field on the related items that points back (one-to-many) */
|
|
25
|
+
via?: string;
|
|
26
|
+
label?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ContentType {
|
|
29
|
+
collection: string;
|
|
30
|
+
fields: ContentField[];
|
|
31
|
+
/** Where the declaration comes from, for messages (e.g. "template hotelplatform, bundle integrations") */
|
|
32
|
+
declaredBy?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const TEXT_KINDS: ReadonlySet<ContentFieldKind>;
|
|
35
|
+
/**
|
|
36
|
+
* The publish checks a set of content types implies, as a target: each declared collection's
|
|
37
|
+
* required fields (texts in the source locale, values on the item) and select values. A collection
|
|
38
|
+
* without items passes: declaring a type doesn't require content for it.
|
|
39
|
+
*/
|
|
40
|
+
export declare function contentTypeTarget(types: ContentType[], id?: string): TargetDefinition;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const TEXT_KINDS = new Set(["text", "richText"]);
|
|
2
|
+
/**
|
|
3
|
+
* The publish checks a set of content types implies, as a target: each declared collection's
|
|
4
|
+
* required fields (texts in the source locale, values on the item) and select values. A collection
|
|
5
|
+
* without items passes: declaring a type doesn't require content for it.
|
|
6
|
+
*/
|
|
7
|
+
export function contentTypeTarget(types, id = "content-types") {
|
|
8
|
+
const collections = {};
|
|
9
|
+
for (const type of types) {
|
|
10
|
+
const required = (kinds) => type.fields.filter((f) => f.required && kinds(f.kind)).map((f) => f.field);
|
|
11
|
+
const localized = required((k) => TEXT_KINDS.has(k));
|
|
12
|
+
const fields = required((k) => !TEXT_KINDS.has(k));
|
|
13
|
+
const enums = Object.fromEntries(type.fields
|
|
14
|
+
.filter((f) => f.kind === "select" && f.options?.length)
|
|
15
|
+
.map((f) => [f.field, { enum: [...f.options, null] }]));
|
|
16
|
+
if (!localized.length && !fields.length && !Object.keys(enums).length)
|
|
17
|
+
continue;
|
|
18
|
+
collections[type.collection] = {
|
|
19
|
+
...(localized.length ? { localized: { type: "object", required: localized } } : {}),
|
|
20
|
+
...(fields.length || Object.keys(enums).length
|
|
21
|
+
? { fields: { type: "object", ...(fields.length ? { required: fields } : {}), ...(Object.keys(enums).length ? { properties: enums } : {}) } }
|
|
22
|
+
: {})
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return { id, scope: Object.keys(collections), collections };
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=content-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.js","sourceRoot":"","sources":["../../src/core/content-types.ts"],"names":[],"mappings":"AAkDA,MAAM,CAAC,MAAM,UAAU,GAAkC,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;AAEvF;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAoB,EAAE,EAAE,GAAG,eAAe;IAC1E,MAAM,WAAW,GAAiD,EAAE,CAAC;IACrE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAG,CAAC,KAAuC,EAAE,EAAE,CAC3D,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC7E,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC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