diff --git a/packages/cactus-cmd-api-server/package-lock.json b/packages/cactus-cmd-api-server/package-lock.json index f4bfbf25cf..7e0aa3fa93 100644 --- a/packages/cactus-cmd-api-server/package-lock.json +++ b/packages/cactus-cmd-api-server/package-lock.json @@ -222,6 +222,14 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "axios": { + "version": "0.21.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz", + "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==", + "requires": { + "follow-redirects": "^1.10.0" + } + }, "base64-js": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", @@ -643,6 +651,11 @@ "unpipe": "~1.0.0" } }, + "follow-redirects": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz", + "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg==" + }, "forwarded": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", diff --git a/packages/cactus-cmd-api-server/package.json b/packages/cactus-cmd-api-server/package.json index 5dbfe2243a..853baaa6d3 100644 --- a/packages/cactus-cmd-api-server/package.json +++ b/packages/cactus-cmd-api-server/package.json @@ -16,6 +16,7 @@ "types": "dist/types/main/typescript/index.d.ts", "scripts": { "generate-sdk": "openapi-generator generate --input-spec src/main/json/openapi.json -g typescript-axios -o src/main/typescript/generated/openapi/typescript-axios/ --reserved-words-mappings protected=protected", + "pretsc": "npm run generate-sdk", "tsc": "tsc --project ./tsconfig.json", "watch": "npm-watch", "webpack": "npm-run-all webpack:dev webpack:prod", @@ -35,7 +36,10 @@ "ignore": [ "src/**/generated/*" ], - "extensions": ["ts", "json"], + "extensions": [ + "ts", + "json" + ], "quiet": true, "verbose": false, "runOnChangeOnly": true @@ -85,6 +89,7 @@ "@hyperledger/cactus-core-api": "0.3.0", "@hyperledger/cactus-plugin-consortium-manual": "0.3.0", "@hyperledger/cactus-plugin-keychain-memory": "0.3.0", + "axios": "0.21.1", "body-parser": "1.19.0", "compression": "1.7.4", "convict": "6.0.0", diff --git a/packages/cactus-cmd-api-server/src/main/json/openapi.json b/packages/cactus-cmd-api-server/src/main/json/openapi.json index c7ad9278dd..abc4f9045c 100644 --- a/packages/cactus-cmd-api-server/src/main/json/openapi.json +++ b/packages/cactus-cmd-api-server/src/main/json/openapi.json @@ -87,7 +87,7 @@ "path": "/api/v1/api-server/healthcheck" } }, - "operationId": "getConsortiumJws", + "operationId": "getHealthCheck", "parameters": [], "responses": { "200": { diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore new file mode 100644 index 0000000000..ecd97ff37f --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator-ignore @@ -0,0 +1,27 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md + +git_push.sh +.npmignore +.gitignore \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES new file mode 100644 index 0000000000..c123dd7d45 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/FILES @@ -0,0 +1,4 @@ +api.ts +base.ts +configuration.ts +index.ts diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION new file mode 100644 index 0000000000..1a487e1a2e --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/.openapi-generator/VERSION @@ -0,0 +1 @@ +5.0.0-beta2 \ No newline at end of file diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/api.ts b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/api.ts new file mode 100644 index 0000000000..0ea32cb0b4 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/api.ts @@ -0,0 +1,189 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus API + * Interact with a Cactus deployment through HTTP. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { Configuration } from './configuration'; +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; +// Some imports not used depending on template conditions +// @ts-ignore +import { BASE_PATH, COLLECTION_FORMATS, RequestArgs, BaseAPI, RequiredError } from './base'; + +/** + * + * @export + * @interface HealthCheckResponse + */ +export interface HealthCheckResponse { + /** + * + * @type {boolean} + * @memberof HealthCheckResponse + */ + success?: boolean; + /** + * + * @type {string} + * @memberof HealthCheckResponse + */ + createdAt: string; + /** + * + * @type {MemoryUsage} + * @memberof HealthCheckResponse + */ + memoryUsage: MemoryUsage; +} +/** + * + * @export + * @interface MemoryUsage + */ +export interface MemoryUsage { + /** + * + * @type {number} + * @memberof MemoryUsage + */ + rss?: number; + /** + * + * @type {number} + * @memberof MemoryUsage + */ + heapTotal?: number; + /** + * + * @type {number} + * @memberof MemoryUsage + */ + heapUsed?: number; + /** + * + * @type {number} + * @memberof MemoryUsage + */ + external?: number; + /** + * + * @type {number} + * @memberof MemoryUsage + */ + arrayBuffers?: number; +} + +/** + * DefaultApi - axios parameter creator + * @export + */ +export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) { + return { + /** + * Returns the current timestamp of the API server as proof of health/liveness + * @summary Can be used to verify liveness of an API server instance + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getHealthCheck: async (options: any = {}): Promise => { + const localVarPath = `/api/v1/api-server/healthcheck`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, 'https://example.com'); + let baseOptions; + if (configuration) { + baseOptions = configuration.baseOptions; + } + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options}; + const localVarHeaderParameter = {} as any; + const localVarQueryParameter = {} as any; + + + + const query = new URLSearchParams(localVarUrlObj.search); + for (const key in localVarQueryParameter) { + query.set(key, localVarQueryParameter[key]); + } + for (const key in options.query) { + query.set(key, options.query[key]); + } + localVarUrlObj.search = (new URLSearchParams(query)).toString(); + let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; + + return { + url: localVarUrlObj.pathname + localVarUrlObj.search + localVarUrlObj.hash, + options: localVarRequestOptions, + }; + }, + } +}; + +/** + * DefaultApi - functional programming interface + * @export + */ +export const DefaultApiFp = function(configuration?: Configuration) { + return { + /** + * Returns the current timestamp of the API server as proof of health/liveness + * @summary Can be used to verify liveness of an API server instance + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + async getHealthCheck(options?: any): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise> { + const localVarAxiosArgs = await DefaultApiAxiosParamCreator(configuration).getHealthCheck(options); + return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => { + const axiosRequestArgs = {...localVarAxiosArgs.options, url: basePath + localVarAxiosArgs.url}; + return axios.request(axiosRequestArgs); + }; + }, + } +}; + +/** + * DefaultApi - factory interface + * @export + */ +export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) { + return { + /** + * Returns the current timestamp of the API server as proof of health/liveness + * @summary Can be used to verify liveness of an API server instance + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + getHealthCheck(options?: any): AxiosPromise { + return DefaultApiFp(configuration).getHealthCheck(options).then((request) => request(axios, basePath)); + }, + }; +}; + +/** + * DefaultApi - object-oriented interface + * @export + * @class DefaultApi + * @extends {BaseAPI} + */ +export class DefaultApi extends BaseAPI { + /** + * Returns the current timestamp of the API server as proof of health/liveness + * @summary Can be used to verify liveness of an API server instance + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof DefaultApi + */ + public getHealthCheck(options?: any) { + return DefaultApiFp(this.configuration).getHealthCheck(options).then((request) => request(this.axios, this.basePath)); + } +} + + diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/base.ts b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/base.ts new file mode 100644 index 0000000000..adf5c6b69d --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/base.ts @@ -0,0 +1,71 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus API + * Interact with a Cactus deployment through HTTP. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import { Configuration } from "./configuration"; +// Some imports not used depending on template conditions +// @ts-ignore +import globalAxios, { AxiosPromise, AxiosInstance } from 'axios'; + +export const BASE_PATH = "https://www.cactus.stream".replace(/\/+$/, ""); + +/** + * + * @export + */ +export const COLLECTION_FORMATS = { + csv: ",", + ssv: " ", + tsv: "\t", + pipes: "|", +}; + +/** + * + * @export + * @interface RequestArgs + */ +export interface RequestArgs { + url: string; + options: any; +} + +/** + * + * @export + * @class BaseAPI + */ +export class BaseAPI { + protected configuration: Configuration | undefined; + + constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) { + if (configuration) { + this.configuration = configuration; + this.basePath = configuration.basePath || this.basePath; + } + } +}; + +/** + * + * @export + * @class RequiredError + * @extends {Error} + */ +export class RequiredError extends Error { + name: "RequiredError" = "RequiredError"; + constructor(public field: string, msg?: string) { + super(msg); + } +} diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/configuration.ts b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/configuration.ts new file mode 100644 index 0000000000..f4f99880d4 --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/configuration.ts @@ -0,0 +1,76 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus API + * Interact with a Cactus deployment through HTTP. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export interface ConfigurationParameters { + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + username?: string; + password?: string; + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + basePath?: string; + baseOptions?: any; +} + +export class Configuration { + /** + * parameter for apiKey security + * @param name security name + * @memberof Configuration + */ + apiKey?: string | Promise | ((name: string) => string) | ((name: string) => Promise); + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + username?: string; + /** + * parameter for basic security + * + * @type {string} + * @memberof Configuration + */ + password?: string; + /** + * parameter for oauth2 security + * @param name security name + * @param scopes oauth2 scope + * @memberof Configuration + */ + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise); + /** + * override base path + * + * @type {string} + * @memberof Configuration + */ + basePath?: string; + /** + * base options for axios calls + * + * @type {any} + * @memberof Configuration + */ + baseOptions?: any; + + constructor(param: ConfigurationParameters = {}) { + this.apiKey = param.apiKey; + this.username = param.username; + this.password = param.password; + this.accessToken = param.accessToken; + this.basePath = param.basePath; + this.baseOptions = param.baseOptions; + } +} diff --git a/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/index.ts b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/index.ts new file mode 100644 index 0000000000..eb4082062f --- /dev/null +++ b/packages/cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios/index.ts @@ -0,0 +1,18 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * Hyperledger Cactus API + * Interact with a Cactus deployment through HTTP. + * + * The version of the OpenAPI document: 0.0.1 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +export * from "./api"; +export * from "./configuration"; + diff --git a/packages/cactus-cmd-api-server/src/main/typescript/index.web.ts b/packages/cactus-cmd-api-server/src/main/typescript/index.web.ts index cb0ff5c3b5..bdf54028d2 100755 --- a/packages/cactus-cmd-api-server/src/main/typescript/index.web.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/index.web.ts @@ -1 +1 @@ -export {}; +export * from "./generated/openapi/typescript-axios/index"; diff --git a/packages/cactus-cmd-api-server/src/main/typescript/public-api.ts b/packages/cactus-cmd-api-server/src/main/typescript/public-api.ts index 1d46a22591..4945faa828 100755 --- a/packages/cactus-cmd-api-server/src/main/typescript/public-api.ts +++ b/packages/cactus-cmd-api-server/src/main/typescript/public-api.ts @@ -15,3 +15,5 @@ export { ForgePrivateKey, IPki, } from "./config/self-signed-pki-generator"; + +export * from "./generated/openapi/typescript-axios/index";