Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/studio/src/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@
"missingTheme": "Themen: {theme} fehlt.",
"missingContact": "Kontakt: Der der Bibliothek, {contact}, ist nicht angegeben. Eine Veröffentlichung für die Bibliothek nennt ihn, keine E-Mail-Adresse.",
"emailNamed": "Nennt eine E-Mail-Adresse: Eine Veröffentlichung für die Bibliothek nennt keine E-Mail-Adresse, nur den Kontakt der Bibliothek.",
"contactAmbiguous": "Kontakt: Nennt mehr als einen Kontakt oder einen Kontakt mit mehr als einer Webseite, sodass Lernende keinen haben, an den sie einen Fehler melden können. Gib den Kontakt erneut ein, um einen zu behalten.",
"required": "{field}: noch nicht angegeben.",
"previousUnread": "Die Ausgabe, auf die sie folgt, {previous}, konnte nicht gelesen werden, daher wird nichts mit ihr verglichen. Prüfe später noch einmal.",
"libraryUnread": "Der Index der Bibliothek konnte nicht gelesen werden, daher wird der Platz des Entwurfs in der Bibliothek nicht geprüft. Prüfe später noch einmal.",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@
"missingTheme": "Themes: {theme} is missing.",
"missingContact": "Contact: the library's, {contact}, is not stated. A release for the library names it, not an email.",
"emailNamed": "Names an email: a release for the library names no one's email, only the library's contact.",
"contactAmbiguous": "Contact: names more than one contact, or a contact with more than one web page, so learners get none to report a mistake to. Enter the contact again to keep one.",
"required": "{field}: not stated yet.",
"previousUnread": "The release it follows, {previous}, could not be read, so nothing is checked against it. Check again later.",
"libraryUnread": "The library's index could not be read, so the draft's place in the library is not checked. Check again later.",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/i18n/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@
"missingTheme": "Temas: falta {theme}.",
"missingContact": "Contacto: no se indica el de la biblioteca, {contact}. Una publicación para la biblioteca lo indica, no un correo electrónico.",
"emailNamed": "Indica un correo electrónico: una publicación para la biblioteca no indica el correo de nadie, solo el contacto de la biblioteca.",
"contactAmbiguous": "Contacto: indica más de un contacto, o un contacto con más de una página web, así que los estudiantes no tienen ninguno al que informar de un error. Vuelve a escribir el contacto para quedarte con uno.",
"required": "{field}: aún no se ha indicado.",
"previousUnread": "No se pudo leer la publicación a la que sigue, {previous}, así que no se comprueba nada con ella. Vuelve a comprobarlo más tarde.",
"libraryUnread": "No se pudo leer el índice de la biblioteca, así que no se comprueba la ubicación del borrador en la biblioteca. Vuelve a comprobarlo más tarde.",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/i18n/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,7 @@
"missingTheme": "Thèmes : {theme} est manquant.",
"missingContact": "Contact : celui de la bibliothèque, {contact}, n'est pas indiqué. Une publication pour la bibliothèque l'indique, pas une adresse e-mail.",
"emailNamed": "Indique une adresse e-mail : une publication pour la bibliothèque n'indique l'adresse e-mail de personne, seulement le contact de la bibliothèque.",
"contactAmbiguous": "Contact : indique plus d’un contact, ou un contact avec plus d’une page web, si bien que les apprenants n’en ont aucun à qui signaler une erreur. Saisissez de nouveau le contact pour n’en garder qu’un.",
"required": "{field} : à renseigner.",
"previousUnread": "Impossible de lire la publication qu’elle suit, {previous} : rien n’est donc vérifié par rapport à elle. Vérifiez à nouveau plus tard.",
"libraryUnread": "Impossible de lire l’index de la bibliothèque : la place du brouillon dans la bibliothèque n’est donc pas vérifiée. Vérifiez à nouveau plus tard.",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/i18n/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@
"missingTheme": "주제: {theme}이(가) 없어요.",
"missingContact": "연락처: 라이브러리 연락처 {contact}이(가) 없어요. 라이브러리용 릴리스는 이메일이 아니라 이 연락처를 적어요.",
"emailNamed": "이메일이 있어요: 라이브러리용 릴리스에는 누구의 이메일도 넣지 않고 라이브러리 연락처만 적어요.",
"contactAmbiguous": "연락처: 연락처가 둘 이상이거나 웹 페이지가 둘 이상인 연락처가 있어서, 학습자에게는 실수를 알릴 연락처가 없어요. 하나만 남기려면 연락처를 다시 입력하세요.",
"required": "{field}: 아직 지정되지 않았어요.",
"previousUnread": "이어받는 이전 릴리스 {previous}을(를) 읽을 수 없어서, 그에 대해서는 아무것도 검사하지 않았어요. 나중에 다시 검사해 주세요.",
"libraryUnread": "덱 라이브러리 색인을 읽을 수 없어서, 덱 라이브러리에서 초안의 위치는 검사하지 않았어요. 나중에 다시 검사해 주세요.",
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/i18n/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -1238,6 +1238,7 @@
"missingTheme": "Teman: saknar {theme}.",
"missingContact": "Kontakt: bibliotekets, {contact}, anges inte. En utgåva för biblioteket anger den, inte en e-postadress.",
"emailNamed": "Anger en e-postadress: en utgåva för biblioteket anger ingens e-postadress, bara bibliotekets kontakt.",
"contactAmbiguous": "Kontakt: anger mer än en kontakt, eller en kontakt med mer än en webbsida, så elever får ingen att rapportera ett fel till. Ange kontakten igen för att behålla en.",
"required": "{field}: inte angivet än.",
"previousUnread": "Utgåvan den följer, {previous}, kunde inte läsas, så inget kontrolleras mot den. Kontrollera igen senare.",
"libraryUnread": "Bibliotekets index kunde inte läsas, så utkastets plats i biblioteket kontrolleras inte. Kontrollera igen senare.",
Expand Down
3 changes: 3 additions & 0 deletions apps/studio/src/ui/problemText.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,9 @@ describe("problemMessage", () => {
expect(say({ code: "emailNamed", params: {} })).toBe(
"Names an email: a release for the library names no one's email, only the library's contact.",
);
expect(say({ code: "contactAmbiguous", params: {} })).toBe(
"Contact: names more than one contact, or a contact with more than one web page, so learners get none to report a mistake to. Enter the contact again to keep one.",
);
expect(say({ code: "required", params: {} }, `${DCTERMS}publisher`)).toBe(
"Publisher: not stated yet.",
);
Expand Down
1 change: 1 addition & 0 deletions apps/studio/src/ui/problemText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ export function problemMessage(
case "missingContact":
return t(key, { contact: problem.params.contact });
case "emailNamed":
case "contactAmbiguous":
return t(key);
case "required":
return t(key, { field });
Expand Down
8 changes: 6 additions & 2 deletions docs/deck-library.md
Original file line number Diff line number Diff line change
Expand Up @@ -1340,11 +1340,15 @@ reported (`ReportPlace`):
no dropdown from the query, so "What is it" is left to the learner.
- **A release from a link** leads to the web page its contact names
(`dcat:contactPoint`'s `vcard:hasURL`, read with the release as
`LibraryDeckContent.contact`), unfilled. The release names this page
`LibraryDeckContent.contact`), unfilled. That's the one contact
point, named or blank, with one web page, as the Studio reads it
([studio.md](studio.md#the-releases-metadata-and-provenance)); a
release with more than one point, or a point with more than one web
page, names no contact. The release names this page
itself, so the link follows it as a release's other links are
followed (`DataLink`, [Safety](markdown.md#safety)): http(s) with no
`user@` before the host, and the host shown beside the link. With
none, only an email, or an address that rule refuses, there's no link
no contact, only an email, or an address that rule refuses, there's no link
(never the library's tracker).
- **A deck the learner wrote**, with no release, has no link, nor has
a Studio [trial](studio.md#the-trial) (`createTrialUseCases`).
12 changes: 11 additions & 1 deletion docs/studio.md
Original file line number Diff line number Diff line change
Expand Up @@ -2069,6 +2069,11 @@ becomes: the rules `npm run library:check` runs on `decks/`
a series, a distribution, the theme EDUC, and each chapter's and
step's fields the draft shapes relax;
- the policy's curation (`curationProblems`);
- its one contact, in either policy (`contactPointProblems`): a
warning of more than one contact point, or a point with more than
one web page (`contactAmbiguous`). Learners read such a release as
naming no contact, so **Report a mistake** has no page to lead to
([deck-library.md](deck-library.md#reporting-a-mistake));
- how the release says it was made (`provenanceProblems`,
[below](#what-the-check-asks-of-a-releases-provenance));
- the draft's series (the pod policy only; `ownSeriesProblems` in
Expand Down Expand Up @@ -2360,7 +2365,12 @@ the library's releases are
the release's one `dcat:contactPoint`, `#contact`, a `vcard:Kind`
with that `vcard:hasURL` ([deck-library.md](deck-library.md#contact)).
It's saved once it's an http(s) address, and the contact it
replaces goes with what it stated. **Use the library's contact**
replaces goes with what it stated, every contact point the release
named. The field reads the contact as learners do (`contactOf`):
the one contact point, named or blank, with one web page. A release
that names more than one contact point, or a point with more than
one web page, names no contact, and the field is empty; the release
check warns of it (`contactAmbiguous`). **Use the library's contact**
fills in `LIBRARY_CONTACT`
([curationRules.ts](../packages/domain/src/release/curationRules.ts)).
The app reads it to say where a mistake is reported
Expand Down
40 changes: 39 additions & 1 deletion packages/domain/src/release/curationRules.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { expect, it } from "vitest";
import { LOCALES } from "../locale";
import { growth } from "../testing/growth";
import { at, card, iri, model, RELEASE, text } from "../testing/releaseModel";
import { curationProblems, LIBRARY_CONTACT, podPolicy, repoPolicy } from "./curationRules";
import {
contactPointProblems,
curationProblems,
LIBRARY_CONTACT,
podPolicy,
repoPolicy,
} from "./curationRules";

const SM = "https://solid-memo.com/ns/vocab/v1.ttl#";
const EDUC = "http://publications.europa.eu/resource/authority/data-theme/EDUC";
Expand Down Expand Up @@ -112,6 +118,38 @@ it("asks the library's contact, a vcard:Kind, and no one's email", () => {
expect(found({ emails })).toHaveLength(emails.length);
});

it("warns of more than one contact point, or a point with more than one web page (GHSA-g8xv-c484-62vx)", () => {
const found = (contacts: ReturnType<typeof model>["contacts"]) =>
contactPointProblems(model({ contacts })).map(({ code, subject, field, severity }) => ({
code,
subject,
field,
severity,
}));
const ambiguous = [
{
code: "contactAmbiguous",
subject: RELEASE,
field: "http://www.w3.org/ns/dcat#contactPoint",
severity: "warning",
},
];
expect(found([])).toEqual([]);
expect(found([contact(LIBRARY_CONTACT)])).toEqual([]);
// A page that is text is no page learners follow.
expect(
found([{ ...contact(LIBRARY_CONTACT), urls: [iri(LIBRARY_CONTACT), text("x", "")] }]),
).toEqual([]);
expect(found([contact("https://example.com/other"), contact(LIBRARY_CONTACT)])).toEqual(
ambiguous,
);
expect(
found([
{ ...contact(LIBRARY_CONTACT), urls: [iri(LIBRARY_CONTACT), iri("https://x.example/")] },
]),
).toEqual(ambiguous);
});

it("asks a description of each picture in English and every language its card's text is in", () => {
const picture = "https://example.com/flag.svg";
const pictured = {
Expand Down
21 changes: 21 additions & 0 deletions packages/domain/src/release/curationRules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,27 @@ function pictureProblems(card: ReleaseCard): ReleaseProblem[] {
];
}

/**
* A release that names more than one contact point, or a point that
* names more than one web page, whatever the policy: the Studio and
* learners read it as naming no contact (`contactOf`), so "Report a
* mistake" has no page to lead to, and the creator is told, as the
* Contact field shows none. A warning: setting the contact again keeps
* one (GHSA-g8xv-c484-62vx).
*/
export function contactPointProblems(model: ReleaseModel): ReleaseProblem[] {
const pages = model.contacts[0]?.urls.filter((url) => url.kind === "iri") ?? [];
return model.contacts.length > 1 || pages.length > 1
? [
problem(
model.url,
{ code: "contactAmbiguous", params: {} },
{ field: `${DCAT_NS}contactPoint`, severity: "warning" },
),
]
: [];
}

/** A release's contact, unless it names `contact`, and each email it names. */
function contactProblems(model: ReleaseModel, contact: string): ReleaseProblem[] {
const named = model.contacts.some(
Expand Down
2 changes: 2 additions & 0 deletions packages/domain/src/release/problems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export type CurationProblem =
| { code: "missingContact"; params: { contact: string } }
/** An email (foaf:mbox) of the subject, which the policy asks no release to name. */
| { code: "emailNamed"; params: Record<string, never> }
/** More than one contact point (dcat:contactPoint), or a point with more than one web page (vcard:hasURL): learners read it as no contact (contactPointProblems). */
| { code: "contactAmbiguous"; params: Record<string, never> }
/** A source that does not say what it is, whose it is, or on what terms it was used. */
| { code: "sourceUndescribed"; params: { missing: SourceDetail[] } }
/** A source with more than one title, or a title or creator that is not plain text, which learners would read otherwise than the Studio shows it. */
Expand Down
28 changes: 28 additions & 0 deletions packages/domain/src/release/releaseCheck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,30 @@ describe("ruleProblems", () => {
});
});

describe("ruleProblems' contact", () => {
it("names, in a pod and the library, a release whose contact learners would read as none", () => {
const model = draftReleaseModel(courseDraft());
const point = (url: string) => ({
point: { kind: "iri" as const, value: `${model.url}#contact` },
types: [],
urls: [{ kind: "iri" as const, value: url }],
});
const two = { ...model, contacts: [point("https://a.example/"), point("https://b.example/")] };
for (const policy of ["pod", "library"] as const) {
expect(ruleProblems(two, policy).filter((p) => p.code === "contactAmbiguous")).toEqual([
{
code: "contactAmbiguous",
params: {},
subject: model.url,
field: `${DCAT}contactPoint`,
severity: "warning",
},
]);
}
expect(ruleProblems(model, "pod").map((p) => p.code)).not.toContain("contactAmbiguous");
});
});

describe("ruleProblems' growth", () => {
it("names a problem of each of many cards, each as long as a term may be, once, in time linear in them", () => {
// V8 hashes a string longer than 16,383 characters by its length
Expand Down Expand Up @@ -388,6 +412,10 @@ describe("problemTarget", () => {
screen: "release",
field: "contact",
});
expect(target(DRAFT, { field: `${DCAT}contactPoint`, code: "contactAmbiguous" })).toEqual({
screen: "release",
field: "contact",
});
expect(target(DRAFT, { field: `${DCTERMS}language` })).toEqual({
screen: "release",
field: "languages",
Expand Down
14 changes: 11 additions & 3 deletions packages/domain/src/release/releaseCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import type { CardTextPart } from "../deck.ts";
import { jsonPath, PathMap } from "../pathKeys.ts";
import { ownSeriesProblems } from "./continuityRules.ts";
import { courseProblems, readinessProblems } from "./courseRules.ts";
import { curationProblems, podPolicy, repoPolicy, type LibraryPolicy } from "./curationRules.ts";
import {
contactPointProblems,
curationProblems,
podPolicy,
repoPolicy,
type LibraryPolicy,
} from "./curationRules.ts";
import {
metadataProblems,
pathProblems,
Expand Down Expand Up @@ -80,14 +86,16 @@ function distinct(problems: readonly ReleaseProblem[]): ReleaseProblem[] {

/**
* The rules of a release read from its data alone: its course's, its
* readiness, the policy's curation, its provenance's, and in a pod its
* series, its own when it follows no release (ownSeriesProblems).
* readiness, the policy's curation, its one contact, its provenance's,
* and in a pod its series, its own when it follows no release
* (ownSeriesProblems).
*/
export function ruleProblems(model: ReleaseModel, policy: CheckPolicy): ReleaseProblem[] {
return distinct([
...courseProblems(model),
...readinessProblems(model),
...curationProblems(model, curationOf(policy)),
...contactPointProblems(model),
...provenanceProblems(model),
...(policy === "pod" ? ownSeriesProblems(model) : []),
]);
Expand Down
Loading
Loading