@hexagramio/saga-ts 0.9.293-6 → 0.9.293-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +105 -22
- package/dist/cjs/senders/http.d.ts +16 -4
- package/dist/cjs/senders/http.d.ts.map +1 -1
- package/dist/cjs/senders/http.js +11 -4
- package/dist/cjs/senders/http.js.map +1 -1
- package/dist/senders/http.d.ts +16 -4
- package/dist/senders/http.d.ts.map +1 -1
- package/dist/senders/http.js +11 -4
- package/dist/senders/http.js.map +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -1,27 +1,118 @@
|
|
|
1
1
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
2
2
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
3
|
+
**Table of Contents**
|
|
4
|
+
|
|
5
|
+
- [Saga Typescript SDK](#saga-typescript-sdk)
|
|
6
|
+
- [Install](#install)
|
|
7
|
+
- [Description](#description)
|
|
8
|
+
- [Fundamental Types](#fundamental-types)
|
|
9
|
+
- [HTTPCommand](#httpcommand)
|
|
10
|
+
- [Example Custom Command](#example-custom-command)
|
|
11
|
+
- [SocketCommand](#socketcommand)
|
|
12
|
+
- [Quickstart](#quickstart)
|
|
13
|
+
- [Register User](#register-user)
|
|
14
|
+
- [Login User and Add User Property](#login-user-and-add-user-property)
|
|
15
|
+
- [Paginate Listing, example using Listing](#paginate-listing-example-using-listing)
|
|
16
|
+
- [Handle HTTP Error](#handle-http-error)
|
|
17
|
+
- [Inspect Missing Fields in failed HTTP Call](#inspect-missing-fields-in-failed-http-call)
|
|
18
|
+
- [Subscribe to Socket Bot Property Changes](#subscribe-to-socket-bot-property-changes)
|
|
19
|
+
- [Handle Socket Emit Comand Errors](#handle-socket-emit-comand-errors)
|
|
20
|
+
- [Handle Socket Connection Error](#handle-socket-connection-error)
|
|
21
|
+
|
|
3
22
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
|
4
23
|
|
|
5
24
|
# Saga Typescript SDK
|
|
6
25
|
|
|
7
|
-
Typescript SDK to interface with a Saga API host. The implementation is inspired by the Command Design Pattern. A command is send to a Reveiver. A command encapsulates all the data needed to call the API except the domain name. Currently there two kinds of command receivers, HTTP and Socket. Almost all commands except for logging and some user creation methods require a accessToken. If a command fails an exception is being thrown that mirrors SAGA API errors.
|
|
8
|
-
|
|
9
|
-
[Browse Complete Documentation](modules.md)
|
|
10
|
-
|
|
11
26
|
## Install
|
|
12
27
|
|
|
13
28
|
```shell
|
|
14
29
|
npm install @hexagramio/saga-ts
|
|
15
30
|
```
|
|
16
31
|
|
|
32
|
+
## Description
|
|
17
33
|
|
|
18
|
-
|
|
34
|
+
Typescript SDK to interface with a Saga API. The implementation is inspired by the Command Design Pattern. A command is send to a Reveiver. A command encapsulates all the data needed to call the API except the domain name. Currently there two kinds of command receivers, HTTP and Socket. Almost all commands except log in and some user creation methods require a accessToken. If a command fails an exception is being thrown that mirrors SAGA API errors.
|
|
19
35
|
|
|
36
|
+
[SDK Documentation](https://saga.hexagram.io/documentation/clients/saga-ts/modules.md)
|
|
20
37
|
|
|
21
|
-
|
|
38
|
+
## Fundamental Types
|
|
39
|
+
|
|
40
|
+
Both HTTPCommand and SocketCommand below show the entire complexity of both types. Easy to adopt for specialized and new commands or to use for HTTP Scripts.
|
|
22
41
|
|
|
23
|
-
|
|
42
|
+
### HTTPCommand
|
|
43
|
+
```ts
|
|
44
|
+
/**
|
|
45
|
+
* Interfaces to represent the various mutations of a HTTP Command profile.
|
|
46
|
+
*/
|
|
47
|
+
export interface HTTPGetCommand<T> {
|
|
48
|
+
method: "GET" ,
|
|
49
|
+
path: string,
|
|
50
|
+
params?: URLSearchParams,
|
|
51
|
+
accessToken?: string
|
|
52
|
+
}
|
|
53
|
+
export interface HTTPPostPutCommand<T> {
|
|
54
|
+
method: "PUT" | "POST",
|
|
55
|
+
path: string,
|
|
56
|
+
data: any ,
|
|
57
|
+
accessToken?: string
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface HTTPDeleteCommand<T> {
|
|
61
|
+
method: "DELETE",
|
|
62
|
+
path: string,
|
|
63
|
+
params?: URLSearchParams,
|
|
64
|
+
accessToken?: string
|
|
65
|
+
}
|
|
24
66
|
|
|
67
|
+
export type HTTPCommand<T> = HTTPGetCommand<T> | HTTPPostPutCommand<T> | HTTPDeleteCommand<T>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Example Custom Command
|
|
71
|
+
|
|
72
|
+
Sends HTTP post to requests/slack with the assembled body.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
/**
|
|
76
|
+
* Get a bot command
|
|
77
|
+
* @param id the id of the bot
|
|
78
|
+
* @param accessToken the required accessToken
|
|
79
|
+
* @group HTTP Commands
|
|
80
|
+
*/
|
|
81
|
+
export const PostSlackMessageCommand = (accessToken: string, slack_id: string, slack_channel: string, message: string):HTTPCommand<{ok:boolean}> =>{
|
|
82
|
+
return {
|
|
83
|
+
method:"POST",
|
|
84
|
+
path:`requests/slack`,
|
|
85
|
+
accessToken,
|
|
86
|
+
data: {slack_id,slack_channel,message}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### SocketCommand
|
|
92
|
+
```ts
|
|
93
|
+
/**
|
|
94
|
+
* A socket join command
|
|
95
|
+
*/
|
|
96
|
+
export interface SocketJoinCommand {
|
|
97
|
+
method: "/users" | "/bots" | "/globals" |
|
|
98
|
+
"/jobs/runnable_calls" | "/jobs/versions" |
|
|
99
|
+
"/scripts/runnable_calls" | "/scripts/versions" |
|
|
100
|
+
"/system" | "/npm_packages"
|
|
101
|
+
id: string,
|
|
102
|
+
join: boolean,
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
## Quickstart
|
|
110
|
+
|
|
111
|
+
For the unhurried among us ;)
|
|
112
|
+
|
|
113
|
+
### Register User
|
|
114
|
+
|
|
115
|
+
```ts
|
|
25
116
|
import {
|
|
26
117
|
RegisterUserCommand,
|
|
27
118
|
sendHTTPCommand} from "saga-ts";
|
|
@@ -32,10 +123,8 @@ const user = await sendHTTPCommand(baseUrl,RegisterUserCommand({username:`foo`,p
|
|
|
32
123
|
|
|
33
124
|
### Login User and Add User Property
|
|
34
125
|
|
|
35
|
-
```
|
|
36
|
-
|
|
126
|
+
```ts
|
|
37
127
|
import {
|
|
38
|
-
Authentication,
|
|
39
128
|
AddUserPropertyCommand,
|
|
40
129
|
LoginUserCommand,
|
|
41
130
|
sendHTTPCommand} from "saga-ts";
|
|
@@ -47,8 +136,7 @@ await sendHTTPCommand(baseUrl,AddUserPropertyCommand(user.accessToken,{parent_id
|
|
|
47
136
|
|
|
48
137
|
### Paginate Listing, example using Listing
|
|
49
138
|
|
|
50
|
-
```
|
|
51
|
-
|
|
139
|
+
```ts
|
|
52
140
|
import {
|
|
53
141
|
ListBotsCommand,
|
|
54
142
|
sendHTTPCommand} from "saga-ts";
|
|
@@ -72,8 +160,7 @@ if (botsListing.prevCommand) {
|
|
|
72
160
|
|
|
73
161
|
### Handle HTTP Error
|
|
74
162
|
|
|
75
|
-
```
|
|
76
|
-
|
|
163
|
+
```ts
|
|
77
164
|
import {
|
|
78
165
|
ListUserCommand,
|
|
79
166
|
RegisterUserCommand,
|
|
@@ -95,8 +182,7 @@ try{
|
|
|
95
182
|
|
|
96
183
|
### Inspect Missing Fields in failed HTTP Call
|
|
97
184
|
|
|
98
|
-
```
|
|
99
|
-
|
|
185
|
+
```ts
|
|
100
186
|
import {
|
|
101
187
|
ListUserCommand,
|
|
102
188
|
RegisterUserCommand,
|
|
@@ -114,8 +200,7 @@ try{
|
|
|
114
200
|
|
|
115
201
|
### Subscribe to Socket Bot Property Changes
|
|
116
202
|
|
|
117
|
-
```
|
|
118
|
-
|
|
203
|
+
```ts
|
|
119
204
|
import {
|
|
120
205
|
Authentication,
|
|
121
206
|
SocketSession} from "saga-ts";
|
|
@@ -138,8 +223,7 @@ await socketSession.emitCommand(JoinBotCommand("ID OF BOT TO JOIN"))
|
|
|
138
223
|
|
|
139
224
|
### Handle Socket Emit Comand Errors
|
|
140
225
|
|
|
141
|
-
```
|
|
142
|
-
|
|
226
|
+
```ts
|
|
143
227
|
import {
|
|
144
228
|
Authentication,
|
|
145
229
|
SocketSession} from "saga-ts";
|
|
@@ -161,8 +245,7 @@ try{
|
|
|
161
245
|
|
|
162
246
|
### Handle Socket Connection Error
|
|
163
247
|
|
|
164
|
-
```
|
|
165
|
-
|
|
248
|
+
```ts
|
|
166
249
|
import {SocketSession} from "saga-ts";
|
|
167
250
|
const baseURL=new URL("https://saga-api.com");
|
|
168
251
|
new SocketSession(
|
|
@@ -6,15 +6,27 @@
|
|
|
6
6
|
/// <reference types="node" />
|
|
7
7
|
import { URLSearchParams } from "url";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Interfaces to represent the various mutations of a HTTP Command profile.
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
12
|
-
method: "GET"
|
|
11
|
+
export interface HTTPGetCommand<T> {
|
|
12
|
+
method: "GET";
|
|
13
13
|
path: string;
|
|
14
14
|
params?: URLSearchParams;
|
|
15
|
-
data?: any;
|
|
16
15
|
accessToken?: string;
|
|
17
16
|
}
|
|
17
|
+
export interface HTTPPostPutCommand<T> {
|
|
18
|
+
method: "PUT" | "POST";
|
|
19
|
+
path: string;
|
|
20
|
+
data: any;
|
|
21
|
+
accessToken?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface HTTPDeleteCommand<T> {
|
|
24
|
+
method: "DELETE";
|
|
25
|
+
path: string;
|
|
26
|
+
params?: URLSearchParams;
|
|
27
|
+
accessToken?: string;
|
|
28
|
+
}
|
|
29
|
+
export type HTTPCommand<T> = HTTPGetCommand<T> | HTTPPostPutCommand<T> | HTTPDeleteCommand<T>;
|
|
18
30
|
/**
|
|
19
31
|
* Send the HTTP Command to the host with the given baseURL
|
|
20
32
|
* @param baseURL the baseURL of the HTTP Api, i.e 'https://example.api.hexagram.io'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AAQpC;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AAQpC;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,CAAE;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAE;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,eAAsB,GAAG,wCAiDpD,CAAA"}
|
package/dist/cjs/senders/http.js
CHANGED
|
@@ -32,19 +32,26 @@ const debug = (0, debug_1.default)("saga-ts");
|
|
|
32
32
|
*/
|
|
33
33
|
const sendHTTPCommand = (baseURL, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
34
|
var _a, _b, _c, _d, _e;
|
|
35
|
+
debug(`sendHTTPCommand request path:${command.path} method:${command.method}`);
|
|
35
36
|
const headers = { 'Content-Type': 'application/json' };
|
|
36
37
|
if (command.accessToken) {
|
|
37
38
|
headers.Authorization = `Bearer ${command.accessToken}`;
|
|
38
39
|
}
|
|
39
|
-
const
|
|
40
|
+
const options = {
|
|
40
41
|
headers,
|
|
41
42
|
baseURL: baseURL.toString(),
|
|
42
43
|
validateStatus: () => true,
|
|
43
44
|
method: command.method,
|
|
44
45
|
url: command.path,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
};
|
|
47
|
+
if (command.method === "GET") {
|
|
48
|
+
options.params = command.params;
|
|
49
|
+
}
|
|
50
|
+
if (command.method === "POST" || command.method === "PUT") {
|
|
51
|
+
options.data = command.data;
|
|
52
|
+
}
|
|
53
|
+
const response = yield (0, axios_1.default)(options);
|
|
54
|
+
debug(`sendHTTPCommand response status:${response.status} path:${command.path} method:${command.method}`);
|
|
48
55
|
if (response.status !== 200) {
|
|
49
56
|
throw new types_1.APIError(response.data.toString(), response.status, (_a = response.data) === null || _a === void 0 ? void 0 : _a.errors, command.path);
|
|
50
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/senders/http.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;AAEH,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/senders/http.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;AAEH,kDAA8D;AAG9D,2CAAyC;AACzC,0EAAgD;AAEhD,kDAA0B;AAC1B,MAAM,KAAK,GAAG,IAAA,eAAK,EAAC,SAAS,CAAC,CAAC;AA0B/B;;;;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OAAO,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE;QACtE,MAAM,MAAM,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QAExD,MAAM,IAAI,GAAG,CAAI,GAAQ,EAAkB,EAAE;YAC3C,OAAO;gBACL,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,GAAG,CAAC,QAAQ;gBAClB,MAAM,EAAE,GAAG,CAAC,YAAY;gBACxB,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAA;QACH,CAAC,CAAA;QAED,OAAU;YACR,MAAM,EAAE,QAAQ,CAAC,IAAI;YACrB,WAAW,EAAE,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,EAAC,CAAC,CAAC,IAAI,CAAI,IAAI,GAAG,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAChF,WAAW,EAAE,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,EAAC,CAAC,CAAC,IAAI,CAAI,IAAI,GAAG,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SACjF,CAAA;KACF;SAAM;QACL,OAAO,QAAQ,CAAC,IAAI,CAAA;KACrB;AAEH,CAAC,CAAA,CAAA;AAjDY,QAAA,eAAe,mBAiD3B"}
|
package/dist/senders/http.d.ts
CHANGED
|
@@ -6,15 +6,27 @@
|
|
|
6
6
|
/// <reference types="node" />
|
|
7
7
|
import { URLSearchParams } from "url";
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* Interfaces to represent the various mutations of a HTTP Command profile.
|
|
10
10
|
*/
|
|
11
|
-
export interface
|
|
12
|
-
method: "GET"
|
|
11
|
+
export interface HTTPGetCommand<T> {
|
|
12
|
+
method: "GET";
|
|
13
13
|
path: string;
|
|
14
14
|
params?: URLSearchParams;
|
|
15
|
-
data?: any;
|
|
16
15
|
accessToken?: string;
|
|
17
16
|
}
|
|
17
|
+
export interface HTTPPostPutCommand<T> {
|
|
18
|
+
method: "PUT" | "POST";
|
|
19
|
+
path: string;
|
|
20
|
+
data: any;
|
|
21
|
+
accessToken?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface HTTPDeleteCommand<T> {
|
|
24
|
+
method: "DELETE";
|
|
25
|
+
path: string;
|
|
26
|
+
params?: URLSearchParams;
|
|
27
|
+
accessToken?: string;
|
|
28
|
+
}
|
|
29
|
+
export type HTTPCommand<T> = HTTPGetCommand<T> | HTTPPostPutCommand<T> | HTTPDeleteCommand<T>;
|
|
18
30
|
/**
|
|
19
31
|
* Send the HTTP Command to the host with the given baseURL
|
|
20
32
|
* @param baseURL the baseURL of the HTTP Api, i.e 'https://example.api.hexagram.io'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AAQpC;;GAEG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AAQpC;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,MAAM,EAAE,KAAK,CAAE;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAE;IACX,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,MAAM,EAAE,QAAQ,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AACD,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,CAAC,CAAC;AAE9F;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,eAAsB,GAAG,wCAiDpD,CAAA"}
|
package/dist/senders/http.js
CHANGED
|
@@ -26,19 +26,26 @@ const debug = Debug("saga-ts");
|
|
|
26
26
|
*/
|
|
27
27
|
export const sendHTTPCommand = (baseURL, command) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
28
|
var _a, _b, _c, _d, _e;
|
|
29
|
+
debug(`sendHTTPCommand request path:${command.path} method:${command.method}`);
|
|
29
30
|
const headers = { 'Content-Type': 'application/json' };
|
|
30
31
|
if (command.accessToken) {
|
|
31
32
|
headers.Authorization = `Bearer ${command.accessToken}`;
|
|
32
33
|
}
|
|
33
|
-
const
|
|
34
|
+
const options = {
|
|
34
35
|
headers,
|
|
35
36
|
baseURL: baseURL.toString(),
|
|
36
37
|
validateStatus: () => true,
|
|
37
38
|
method: command.method,
|
|
38
39
|
url: command.path,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
};
|
|
41
|
+
if (command.method === "GET") {
|
|
42
|
+
options.params = command.params;
|
|
43
|
+
}
|
|
44
|
+
if (command.method === "POST" || command.method === "PUT") {
|
|
45
|
+
options.data = command.data;
|
|
46
|
+
}
|
|
47
|
+
const response = yield axios(options);
|
|
48
|
+
debug(`sendHTTPCommand response status:${response.status} path:${command.path} method:${command.method}`);
|
|
42
49
|
if (response.status !== 200) {
|
|
43
50
|
throw new APIError(response.data.toString(), response.status, (_a = response.data) === null || _a === void 0 ? void 0 : _a.errors, command.path);
|
|
44
51
|
}
|
package/dist/senders/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/senders/http.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;;;;;;;;;AAEH,OAAO,KAAyC,MAAM,OAAO,CAAC;AAG9D,OAAO,EAAC,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACzC,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC;AA0B/B;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAU,OAAY,EAAE,OAAuB,EAAc,EAAE;;IAE5F,KAAK,CAAC,gCAAgC,OAAO,CAAC,IAAI,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC9E,MAAM,OAAO,GAA2B,EAAC,cAAc,EAAE,kBAAkB,EAAC,CAAA;IAC5E,IAAI,OAAO,CAAC,WAAW,EAAE;QACvB,OAAO,CAAC,aAAa,GAAG,UAAU,OAAO,CAAC,WAAW,EAAE,CAAC;KACzD;IACD,MAAM,OAAO,GAAuB;QAClC,OAAO;QACP,OAAO,EAAE,OAAO,CAAC,QAAQ,EAAE;QAC3B,cAAc,EAAE,GAAG,EAAE,CAAC,IAAI;QAC1B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,GAAG,EAAE,OAAO,CAAC,IAAI;KAClB,CAAA;IAED,IAAG,OA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AI,IAAI,GAAG,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;YAChF,WAAW,EAAE,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,EAAC,CAAC,CAAC,IAAI,CAAI,IAAI,GAAG,CAAC,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,0CAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS;SACjF,CAAA;KACF;SAAM;QACL,OAAO,QAAQ,CAAC,IAAI,CAAA;KACrB;AAEH,CAAC,CAAA,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hexagramio/saga-ts",
|
|
3
|
-
"version": "0.9.293-
|
|
3
|
+
"version": "0.9.293-9",
|
|
4
4
|
"description": "Saga SDK",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
6
7
|
"scripts": {
|
|
7
8
|
"test": "jest --forceExit",
|
|
8
9
|
"coverage": "jest --coverage --forceExit",
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
"build": "npx tsc --project tsconfig.json && npx tsc --project tsconfig.cjs.json",
|
|
11
12
|
"typedoc": "rm -rf docs/; npx typedoc --tsconfig tsconfig.json --disableSources --hideGenerator src/index.ts",
|
|
12
13
|
"typedoc-md": "rm -rf docs-md/;typedoc --plugin typedoc-plugin-markdown --hideBreadcrumbs --disableSources --excludeReferences --includeVersion --out docs-md src/index.ts",
|
|
14
|
+
"copy-md-docs": "npm run typedoc-md; cp -r docs-md/* ../../documentation/docs/clients/saga-ts/",
|
|
13
15
|
"prepare": "npm run build;"
|
|
14
16
|
},
|
|
15
17
|
"keywords": [],
|
|
@@ -37,9 +39,15 @@
|
|
|
37
39
|
"axios": "1.4",
|
|
38
40
|
"debug": "4",
|
|
39
41
|
"parse-link-header": "2",
|
|
40
|
-
"socket.io-client": "4"
|
|
41
|
-
"stripe": "^12.10.0"
|
|
42
|
+
"socket.io-client": "4"
|
|
42
43
|
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"saga",
|
|
46
|
+
"hexagram",
|
|
47
|
+
"events",
|
|
48
|
+
"networking",
|
|
49
|
+
"command"
|
|
50
|
+
],
|
|
43
51
|
"license": "MIT",
|
|
44
52
|
"homepage": "https://saga.hexagram.io/documentation/clients/saga-ts/README.html",
|
|
45
53
|
"author": "Hexagram <admin@hexagram.io> (https:/hexagram.io/)"
|