@hexagramio/saga-ts 0.9.293-8 → 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 +60 -47
- 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 +3 -1
package/README.md
CHANGED
|
@@ -4,7 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
- [Saga Typescript SDK](#saga-typescript-sdk)
|
|
6
6
|
- [Install](#install)
|
|
7
|
-
- [
|
|
7
|
+
- [Description](#description)
|
|
8
|
+
- [Fundamental Types](#fundamental-types)
|
|
9
|
+
- [HTTPCommand](#httpcommand)
|
|
10
|
+
- [Example Custom Command](#example-custom-command)
|
|
11
|
+
- [SocketCommand](#socketcommand)
|
|
12
|
+
- [Quickstart](#quickstart)
|
|
8
13
|
- [Register User](#register-user)
|
|
9
14
|
- [Login User and Add User Property](#login-user-and-add-user-property)
|
|
10
15
|
- [Paginate Listing, example using Listing](#paginate-listing-example-using-listing)
|
|
@@ -28,32 +33,63 @@ npm install @hexagramio/saga-ts
|
|
|
28
33
|
|
|
29
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.
|
|
30
35
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
Detailed documentation is embedded in each admin interface and also embedded in the [standalone documentation](https://saga.hexagram.io/documentation/clients/saga-ts/module.md).
|
|
36
|
+
[SDK Documentation](https://saga.hexagram.io/documentation/clients/saga-ts/modules.md)
|
|
34
37
|
|
|
35
38
|
## Fundamental Types
|
|
36
39
|
|
|
37
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.
|
|
38
41
|
|
|
39
42
|
### HTTPCommand
|
|
40
|
-
```
|
|
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
|
+
}
|
|
66
|
+
|
|
67
|
+
export type HTTPCommand<T> = HTTPGetCommand<T> | HTTPPostPutCommand<T> | HTTPDeleteCommand<T>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Example Custom Command
|
|
41
71
|
|
|
72
|
+
Sends HTTP post to requests/slack with the assembled body.
|
|
73
|
+
|
|
74
|
+
```ts
|
|
42
75
|
/**
|
|
43
|
-
*
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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}
|
|
51
87
|
}
|
|
88
|
+
}
|
|
52
89
|
```
|
|
53
90
|
|
|
54
91
|
### SocketCommand
|
|
55
|
-
```
|
|
56
|
-
|
|
92
|
+
```ts
|
|
57
93
|
/**
|
|
58
94
|
* A socket join command
|
|
59
95
|
*/
|
|
@@ -67,22 +103,7 @@ export interface SocketJoinCommand {
|
|
|
67
103
|
}
|
|
68
104
|
```
|
|
69
105
|
|
|
70
|
-
|
|
71
|
-
```js
|
|
72
|
-
/**
|
|
73
|
-
* Get a bot command
|
|
74
|
-
* @param id the id of the bot
|
|
75
|
-
* @param accessToken the required accessToken
|
|
76
|
-
* @group HTTP Commands
|
|
77
|
-
*/
|
|
78
|
-
export const GetBotCommand = (accessToken: string, id: string):HTTPCommand<ReadBot>=>{
|
|
79
|
-
return {
|
|
80
|
-
method:"GET",
|
|
81
|
-
path:`/bots/${id}`,
|
|
82
|
-
accessToken
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
106
|
+
|
|
86
107
|
|
|
87
108
|
|
|
88
109
|
## Quickstart
|
|
@@ -91,8 +112,7 @@ For the unhurried among us ;)
|
|
|
91
112
|
|
|
92
113
|
### Register User
|
|
93
114
|
|
|
94
|
-
```
|
|
95
|
-
|
|
115
|
+
```ts
|
|
96
116
|
import {
|
|
97
117
|
RegisterUserCommand,
|
|
98
118
|
sendHTTPCommand} from "saga-ts";
|
|
@@ -103,8 +123,7 @@ const user = await sendHTTPCommand(baseUrl,RegisterUserCommand({username:`foo`,p
|
|
|
103
123
|
|
|
104
124
|
### Login User and Add User Property
|
|
105
125
|
|
|
106
|
-
```
|
|
107
|
-
|
|
126
|
+
```ts
|
|
108
127
|
import {
|
|
109
128
|
AddUserPropertyCommand,
|
|
110
129
|
LoginUserCommand,
|
|
@@ -117,8 +136,7 @@ await sendHTTPCommand(baseUrl,AddUserPropertyCommand(user.accessToken,{parent_id
|
|
|
117
136
|
|
|
118
137
|
### Paginate Listing, example using Listing
|
|
119
138
|
|
|
120
|
-
```
|
|
121
|
-
|
|
139
|
+
```ts
|
|
122
140
|
import {
|
|
123
141
|
ListBotsCommand,
|
|
124
142
|
sendHTTPCommand} from "saga-ts";
|
|
@@ -142,8 +160,7 @@ if (botsListing.prevCommand) {
|
|
|
142
160
|
|
|
143
161
|
### Handle HTTP Error
|
|
144
162
|
|
|
145
|
-
```
|
|
146
|
-
|
|
163
|
+
```ts
|
|
147
164
|
import {
|
|
148
165
|
ListUserCommand,
|
|
149
166
|
RegisterUserCommand,
|
|
@@ -165,8 +182,7 @@ try{
|
|
|
165
182
|
|
|
166
183
|
### Inspect Missing Fields in failed HTTP Call
|
|
167
184
|
|
|
168
|
-
```
|
|
169
|
-
|
|
185
|
+
```ts
|
|
170
186
|
import {
|
|
171
187
|
ListUserCommand,
|
|
172
188
|
RegisterUserCommand,
|
|
@@ -184,8 +200,7 @@ try{
|
|
|
184
200
|
|
|
185
201
|
### Subscribe to Socket Bot Property Changes
|
|
186
202
|
|
|
187
|
-
```
|
|
188
|
-
|
|
203
|
+
```ts
|
|
189
204
|
import {
|
|
190
205
|
Authentication,
|
|
191
206
|
SocketSession} from "saga-ts";
|
|
@@ -208,8 +223,7 @@ await socketSession.emitCommand(JoinBotCommand("ID OF BOT TO JOIN"))
|
|
|
208
223
|
|
|
209
224
|
### Handle Socket Emit Comand Errors
|
|
210
225
|
|
|
211
|
-
```
|
|
212
|
-
|
|
226
|
+
```ts
|
|
213
227
|
import {
|
|
214
228
|
Authentication,
|
|
215
229
|
SocketSession} from "saga-ts";
|
|
@@ -231,8 +245,7 @@ try{
|
|
|
231
245
|
|
|
232
246
|
### Handle Socket Connection Error
|
|
233
247
|
|
|
234
|
-
```
|
|
235
|
-
|
|
248
|
+
```ts
|
|
236
249
|
import {SocketSession} from "saga-ts";
|
|
237
250
|
const baseURL=new URL("https://saga-api.com");
|
|
238
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;;;;;;GAMG;AACI,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,I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AAI;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,KA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/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": [],
|