Skip to content

Commit

Permalink
#1 Upgrade to multi-artifacts support
Browse files Browse the repository at this point in the history
  • Loading branch information
lbroudoux committed Jul 5, 2021
1 parent 49d49a2 commit d6b7ecf
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 55 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app/models/package.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class APIVersion {
imgUrl: string;
thumbUrl: string;
capabilityLevel: string;
contract: Contract;
contracts: Contract[];
links: Link[];
maintainers: Maintainer[];
keywords: string;
Expand Down
19 changes: 9 additions & 10 deletions frontend/src/app/pages/package/apiVersion/apiVersion.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ <h5 class="properties-side-panel-pf-property-label">Links</h5>
</div>
<div class="properties-side-panel-pf-property">
<h5 class="properties-side-panel-pf-property-label">Contracts</h5>
<div class="properties-side-panel-pf-property-value">
<a class="mh-external-link indicator" href="{{ resolvedAPIVersion.contract.url }}" target="_blank" rel="noopener noreferrer">{{ resolvedAPIVersion.contract.type }}</a>
<div *ngFor="let contract of resolvedAPIVersion.contracts" class="properties-side-panel-pf-property-value">
<a class="mh-external-link indicator" href="{{ contract.url }}" target="_blank" rel="noopener noreferrer">{{ contract.type }}</a>
</div>
</div>
<div class="properties-side-panel-pf-property">
Expand Down Expand Up @@ -137,13 +137,13 @@ <h2>Install on Microcks</h2>
<h6 class="mh-api-install-modal_options">2 options for installing this API Mocks into your Microcks instance:</h6>
<ol class="mh-api-install-modal_list">
<li class="mh-api-install-modal_list-item">
<p>Create a new Import Job into Microcks UI, copy/pasting this URL:</p>
<div class="mh-api-install-modal_install-command-container">
<p>Create new Import Job(s) into Microcks UI, copy/pasting these URL(s):</p>
<div *ngFor="let contract of resolvedAPIVersion.contracts" class="mh-api-install-modal_install-command-container">
<div class="mh-code">
{{ resolvedAPIVersion.contract.url }}
{{ contract.url }}
</div>
<div style="position: relative; display: inline-block; z-index: 98; color: rgb(85, 85, 85); cursor: pointer; top: 2px;">
<a (mouseenter)="onCopyEnter($event)" (click)="copyToClipboard(resolvedAPIVersion.contract.url, $event)"
<a (mouseenter)="onCopyEnter($event)" (click)="copyToClipboard(contract, $event)"
data-toggle="tooltip" data-placement="top" title="{{ guiCommandStatus }}" class="oh-install-modal_install-command-copy">
<span aria-hidden="true" class="fa fa-clipboard"></span>
<span class="sr-only">Copy to Clipboard</span>
Expand All @@ -155,10 +155,9 @@ <h6 class="mh-api-install-modal_options">2 options for installing this API Mocks
<p>Use <code>microcks-cli</code> command line tool with the <code>importAPI</code> command:</p>
<div class="mh-api-install-modal_install-command-container">
<div class="mh-code">$ microcks-cli importAPI {{ resolvedPackage.name}}:{{ resolvedAPIVersion.name }} \<br/>
&nbsp; &nbsp; --microcksURL=http://localhost:8080/api/ \<br/>
&nbsp; &nbsp; --keycloakClientId=microcks-serviceaccount \<br/>
&nbsp; &nbsp; --keycloakClientSecret=7deb71e8-8c80-4376-95ad-00a399ee3ca1 \<br/>
&nbsp; &nbsp; --insecure --verbose
&nbsp; &nbsp; --microcksURL=&lt;microcks-service-api&gt; \<br/>
&nbsp; &nbsp; --keycloakClientId=&lt;service-account&gt; \<br/>
&nbsp; &nbsp; --keycloakClientSecret=&lt;service-account-secret&gt;
</div>
<div style="position: relative; display: inline-block; z-index: 98; color: rgb(85, 85, 85); cursor: pointer; top: 2px;">
<a (mouseenter)="onCopyEnter($event)" (click)="copyToClipboard(getImportAPICommand(), $event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ metadata:
spec:
version: 3.1.0
capabilities: Incomplete Mocks
contract:
type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/Openbanking.org.uk%20Account%20and%20Transaction%20API%20-%20v3.1.0.postman_collection.json
contracts:
- type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/Openbanking.org.uk%20Account%20and%20Transaction%20API%20-%20v3.1.0.postman_collection.json
links:
- name: OpenBanking.org.uk mocks repository
url: https://github.com/microcks/microcks-quickstarters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ metadata:
spec:
version: '2.3.0'
capabilities: Incomplete Mocks
contract:
type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/Openbanking.org.uk%20ATM%20API%20v2.3.0.postman_collection.json
contracts:
- type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/Openbanking.org.uk%20ATM%20API%20v2.3.0.postman_collection.json
links:
- name: OpenBanking.org.uk mocks repository
url: https://github.com/microcks/microcks-quickstarters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ metadata:
spec:
version: '2.3.0'
capabilities: Incomplete Mocks
contract:
type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/OpenBanking.org.uk%20Branch%20API%20v2.3.0-RC1.postman_collection.json
contracts:
- type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/openbanking.org.uk/OpenBanking.org.uk%20Branch%20API%20v2.3.0-RC1.postman_collection.json
links:
- name: OpenBanking.org.uk mocks repository
url: https://github.com/microcks/microcks-quickstarters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ metadata:
spec:
version: '1.4.2'
capabilities: Incomplete Mocks
contract:
type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/stet.eu/PSD2%20ASPSP%20services%20for%20AISP%2C%20PISP%20and%20CBPII%20v1.4.postman_collection.json
contracts:
- type: postman
url: https://github.com/microcks/microcks-quickstarters/raw/main/banking/stet.eu/PSD2%20ASPSP%20services%20for%20AISP%2C%20PISP%20and%20CBPII%20v1.4.postman_collection.json
links:
- name: Stet.eu mocks repository
url: https://github.com/microcks/microcks-quickstarters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ metadata:
spec:
version: '2.0'
capabilities: Full Mocks
contract:
type: postman
url: https://github.com/nehrman/terraform-enterprise/raw/master/mocks/terraform-enterprise.api.v2-RC1.postman_collection.json
contracts:
- type: postman
url: https://github.com/nehrman/terraform-enterprise/raw/master/mocks/terraform-enterprise.api.v2-RC1.postman_collection.json
links:
- name: Terraform Enterprise mocks repository
url: https://github.com/nehrman/terraform-enterprise
Expand Down
45 changes: 23 additions & 22 deletions server/services/loadService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const extractAPIVersionData = (versionDirPath, fileName) => {
content = yaml.load(fs.readFileSync(filePath));
fileType = getFileType(content);
} catch (e) {
console.error(`ERROR: Unable to parse ${fileName}`);
console.error(`ERROR: Unable to parse ${fileName} as an APIVersion`);
console.error(e.message);
return null;
}
Expand Down Expand Up @@ -127,29 +127,30 @@ const extractMockData = (packageDirPath, packageDirFileName) => {
};
}
});
}
} else {

// packageDirFileName is not a directory but a file.
try {
console.log(` Reading APIPackage file ${apiDirPath}`); // openbanking.org.uk.package.yml
//content = yaml.safeLoad(fs.readFileSync(apiDirPath));
content = yaml.load(fs.readFileSync(apiDirPath));
fileType = getFileType(content);
} catch (e) {
console.error(`ERROR: Unable to parse ${packageDirFileName}`);
console.error(e.message);
return {
packageFile: null,
apiVersionsFiles
};
}
// packageDirFileName is not a directory but a file.
try {
console.log(` Reading APIPackage file ${apiDirPath}`); // openbanking.org.uk.package.yml
//content = yaml.safeLoad(fs.readFileSync(apiDirPath));
content = yaml.load(fs.readFileSync(apiDirPath));
fileType = getFileType(content);
} catch (e) {
console.error(`ERROR: Unable to parse ${packageDirFileName} as an APIPackage`);
console.error(e.message);
return {
packageFile: null,
apiVersionsFiles
};
}

if (fileType === 'PKG') {
packageFile = content;
} else if (fileType === 'API') {
apiVersionFiles.push(content);
} else if (fileType === 'Unknown') {
console.warn(`Cannot identify file ${packageDirFileName} at folder ${packageDirPath}. Ignoring file`);
if (fileType === 'PKG') {
packageFile = content;
} else if (fileType === 'API') {
apiVersionFiles.push(content);
} else if (fileType === 'Unknown') {
console.warn(`Cannot identify file ${packageDirFileName} at folder ${packageDirPath}. Ignoring file`);
}
}

return {
Expand Down
10 changes: 5 additions & 5 deletions server/store/persistentStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DESCRIPTION_FIELD = 'description TEXT';
const IMG_FIELD = 'imgUrl TEXT';
const THUMB_FIELD = 'thumbUrl TEXT';
const CAPABILITY_LEVEL_FIELD = 'capabilityLevel BLOB';
const CONTRACT_FIELD = 'contract BLOB';
const CONTRACTS_FIELD = 'contracts BLOB';
const LINKS_FIELD = 'links BLOB';
const MAINTAINERS_FIELD = 'maintainers BLOB';
const CREATED_FIELD = 'createdAt BLOB';
Expand All @@ -54,7 +54,7 @@ const apiVersionFields = [
'imgUrl',
'thumbUrl',
'capabilityLevel',
'contract',
'contracts',
'links',
'maintainers',
'createdAt',
Expand Down Expand Up @@ -118,7 +118,7 @@ exports.initialize = callback => {
${IMG_FIELD},
${THUMB_FIELD},
${CAPABILITY_LEVEL_FIELD},
${CONTRACT_FIELD},
${CONTRACTS_FIELD},
${LINKS_FIELD},
${MAINTAINERS_FIELD},
${CREATED_FIELD},
Expand Down Expand Up @@ -157,7 +157,7 @@ exports.close = () => {

const normalizeAPIVersionRow = row => {
row.createdAt = JSON.parse(row.createdAt);
row.contract = JSON.parse(row.contract);
row.contracts = JSON.parse(row.contracts);
row.links = JSON.parse(row.links);
row.maintainers = JSON.parse(row.maintainers);
row.keywords = JSON.parse(row.keywords);
Expand Down Expand Up @@ -294,7 +294,7 @@ exports.setAPIVersions = (apiVersions, callback) => {
apiVersion.imgUrl,
apiVersion.thumbUrl,
apiVersion.capabilityLevel || null,
JSON.stringify(apiVersion.contract),
JSON.stringify(apiVersion.contracts),
JSON.stringify(apiVersion.links),
JSON.stringify(apiVersion.maintainers),
JSON.stringify(apiVersion.createdAt),
Expand Down
4 changes: 2 additions & 2 deletions server/utils/mockUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const normalizeAPIVersion = async apiVersion => {
'imgUrl',
'thumbUrl',
'capabilityLevel',
'contract',
'contracts',
'links',
'maintainers',
'createdAt',
Expand All @@ -125,7 +125,7 @@ const normalizeAPIVersion = async apiVersion => {
imgUrl: iconObj ? `data:${iconObj.mediatype};base64,${iconObj.base64data}` : '',
thumbUrl: thumbBase64 || '',
capabilityLevel: normalizeCapabilityLevel(capabilitiesString || ''),
contract: spec.contract,
contracts: spec.contracts,
links: spec.links,
maintainers: spec.maintainers,
createdAt: metadata.createdAt,
Expand Down

0 comments on commit d6b7ecf

Please sign in to comment.