diff --git a/bdd/data/python-weather-startup-config.json b/bdd/data/python-weather-startup-config.json new file mode 100644 index 000000000..f2843fb55 --- /dev/null +++ b/bdd/data/python-weather-startup-config.json @@ -0,0 +1,12 @@ +{ + "appConfig": { + "current": [ + "temperature_2m", + "is_day", + "rain", + "snowfall", + "wind_speed_10m" + ] + }, + "args": [{ "cities": ["Warszawa", "Berlin", "Moskwa"] }] +} diff --git a/bdd/features/e2e/E2E-010-cli.feature b/bdd/features/e2e/E2E-010-cli.feature index 80e6647de..098652ebf 100644 --- a/bdd/features/e2e/E2E-010-cli.feature +++ b/bdd/features/e2e/E2E-010-cli.feature @@ -174,4 +174,11 @@ Feature: CLI tests When I execute CLI with "seq send ../packages/endless-names-output.tar.gz" And I execute CLI with "seq start - --startup-config ../bdd/data/seq-startup-config.json" And I execute CLI with "inst info -" - Then Instance info should contain provided parameters + Then Instance info should contain provided parameters in "seq-startup-config.json" + + @ci-api @cli + Scenario: E2E-010 TC-021 Test Start sequence in python with startup-config + When I execute CLI with "seq send ../packages/python-weather-args.tar.gz" + And I execute CLI with "seq start - --startup-config ../bdd/data/python-weather-startup-config.json" + And I execute CLI with "inst info -" + Then Instance info should contain provided parameters in "python-weather-startup-config.json" \ No newline at end of file diff --git a/bdd/step-definitions/e2e/cli.ts b/bdd/step-definitions/e2e/cli.ts index 54ef3e6e4..6d9e752f7 100644 --- a/bdd/step-definitions/e2e/cli.ts +++ b/bdd/step-definitions/e2e/cli.ts @@ -554,29 +554,30 @@ Then("I should see exitCode: {string}", async function ( } }); -Then("Instance info should contain provided parameters", async function ( - this: CustomWorld -) { - const res = this.cliResources; - if (res.stdio) { - try { - const expected = await fs.promises - .readFile("../bdd/data/seq-startup-config.json", "utf8") - .then(JSON.parse); - - const received = res.stdio[0] ? JSON.parse(res.stdio[0]) : null; - if (process.env.SCRAMJET_TEST_LOG) { - logger.debug("received.appConfig:", received.appConfig); - logger.debug("expected.appConfig:", expected.appConfig); - logger.debug("received.args:", received.args); - logger.debug("expected.args:", expected.args); +Then( + "Instance info should contain provided parameters in {string}", + async function (this: CustomWorld, file: string) { + const res = this.cliResources; + if (res.stdio) { + try { + const expected = await fs.promises + .readFile(`../bdd/data/${file}`, "utf8") + .then(JSON.parse); + + const received = res.stdio[0] ? JSON.parse(res.stdio[0]) : null; + if (process.env.SCRAMJET_TEST_LOG) { + logger.debug("received.appConfig:", received.appConfig); + logger.debug("expected.appConfig:", expected.appConfig); + logger.debug("received.args:", received.args); + logger.debug("expected.args:", expected.args); + } + assert.deepEqual(received.appConfig, expected.appConfig); + assert.deepEqual(received.args, expected.args); + } catch (error) { + logger.error(error); } - assert.deepEqual(received.appConfig, expected.appConfig); - assert.deepEqual(received.args, expected.args); - } catch (error) { - logger.error(error); + } else { + assert.fail("cliResources or stdio is undefined"); } - } else { - assert.fail("cliResources or stdio is undefined"); } -}); +); diff --git a/packages/api-client/package.json b/packages/api-client/package.json index fdad834e7..c70d51532 100644 --- a/packages/api-client/package.json +++ b/packages/api-client/package.json @@ -14,7 +14,6 @@ "license": "MIT", "dependencies": { "@scramjet/client-utils": "^0.39.0", - "@scramjet/manager-api-client": "^0.39.0", "@scramjet/sth-config": "^0.39.0", "@scramjet/symbols": "^0.39.0", "n-readlines": "^1.0.1", diff --git a/packages/api-client/src/definitions.d.ts b/packages/api-client/src/definitions.d.ts new file mode 100644 index 000000000..6c526b81b --- /dev/null +++ b/packages/api-client/src/definitions.d.ts @@ -0,0 +1,2 @@ +/// +/// diff --git a/packages/api-client/src/host-client.ts b/packages/api-client/src/host-client.ts index ea89fda28..e0075b4a2 100644 --- a/packages/api-client/src/host-client.ts +++ b/packages/api-client/src/host-client.ts @@ -1,9 +1,12 @@ +/// + import { ClientProvider, ClientUtils, ClientUtilsCustomAgent, Headers, HttpClient } from "@scramjet/client-utils"; import { STHRestAPI } from "@scramjet/types"; import { InstanceClient } from "./instance-client"; import { SequenceClient } from "./sequence-client"; import { HostHeaders } from "@scramjet/symbols"; -import { ManagerClient } from "@scramjet/manager-api-client"; +// eslint-disable-next-line import/no-cycle +import { ManagerClient } from "./manager-client"; /** * Host client. diff --git a/packages/api-client/src/index.ts b/packages/api-client/src/index.ts index 600f9246d..fcecd5198 100644 --- a/packages/api-client/src/index.ts +++ b/packages/api-client/src/index.ts @@ -1,3 +1,4 @@ export { HostClient } from "./host-client"; export { InstanceClient, InstanceInputStream, InstanceOutputStream } from "./instance-client"; export { SequenceClient } from "./sequence-client"; +export * from "./manager-client"; diff --git a/packages/manager-api-client/src/manager-client.ts b/packages/api-client/src/manager-client.ts similarity index 96% rename from packages/manager-api-client/src/manager-client.ts rename to packages/api-client/src/manager-client.ts index cb0a74896..55f8deff6 100644 --- a/packages/manager-api-client/src/manager-client.ts +++ b/packages/api-client/src/manager-client.ts @@ -1,4 +1,7 @@ -import { HostClient, } from "@scramjet/api-client"; +/// + +// eslint-disable-next-line import/no-cycle +import { HostClient } from "./host-client"; import { ClientUtils, ClientProvider, HttpClient, ClientUtilsCustomAgent } from "@scramjet/client-utils"; import { MRestAPI, LoadCheckStat } from "@scramjet/types"; import { Readable } from "stream"; diff --git a/packages/cli/src/lib/commands/topic.ts b/packages/cli/src/lib/commands/topic.ts index 834b8292c..02fe3630e 100644 --- a/packages/cli/src/lib/commands/topic.ts +++ b/packages/cli/src/lib/commands/topic.ts @@ -5,7 +5,10 @@ import { profileManager } from "../config"; import { displayEntity, displayStream } from "../output"; import { Option, Argument } from "commander"; import { initPlatform } from "../platform"; -import { CommandCompleterDetails, CompleterDetailsEvent } from "../../events/completerDetails"; +import { + CommandCompleterDetails, + CompleterDetailsEvent, +} from "../../events/completerDetails"; const validateTopicName = (topicName: string) => { if (topicName.match(/^[\\a-zA-Z0-9_+-]+$/)) { @@ -22,9 +25,19 @@ const validateTopicName = (topicName: string) => { */ export const topic: CommandDefinition = (program) => { const format = profileManager.getProfileConfig().format; - const topicNameArgument = new Argument("").argParser(validateTopicName); - const contentTypeOption = new Option("-t, --content-type [content-type]", "Specifies type of data in topic") - .choices(["text/x-ndjson", "application/x-ndjson", "text/plain", "application/octet-stream"]) + const topicNameArgument = new Argument("").argParser( + validateTopicName + ); + const contentTypeOption = new Option( + "-t, --content-type [content-type]", + "Specifies type of data in topic" + ) + .choices([ + "text/x-ndjson", + "application/x-ndjson", + "text/plain", + "application/octet-stream", + ]) .default("application/x-ndjson"); const topicCmd = program @@ -41,7 +54,10 @@ export const topic: CommandDefinition = (program) => { .addOption(contentTypeOption) .description("Create topic") .action(async (topicName, { contentType }) => - displayEntity(getHostClient().createTopic(topicName, contentType), format) + displayEntity( + getHostClient().createTopic(topicName, contentType), + format + ) ); topicCmd @@ -49,7 +65,9 @@ export const topic: CommandDefinition = (program) => { .alias("rm") .addArgument(topicNameArgument) .description("Delete topic") - .action(async (topicName) => displayEntity(getHostClient().deleteTopic(topicName), format)); + .action(async (topicName) => + displayEntity(getHostClient().deleteTopic(topicName), format) + ); topicCmd .command("get") @@ -57,7 +75,9 @@ export const topic: CommandDefinition = (program) => { .addOption(contentTypeOption) .description("Get data from topic") .action(async (topicName, { contentType }) => - displayStream(getHostClient().getNamedData(topicName, {}, contentType)) + displayStream( + getHostClient().getNamedData(topicName, {}, contentType) + ) ); topicCmd @@ -65,20 +85,26 @@ export const topic: CommandDefinition = (program) => { .addArgument(topicNameArgument) .argument("[file]") .addOption(contentTypeOption) - .description("Send data on topic from file, directory or directly through the console") + .description( + "Send data on topic from file, directory or directly through the console" + ) .on(CompleterDetailsEvent, (complDetails: CommandCompleterDetails) => { complDetails.file = "filenames"; }) .action(async (topicName, filename, { contentType }) => { await getHostClient().sendTopic( topicName, - filename ? await getReadStreamFromFile(filename) : process.stdin, + filename + ? await getReadStreamFromFile(filename) + : process.stdin, {}, contentType ); }); - topicCmd.command("ls") + topicCmd + .command("list") + .alias("ls") .description("List information about topics") .action(async () => displayEntity(getHostClient().getTopics(), format)); }; diff --git a/packages/manager-api-client/.eslintrc.js b/packages/manager-api-client/.eslintrc.js deleted file mode 100644 index 0c111683c..000000000 --- a/packages/manager-api-client/.eslintrc.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - ignorePatterns: [".eslintrc.js"], - parserOptions:{ - project: "./tsconfig.json", - tsconfigRootDir: __dirname - } -}; diff --git a/packages/manager-api-client/package.json b/packages/manager-api-client/package.json deleted file mode 100644 index 242dc3309..000000000 --- a/packages/manager-api-client/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@scramjet/manager-api-client", - "version": "0.39.0", - "description": "Scramjet Manager API Client", - "main": "src/index.ts", - "scripts": { - "build": "../../scripts/build-all.js --config-name=tsconfig.build.json --copy-dist", - "build:docs": "typedoc", - "clean": "rm -rf ./dist .bic_cache", - "watch": "tsc -b --watch", - "test": "npm run test:ava", - "test:ava": "ava" - }, - "dependencies": { - "@scramjet/api-client": "^0.39.0", - "@scramjet/client-utils": "^0.39.0" - }, - "devDependencies": { - "@scramjet/types": "^0.39.0", - "@types/node": "15.12.5", - "ava": "^3.15.0", - "ts-node": "^10.9.1", - "typedoc": "0.23.17", - "typedoc-plugin-markdown": "3.13.6", - "typescript": "~4.7.4" - }, - "ava": { - "extensions": [ - "ts" - ], - "files": [ - "**/*.spec.ts" - ], - "require": [ - "ts-node/register" - ] - }, - "author": "Scramjet ", - "license": "AGPL-3.0", - "repository": { - "type": "git", - "url": "https://github.com/scramjetorg/scramjet-cpm-dev.git" - } -} diff --git a/packages/manager-api-client/src/index.ts b/packages/manager-api-client/src/index.ts deleted file mode 100644 index 69972615a..000000000 --- a/packages/manager-api-client/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./manager-client"; diff --git a/packages/manager-api-client/test/pass.spec.ts b/packages/manager-api-client/test/pass.spec.ts deleted file mode 100644 index 57dc6c738..000000000 --- a/packages/manager-api-client/test/pass.spec.ts +++ /dev/null @@ -1,5 +0,0 @@ -import test from "ava"; - -test("Passing test", (t) => { - t.pass(); -}); diff --git a/packages/manager-api-client/tsconfig.build.json b/packages/manager-api-client/tsconfig.build.json deleted file mode 100644 index e0848624e..000000000 --- a/packages/manager-api-client/tsconfig.build.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./dist" - }, - "include": [ - "src/**/*" - ] -} diff --git a/packages/manager-api-client/tsconfig.json b/packages/manager-api-client/tsconfig.json deleted file mode 100644 index 392644404..000000000 --- a/packages/manager-api-client/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "outDir": "./dist" - }, - "extends": "../../tsconfig.base.json", - "include": [ - "./src", - "./test" - ], - "exclude": [ - "node_modules" - ], - "typedocOptions": { - "entryPoints": [ - "src/index.ts" - ], - "out": "../../docs/manager-api-client", - "plugin": "typedoc-plugin-markdown", - "excludePrivate": "true", - "gitRevision": "HEAD", - "sort": "alphabetical" - } -} diff --git a/packages/middleware-api-client/package.json b/packages/middleware-api-client/package.json index b3d9fa64c..a91e065c5 100644 --- a/packages/middleware-api-client/package.json +++ b/packages/middleware-api-client/package.json @@ -16,7 +16,6 @@ "dependencies": { "@scramjet/api-client": "^0.39.0", "@scramjet/client-utils": "^0.39.0", - "@scramjet/manager-api-client": "^0.39.0", "@scramjet/multi-manager-api-client": "^0.39.0" }, "devDependencies": { diff --git a/packages/middleware-api-client/src/middleware-client.ts b/packages/middleware-api-client/src/middleware-client.ts index ac4128940..f1afc42da 100644 --- a/packages/middleware-api-client/src/middleware-client.ts +++ b/packages/middleware-api-client/src/middleware-client.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { ClientProvider, ClientUtils } from "@scramjet/client-utils"; -import { ManagerClient } from "@scramjet/manager-api-client"; +import { ManagerClient } from "@scramjet/api-client"; import { MWRestAPI, MMRestAPI } from "@scramjet/types"; /** diff --git a/packages/multi-manager-api-client/package.json b/packages/multi-manager-api-client/package.json index 70ee1ae25..f563a6f3a 100644 --- a/packages/multi-manager-api-client/package.json +++ b/packages/multi-manager-api-client/package.json @@ -13,8 +13,7 @@ }, "dependencies": { "@scramjet/api-client": "^0.39.0", - "@scramjet/client-utils": "^0.39.0", - "@scramjet/manager-api-client": "^0.39.0" + "@scramjet/client-utils": "^0.39.0" }, "devDependencies": { "@scramjet/types": "^0.39.0", diff --git a/packages/multi-manager-api-client/src/multi-cpm-client.ts b/packages/multi-manager-api-client/src/multi-cpm-client.ts index a19dbc122..1b9db5513 100644 --- a/packages/multi-manager-api-client/src/multi-cpm-client.ts +++ b/packages/multi-manager-api-client/src/multi-cpm-client.ts @@ -1,6 +1,6 @@ /* eslint-disable no-console */ import { ClientProvider, ClientUtils, HttpClient } from "@scramjet/client-utils"; -import { ManagerClient } from "@scramjet/manager-api-client"; +import { ManagerClient } from "@scramjet/api-client"; import { DeepPartial, LoadCheckStat, ManagerConfiguration, MMRestAPI } from "@scramjet/types"; export class MultiManagerClient implements ClientProvider { diff --git a/packages/runner/Dockerfile b/packages/runner/Dockerfile index 324405474..1117a68be 100644 --- a/packages/runner/Dockerfile +++ b/packages/runner/Dockerfile @@ -20,7 +20,6 @@ WORKDIR /app/ COPY ./dist/sth-config ./dist/sth-config COPY ./dist/api-client ./dist/api-client -COPY ./dist/manager-api-client ./dist/manager-api-client COPY ./dist/client-utils ./dist/client-utils COPY ./dist/utility ./dist/utility COPY ./dist/symbols ./dist/symbols diff --git a/packages/runner/package.json b/packages/runner/package.json index e67c3b23a..6456b2b37 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -18,7 +18,6 @@ "dependencies": { "@scramjet/api-client": "^0.39.0", "@scramjet/client-utils": "^0.39.0", - "@scramjet/manager-api-client": "^0.39.0", "@scramjet/model": "^0.39.0", "@scramjet/obj-logger": "^0.39.0", "@scramjet/symbols": "^0.39.0", diff --git a/packages/sth/Dockerfile b/packages/sth/Dockerfile index 631a1ff6e..67cdfe64e 100644 --- a/packages/sth/Dockerfile +++ b/packages/sth/Dockerfile @@ -9,7 +9,6 @@ COPY ./dist/api-server ./dist/api-server COPY ./dist/sth-config ./dist/sth-config COPY ./dist/host ./dist/host COPY ./dist/obj-logger ./dist/obj-logger -COPY ./dist/manager-api-client ./dist/manager-api-client COPY ./dist/model ./dist/model COPY ./dist/module-loader ./dist/module-loader COPY ./dist/runner ./dist/runner diff --git a/packages/types/src/api-client/host-client.ts b/packages/types/src/api-client/host-client.ts index fa350fb43..c0b4ce954 100644 --- a/packages/types/src/api-client/host-client.ts +++ b/packages/types/src/api-client/host-client.ts @@ -75,5 +75,5 @@ export declare class HostClient { getTopics(): Promise; getInstanceClient(id: string): InstanceClient; getSequenceClient(id: string): SequenceClient; - getManagerClient(apiBase: string, utils: ClientUtils | undefined): import("../manager-api-client/manager-client").ManagerClient; + getManagerClient(apiBase: string, utils: ClientUtils | undefined): import("./manager-client").ManagerClient; } diff --git a/packages/types/src/manager-api-client/manager-client.ts b/packages/types/src/api-client/manager-client.ts similarity index 92% rename from packages/types/src/manager-api-client/manager-client.ts rename to packages/types/src/api-client/manager-client.ts index d36fa277b..638aa2c23 100644 --- a/packages/types/src/manager-api-client/manager-client.ts +++ b/packages/types/src/api-client/manager-client.ts @@ -12,7 +12,7 @@ export declare class ManagerClient { constructor(apiBase: string, utils: ClientUtils | undefined); - getHostClient(id: string, hostApiBase: string): import("../api-client/host-client").HostClient; + getHostClient(id: string, hostApiBase: string): import("./host-client").HostClient; getHosts(): Promise; getVersion(): Promise; sendNamedData(topic: string, stream: Parameters[1], requestInit?: RequestInit, contentType?: string, end?: boolean): Promise; diff --git a/packages/types/src/app-context.ts b/packages/types/src/app-context.ts index fe5d2ca2a..e38884fd4 100644 --- a/packages/types/src/app-context.ts +++ b/packages/types/src/app-context.ts @@ -180,11 +180,11 @@ export interface AppContext /** Allows setting timeout in millis to exit the sequence after exit called (default 10000) */ exitTimeout: number; - /** Allows to access Hub, for datails please refer to @scramjet/api-client */ + /** Allows to access Hub, for details please refer to @scramjet/api-client */ hub: import("./api-client/host-client").HostClient; - /** Allows to access Space, for datails please refer to @scramjet/manager-api-client */ - space: import("./manager-api-client/manager-client").ManagerClient; + /** Allows to access Space, for details please refer to @scramjet/api-client */ + space: import("./api-client/manager-client").ManagerClient; /** Instance Id */ instanceId: string; diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 9913d7728..fd46a8c92 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -44,7 +44,7 @@ export * from "./sd-stream-handler"; export * from "./sd-topic-handler"; export * from "./topic-router"; -export type ManagerClient = import("./manager-api-client/manager-client").ManagerClient; +export type ManagerClient = import("./api-client/manager-client").ManagerClient; export { MRestAPI }; export { MWRestAPI };