Skip to content

Commit

Permalink
2.1 website version
Browse files Browse the repository at this point in the history
  • Loading branch information
kriswest committed Sep 13, 2023
1 parent 6594af5 commit 34fb6f4
Show file tree
Hide file tree
Showing 203 changed files with 16,525 additions and 0 deletions.
10 changes: 10 additions & 0 deletions website/static/schemas/2.1/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Intro

Quicktype, the chosen generation tool currently has some limitations that prevent fully automatic schema generation from the existing TS types. For example it can not handle interfaces that contain methods in their definition. It also fails to generate schemas even if a type contains unused references to other types or interfaces that contain async functions (Promise return types). Therefore, in order to generate the `api\schemas\api.schema.json` some manual intervention was needed.

Once these limitations are not an issue the `api\schemas\t2sQuicktypeUtil.js` script should be moved to the root level of the project and a new npm script `"api-schema-gen": "node t2sQuicktypeUtil.js src/api schemas/api/api.schema.json"` should be added.

`api\schemas\api.schema.json` - partially auto-generated schema from the existing `src\api` types.
`api\schemas\baseImplementationMetadata.schema.json` - Used by bridging types that leave out the metadata of the calling application as it does not apply to bridging.
`api\schemas\intentResolution.schema.json` - At the moment it is not possible to auto-generate this due to limitations in the generation tool (quicktype)
`api\schemas\t2sQuicktypeUtil.js` - Script used to run the generation of the schema from the types. Should be moved to the root level of the repo once fully-automated generation can be achieved.
450 changes: 450 additions & 0 deletions website/static/schemas/2.1/api/api.schema.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://fdc3.finos.org/schemas/2.1/api/baseImplementationMetadata.schema.json",
"title": "BaseImplementationMetadata",
"description": "Metadata relating to the FDC3 Desktop Agent implementation and its provider.",
"type": "object",
"properties": {
"fdc3Version": {
"description": "The version number of the FDC3 specification that the implementation provides.\nThe string must be a numeric semver version, e.g. 1.2 or 1.2.1.",
"type": "string",
"title": "fdc3Version"
},
"provider": {
"description": "The name of the provider of the Desktop Agent implementation (e.g. Finsemble, Glue42, OpenFin etc.).",
"type": "string",
"title": "provider"
},
"providerVersion": {
"description": "The version of the provider of the Desktop Agent implementation (e.g. 5.3.0).",
"type": "string",
"title": "providerVersion"
},
"optionalFeatures": {
"description": "Metadata indicating whether the Desktop Agent implements optional features of\nthe Desktop Agent API.",
"type": "object",
"properties": {
"OriginatingAppMetadata": {
"description": "Used to indicate whether the exposure of 'originating app metadata' for\ncontext and intent messages is supported by the Desktop Agent.",
"type": "boolean",
"title": "OriginatingAppMetadata"
},
"UserChannelMembershipAPIs": {
"description": "Used to indicate whether the optional `fdc3.joinUserChannel`,\n`fdc3.getCurrentChannel` and `fdc3.leaveCurrentChannel` are implemented by\nthe Desktop Agent.",
"type": "boolean",
"title": "UserChannelMembershipAPIs"
},
"DesktopAgentBridging": {
"description": "Used to indicate whether the experimental Desktop Agent Bridging\nfeature is implemented by the Desktop Agent.",
"type": "boolean",
"title": "DesktopAgentBridging"
}
},
"additionalProperties": false,
"required": [
"DesktopAgentBridging",
"OriginatingAppMetadata",
"UserChannelMembershipAPIs"
],
"title": "optionalFeatures"
}
},
"additionalProperties": false,
"required": [
"fdc3Version",
"optionalFeatures",
"provider"
]
}
64 changes: 64 additions & 0 deletions website/static/schemas/2.1/api/t2sQuicktypeUtil.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/** Utility for preparing arguments to quicktype, which workaround a specific
* quicktype bug in command line argument handling (where a directory is used
* as input the source language argument is ignored which causes our schemas
* to be interpreted as JSON input, rather than JSONSchema).
* Bug issue:
* */

const path = require('path');
const fs = require('fs');
const exec = require('child_process').exec;

const args = process.argv.slice(2);
const outputPath = args.pop();
const inputs = args;

console.log('Inputs: ' + inputs.join(' | '));
console.log('Output path argument: ' + outputPath);

let source = '';

let dirIndex = 0;

const excludedTypes = [
'DesktopAgent.ts',
'Listener.ts',
'Methods.ts',
'PrivateChannel.ts',
'Types.ts',
'RecommendedChannels.ts',
];

let sources = '';

while (dirIndex < inputs.length) {
if (inputs[dirIndex].endsWith('.ts')) {
sources += `--src ${path.join(inputs[dirIndex])} `;
} else {
fs.readdirSync(inputs[dirIndex], { withFileTypes: true }).forEach(file => {
if (file.isDirectory()) {
inputs.push(path.join(inputs[dirIndex], file.name));
} else {
if (!excludedTypes.includes(file.name)) {
sources += `--src ${path.join(inputs[dirIndex], file.name)} `;
}
}
});
}
dirIndex++;
}

// Normalise path to local quicktype executable.
const quicktypeExec = ['.', 'node_modules', '.bin', 'quicktype'].join(path.sep);

const command = `${quicktypeExec} -l schema -o ${outputPath} ${sources}`;
console.log('command to run: ' + command);

exec(command, function(error, stdout, stderr) {
if (stdout) {
console.log(stdout);
}
if (stderr) {
console.log(stderr);
}
});
9 changes: 9 additions & 0 deletions website/static/schemas/2.1/app-directory.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet">
<style>
body {
margin: 0;
padding: 0;
}
</style>
<redoc spec-url='/schemas/next/appd.schema.json'></redoc>
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
Loading

0 comments on commit 34fb6f4

Please sign in to comment.