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

Move Credentials into their own Section #364

Merged
merged 8 commits into from
Mar 29, 2022
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ docs/schemas
docs/traceability-openapi-v1.json
docs/intermediate.json
docs/sections/vocab.html
docs/sections/credentials.html
docs/testsuite/index.html
docs/openapi/openapi.yml

packages/traceability-schemas/data/*.json
packages/traceability-schemas/data/*.json
148 changes: 86 additions & 62 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,27 @@ <h4>Vocabulary Linkage</h4>
defined in a industry-specific vocabulary. This is to ensure the
broadest possible interoperability, within and beyond supply chain.
</p>
</section>
</section>

<section class="informative">
<h4>Open API</h4>
<p>
This vocabulary can also be viewed as an
<a href="https://w3id.org/traceability/openapi/">Open API Specification</a>.
</p>
</section>

<section>
<h4>Undefined Terms</h4>
<p>
This vocabulary uses
<code> '@vocab': 'https://w3id.org/traceability/#undefinedTerm' </code>
to disable JSON-LD related errors associated with Verifiable Credentials,
issued about terms that have not yet been added here.
</p>
</section>


</section>

<section class="informative">
Expand Down Expand Up @@ -532,64 +552,6 @@ <h5>Sample Steel Workflow</h5>
Origin, Steel Import License, Mill Test Report, and Commercial Invoice.
Data is verified by CBP’s automated processes.
</p>

<h5>Featured Steel Credentials</h5>
<dl>
<dt>Mill Test Report Certificate</dt>
<dd>
<p>The <a href="#MillTestReportCertificate">Mill Test Report</a>
certifies steel type and quality, listing chemical and mechanical
properties.</p>
</dd>
<dt>Commercial Invoice Certificate</dt>
<dd>
<figure>
<img src="samples/commercial-invoice-ex.png" alt="Commercial Invoice example" style="width:40%">
<figcaption>Sample Commercial Invoice</figcaption>
</figure>
<p>
<a href="#CommercialInvoiceCertificate">Commercial Invoice</a>
indicates to authorities the value of goods subject to tariffs
and duties.
</p>
</dd>
<dt>Bill of Lading Certificate</dt>
<dd>
<figure>
<img src="samples/bill-of-lading-ex-2.png" alt="Bill of Lading example" style="width:40%">
<figcaption>Sample Bill of Lading</figcaption>
</figure>
<p>
<a href="#BillOfLadingCertificate">Bill of Lading</a> certificates
are issued by the carrier, indicating a) receipt of goods, b) evidence
of consignment contract, and c) title of goods.
</p>
</dd>
<dt>Verifiable Business Card</dt>
<dd>
<p>
<a href="#VerifiableBusinessCard">Verifiable Business Cards</a> hold
verifiable presentation endpoint addresses.
</p>
</dd>

<dt>USMCA Certificate Of Origin</dt>
<dd>
<figure>
<img src="samples/usmca-form.png" alt="USMCA Certificate Of Origin" style="width:40%">
<figcaption>USMCA Certificate Of Origin</figcaption>
</figure>
<p>
The <a href="#USMCACertificateOfOrigin">USMCA Certificate Of Origin</a>
schema is adapted from
<a href="https://www.fedex.com/content/dam/fedex/us-united-states/International/upload/FedEx_USMCA_T-MEC_CUSMA_Fillable_Form.pdf">
FedEx's</a> and <a href="https://www.ups.com/assets/resources/media/ups-usmca-fillable-form-us.pdf">UPS's</a>
USMCA Forms, implementing the
<a href="https://trade.cbp.gov/USMCA/s/">United States - Mexico - Canada
Agreement (USMCA)</a>.
</p>
</dd>
</dl>
</section>

<section>
Expand Down Expand Up @@ -732,8 +694,66 @@ <h5>Sample E-Commerce Workflow</h5>
are cross referenced; commercial and physical provenance is verified; and CBP’s
automated processes can issue Import Approval (13) documentation for presentation
back to the Express Carrier (14) well in advance of the goods arrival.
</p>
<h5>Featured E-Commerce Credentials</h5>
</p>
</section>
<section>
<h5>Supporting Documents</h5>
<dl>
<dt>Mill Test Report Certificate</dt>
<dd>
<p>The <a href="#MillTestReportCertificate">Mill Test Report</a>
certifies steel type and quality, listing chemical and mechanical
properties.</p>
</dd>
<dt>Commercial Invoice Certificate</dt>
<dd>
<figure>
<img src="samples/commercial-invoice-ex.png" alt="Commercial Invoice example" style="width:40%">
<figcaption>Sample Commercial Invoice</figcaption>
</figure>
<p>
<a href="#CommercialInvoiceCertificate">Commercial Invoice</a>
indicates to authorities the value of goods subject to tariffs
and duties.
</p>
</dd>
<dt>Bill of Lading Certificate</dt>
<dd>
<figure>
<img src="samples/bill-of-lading-ex-2.png" alt="Bill of Lading example" style="width:40%">
<figcaption>Sample Bill of Lading</figcaption>
</figure>
<p>
<a href="#BillOfLadingCertificate">Bill of Lading</a> certificates
are issued by the carrier, indicating a) receipt of goods, b) evidence
of consignment contract, and c) title of goods.
</p>
</dd>
<dt>Verifiable Business Card</dt>
<dd>
<p>
<a href="#VerifiableBusinessCard">Verifiable Business Cards</a> hold
verifiable presentation endpoint addresses.
</p>
</dd>

<dt>USMCA Certificate Of Origin</dt>
<dd>
<figure>
<img src="samples/usmca-form.png" alt="USMCA Certificate Of Origin" style="width:40%">
<figcaption>USMCA Certificate Of Origin</figcaption>
</figure>
<p>
The <a href="#USMCACertificateOfOrigin">USMCA Certificate Of Origin</a>
schema is adapted from
<a href="https://www.fedex.com/content/dam/fedex/us-united-states/International/upload/FedEx_USMCA_T-MEC_CUSMA_Fillable_Form.pdf">
FedEx's</a> and <a href="https://www.ups.com/assets/resources/media/ups-usmca-fillable-form-us.pdf">UPS's</a>
USMCA Forms, implementing the
<a href="https://trade.cbp.gov/USMCA/s/">United States - Mexico - Canada
Agreement (USMCA)</a>.
</p>
</dd>
</dl>
<dl>
<dt>Purchase Order</dt>
<dd>
Expand Down Expand Up @@ -786,7 +806,11 @@ <h5>Featured E-Commerce Credentials</h5>
</section>
</section>



<section
data-include="sections/credentials.html"
data-include-replace="true"
></section>

<section
data-include="sections/vocab.html"
Expand Down
77 changes: 46 additions & 31 deletions packages/traceability-schemas/scripts/schemas-to-vocab.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const path = require('path');
const { schemas } = require('../services/schemas');

const vocabPath = path.resolve(__dirname, '../../../docs/sections/vocab.html');
const credentialPath = path.resolve(__dirname, '../../../docs/sections/credentials.html');

const baseUrl = 'https://w3id.org/traceability';

Expand All @@ -20,15 +21,14 @@ const buildLinkedDataTable = (schema) => {
<td><a href="${$linkedData['@id']}">${$linkedData['@id']}</a></td>
</tr>

${
$id
${$id
? `
<tr>
<td><a href="https://swagger.io/specification/#schema-object">schema</a></td>
<td><a href="${baseUrl + $id}">${baseUrl + $id}</a></td>
</tr>`
: ''
}
}

</tbody>
</table>
Expand Down Expand Up @@ -91,34 +91,49 @@ const buildVocabSection = (schema) => {
return buildProperty(schema);
};

(async () => {
const separateSchemas = (schemaList) => {
// Define Arrays to sort the schemas into
const credentialSchemas = [];
const vocabSchemas = [];

// Separates Schemas into Credentials and Vocabulary
schemaList.forEach((schema) => {
const { example } = schema;
const obj = JSON.parse(example);
const type = Array.isArray(obj.type) ? obj.type : [obj.type];
if (type.indexOf('VerifiableCredential') === -1) {
vocabSchemas.push(schema);
} else {
credentialSchemas.push(schema);
}
});

// Generate the text for each respective section
const credentials = credentialSchemas.map(buildVocabSection).join('\n');
const vocab = vocabSchemas.map(buildVocabSection).join('\n');

// Return the html text for each section
return { credentials, vocab };
};

(() => {
console.log('🧪 build vocab from schemas');
const sections = schemas.map(buildVocabSection).join('\n');
const section = `
<section id="vocabulary" class="normative">
<h2>Vocabulary </h2>

<section id="Open API" class="informative">
<h2>Open API</h2>
<p>
This vocabulary can also be viewed as an
<a href="https://w3id.org/traceability/openapi/">Open API Specification</a>.
</p>
</section>

<section>
<h3 id="undefinedTerm">Undefined Terms</h3>
<p>This vocabulary uses <code> '@vocab': 'https://w3id.org/traceability/#undefinedTerm' </code>
to disable JSON-LD related errors associated with Verifiable Credentials, issued about
terms that have not yet been added here.
</p>
</section>

<section>
<h2>Defined Terms</h2>
${sections}
</section>
</section>
const { credentials, vocab } = separateSchemas(schemas);

const credentialSection = `
<section>
<h2>Credentials</h2>
${credentials}
</section>
`;

const vocabSection = `
<section>
<h2>Vocabulary</h2>
${vocab}
</section>
`;
fs.writeFileSync(vocabPath, section);

fs.writeFileSync(credentialPath, credentialSection);
fs.writeFileSync(vocabPath, vocabSection);
})();