Skip to content

Commit 37d2f53

Browse files
tpinakriswest
andauthored
new schema structure (#65)
* new schema structure quicktypeUtils update npm scripts update * PR feedback * cleanup * typos * fix type generation folder * Fixed schema structures * copy schemas to website * package json update * removed defunct file * make sources optional * cleanup * Update schemas/bridging/raiseIntentResultResponse.schema.json Co-authored-by: Kris West <[email protected]> * cleanup * regenerated types * PR feedback * Fixe meta for requests * Apply suggestions from code review * Regenerating bridging typescript * Apply suggestions from code review * adjust OptionalFeatures and IntentResult schemas --------- Co-authored-by: Kris West <[email protected]>
1 parent 6830c73 commit 37d2f53

File tree

102 files changed

+4230
-117
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4230
-117
lines changed

docs/api-bridging/spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ Response messages will be differentiated from requests by the presence of a `met
476476
* to the bridge before the timeout or because an error occurred.
477477
* Should be the same length as the `errorSources` array and ordered the
478478
* same. May be omitted if all sources responded. */
479+
479480
errorDetails?: string[]
480481
}
481482
}

docs/api/ref/Metadata.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,9 @@ interface ImplementationMetadata {
279279
* `fdc3.getCurrentChannel` and `fdc3.leaveCurrentChannel` are implemented by
280280
* the Desktop Agent.*/
281281
"UserChannelMembershipAPIs": boolean;
282+
/** Used to indicate whether the experimental Desktop Agent Bridging
283+
* feature is implemented by the Desktop Agent.*/
284+
DesktopAgentBridging: boolean;
282285
};
283286

284287
/** The calling application instance's own metadata, according to the

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
},
2424
"scripts": {
2525
"start": "tsdx watch",
26+
"prebuild": "npm run typegen && npm run typegen-bridging",
2627
"build": "tsdx build",
2728
"test": "tsdx test --verbose",
2829
"lint": "tsdx lint src/api test",
30+
"preprepare": "npm run typegen && npm run typegen-bridging",
2931
"prepare": "tsdx build",
30-
"typegen": "node quicktypeUtil.js src/context/schemas src/context/ContextTypes.ts && tsdx lint src/context --fix"
32+
"typegen": "node quicktypeUtil.js schemas/context src/context/ContextTypes.ts && tsdx lint src/context/ --fix",
33+
"typegen-bridging": "node quicktypeUtil.js schemas/api schemas/bridging schemas/context/context.schema.json src/bridging/BridgingTypes.ts && tsdx lint src/bridging/ --fix"
3134
},
3235
"peerDependencies": {},
3336
"husky": {

quicktypeUtil.js

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
1-
/** Utility for preparing arguments to quicktype, which workaround a specific
2-
* quicktype bug in command line argument handling (where a directory is used
1+
/** Utility for preparing arguments to quicktype, which workaround a specific
2+
* quicktype bug in command line argument handling (where a directory is used
33
* as input the source language argument is ignored which causes our schemas
44
* to be interpreted as JSON input, rather than JSONSchema).
5-
* Bug issue:
5+
* Bug issue:
66
* */
77

88
const path = require('path');
99
const fs = require('fs');
1010
const exec = require('child_process').exec;
1111

12-
const args = process.argv;
13-
const inputFolder = args[2]
14-
const outputFile = args[3];
12+
const args = process.argv.slice(2);
13+
const outputFile = args.pop();
14+
const inputs = args;
1515

16-
console.log("Input folder argument: " + inputFolder);
17-
console.log("Output file argument: " + outputFile);
16+
console.log('Inputs: ' + inputs.join(' | '));
17+
console.log('Output file argument: ' + outputFile);
1818

19-
let srcs = "";
20-
fs.readdirSync(inputFolder).forEach(file => {
21-
srcs += `--src ${path.join(inputFolder, file)} `;
22-
});
19+
let sources = '';
20+
21+
let dirIndex = 0;
22+
23+
while (dirIndex < inputs.length) {
24+
if (inputs[dirIndex].endsWith('.schema.json')) {
25+
sources += `--src ${path.join(inputs[dirIndex])} `;
26+
} else {
27+
fs.readdirSync(inputs[dirIndex], { withFileTypes: true }).forEach(file => {
28+
if (file.isDirectory()) {
29+
inputs.push(path.join(inputs[dirIndex], file.name));
30+
} else {
31+
sources += `--src ${path.join(inputs[dirIndex], file.name)} `;
32+
}
33+
});
34+
}
35+
dirIndex++;
36+
}
2337

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

27-
const command = `${quicktypeExec} -s schema -o ${outputFile} ${srcs}`;
28-
console.log("command to run: " + command);
41+
const command = `${quicktypeExec} -s schema -o ${outputFile} ${sources}`;
42+
console.log('command to run: ' + command);
2943

3044
exec(command, function(error, stdout, stderr) {
31-
if (stdout) {
32-
console.log(stdout);
33-
}
34-
if (stderr) {
35-
console.log(stderr);
36-
}
45+
if (stdout) {
46+
console.log(stdout);
47+
}
48+
if (stderr) {
49+
console.log(stderr);
50+
}
3751
});
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/appIdentifier.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/appIdentifier.schema.json",
44
"title": "AppIdentifier",
55
"description": "Identifies an application, or instance of an application, and is used to target FDC3 API calls at specific applications.",
66
"type": "object",
@@ -10,10 +10,13 @@
1010
},
1111
"instanceId": {
1212
"type": "string"
13+
},
14+
"desktopAgent": {
15+
"type": "string"
1316
}
1417
},
1518
"required": [
1619
"appId"
1720
],
18-
"additionalProperties": false
21+
"unevaluatedProperties": false
1922
}

src/api/schemas/appIntent.schema.json renamed to schemas/api/appIntent.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/appIntent.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/appIntent.schema.json",
44
"title": "AppIntent",
55
"description": "Represents the binding of an intent to apps",
66
"type": "object",
77
"properties": {
88
"intent": {
9-
"$ref": "https://fdc3.finos.org/schemas/next/intentMetadata.schema.json"
9+
"$ref": "intentMetadata.schema.json"
1010
},
1111
"apps": {
1212
"type": "array",
1313
"items": {
14-
"$ref": "https://fdc3.finos.org/schemas/next/appMetadata.schema.json"
14+
"$ref": "appMetadata.schema.json"
1515
}
1616
}
1717
},

src/api/schemas/appMetadata.schema.json renamed to schemas/api/appMetadata.schema.json

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/appMetadata.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/appMetadata.schema.json",
44
"title": "AppMetadata",
55
"description": "Extends an AppIdentifier, describing an application or instance of an application.",
66
"type": "object",
7+
"allOf": [
8+
{
9+
"$ref": "appIdentifier.schema.json"
10+
}
11+
],
712
"properties": {
8-
"appId": {
9-
"type": "string"
10-
},
11-
"instanceId": {
12-
"type": "string"
13-
},
13+
"appId": true,
14+
"instanceId": true,
15+
"desktopAgent": true,
1416
"name": {
1517
"type": "string"
1618
},
@@ -32,13 +34,13 @@
3234
"icons": {
3335
"type": "array",
3436
"items": {
35-
"$ref": "https://fdc3.finos.org/schemas/next/icon.schema.json"
37+
"$ref": "icon.schema.json"
3638
}
3739
},
3840
"screenshots": {
3941
"type": "array",
4042
"items": {
41-
"$ref": "https://fdc3.finos.org/schemas/next/image.schema.json"
43+
"$ref": "image.schema.json"
4244
}
4345
},
4446
"resultType": {
@@ -48,8 +50,5 @@
4850
]
4951
}
5052
},
51-
"additionalProperties": false,
52-
"required": [
53-
"appId"
54-
]
53+
"additionalProperties": false
5554
}

src/api/schemas/channel.schema.json renamed to schemas/api/channel.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/channel.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/channel.schema.json",
44
"title": "Channel",
55
"description": "Represents a context channel that applications can join to share context data.",
66
"type": "object",
@@ -17,7 +17,7 @@
1717
]
1818
},
1919
"displayMetadata": {
20-
"$ref": "https://fdc3.finos.org/schemas/next/displayMetadata.schema.json"
20+
"$ref": "displayMetadata.schema.json"
2121
}
2222
},
2323
"required": [

src/api/schemas/contextMetadata.schema.json renamed to schemas/api/contextMetadata.schema.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/contextMetadata.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/contextMetadata.schema.json",
44
"title": "ContextMetadata",
55
"description": "Metadata relating to a context or intent & context received through the addContextListener and addIntentListener functions.",
66
"type": "object",
77
"properties": {
88
"source": {
9-
"$ref": "https://fdc3.finos.org/schemas/next/appIdentifier.schema.json"
9+
"$ref": "appIdentifier.schema.json"
1010
}
1111
},
1212
"required": [
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/desktopAgentIdentifier.schema.json",
4+
"title": "DesktopAgentIdentifier",
5+
"description": "Identifies a particular Desktop Agent. Used by Desktop Agent Bridging to indicate the source or destination of a message which was produced by or should be processed by the Desktop Agent itself rather than a specific application. Often added to messages by the Desktop Agent Bridge.",
6+
"type": "object",
7+
"properties": {
8+
"desktopAgent": {
9+
"type": "string"
10+
}
11+
},
12+
"required": [
13+
"desktopAgent"
14+
],
15+
"additionalProperties": false
16+
}

src/api/schemas/displayMetadata.schema.json renamed to schemas/api/displayMetadata.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/displayMetadata.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/displayMetadata.schema.json",
44
"title": "DisplayMetadata",
55
"description": "A desktop agent (typically for user channels) may want to provide additional information about how a channel can be represented in a UI. A common use case is for color linking.",
66
"type": "object",

src/api/schemas/errors.schema.json renamed to schemas/api/errors.schema.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/errors.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/errors.schema.json",
44
"definitions": {
55
"OpenError": {
66
"type": "string",
@@ -9,7 +9,8 @@
99
"AppNotFound",
1010
"ErrorOnLaunch",
1111
"AppTimeout",
12-
"ResolverUnavailable"
12+
"ResolverUnavailable",
13+
"DesktopAgentNotFound"
1314
]
1415
},
1516
"ResolveError": {
@@ -22,7 +23,8 @@
2223
"ResolverTimeout",
2324
"TargetAppUnavailable",
2425
"TargetInstanceUnavailable",
25-
"IntentDeliveryFailed"
26+
"IntentDeliveryFailed",
27+
"DesktopAgentNotFound"
2628
]
2729
},
2830
"ResultError": {
@@ -41,6 +43,15 @@
4143
"AccessDenied",
4244
"CreationFailed"
4345
]
46+
},
47+
"BridgingError": {
48+
"type": "string",
49+
"description": "Contains constants representing the errors that can be encountered by Desktop Agents when exchanging bridging messages.",
50+
"enum": [
51+
"ResponseToBridgeTimedOut",
52+
"AgentDisconnected",
53+
"NotConnectedToBridge"
54+
]
4455
}
4556
}
4657
}

src/api/schemas/icon.schema.json renamed to schemas/api/icon.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/icon.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/icon.schema.json",
44
"title": "Icon",
55
"description": "Metadata relating to a single icon image at a remote URL, used to represent an application in a user interface.",
66
"type": "object",

src/api/schemas/image.schema.json renamed to schemas/api/image.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "https://fdc3.finos.org/schemas/next/image.schema.json",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/image.schema.json",
44
"title": "Image",
55
"description": "Metadata relating to a single image at a remote URL, used to represent screenshot images.",
66
"type": "object",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://fdc3.finos.org/schemas/next/api/implementationMetadata.schema.json",
4+
"title": "ImplementationMetadata",
5+
"description": "Metadata relating to the FDC3 DesktopAgent object and its provider",
6+
"type": "object",
7+
"properties": {
8+
"fdc3Version": {
9+
"type": "string"
10+
},
11+
"provider": {
12+
"type": "string"
13+
},
14+
"providerVersion": {
15+
"type": "string"
16+
},
17+
"optionalFeatures": {
18+
"type": "object",
19+
"properties": {
20+
"OriginatingAppMetadata": {
21+
"type": "boolean"
22+
},
23+
"UserChannelMembershipAPIs": {
24+
"type": "boolean"
25+
},
26+
"DesktopAgentBridging": {
27+
"type": "boolean"
28+
}
29+
},
30+
"required": [
31+
"OriginatingAppMetadata",
32+
"UserChannelMembershipAPIs"
33+
],
34+
"additionalProperties": false
35+
},
36+
"appMetadata": {
37+
"$ref": "appMetadata.schema.json"
38+
}
39+
},
40+
"required": [
41+
"fdc3Version",
42+
"provider",
43+
"optionalFeatures",
44+
"appMetadata"
45+
],
46+
"additionalProperties": false
47+
}

0 commit comments

Comments
 (0)