Skip to content

Commit 20e571c

Browse files
Merge pull request #776 from scramjetorg/devel
Prepare v0.31.4
2 parents 03694d3 + ea65d38 commit 20e571c

File tree

24 files changed

+1368
-250
lines changed

24 files changed

+1368
-250
lines changed

docs/api-client/README.md

Lines changed: 150 additions & 131 deletions
Large diffs are not rendered by default.

docs/api-client/classes/HostClient.md

Lines changed: 431 additions & 0 deletions
Large diffs are not rendered by default.

docs/api-client/classes/InstanceClient.md

Lines changed: 424 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
[@scramjet/api-client](../README.md) / [Exports](../modules.md) / SequenceClient
2+
3+
# Class: SequenceClient
4+
5+
Sequence client.
6+
Provides methods to interact with Sequence.
7+
8+
## Table of contents
9+
10+
### Properties
11+
12+
- [\_id](SequenceClient.md#_id)
13+
- [host](SequenceClient.md#host)
14+
- [sequenceURL](SequenceClient.md#sequenceurl)
15+
16+
### Accessors
17+
18+
- [clientUtils](SequenceClient.md#clientutils)
19+
- [id](SequenceClient.md#id)
20+
21+
### Constructors
22+
23+
- [constructor](SequenceClient.md#constructor)
24+
25+
### Methods
26+
27+
- [from](SequenceClient.md#from)
28+
- [getInfo](SequenceClient.md#getinfo)
29+
- [getInstance](SequenceClient.md#getinstance)
30+
- [listInstances](SequenceClient.md#listinstances)
31+
- [overwrite](SequenceClient.md#overwrite)
32+
- [start](SequenceClient.md#start)
33+
34+
## Properties
35+
36+
### \_id
37+
38+
`Private` **\_id**: `string`
39+
40+
#### Defined in
41+
42+
[api-client/src/sequence-client.ts:12](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L12)
43+
44+
___
45+
46+
### host
47+
48+
`Private` **host**: `ClientProvider`
49+
50+
#### Defined in
51+
52+
[api-client/src/sequence-client.ts:14](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L14)
53+
54+
___
55+
56+
### sequenceURL
57+
58+
`Private` **sequenceURL**: `string`
59+
60+
#### Defined in
61+
62+
[api-client/src/sequence-client.ts:13](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L13)
63+
64+
## Accessors
65+
66+
### clientUtils
67+
68+
`Private` `get` **clientUtils**(): `HttpClientNode`
69+
70+
#### Returns
71+
72+
`HttpClientNode`
73+
74+
#### Defined in
75+
76+
[api-client/src/sequence-client.ts:23](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L23)
77+
78+
___
79+
80+
### id
81+
82+
`get` **id**(): `string`
83+
84+
Sequence id.
85+
86+
#### Returns
87+
88+
`string`
89+
90+
#### Defined in
91+
92+
[api-client/src/sequence-client.ts:19](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L19)
93+
94+
## Constructors
95+
96+
### constructor
97+
98+
`Private` **new SequenceClient**(`id`, `host`)
99+
100+
#### Parameters
101+
102+
| Name | Type |
103+
| :------ | :------ |
104+
| `id` | `string` |
105+
| `host` | `ClientProvider` |
106+
107+
#### Defined in
108+
109+
[api-client/src/sequence-client.ts:38](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L38)
110+
111+
## Methods
112+
113+
### from
114+
115+
`Static` **from**(`id`, `host`): [`SequenceClient`](SequenceClient.md)
116+
117+
Creates SequenceClient instance for Sequence with given id and host.
118+
119+
#### Parameters
120+
121+
| Name | Type | Description |
122+
| :------ | :------ | :------ |
123+
| `id` | `string` | Sequence id |
124+
| `host` | `ClientProvider` | Host client |
125+
126+
#### Returns
127+
128+
[`SequenceClient`](SequenceClient.md)
129+
130+
Sequence client
131+
132+
#### Defined in
133+
134+
[api-client/src/sequence-client.ts:34](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L34)
135+
136+
___
137+
138+
### getInfo
139+
140+
**getInfo**(): `Promise`<`GetSequenceResponse`\>
141+
142+
Returns Sequence details.
143+
144+
#### Returns
145+
146+
`Promise`<`GetSequenceResponse`\>
147+
148+
Promise resolving to Sequence info.
149+
150+
#### Defined in
151+
152+
[api-client/src/sequence-client.ts:94](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L94)
153+
154+
___
155+
156+
### getInstance
157+
158+
**getInstance**(`id`, `host`): `Promise`<[`InstanceClient`](InstanceClient.md)\>
159+
160+
Return Instance Client for given Instance id.
161+
162+
#### Parameters
163+
164+
| Name | Type | Description |
165+
| :------ | :------ | :------ |
166+
| `id` | `string` | Instance id. |
167+
| `host` | `ClientProvider` | Host client. |
168+
169+
#### Returns
170+
171+
`Promise`<[`InstanceClient`](InstanceClient.md)\>
172+
173+
Instance client.
174+
175+
#### Defined in
176+
177+
[api-client/src/sequence-client.ts:85](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L85)
178+
179+
___
180+
181+
### listInstances
182+
183+
**listInstances**(): `Promise`<`string`[]\>
184+
185+
Returns list of all Instances created from Sequence.
186+
187+
#### Returns
188+
189+
`Promise`<`string`[]\>
190+
191+
Promise resolving to list of Instances.
192+
193+
#### Defined in
194+
195+
[api-client/src/sequence-client.ts:74](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L74)
196+
197+
___
198+
199+
### overwrite
200+
201+
**overwrite**(`stream`): `Promise`<[`SequenceClient`](SequenceClient.md)\>
202+
203+
#### Parameters
204+
205+
| Name | Type |
206+
| :------ | :------ |
207+
| `stream` | `Readable` |
208+
209+
#### Returns
210+
211+
`Promise`<[`SequenceClient`](SequenceClient.md)\>
212+
213+
#### Defined in
214+
215+
[api-client/src/sequence-client.ts:98](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L98)
216+
217+
___
218+
219+
### start
220+
221+
**start**(`payload`): `Promise`<[`InstanceClient`](InstanceClient.md)\>
222+
223+
Starts Sequence.
224+
225+
#### Parameters
226+
227+
| Name | Type | Description |
228+
| :------ | :------ | :------ |
229+
| `payload` | `StartSequencePayload` | App start configuration. |
230+
231+
#### Returns
232+
233+
`Promise`<[`InstanceClient`](InstanceClient.md)\>
234+
235+
Promise resolving to Instance Client.
236+
237+
#### Defined in
238+
239+
[api-client/src/sequence-client.ts:54](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/sequence-client.ts#L54)

docs/api-client/modules.md

Lines changed: 13 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,36 @@
1-
[@scramjet/client-utils](README.md) / Exports
1+
[@scramjet/api-client](README.md) / Exports
22

3-
# @scramjet/client-utils
3+
# @scramjet/api-client
44

55
## Table of contents
66

77
### Classes
88

9-
- [ClientError](classes/ClientError.md)
10-
- [ClientUtils](classes/ClientUtils.md)
9+
- [HostClient](classes/HostClient.md)
10+
- [InstanceClient](classes/InstanceClient.md)
11+
- [SequenceClient](classes/SequenceClient.md)
1112

1213
### Type Aliases
1314

14-
- [ClientErrorCode](modules.md#clienterrorcode)
15-
- [RequestLogger](modules.md#requestlogger)
16-
- [SendStreamOptions](modules.md#sendstreamoptions)
17-
18-
### Interfaces
19-
20-
- [ClientProvider](interfaces/ClientProvider.md)
21-
- [HttpClient](interfaces/HttpClient.md)
15+
- [InstanceInputStream](modules.md#instanceinputstream)
16+
- [InstanceOutputStream](modules.md#instanceoutputstream)
2217

2318
## Type Aliases
2419

25-
### ClientErrorCode
20+
### InstanceInputStream
2621

27-
Ƭ **ClientErrorCode**: ``"GENERAL_ERROR"`` \| ``"BAD_PARAMETERS"`` \| ``"NEED_AUTHENTICATION"`` \| ``"NOT_AUTHORIZED"`` \| ``"NOT_FOUND"`` \| ``"GONE"`` \| ``"SERVER_ERROR"`` \| ``"REQUEST_ERROR"`` \| ``"UNKNOWN_ERROR"`` \| ``"CANNOT_CONNECT"`` \| ``"INVALID_RESPONSE"`` \| ``"INSUFFICIENT_RESOURCES"`` \| ``"UNPROCESSABLE_ENTITY"``
22+
Ƭ **InstanceInputStream**: ``"stdin"`` \| ``"input"``
2823

2924
#### Defined in
3025

31-
[packages/client-utils/src/client-error.ts:32](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/client-utils/src/client-error.ts#L32)
26+
[api-client/src/instance-client.ts:5](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/instance-client.ts#L5)
3227

3328
___
3429

35-
### RequestLogger
36-
37-
Ƭ **RequestLogger**: `Object`
38-
39-
Request logger.
40-
41-
#### Type declaration
42-
43-
| Name | Type |
44-
| :------ | :------ |
45-
| `end` | (...`req`: `any`) => `void` |
46-
| `error` | (`res`: [`ClientError`](classes/ClientError.md)) => `void` |
47-
| `ok` | (`res`: `any`) => `void` |
48-
| `request` | (...`req`: `any`) => `void` |
49-
50-
#### Defined in
51-
52-
[packages/client-utils/src/types/index.ts:22](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/client-utils/src/types/index.ts#L22)
53-
54-
___
55-
56-
### SendStreamOptions
57-
58-
Ƭ **SendStreamOptions**: `Partial`<{ `end`: `boolean` ; `parseResponse?`: ``"json"`` \| ``"text"`` \| ``"stream"`` ; `put`: `boolean` ; `type`: `string` }\>
30+
### InstanceOutputStream
5931

60-
Options for sending sending stream.
32+
Ƭ **InstanceOutputStream**: ``"stdout"`` \| ``"stderr"`` \| ``"output"`` \| ``"log"``
6133

6234
#### Defined in
6335

64-
[packages/client-utils/src/types/index.ts:7](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/client-utils/src/types/index.ts#L7)
36+
[api-client/src/instance-client.ts:6](https://github.com/scramjetorg/transform-hub/blob/HEAD/packages/api-client/src/instance-client.ts#L6)

packages/api-client/src/host-client.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ export class HostClient implements ClientProvider {
3535
return this.client.get<STHRestAPI.GetInstancesResponse>("instances");
3636
}
3737

38+
/**
39+
* Returns list of all entities on Host.
40+
*
41+
* @returns {Promise<STHRestAPI.GetEntitiesResponse>} Promise resolving to list of entities.
42+
*/
43+
async listEntities() {
44+
return this.client.get<STHRestAPI.GetEntitiesResponse>("entities");
45+
}
46+
3847
/**
3948
* Returns Host log stream.
4049
*
@@ -185,4 +194,8 @@ export class HostClient implements ClientProvider {
185194
getSequenceClient(id: string) {
186195
return SequenceClient.from(id, this);
187196
}
197+
198+
getEntities(): Promise<STHRestAPI.GetEntitiesResponse> {
199+
return this.client.get("entities");
200+
}
188201
}

packages/cli/src/lib/commands/sequence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const sequence: CommandDefinition = (program) => {
5151

5252
sequenceCmd
5353
.command("send")
54-
.argument("<package>", "The file or directory to upload or '-' to use the last packed. If directory, it will be packed and send.")
54+
.argument("<package>", "The file or directory to upload or '-' to use the last packed. If directory, it will be packed and sent.")
5555
.option("--name <name>", "Allows to name sequence")
5656
.description("Send the Sequence package to the Hub")
5757
.action(

packages/cli/src/lib/commands/store.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const store: CommandDefinition = (program) => {
3333

3434
storeCmd
3535
.command("send")
36-
.argument("<package>", "The file or directory to upload. If directory, it will be packed and send.")
36+
.argument("<package>", "The file or directory to upload. If directory, it will be packed and sent.")
3737
.option("--name <name>", "Allows to name sequence")
3838
.description("Send the Sequence package to the Store")
3939
.action(async (sequencePackage: string, { name }) => {

packages/client-utils/src/client-utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { ClientError, QueryError } from "./client-error";
22
import { Headers, HttpClient, RequestLogger, SendStreamOptions, RequestConfig } from "./types";
3+
import { Agent as HTTPAgent } from "http";
4+
import { Agent as HTTPSAgent } from "https";
35

46
/**
57
* Provides HTTP communication methods.
@@ -10,6 +12,8 @@ export abstract class ClientUtilsBase implements HttpClient {
1012

1113
static headers: Headers = {};
1214

15+
public agent: HTTPAgent | HTTPSAgent = new HTTPAgent();
16+
1317
constructor(
1418
public apiBase: string,
1519
private fetch: any,
@@ -48,7 +52,7 @@ export abstract class ClientUtilsBase implements HttpClient {
4852
const AbortController = globalThis.AbortController || (await import("abort-controller")).AbortController;
4953
const abortController = new AbortController();
5054

51-
const fetchInit: RequestInit = { signal: abortController.signal, ...init };
55+
const fetchInit: RequestInit & { agent?: HTTPAgent } = { signal: abortController.signal, ...init };
5256

5357
fetchInit.headers = { ...ClientUtilsBase.headers, ...fetchInit.headers };
5458

0 commit comments

Comments
 (0)