Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter adjustements #425

Merged
merged 1 commit into from
Nov 3, 2023
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
69 changes: 40 additions & 29 deletions src/1edtech/privacy.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
// @ts-check
// Module 1edtech/privacy
// Handle the privacy section properly.
import { getIntlData } from "../core/utils.js";
import privacyTmpl from "./templates/privacyImplicationsTemplate.js";
import confLevelTmpl from "./templates/confidentialityLevelTemplate.js";
import { getIntlData } from "../core/utils.js";
import { html } from "../core/import-maps.js";
import localizationStrings from "./translations/1edtech.js";
import privacyTmpl from "./templates/privacyImplicationsTemplate.js";

export const name = "1edtech/privacy";

const l10n = getIntlData(localizationStrings);
const privacyImplicationsKeys = ["ACCESSIBILITY",
"ANALYTICS",
"CONTAINER",
"CREDENTIALS",
"CREDENTIALSIDREF",
"DEMOGRAPHICS",
"EXTENSION",
"FINANCIAL",
"IDENTIFIER",
"IDENTIFIERREF",
"INSURANCE",
"LEGAL",
"MEDICAL",
"NA",
"OTHER",
"QUALIFICATION",
"PERSONAL",
"SOURCEDID",
"SOURCEDIDREF"];
const confidentialityLevelKeys = ["UNRESTRICTED",
"NORMAL",
"RESTRICTED",
"VERYRESTRICTED"];
const privacyImplicationsKeys = [
"ACCESSIBILITY",
"ANALYTICS",
"CONTAINER",
"CREDENTIALS",
"CREDENTIALSIDREF",
"DEMOGRAPHICS",
"EXTENSION",
"FINANCIAL",
"IDENTIFIER",
"IDENTIFIERREF",
"INSURANCE",
"LEGAL",
"MEDICAL",
"NA",
"OTHER",
"QUALIFICATION",
"PERSONAL",
"SOURCEDID",
"SOURCEDIDREF",
];

const confidentialityLevelKeys = [
"UNRESTRICTED",
"NORMAL",
"RESTRICTED",
"VERYRESTRICTED",
];

/**
* @param {string} title
* @returns {HTMLElement}
Expand All @@ -41,7 +47,7 @@ function createSection(title, header) {
return html`<section>
<h3>${title}</h3>
<p>${header}</p>
</section>`
</section>`;
}

/**
Expand All @@ -63,14 +69,19 @@ export async function run(conf) {

privacySection.classList.add("appendix");

const piSection = createSection(l10n.privacy_implications, l10n.privacy_implications_paragraph);
const piSection = createSection(
l10n.privacy_implications,
l10n.privacy_implications_paragraph
);
piSection.appendChild(privacyTmpl(privacyImplicationsKeys, l10n));
privacySection.appendChild(piSection);

const confSection = createSection(l10n.confidentiality_level, l10n.confidentiality_level_paragram);
const confSection = createSection(
l10n.confidentiality_level,
l10n.confidentiality_level_paragram
);
confSection.appendChild(confLevelTmpl(confidentialityLevelKeys, l10n));
privacySection.appendChild(confSection);

document.body.appendChild(privacySection);

}
2 changes: 1 addition & 1 deletion src/1edtech/templates/classDiagramTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { html, mermaidModule } from "../../core/import-maps.js";
*/
export default async (index, diagram, title) => {
// dinamycally import mermaid to avoid increase of size of the library
const { default: mermaid } = await import(mermaidModule);
const { default: mermaid } = await import(mermaidModule);
mermaid.initialize({ startOnLoad: false });
const { svg } = await mermaid.render(`class-diagram-${index}`, diagram);
const cleanedSvg = svg.trim().replace(/height="[0-9]*"/, "");
Expand Down
16 changes: 13 additions & 3 deletions src/1edtech/templates/classTemplate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
// @ts-check
import { renderIssue, renderNote, renderPrivacyImplicationDoc } from "./templateUtils.js";
import {
renderIssue,
renderNote,
renderPrivacyImplicationDoc,
} from "./templateUtils.js";
import { html } from "../../core/import-maps.js";

/**
Expand Down Expand Up @@ -69,7 +73,9 @@ function renderProperty(config, property) {
${renderPrivacyImplicationDoc(config, property.documentation.privacyDoc)}
</td>
<td>${renderCardinality(property)}</td>
${config.showPrivacyAnnotations ? renderPrivacyImplicationCell(property) : null}
${config.showPrivacyAnnotations
? renderPrivacyImplicationCell(property)
: null}
</tr>`;
}

Expand Down Expand Up @@ -101,7 +107,11 @@ function renderCardinality(property) {
* @returns {HTMLTableCellElement} A table cell with a string describing the privacy implications of a property.
*/
function renderPrivacyImplicationCell(property) {
return html`<td><a href="#privacy-${property.privacyImplications.value.toLowerCase()}">${renderPrivacyImplication(property)}</a></td>`;
return html`<td>
<a href="#privacy-${property.privacyImplications.value.toLowerCase()}">
${renderPrivacyImplication(property)}
</a>
</td>`;
}

/**
Expand Down
15 changes: 10 additions & 5 deletions src/1edtech/templates/confidentialityLevelTemplate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/* eslint-disable prefer-template */
// @ts-check
import { html } from "../../core/import-maps.js";

export default (keys, translations) => {
return html`
<dl>
${keys.map(key => html`
<dt><dfn id="privacy-${key.toLowerCase()}">${translations[key + '_label']}</dfn></dt><dd>${translations[key + '_def']}</dd>
`)}
return html`<dl>
${keys.map(
key => html`<dt>
<dfn id="privacy-${key.toLowerCase()}">
${translations[key + "_label"]}
</dfn>
</dt>
<dd>${translations[key + "_def"]}</dd>`
)}
</dl>`;
};
46 changes: 32 additions & 14 deletions src/1edtech/templates/operationTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default (config, rootPath, operation, title) => {
<p>${operation.documentation.description}</p>
${operation.documentation.issues.map(renderIssue)}
${operation.documentation.notes.map(renderNote)}
${renderRequest(config, rootPath, operation)} ${renderResponses(config, operation)}`;
${renderRequest(config, rootPath, operation)}
${renderResponses(config, operation)}`;
}
};

Expand All @@ -30,7 +31,8 @@ export default (config, rootPath, operation, title) => {
*/
function renderRequest(config, rootPath, operation) {
return html`<h5>Request</h5>
${renderUrl(rootPath, operation)} ${renderRequestParameters(config, operation)}
${renderUrl(rootPath, operation)}
${renderRequestParameters(config, operation)}
${renderRequestBodies(config, operation)}`;
}

Expand Down Expand Up @@ -74,11 +76,15 @@ function renderRequestParameters(config, operation) {
<th>Parameter Type</th>
<th>Description</th>
<th>Required</th>
${config.showPrivacyAnnotations ? html`<th>Confidentiality Level</th>` : null}
${config.showPrivacyAnnotations
? html`<th>Confidentiality Level</th>`
: null}
</tr>
</thead>
<tbody>
${operation.request.parameters.map(param => renderParameter(config, param))}
${operation.request.parameters.map(param =>
renderParameter(config, param)
)}
</tbody>
</table>
`;
Expand All @@ -104,11 +110,15 @@ function renderRequestBodies(config, operation) {
<th>Content Type</th>
<th>Content Description</th>
<th>Content Required</th>
${config.showPrivacyAnnotations ? html`<th>Confidentiality Level</th>` : null}
</tr>
${config.showPrivacyAnnotations
? html`<th>Confidentiality Level</th>`
: null}
</tr>
</thead>
<tbody>
${operation.request.bodies.map(body => renderRequestBody(config, body))}
${operation.request.bodies.map(body =>
renderRequestBody(config, body)
)}
</tbody>
</table>
`;
Expand All @@ -135,8 +145,6 @@ function renderRequestBody(config, body) {
</tr>`;
}



function renderParameter(config, parameter) {
return html` <tr>
<td>
Expand All @@ -150,7 +158,9 @@ function renderParameter(config, parameter) {
${parameter.documentation.notes.map(renderNote)}
</td>
<td>${renderRequired(parameter)}</td>
${config.showPrivacyAnnotations ? renderConfidentialityCell(parameter) : null}
${config.showPrivacyAnnotations
? renderConfidentialityCell(parameter)
: null}
</tr>`;
}

Expand All @@ -168,8 +178,10 @@ function renderResponses(config, operation) {
<th>Content Type</th>
<th>Content Description</th>
<th>Content Required</th>
${config.showPrivacyAnnotations ? html`<th>Confidentiality Level</th>` : null}
</tr>
${config.showPrivacyAnnotations
? html`<th>Confidentiality Level</th>`
: null}
</tr>
</thead>
<tbody>
${responses.map(resp => renderResponse(config, resp))}
Expand All @@ -189,7 +201,9 @@ function renderResponse(config, response) {
${response.body?.documentation?.notes.map(renderNote)}
</td>
<td>${renderRequired(response.body)}</td>
${config.showPrivacyAnnotations ? renderConfidentialityCell(response.body) : null}
${config.showPrivacyAnnotations
? renderConfidentialityCell(response.body)
: null}
</tr>`;
}

Expand Down Expand Up @@ -222,7 +236,11 @@ function renderRequired(value) {
*/
function renderConfidentialityCell(value) {
if (value?.confidentiality) {
return html`<td><a href="#privacy-${value.confidentiality.value.toLowerCase()}">${renderConfidentiality(value)}</a></td>`;
return html`<td>
<a href="#privacy-${value.confidentiality.value.toLowerCase()}">
${renderConfidentiality(value)}
</a>
</td>`;
}
}
function renderConfidentiality(value) {
Expand Down
15 changes: 10 additions & 5 deletions src/1edtech/templates/privacyImplicationsTemplate.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
/* eslint-disable prefer-template */
// @ts-check
import { html } from "../../core/import-maps.js";

export default (keys, translations) => {
return html`
<dl>
${keys.map(key => html`
<dt><dfn id="privacy-${key.toLowerCase()}">${translations[key + '_label']}</dfn></dt><dd>${translations[key + '_def']}</dd>
`)}
return html`<dl>
${keys.map(
key => html`<dt>
<dfn id="privacy-${key.toLowerCase()}">
${translations[key + "_label"]}
</dfn>
</dt>
<dd>${translations[key + "_def"]}</dd>`
)}
</dl>`;
};
Loading
Loading