diff --git a/bdd/step-definitions/hub/config.ts b/bdd/step-definitions/hub/config.ts index 1da033e0b..8e039f773 100644 --- a/bdd/step-definitions/hub/config.ts +++ b/bdd/step-definitions/hub/config.ts @@ -120,7 +120,7 @@ Then("I see a sequence called {string}", function(string: string) { Then("the output of an instance of {string} is as in {string} file", async function(this: CustomWorld, sequenceId, outputContentsFile) { const fileData = await readFile(outputContentsFile, "utf-8"); const hostClient = getHostClient(); - const instance = this.cliResources.instances?.find(inst => inst.sequence === sequenceId); + const instance = this.cliResources.instances?.find(inst => inst.sequence.id === sequenceId); if (!instance) throw new Error("Instance not found"); diff --git a/packages/cli/src/lib/helpers/instance.ts b/packages/cli/src/lib/helpers/instance.ts index 15adf0f7e..9a3c9154a 100644 --- a/packages/cli/src/lib/helpers/instance.ts +++ b/packages/cli/src/lib/helpers/instance.ts @@ -29,7 +29,7 @@ export const instanceRestart = async ( instanceId: string ) => { const instanceInfo = await getInstance(instanceId).getInfo(); - const sequenceId = instanceInfo.sequence; + const sequenceId = instanceInfo.sequence.id; const sequenceClient = SequenceClient.from(sequenceId, getHostClient()); const { provides, requires, args } = instanceInfo; const appConfig = instanceInfo.appConfig || {}; diff --git a/packages/host/src/lib/cpm-connector.ts b/packages/host/src/lib/cpm-connector.ts index e1b9de200..e0800c8c6 100644 --- a/packages/host/src/lib/cpm-connector.ts +++ b/packages/host/src/lib/cpm-connector.ts @@ -570,9 +570,8 @@ export class CPMConnector extends TypedEmitter { */ async sendInstanceInfo(instance: Instance, instanceStatus: InstanceMessageCode): Promise { this.logger.trace("Send instance status update", instanceStatus); - await this.communicationStream?.whenWrote( - [CPMMessageCode.INSTANCE, { ...instance, status: instanceStatus }] + [CPMMessageCode.INSTANCE, { instance, status: instanceStatus }] ); this.logger.trace("Instance status update sent", instanceStatus); diff --git a/packages/host/src/lib/csi-controller.ts b/packages/host/src/lib/csi-controller.ts index eaff1280b..9e4be5eba 100644 --- a/packages/host/src/lib/csi-controller.ts +++ b/packages/host/src/lib/csi-controller.ts @@ -785,11 +785,11 @@ export class CSIController extends TypedEmitter { args: this.args, provides: this.provides, requires: this.requires, - sequence: this.sequence.id, - sequenceInfo: { + sequence: { id: this.sequence.id, config: this.sequence.config, - name: this.sequence.name + name: this.sequence.name, + location : this.sequence.location }, ports: this.info.ports, created: this.info.created, diff --git a/packages/host/src/lib/host.ts b/packages/host/src/lib/host.ts index 30196e313..37359e871 100644 --- a/packages/host/src/lib/host.ts +++ b/packages/host/src/lib/host.ts @@ -931,7 +931,12 @@ export class Host implements IComponent { id: csic.id, appConfig: csic.appConfig, args: csic.args, - sequence: sequenceId, + sequence: (info => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { instances, ...rest } = info; + + return rest; + })(sequence), ports: csic.info.ports, created: csic.info.created, started: csic.info.started, @@ -1040,7 +1045,7 @@ export class Host implements IComponent { await this.cpmConnector?.sendInstanceInfo({ id: csic.id, - sequence: sequence.id + sequence: sequence }, InstanceMessageCode.INSTANCE_ENDED); this.auditor.auditInstance(id, InstanceMessageCode.INSTANCE_ENDED); diff --git a/packages/types/src/instance-store.ts b/packages/types/src/instance-store.ts index bee5a49c6..cf7f39ec8 100644 --- a/packages/types/src/instance-store.ts +++ b/packages/types/src/instance-store.ts @@ -1,7 +1,6 @@ import { AppConfig } from "./app-config"; -import { InstanceId, InstanceStatus } from "./instance"; - -export type InstanceArgs = any[]; +import { InstanceArgs, InstanceId, InstanceStatus } from "./instance"; +import { SequenceInfoInstance } from "./sequence-adapter"; export type Instance = { id: InstanceId, @@ -9,8 +8,8 @@ export type Instance = { args?: InstanceArgs, provides?: string, requires?: string, - sequence: string, - ports?: Record + sequence: SequenceInfoInstance, + ports?: Record, created?: Date, started?: Date, ended?: Date, diff --git a/packages/types/src/instance.ts b/packages/types/src/instance.ts index c50d4cc6a..7008e7be0 100644 --- a/packages/types/src/instance.ts +++ b/packages/types/src/instance.ts @@ -1,4 +1,7 @@ export type InstanceId = string; + +export type InstanceArgs = any[]; + export const enum InstanceStatus { INITIALIZING = "initializing", STARTING = "starting", diff --git a/packages/types/src/messages/instance.ts b/packages/types/src/messages/instance.ts index 366c8402b..eb4569a03 100644 --- a/packages/types/src/messages/instance.ts +++ b/packages/types/src/messages/instance.ts @@ -1,9 +1,10 @@ import { CPMMessageCode, InstanceMessageCode } from "@scramjet/symbols"; +import { Instance } from "../instance-store"; export type InstanceMessageData = { - id: string; - sequence: string; status: InstanceMessageCode; + instance: Instance; + //id : string } export type InstanceMessage = { msgCode: CPMMessageCode.INSTANCE } & InstanceMessageData; diff --git a/packages/types/src/rest-api-manager/common.ts b/packages/types/src/rest-api-manager/common.ts index eecbf1d21..f958bd3fe 100644 --- a/packages/types/src/rest-api-manager/common.ts +++ b/packages/types/src/rest-api-manager/common.ts @@ -11,7 +11,7 @@ export type ConnectedSTHInfo = { selfHosted: boolean, isConnectionActive: boolean, description?: string, - tags?: Array, + tags?: string[], disconnectReason?: string; }; diff --git a/packages/types/src/rest-api-manager/get-entities.ts b/packages/types/src/rest-api-manager/get-entities.ts index 26862bac0..37e8f4882 100644 --- a/packages/types/src/rest-api-manager/get-entities.ts +++ b/packages/types/src/rest-api-manager/get-entities.ts @@ -1,4 +1,6 @@ -import { GetEntitiesResponse as STHRestAPIGetEntitiesResponse } from "../rest-api-sth"; - -export type GetEntitiesResponse = - (STHRestAPIGetEntitiesResponse & { hostId: string })[] +export type GetEntitiesResponse = { + hubs: string[], + topics: string[], + sequences: string[], + instances: string[], +} diff --git a/packages/types/src/rest-api-manager/get-instance.ts b/packages/types/src/rest-api-manager/get-instance.ts index 93dc19e66..2731a4e09 100644 --- a/packages/types/src/rest-api-manager/get-instance.ts +++ b/packages/types/src/rest-api-manager/get-instance.ts @@ -1 +1,3 @@ -export type GetInstanceResponse = string +import { Instance } from "../instance-store"; + +export type GetInstanceResponse = Instance diff --git a/packages/types/src/rest-api-manager/get-instances.ts b/packages/types/src/rest-api-manager/get-instances.ts index b36c6644a..c51b12af8 100644 --- a/packages/types/src/rest-api-manager/get-instances.ts +++ b/packages/types/src/rest-api-manager/get-instances.ts @@ -1,3 +1,3 @@ -import { GetSequencesResponse } from "./get-sequences"; +import { GetInstanceResponse } from "../rest-api-sth"; -export type GetInstancesResponse = GetSequencesResponse[][]; +export type GetInstancesResponse = GetInstanceResponse[]; diff --git a/packages/types/src/rest-api-manager/get-list.ts b/packages/types/src/rest-api-manager/get-list.ts new file mode 100644 index 000000000..6b98bf649 --- /dev/null +++ b/packages/types/src/rest-api-manager/get-list.ts @@ -0,0 +1,15 @@ +import { ConnectedSTHInfoDetails } from "./common"; + +export type GetListResponse = { + id: string, + info: ConnectedSTHInfoDetails, + healthy: boolean, + selfHosted: boolean, + isConnectionActive: boolean, + description?: string, + tags?: string[], + disconnectReason?: string, + topics : string[], + sequences: string[], + instances: string[], +}[] diff --git a/packages/types/src/rest-api-manager/get-sequence-ids.ts b/packages/types/src/rest-api-manager/get-sequence-ids.ts new file mode 100644 index 000000000..41f8fc79f --- /dev/null +++ b/packages/types/src/rest-api-manager/get-sequence-ids.ts @@ -0,0 +1 @@ +export type GetSequenceIDSResponse = string[]; diff --git a/packages/types/src/rest-api-manager/get-topics.ts b/packages/types/src/rest-api-manager/get-topics.ts index 142b1a209..23fdcbdf7 100644 --- a/packages/types/src/rest-api-manager/get-topics.ts +++ b/packages/types/src/rest-api-manager/get-topics.ts @@ -1,4 +1,11 @@ export type GetTopicsResponse = { name: string; contentType: string; + actors: { + hostId?:string; + stream: boolean, + retired: boolean, + role: string, + type: string + }[] }[]; diff --git a/packages/types/src/rest-api-manager/index.ts b/packages/types/src/rest-api-manager/index.ts index b10dfb94d..3d121f0c8 100644 --- a/packages/types/src/rest-api-manager/index.ts +++ b/packages/types/src/rest-api-manager/index.ts @@ -6,9 +6,11 @@ export * from "./get-health"; export * from "./get-load"; export * from "./get-sequences"; export * from "./get-sequence"; +export * from "./get-sequence-ids"; export * from "./get-instance"; export * from "./get-instances"; export * from "./get-topics"; +export * from "./get-list"; export * from "./get-store-items"; export * from "./put-store-item"; export * from "./get-entities"; diff --git a/packages/types/src/rest-api-sth/get-instance.ts b/packages/types/src/rest-api-sth/get-instance.ts index c03c9f63c..416fa5d9f 100644 --- a/packages/types/src/rest-api-sth/get-instance.ts +++ b/packages/types/src/rest-api-sth/get-instance.ts @@ -3,5 +3,5 @@ import { DeepPartial } from "../utils"; import { GetSequenceResponse } from "./get-sequence"; export type GetInstanceResponse = Instance & { - sequenceInfo: DeepPartial + sequence: DeepPartial }; diff --git a/packages/types/src/runner-config.ts b/packages/types/src/runner-config.ts index 561897177..251341012 100644 --- a/packages/types/src/runner-config.ts +++ b/packages/types/src/runner-config.ts @@ -1,7 +1,7 @@ // TODO: Rename. it is not a runner config but response from Pre-runner. - valid!!! import { InstanceLimits } from "./instance-limits"; -import { InstanceArgs } from "./instance-store"; +import { InstanceArgs } from "./instance"; import { PortConfig } from "./sequence-package-json"; import { RunnerContainerConfiguration } from "./sth-configuration"; diff --git a/packages/types/src/sequence-adapter.ts b/packages/types/src/sequence-adapter.ts index 7f8dd968f..86a2d966e 100644 --- a/packages/types/src/sequence-adapter.ts +++ b/packages/types/src/sequence-adapter.ts @@ -1,6 +1,6 @@ -import { SequenceConfig } from "./runner-config"; import { Readable } from "stream"; import { IObjectLogger } from "./object-logger"; +import { SequenceConfig } from "./runner-config"; export type SequenceInfo = { config: SequenceConfig; @@ -10,6 +10,8 @@ export type SequenceInfo = { name? : string; } +export type SequenceInfoInstance = Omit; + export interface ISequenceAdapter { /** * Adapter name. diff --git a/packages/types/src/sequence-package-json.ts b/packages/types/src/sequence-package-json.ts index ca641ce28..c9f99ead6 100644 --- a/packages/types/src/sequence-package-json.ts +++ b/packages/types/src/sequence-package-json.ts @@ -1,4 +1,4 @@ -import { InstanceArgs } from "./instance-store"; +import { InstanceArgs } from "./instance"; export type PortConfig = `${number}/${"tcp" | "udp"}`