From 07d7cf49685a8b6a4d0923b07d59ec9cd530ebd9 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Tue, 8 Jul 2025 18:38:51 +0200 Subject: [PATCH 1/9] Enhance protocol #17 --- api/csolution-openapi.yml | 104 +++++++++++------- bridge/.vscode/launch.json | 3 +- bridge/src/server.ts | 24 +++- codegen/src/codegen.ts | 5 +- .../src/rpc-interface.ts | 15 +++ 5 files changed, 109 insertions(+), 42 deletions(-) diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index 7fe2628..46d1b54 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -1,7 +1,7 @@ openapi: 3.1.0 info: title: csolution rpc - version: 0.0.1 + version: 0.0.2 description: Specification of remote procedure call methods for CMSIS csolution integration license: name: Apache 2.0 @@ -43,6 +43,17 @@ paths: '200': description: OK content: {application/json: {schema: {$ref: '#/components/schemas/ApplyResponse'}}} + /rpc/Resolve: + post: + summary: Resolve trivial component dependencies + description: Resolve trivial component dependencies for the given context + tags: [/rpc] + requestBody: + content: {application/json: {schema: {$ref: '#/components/schemas/ResolveRequest'}}} + responses: + '200': + description: OK + content: {application/json: {schema: {$ref: '#/components/schemas/ResolveResponse'}}} /rpc/LoadPacks: post: summary: Load installed and local packs @@ -120,17 +131,6 @@ paths: '200': description: OK content: {application/json: {schema: {$ref: '#/components/schemas/SelectVariantResponse'}}} - /rpc/SelectVersion: - post: - summary: Select version - description: Select version - tags: [/rpc] - requestBody: - content: {application/json: {schema: {$ref: '#/components/schemas/SelectVersionRequest'}}} - responses: - '200': - description: OK - content: {application/json: {schema: {$ref: '#/components/schemas/SelectVersionResponse'}}} /rpc/SelectBundle: post: summary: Select bundle @@ -221,12 +221,27 @@ components: description: Maximum of supported component instances required: - pack + Options: + type: object + properties: + version: + type: string + description: 'Version requirement in SemVer syntax: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#name-conventions' + fixedVendor: + type: boolean + description: Flag to prefix component ID with vendor when adding component to project or layer + enforced: + type: boolean + description: Flag to enforce exact component vendor, version, condition and originating pack CtItem: type: object properties: name: type: string description: Name of element + result: + type: string + description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' required: - name ComponentInstance: @@ -242,7 +257,9 @@ components: $ref: '#/components/schemas/Component' layer: type: string - description: Layer + description: Absolute path to layer file + options: + $ref: '#/components/schemas/Options' required: - id - selectedCount @@ -282,6 +299,8 @@ components: layer: type: string description: Layer + options: + $ref: '#/components/schemas/Options' required: - id - variants @@ -470,6 +489,27 @@ components: - properties: result: type: boolean + ResolveRequest: + allOf: + - $ref: '#/x-jsonrpc-envelope-request-with-params' + - properties: + method: + type: string + const: Resolve + params: + type: object + properties: + context: + type: string + required: + - context + ResolveResponse: + allOf: + - $ref: '#/x-jsonrpc-envelope-response' + - properties: + result: + type: boolean + description: true if all dependencies are resolved LoadPacksRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request' @@ -483,6 +523,7 @@ components: - properties: result: type: boolean + description: installed packs are loaded successfully LoadSolutionRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -503,6 +544,7 @@ components: - properties: result: type: boolean + description: Solution is loaded successfully GetPacksInfoRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -580,8 +622,14 @@ components: type: string id: type: string + description: component aggregate ID count: type: integer + description: number of instances to select, 0 to select unselect + options: + $ref: '#/components/schemas/Options' + layer: + type: string required: - context - id @@ -592,6 +640,7 @@ components: - properties: result: type: boolean + description: true if selection is changed SelectVariantRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -606,6 +655,7 @@ components: type: string id: type: string + description: component aggregate ID variant: type: string required: @@ -618,32 +668,7 @@ components: - properties: result: type: boolean - SelectVersionRequest: - allOf: - - $ref: '#/x-jsonrpc-envelope-request-with-params' - - properties: - method: - type: string - const: SelectVersion - params: - type: object - properties: - context: - type: string - id: - type: string - version: - type: string - required: - - context - - id - - version - SelectVersionResponse: - allOf: - - $ref: '#/x-jsonrpc-envelope-response' - - properties: - result: - type: boolean + description: true if selection is changed SelectBundleRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -670,6 +695,7 @@ components: - properties: result: type: boolean + description: true if selection is changed ValidateComponentsRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' diff --git a/bridge/.vscode/launch.json b/bridge/.vscode/launch.json index 0135bd5..5a457f6 100644 --- a/bridge/.vscode/launch.json +++ b/bridge/.vscode/launch.json @@ -16,7 +16,8 @@ "preLaunchTask": "tsc: build - tsconfig.json", "outFiles": [ "${workspaceFolder}/**/*.js" - ] + ], + "envFile": "${workspaceFolder}/.env" } ] } diff --git a/bridge/src/server.ts b/bridge/src/server.ts index 8c31f64..038525a 100644 --- a/bridge/src/server.ts +++ b/bridge/src/server.ts @@ -7,13 +7,35 @@ import { ChildProcess, spawn } from "node:child_process"; import express from 'express'; import cors from 'cors'; +import path from "node:path"; let child: ChildProcess|undefined; const app = express(); const port = 3000; function launch(): boolean { - child = spawn('csolution', ['rpc'], { cwd: './' }); + + + // Determine platform specifics + const isWindows = process.platform === 'win32'; + const binaryName = isWindows ? 'csolution.exe' : 'csolution'; + + let csolutionBinPath = undefined; + // Override with environment variable if available + if (process.env.CSOLUTION_PATH) { + console.log('Found CSOLUTION_PATH in environment:', process.env.CSOLUTION_PATH); + csolutionBinPath = process.env.CSOLUTION_PATH; + } + + // Resolve the final path to the executable + const csolutionBin = csolutionBinPath ? path.resolve(csolutionBinPath, binaryName) : binaryName; + console.log('Running csolution:', csolutionBin); + + const csolutionArgs = process.env.CSOLUTION_ARGS ?? ''; + const args = csolutionArgs.split(',').map(s => s.trim()); + child = spawn(csolutionBin, ['rpc', ...args], // append extra args from env + { cwd: './' } + ); child.on('error', (err) => { console.error(err.message); diff --git a/codegen/src/codegen.ts b/codegen/src/codegen.ts index bbf8f09..26d15bb 100644 --- a/codegen/src/codegen.ts +++ b/codegen/src/codegen.ts @@ -171,6 +171,9 @@ using namespace jsonrpccxx;\n`; public getType(name: string, item: any, suffix?: string, prefix?: string) : { cpp: string, ts: string } { let cppType = ''; let tsType = ''; + if(!item) { + return { cpp: cppType, ts: tsType }; + } if (item.$ref) { const ref = item.$ref.match(/^#\/components\/schemas\/(.*)/); tsType = ref ? ref[1] : ''; @@ -264,7 +267,7 @@ using namespace jsonrpccxx;\n`; const cppParams: string[] = []; const cppRegParams: string[] = []; for (const [param, item] of Object.entries(params.properties)) { - cppParams.push(`const ${this.getType(name, item).cpp}& ${param}`); + cppParams.push(`const ${this.getType(name, item, '', 'RpcArgs::').cpp}& ${param}`); cppRegParams.push(`"${param}"`); } cppFunction += cppParams.join(", "); diff --git a/examples/vscode-extension-client/src/rpc-interface.ts b/examples/vscode-extension-client/src/rpc-interface.ts index 1f3faf4..317cbf4 100644 --- a/examples/vscode-extension-client/src/rpc-interface.ts +++ b/examples/vscode-extension-client/src/rpc-interface.ts @@ -24,14 +24,21 @@ export interface Component extends Common { implements?: string, maxInstances?: number, } +export interface Options { + version?: string, + fixedVendor?: boolean, + enforced?: boolean, +} export interface CtItem { name: string, + result?: string, } export interface ComponentInstance { id: string, selectedCount: number, resolvedComponent?: Component, layer?: string, + options?: Options, } export interface CtVariant extends CtItem { components: Component[], @@ -43,6 +50,7 @@ export interface CtAggregate extends CtItem { selectedCount?: number, variants: CtVariant[], layer?: string, + options?: Options, } export interface CtTreeItem extends CtItem { cgroups?: CtGroup[], @@ -91,6 +99,9 @@ export interface LogMessages { export interface ApplyParams { context: string, } +export interface ResolveParams { + context: string, +} export interface LoadSolutionParams { solution: string, } @@ -132,6 +143,7 @@ export interface RpcInterface { getVersion(): Promise; shutdown(): Promise; apply(args: ApplyParams): Promise; + resolve(args: ResolveParams): Promise; loadPacks(): Promise; loadSolution(args: LoadSolutionParams): Promise; getPacksInfo(args: GetPacksInfoParams): Promise; @@ -158,6 +170,9 @@ export abstract class RpcMethods implements RpcInterface { public async apply(args: ApplyParams): Promise { return this.get('Apply', args); } + public async resolve(args: ResolveParams): Promise { + return this.get('Resolve', args); + } public async loadPacks(): Promise { return this.get('LoadPacks'); } From 5f6407460e0f4559873b73158e8c79aec2951d05 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 13:46:13 +0200 Subject: [PATCH 2/9] Enhance protocol Options and SuccessResult --- api/csolution-openapi.yml | 93 ++++++++++++++++++++++----------------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index 46d1b54..716ff51 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -224,26 +224,15 @@ components: Options: type: object properties: - version: - type: string - description: 'Version requirement in SemVer syntax: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#name-conventions' - fixedVendor: - type: boolean - description: Flag to prefix component ID with vendor when adding component to project or layer - enforced: - type: boolean - description: Flag to enforce exact component vendor, version, condition and originating pack - CtItem: - type: object - properties: - name: + layer: type: string - description: Name of element - result: + description: Absolute path to .clayer.yml file + explicitVersion: type: string - description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' - required: - - name + description: 'Version requirement in SemVer syntax: https://open-cmsis-pack.github.io/cmsis-toolbox/YML-Input-Format/#name-conventions empty ' + explicitVendor: + type: boolean + description: Flag to prefix component ID with vendor when adding component to project or layer, false ComponentInstance: type: object properties: @@ -253,16 +242,30 @@ components: selectedCount: type: integer description: Number of selected instances - resolvedComponent: - $ref: '#/components/schemas/Component' - layer: + generator: type: string - description: Absolute path to layer file + description: Associated generator name + fixed: + type: boolean + description: Component cannot be unselected options: $ref: '#/components/schemas/Options' + resolvedComponent: + $ref: '#/components/schemas/Component' required: - id - selectedCount + CtItem: + type: object + properties: + name: + type: string + description: Name of element + result: + type: string + description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' + required: + - name CtVariant: allOf: - $ref: '#/components/schemas/CtItem' @@ -292,13 +295,16 @@ components: selectedCount: type: integer description: Number of selected instances + generator: + type: string + description: Associated generator name + fixed: + type: boolean + description: Component cannot be unselected variants: type: array items: $ref: '#/components/schemas/CtVariant' - layer: - type: string - description: Layer options: $ref: '#/components/schemas/Options' required: @@ -409,6 +415,9 @@ components: Results: type: object properties: + result: + type: string + description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' validation: type: array items: @@ -488,7 +497,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean + $ref: '#/components/schemas/SuccessResult' ResolveRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -508,8 +517,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: true if all dependencies are resolved + $ref: '#/components/schemas/SuccessResult' LoadPacksRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request' @@ -522,8 +530,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: installed packs are loaded successfully + $ref: '#/components/schemas/SuccessResult' LoadSolutionRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -543,8 +550,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: Solution is loaded successfully + $ref: '#/components/schemas/SuccessResult' GetPacksInfoRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -628,19 +634,28 @@ components: description: number of instances to select, 0 to select unselect options: $ref: '#/components/schemas/Options' - layer: - type: string required: - context - id - count + - options + SuccessResult: + type: object + properties: + success: + type: boolean + description: true if requested operation has been performed successfully or selection has been modified + message: + type: string + description: optional error/warning/info message + required: + - modified SelectComponentResponse: allOf: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: true if selection is changed + $ref: '#/components/schemas/SuccessResult' SelectVariantRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -667,8 +682,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: true if selection is changed + $ref: '#/components/schemas/SuccessResult' SelectBundleRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -694,8 +708,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean - description: true if selection is changed + $ref: '#/components/schemas/SuccessResult' ValidateComponentsRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' From 7a8ee9030874ffe2eeeae2a49c884b655a74c0c0 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 14:51:17 +0200 Subject: [PATCH 3/9] Enhance protocol Options and SuccessResult Merge from main: generator --- api/csolution-openapi.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index 716ff51..02e3873 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -422,6 +422,8 @@ components: type: array items: $ref: '#/components/schemas/Result' + required: + - result UsedItems: type: object properties: From 07585fc77fccca7ef647669f36db857e2f0784bd Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 14:55:19 +0200 Subject: [PATCH 4/9] Regenerate rpc-interface.ts in examples --- .../src/rpc-interface.ts | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/examples/vscode-extension-client/src/rpc-interface.ts b/examples/vscode-extension-client/src/rpc-interface.ts index 317cbf4..88702d0 100644 --- a/examples/vscode-extension-client/src/rpc-interface.ts +++ b/examples/vscode-extension-client/src/rpc-interface.ts @@ -25,20 +25,21 @@ export interface Component extends Common { maxInstances?: number, } export interface Options { - version?: string, - fixedVendor?: boolean, - enforced?: boolean, -} -export interface CtItem { - name: string, - result?: string, + layer?: string, + explicitVersion?: string, + explicitVendor?: boolean, } export interface ComponentInstance { id: string, selectedCount: number, - resolvedComponent?: Component, - layer?: string, + generator?: string, + fixed?: boolean, options?: Options, + resolvedComponent?: Component, +} +export interface CtItem { + name: string, + result?: string, } export interface CtVariant extends CtItem { components: Component[], @@ -48,8 +49,9 @@ export interface CtAggregate extends CtItem { activeVariant?: string, activeVersion?: string, selectedCount?: number, + generator?: string, + fixed?: boolean, variants: CtVariant[], - layer?: string, options?: Options, } export interface CtTreeItem extends CtItem { @@ -85,6 +87,7 @@ export interface Result { conditions?: Condition[], } export interface Results { + result: string, validation?: Result[], } export interface UsedItems { @@ -119,17 +122,17 @@ export interface SelectComponentParams { context: string, id: string, count: number, + options: Options, +} +export interface SuccessResult { + success?: boolean, + message?: string, } export interface SelectVariantParams { context: string, id: string, variant: string, } -export interface SelectVersionParams { - context: string, - id: string, - version: string, -} export interface SelectBundleParams { context: string, cclass: string, @@ -142,17 +145,16 @@ export interface ValidateComponentsParams { export interface RpcInterface { getVersion(): Promise; shutdown(): Promise; - apply(args: ApplyParams): Promise; - resolve(args: ResolveParams): Promise; - loadPacks(): Promise; - loadSolution(args: LoadSolutionParams): Promise; + apply(args: ApplyParams): Promise; + resolve(args: ResolveParams): Promise; + loadPacks(): Promise; + loadSolution(args: LoadSolutionParams): Promise; getPacksInfo(args: GetPacksInfoParams): Promise; getUsedItems(args: GetUsedItemsParams): Promise; getComponentsTree(args: GetComponentsTreeParams): Promise; - selectComponent(args: SelectComponentParams): Promise; - selectVariant(args: SelectVariantParams): Promise; - selectVersion(args: SelectVersionParams): Promise; - selectBundle(args: SelectBundleParams): Promise; + selectComponent(args: SelectComponentParams): Promise; + selectVariant(args: SelectVariantParams): Promise; + selectBundle(args: SelectBundleParams): Promise; validateComponents(args: ValidateComponentsParams): Promise; getLogMessages(): Promise; } @@ -167,16 +169,16 @@ export abstract class RpcMethods implements RpcInterface { public async shutdown(): Promise { return this.get('Shutdown'); } - public async apply(args: ApplyParams): Promise { + public async apply(args: ApplyParams): Promise { return this.get('Apply', args); } - public async resolve(args: ResolveParams): Promise { + public async resolve(args: ResolveParams): Promise { return this.get('Resolve', args); } - public async loadPacks(): Promise { + public async loadPacks(): Promise { return this.get('LoadPacks'); } - public async loadSolution(args: LoadSolutionParams): Promise { + public async loadSolution(args: LoadSolutionParams): Promise { return this.get('LoadSolution', args); } public async getPacksInfo(args: GetPacksInfoParams): Promise { @@ -188,16 +190,13 @@ export abstract class RpcMethods implements RpcInterface { public async getComponentsTree(args: GetComponentsTreeParams): Promise { return this.get('GetComponentsTree', args); } - public async selectComponent(args: SelectComponentParams): Promise { + public async selectComponent(args: SelectComponentParams): Promise { return this.get('SelectComponent', args); } - public async selectVariant(args: SelectVariantParams): Promise { + public async selectVariant(args: SelectVariantParams): Promise { return this.get('SelectVariant', args); } - public async selectVersion(args: SelectVersionParams): Promise { - return this.get('SelectVersion', args); - } - public async selectBundle(args: SelectBundleParams): Promise { + public async selectBundle(args: SelectBundleParams): Promise { return this.get('SelectBundle', args); } public async validateComponents(args: ValidateComponentsParams): Promise { From dd9f554a4173cec145bce05c2792cc47a779fdd4 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 14:59:02 +0200 Subject: [PATCH 5/9] Fix SuccessResult --- csolution-rpc.code-workspace | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/csolution-rpc.code-workspace b/csolution-rpc.code-workspace index a4abb29..3be3652 100644 --- a/csolution-rpc.code-workspace +++ b/csolution-rpc.code-workspace @@ -13,5 +13,7 @@ "path": "examples/vscode-extension-client" } ], - "settings": {} + "settings": { + "terminal.integrated.defaultProfile.windows": "Command Prompt" + } } From 54446bdbdd9befa9aa2667970c1ccfa2e84d32e5 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 14:59:32 +0200 Subject: [PATCH 6/9] Fix SuccessResult --- api/csolution-openapi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index 02e3873..fdf41c8 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -651,7 +651,7 @@ components: type: string description: optional error/warning/info message required: - - modified + - success SelectComponentResponse: allOf: - $ref: '#/x-jsonrpc-envelope-response' From 891d76483dbf64519f7c5fae0c3c9344982802ed Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 15:02:03 +0200 Subject: [PATCH 7/9] Revert settings change in workspace --- csolution-rpc.code-workspace | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/csolution-rpc.code-workspace b/csolution-rpc.code-workspace index 3be3652..a4abb29 100644 --- a/csolution-rpc.code-workspace +++ b/csolution-rpc.code-workspace @@ -13,7 +13,5 @@ "path": "examples/vscode-extension-client" } ], - "settings": { - "terminal.integrated.defaultProfile.windows": "Command Prompt" - } + "settings": {} } From 4402dfa6a3b50b96d62c1f04e0bc8514558e3e4a Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Thu, 10 Jul 2025 15:04:32 +0200 Subject: [PATCH 8/9] Regenerate rpc-interface.ts in examples --- examples/vscode-extension-client/src/rpc-interface.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/vscode-extension-client/src/rpc-interface.ts b/examples/vscode-extension-client/src/rpc-interface.ts index 88702d0..754c497 100644 --- a/examples/vscode-extension-client/src/rpc-interface.ts +++ b/examples/vscode-extension-client/src/rpc-interface.ts @@ -125,7 +125,7 @@ export interface SelectComponentParams { options: Options, } export interface SuccessResult { - success?: boolean, + success: boolean, message?: string, } export interface SelectVariantParams { From 69c7dc26ee76f0f8f406ee2700dd6826c2c95855 Mon Sep 17 00:00:00 2001 From: Evgueni Driouk Date: Fri, 11 Jul 2025 15:29:28 +0200 Subject: [PATCH 9/9] Make all calls return SuccessResult values --- api/csolution-openapi.yml | 153 ++++++++++-------- .../src/rpc-interface.ts | 29 ++-- 2 files changed, 99 insertions(+), 83 deletions(-) diff --git a/api/csolution-openapi.yml b/api/csolution-openapi.yml index fdf41c8..4d71dd7 100644 --- a/api/csolution-openapi.yml +++ b/api/csolution-openapi.yml @@ -167,6 +167,17 @@ paths: components: schemas: + SuccessResult: + type: object + properties: + success: + type: boolean + description: true if requested operation has been performed successfully or selection has been modified + message: + type: string + description: optional error/warning/info message + required: + - success Common: type: object properties: @@ -197,15 +208,16 @@ components: items: type: string PacksInfo: - type: object - properties: - packs: - type: array - description: List of packs information - items: - $ref: '#/components/schemas/Pack' - required: - - packs + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + packs: + type: array + description: List of packs information + items: + $ref: '#/components/schemas/Pack' + required: + - packs Component: allOf: - $ref: '#/components/schemas/Common' @@ -367,16 +379,16 @@ components: required: - bundles CtRoot: - type: object - description: Root of Component Tree - properties: - classes: - type: array - description: Array of Component Classes - items: - $ref: '#/components/schemas/CtClass' - required: - - classes + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + classes: + type: array + description: Array of Component Classes + items: + $ref: '#/components/schemas/CtClass' + required: + - classes Condition: type: object properties: @@ -413,46 +425,50 @@ components: - id - result Results: - type: object - properties: - result: - type: string - description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' - validation: - type: array - items: - $ref: '#/components/schemas/Result' - required: - - result + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + result: + type: string + description: 'Condition result: https://github.com/Open-CMSIS-Pack/devtools/blob/tools/projmgr/2.8.0/libs/rtemodel/include/RteItem.h#L78-L95' + validation: + type: array + items: + $ref: '#/components/schemas/Result' + required: + - result UsedItems: - type: object - properties: - components: - type: array - items: - $ref: '#/components/schemas/ComponentInstance' - packs: - type: array - items: - $ref: '#/components/schemas/Pack' - required: - - components - - packs + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + components: + type: array + items: + $ref: '#/components/schemas/ComponentInstance' + packs: + type: array + items: + $ref: '#/components/schemas/Pack' + required: + - components + - packs + LogMessages: - type: object - properties: - info: - type: array - items: - type: string - errors: - type: array - items: - type: string - warnings: - type: array - items: - type: string + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + info: + type: array + items: + type: string + errors: + type: array + items: + type: string + warnings: + type: array + items: + type: string GetVersionRequest: allOf: @@ -461,12 +477,20 @@ components: method: type: string const: GetVersion + + GetVersionResult: + allOf: + - $ref: '#/components/schemas/SuccessResult' + - properties: + version: + type: string + description: Tool version GetVersionResponse: allOf: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: string + $ref: '#/components/schemas/GetVersionResult' ShutdownRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request' @@ -479,7 +503,7 @@ components: - $ref: '#/x-jsonrpc-envelope-response' - properties: result: - type: boolean + $ref: '#/components/schemas/SuccessResult' ApplyRequest: allOf: - $ref: '#/x-jsonrpc-envelope-request-with-params' @@ -641,17 +665,6 @@ components: - id - count - options - SuccessResult: - type: object - properties: - success: - type: boolean - description: true if requested operation has been performed successfully or selection has been modified - message: - type: string - description: optional error/warning/info message - required: - - success SelectComponentResponse: allOf: - $ref: '#/x-jsonrpc-envelope-response' diff --git a/examples/vscode-extension-client/src/rpc-interface.ts b/examples/vscode-extension-client/src/rpc-interface.ts index 754c497..7e6dc69 100644 --- a/examples/vscode-extension-client/src/rpc-interface.ts +++ b/examples/vscode-extension-client/src/rpc-interface.ts @@ -6,6 +6,10 @@ * json-rpc-codegen generated file: DO NOT EDIT! */ +export interface SuccessResult { + success: boolean, + message?: string, +} export interface Common { id: string, description?: string, @@ -16,7 +20,7 @@ export interface Pack extends Common { used?: boolean, references?: string[], } -export interface PacksInfo { +export interface PacksInfo extends SuccessResult { packs: Pack[], } export interface Component extends Common { @@ -73,7 +77,7 @@ export interface CtClass extends CtItem { activeBundle?: string, bundles: CtBundle[], } -export interface CtRoot { +export interface CtRoot extends SuccessResult { classes: CtClass[], } export interface Condition { @@ -86,19 +90,22 @@ export interface Result { aggregates?: string[], conditions?: Condition[], } -export interface Results { +export interface Results extends SuccessResult { result: string, validation?: Result[], } -export interface UsedItems { +export interface UsedItems extends SuccessResult { components: ComponentInstance[], packs: Pack[], } -export interface LogMessages { +export interface LogMessages extends SuccessResult { info?: string[], errors?: string[], warnings?: string[], } +export interface GetVersionResult extends SuccessResult { + version?: string, +} export interface ApplyParams { context: string, } @@ -124,10 +131,6 @@ export interface SelectComponentParams { count: number, options: Options, } -export interface SuccessResult { - success: boolean, - message?: string, -} export interface SelectVariantParams { context: string, id: string, @@ -143,8 +146,8 @@ export interface ValidateComponentsParams { } export interface RpcInterface { - getVersion(): Promise; - shutdown(): Promise; + getVersion(): Promise; + shutdown(): Promise; apply(args: ApplyParams): Promise; resolve(args: ResolveParams): Promise; loadPacks(): Promise; @@ -163,10 +166,10 @@ export abstract class RpcMethods implements RpcInterface { abstract get(remoteMethod: string, args?: TArgs): Promise; - public async getVersion(): Promise { + public async getVersion(): Promise { return this.get('GetVersion'); } - public async shutdown(): Promise { + public async shutdown(): Promise { return this.get('Shutdown'); } public async apply(args: ApplyParams): Promise {