@hexagramio/saga-ts 0.9.293
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/LICENSE +19 -0
- package/README.md +36 -0
- package/dist/cjs/commands/bots.d.ts +74 -0
- package/dist/cjs/commands/bots.d.ts.map +1 -0
- package/dist/cjs/commands/bots.js +133 -0
- package/dist/cjs/commands/bots.js.map +1 -0
- package/dist/cjs/commands/system.d.ts +18 -0
- package/dist/cjs/commands/system.d.ts.map +1 -0
- package/dist/cjs/commands/system.js +30 -0
- package/dist/cjs/commands/system.js.map +1 -0
- package/dist/cjs/commands/test_data.d.ts +10 -0
- package/dist/cjs/commands/test_data.d.ts.map +1 -0
- package/dist/cjs/commands/test_data.js +17 -0
- package/dist/cjs/commands/test_data.js.map +1 -0
- package/dist/cjs/commands/user.d.ts +137 -0
- package/dist/cjs/commands/user.d.ts.map +1 -0
- package/dist/cjs/commands/user.js +186 -0
- package/dist/cjs/commands/user.js.map +1 -0
- package/dist/cjs/index.d.ts +116 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +205 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/shared_types.d.ts +58 -0
- package/dist/cjs/lib/shared_types.d.ts.map +1 -0
- package/dist/cjs/lib/shared_types.js +3 -0
- package/dist/cjs/lib/shared_types.js.map +1 -0
- package/dist/commands/bots.d.ts +74 -0
- package/dist/commands/bots.d.ts.map +1 -0
- package/dist/commands/bots.js +121 -0
- package/dist/commands/bots.js.map +1 -0
- package/dist/commands/system.d.ts +18 -0
- package/dist/commands/system.d.ts.map +1 -0
- package/dist/commands/system.js +25 -0
- package/dist/commands/system.js.map +1 -0
- package/dist/commands/test_data.d.ts +10 -0
- package/dist/commands/test_data.d.ts.map +1 -0
- package/dist/commands/test_data.js +13 -0
- package/dist/commands/test_data.js.map +1 -0
- package/dist/commands/user.d.ts +137 -0
- package/dist/commands/user.d.ts.map +1 -0
- package/dist/commands/user.js +170 -0
- package/dist/commands/user.js.map +1 -0
- package/dist/index.d.ts +116 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +196 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/shared_types.d.ts +58 -0
- package/dist/lib/shared_types.d.ts.map +1 -0
- package/dist/lib/shared_types.js +2 -0
- package/dist/lib/shared_types.js.map +1 -0
- package/dist/transport/http.d.ts +7 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +75 -0
- package/dist/transport/http.js.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bots.d.ts","sourceRoot":"","sources":["../../src/commands/bots.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACpD,OAAO,EAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAGtG,MAAM,WAAW,SAAU,SAAQ,QAAQ,EAAE,IAAI;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,SAAU,SAAQ,SAAS,EAAE,EAAE;CAC/C;AACD,MAAM,WAAW,OAAQ,SAAQ,SAAS,EAAC,SAAS;IAClD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;CAC1C;AAGD;;;;;GAKG;AACH,eAAO,MAAM,eAAe,gBAAiB,MAAM,WAAW,MAAM,KAAE,YAAa,KAAK,OAAO,CAAC,CAO/F,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAC,IAAI,EAAE,SAAS,GAAE,WAAW,CAAC,OAAO,CAAC,CAOzF;AAGD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAC,IAAI,EAAE,SAAS,EAAE,GAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAO9F;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,gBAAiB,MAAM,MAAM,MAAM,KAAE,YAAY,OAAO,CAMjF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,QAAQ,SAAS,KAAE,YAAY,OAAO,CAOzF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,OAAO,MAAM,KAAE,YAAY;IAAC,EAAE,EAAC,IAAI,CAAA;CAAC,CAMvF,CAAA;AAGD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,gBAAiB,MAAM,QAAO,cAAc,KAAE,YAAY,YAAY,CAOvG,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAQ,MAAM,KAAG,aAM3C,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAQ,MAAM,KAAG,aAM5C,CAAA"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List Bots command
|
|
3
|
+
* @param search search criteria for bots
|
|
4
|
+
* @param accessToken the required accessToken
|
|
5
|
+
* @group HTTP Commands
|
|
6
|
+
*/
|
|
7
|
+
export const ListBotsCommand = (accessToken, search) => {
|
|
8
|
+
return {
|
|
9
|
+
method: "GET",
|
|
10
|
+
path: "/bots",
|
|
11
|
+
params: search ? new URLSearchParams({ search }) : undefined,
|
|
12
|
+
accessToken
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Create a new bot command
|
|
17
|
+
* @param data a CreateBot Object
|
|
18
|
+
* @param accessToken the required accessToken
|
|
19
|
+
* @group HTTP Commands
|
|
20
|
+
*/
|
|
21
|
+
export function CreateBotCommand(accessToken, data) {
|
|
22
|
+
return {
|
|
23
|
+
method: "POST",
|
|
24
|
+
path: "/bots",
|
|
25
|
+
data,
|
|
26
|
+
accessToken
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create an array of bots command
|
|
31
|
+
* @param data a CreateBot Object array
|
|
32
|
+
* @param accessToken the required accessToken
|
|
33
|
+
* @group HTTP Commands
|
|
34
|
+
*/
|
|
35
|
+
export function CreateBotsCommand(accessToken, data) {
|
|
36
|
+
return {
|
|
37
|
+
method: "POST",
|
|
38
|
+
path: "/bots",
|
|
39
|
+
data,
|
|
40
|
+
accessToken
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get a bot command
|
|
45
|
+
* @param id the id of the bot
|
|
46
|
+
* @param accessToken the required accessToken
|
|
47
|
+
* @group HTTP Commands
|
|
48
|
+
*/
|
|
49
|
+
export const GetBotCommand = (accessToken, id) => {
|
|
50
|
+
return {
|
|
51
|
+
method: "GET",
|
|
52
|
+
path: `/bots/${id}`,
|
|
53
|
+
accessToken
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Update the bot command
|
|
58
|
+
* @param data the bot needing to be updated, the _id of the bot is used to select the bot
|
|
59
|
+
* @param accessToken the required accessToken
|
|
60
|
+
* @group HTTP Commands
|
|
61
|
+
*/
|
|
62
|
+
export const UpdateBotCommand = (accessToken, data) => {
|
|
63
|
+
return {
|
|
64
|
+
method: "PUT",
|
|
65
|
+
path: `/bots/${data._id}`,
|
|
66
|
+
data,
|
|
67
|
+
accessToken
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Delete a bot command
|
|
72
|
+
* @param id the id of the bot to delete
|
|
73
|
+
* @param accessToken the required accessToken
|
|
74
|
+
* @group HTTP Commands
|
|
75
|
+
*/
|
|
76
|
+
export const DeleteBotCommand = (accessToken, _id) => {
|
|
77
|
+
return {
|
|
78
|
+
method: "DELETE",
|
|
79
|
+
path: `/bots/${_id}`,
|
|
80
|
+
accessToken
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Add a bot property command
|
|
85
|
+
* @param data the property
|
|
86
|
+
* @param accessToken the required accessToken
|
|
87
|
+
* @group HTTP Commands
|
|
88
|
+
*/
|
|
89
|
+
export const AddBotPropertyCommand = (accessToken, data) => {
|
|
90
|
+
return {
|
|
91
|
+
method: "POST",
|
|
92
|
+
path: `/bots/${data.parent_id}/properties`,
|
|
93
|
+
data,
|
|
94
|
+
accessToken
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* A command to join a bots realtime socket
|
|
99
|
+
* @param _id id of the bot
|
|
100
|
+
* @group Socket Commands
|
|
101
|
+
*/
|
|
102
|
+
export const JoinBotCommand = (_id) => {
|
|
103
|
+
return {
|
|
104
|
+
method: "/bots",
|
|
105
|
+
join: true,
|
|
106
|
+
id: _id
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* A command to leave a bots realtime socket
|
|
111
|
+
* @param _id id of the bot
|
|
112
|
+
* @group Socket Commands
|
|
113
|
+
*/
|
|
114
|
+
export const LeaveBotCommand = (_id) => {
|
|
115
|
+
return {
|
|
116
|
+
method: "/bots",
|
|
117
|
+
join: false,
|
|
118
|
+
id: _id
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=bots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bots.js","sourceRoot":"","sources":["../../src/commands/bots.ts"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,WAAmB,EAAE,MAAe,EAA8B,EAAE;IAClG,OAAO;QACL,MAAM,EAAC,KAAK;QACZ,IAAI,EAAC,OAAO;QACZ,MAAM,EAAC,MAAM,CAAA,CAAC,CAAA,IAAI,eAAe,CAAC,EAAC,MAAM,EAAC,CAAC,CAAA,CAAC,CAAA,SAAS;QACrD,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,C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EAAE;IAC1D,OAAO;QACL,MAAM,EAAC,OAAO;QACd,IAAI,EAAC,IAAI;QACT,EAAE,EAAC,GAAG;KACP,CAAA;AACH,CAAC,CAAA;AACD;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAU,EAAiB,EAAE;IAC3D,OAAO;QACL,MAAM,EAAC,OAAO;QACd,IAAI,EAAC,KAAK;QACV,EAAE,EAAC,GAAG;KACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { HTTPCommand } from "../index";
|
|
2
|
+
/**
|
|
3
|
+
* Command to return the current saga build version
|
|
4
|
+
* @param accessToken the required accessToken
|
|
5
|
+
* @group HTTP Commands
|
|
6
|
+
*/
|
|
7
|
+
export declare const GetBuildVersionCommand: (accessToken: string) => HTTPCommand<{
|
|
8
|
+
version: string;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Command to trigger a saga rebuild
|
|
12
|
+
* @param accessToken the required accessToken
|
|
13
|
+
* @group HTTP Commands
|
|
14
|
+
*/
|
|
15
|
+
export declare const TriggerBuildCommand: (accessToken: string) => HTTPCommand<{
|
|
16
|
+
version: string;
|
|
17
|
+
}>;
|
|
18
|
+
//# sourceMappingURL=system.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../src/commands/system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAGrC;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,KAAE,YAAa;IAAC,OAAO,EAAC,MAAM,CAAA;CAAC,CAMxF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,gBAAiB,MAAM,KAAE,YAAa;IAAC,OAAO,EAAC,MAAM,CAAA;CAAC,CAMrF,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command to return the current saga build version
|
|
3
|
+
* @param accessToken the required accessToken
|
|
4
|
+
* @group HTTP Commands
|
|
5
|
+
*/
|
|
6
|
+
export const GetBuildVersionCommand = (accessToken) => {
|
|
7
|
+
return {
|
|
8
|
+
method: "GET",
|
|
9
|
+
path: "/build",
|
|
10
|
+
accessToken
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Command to trigger a saga rebuild
|
|
15
|
+
* @param accessToken the required accessToken
|
|
16
|
+
* @group HTTP Commands
|
|
17
|
+
*/
|
|
18
|
+
export const TriggerBuildCommand = (accessToken) => {
|
|
19
|
+
return {
|
|
20
|
+
method: "GET",
|
|
21
|
+
path: "/build",
|
|
22
|
+
accessToken
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=system.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../src/commands/system.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAgC,EAAE;IAC1F,OAAO;QACL,MAAM,EAAC,KAAK;QACZ,IAAI,EAAC,QAAQ;QACb,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,WAAmB,EAAgC,EAAE;IACvF,OAAO;QACL,MAAM,EAAC,KAAK;QACZ,IAAI,EAAC,QAAQ;QACb,WAAW;KACZ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HTTPCommand } from "../index";
|
|
2
|
+
/**
|
|
3
|
+
* Command to remove all data flagged with test_data from the saga
|
|
4
|
+
* @param accessToken the required accessToken
|
|
5
|
+
* @group HTTP Commands
|
|
6
|
+
*/
|
|
7
|
+
export declare const DeleteTestDataCommand: (accessToken: string) => HTTPCommand<{
|
|
8
|
+
ok: 1;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=test_data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_data.d.ts","sourceRoot":"","sources":["../../src/commands/test_data.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,UAAU,CAAC;AAErC;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,gBAAiB,MAAM,KAAE,YAAa;IAAC,EAAE,EAAC,CAAC,CAAA;CAAC,CAM7E,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Command to remove all data flagged with test_data from the saga
|
|
3
|
+
* @param accessToken the required accessToken
|
|
4
|
+
* @group HTTP Commands
|
|
5
|
+
*/
|
|
6
|
+
export const DeleteTestDataCommand = (accessToken) => {
|
|
7
|
+
return {
|
|
8
|
+
method: "DELETE",
|
|
9
|
+
path: "/test",
|
|
10
|
+
accessToken
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=test_data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test_data.js","sourceRoot":"","sources":["../../src/commands/test_data.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,WAAmB,EAAuB,EAAE;IAChF,OAAO;QACL,MAAM,EAAC,QAAQ;QACf,IAAI,EAAC,OAAO;QACZ,WAAW;KACZ,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lit of user messages and functions to generate user commands
|
|
3
|
+
* @packageDocumentation
|
|
4
|
+
*/
|
|
5
|
+
import { Authentication, HTTPCommand, SocketCommand } from "../index";
|
|
6
|
+
import { CreateProperty, Id, List, ReadProperty, Tags, TestData, TimeStamp } from "../lib/shared_types";
|
|
7
|
+
/**
|
|
8
|
+
* used to update basic user
|
|
9
|
+
* @group User Types
|
|
10
|
+
*/
|
|
11
|
+
export interface UpdateUser extends Id {
|
|
12
|
+
username?: string;
|
|
13
|
+
tags?: [string];
|
|
14
|
+
email?: string;
|
|
15
|
+
displayname?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @group User Types
|
|
20
|
+
*/
|
|
21
|
+
export interface ReadUser extends TimeStamp, Id, TestData, Tags {
|
|
22
|
+
username: string;
|
|
23
|
+
properties: Record<string, ReadProperty>;
|
|
24
|
+
tags?: [string];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Basic User Creation Message
|
|
28
|
+
* @group User Types
|
|
29
|
+
*/
|
|
30
|
+
export interface BasicUser extends Tags {
|
|
31
|
+
prefix?: "";
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Register User Message
|
|
35
|
+
* @group User Types
|
|
36
|
+
*/
|
|
37
|
+
export interface RegisterUser extends Tags {
|
|
38
|
+
username: string;
|
|
39
|
+
password: string;
|
|
40
|
+
email?: string;
|
|
41
|
+
displayname?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Login User Message
|
|
45
|
+
* @group User Types
|
|
46
|
+
*/
|
|
47
|
+
export interface LoginUser extends Tags {
|
|
48
|
+
username: string;
|
|
49
|
+
password: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a command to get the user associated with the given accessToken
|
|
53
|
+
* @param accessToken the required accessToken
|
|
54
|
+
* @group HTTP Commands
|
|
55
|
+
*/
|
|
56
|
+
export declare const WhoAmICommand: (accessToken: string) => HTTPCommand<ReadUser>;
|
|
57
|
+
/**
|
|
58
|
+
* Command to login a user
|
|
59
|
+
* @param username string
|
|
60
|
+
* @param password string
|
|
61
|
+
* @group HTTP Commands
|
|
62
|
+
*/
|
|
63
|
+
export declare const LoginUserCommand: (data: LoginUser) => HTTPCommand<ReadUser & Authentication>;
|
|
64
|
+
/**
|
|
65
|
+
* Create command to register a user
|
|
66
|
+
* @param username string
|
|
67
|
+
* @param password string
|
|
68
|
+
* @group HTTP Commands
|
|
69
|
+
*/
|
|
70
|
+
export declare const RegisterUserCommand: (data: RegisterUser) => HTTPCommand<ReadUser & Authentication>;
|
|
71
|
+
/**
|
|
72
|
+
* Command to create a generated user
|
|
73
|
+
* @param basicUser an optional model
|
|
74
|
+
* @group HTTP Commands
|
|
75
|
+
*/
|
|
76
|
+
export declare const CreateGenerateBasicUserCommand: (data?: BasicUser) => HTTPCommand<ReadUser>;
|
|
77
|
+
/**
|
|
78
|
+
* Command to create a test user
|
|
79
|
+
* @param basicUser an optional model
|
|
80
|
+
* @group HTTP Commands
|
|
81
|
+
*/
|
|
82
|
+
export declare const CreateTestUserCommand: (username?: string) => HTTPCommand<ReadUser>;
|
|
83
|
+
/**
|
|
84
|
+
* List Users command
|
|
85
|
+
* @param search search criteria for ysers
|
|
86
|
+
* @param accessToken the required accessToken
|
|
87
|
+
* @group HTTP Commands
|
|
88
|
+
*/
|
|
89
|
+
export declare const ListUsersCommand: (accessToken: string, search?: string) => HTTPCommand<List<ReadUser>>;
|
|
90
|
+
/**
|
|
91
|
+
* Get a user command
|
|
92
|
+
* @param id the id of the user
|
|
93
|
+
* @param accessToken the required accessToken
|
|
94
|
+
* @group HTTP Commands
|
|
95
|
+
*/
|
|
96
|
+
export declare const GetUserCommand: (accessToken: string, id: string) => HTTPCommand<ReadUser>;
|
|
97
|
+
/**
|
|
98
|
+
* Refresh token command
|
|
99
|
+
* @param id the id of the user
|
|
100
|
+
* @param refreshToken the refresh token
|
|
101
|
+
* @group HTTP Commands
|
|
102
|
+
*/
|
|
103
|
+
export declare const RefreshTokenCommand: (refreshToken: string, id: string) => HTTPCommand<Authentication>;
|
|
104
|
+
/**
|
|
105
|
+
* Delete a user command
|
|
106
|
+
* @param id the id of the user
|
|
107
|
+
* @param accessToken the required accessToken
|
|
108
|
+
* @group HTTP Commands
|
|
109
|
+
*/
|
|
110
|
+
export declare const GetDeleteCommand: (accessToken: string, id: string) => HTTPCommand<ReadUser>;
|
|
111
|
+
/**
|
|
112
|
+
* Update the user command
|
|
113
|
+
* @param data the user needing to be updated, the _id of the user is used to select the user
|
|
114
|
+
* @param accessToken the required accessToken
|
|
115
|
+
* @group HTTP Commands
|
|
116
|
+
*/
|
|
117
|
+
export declare const UpdateUserCommand: (accessToken: string, data: UpdateUser) => HTTPCommand<ReadUser>;
|
|
118
|
+
/**
|
|
119
|
+
* Add a bot property command
|
|
120
|
+
* @param data the property
|
|
121
|
+
* @param accessToken the required accessToken
|
|
122
|
+
* @group HTTP Commands
|
|
123
|
+
*/
|
|
124
|
+
export declare const AddUserPropertyCommand: (accessToken: string, data: CreateProperty) => HTTPCommand<ReadProperty>;
|
|
125
|
+
/**
|
|
126
|
+
* A command to join a users realtime socket
|
|
127
|
+
* @param _id the id of the user
|
|
128
|
+
* @group Socket Commands
|
|
129
|
+
*/
|
|
130
|
+
export declare const JoinUserCommand: (_id: string) => SocketCommand;
|
|
131
|
+
/**
|
|
132
|
+
* A command to leave a users realtime socket
|
|
133
|
+
* @param _id the id of the user
|
|
134
|
+
* @group Socket Commands
|
|
135
|
+
*/
|
|
136
|
+
export declare const LeaveUserCommand: (_id: string) => SocketCommand;
|
|
137
|
+
//# sourceMappingURL=user.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.d.ts","sourceRoot":"","sources":["../../src/commands/user.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EACL,cAAc,EACd,WAAW,EACX,aAAa,EACd,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,qBAAqB,CAAC;AAEtG;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,EAAE;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,CAAC,M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AU,MAAM,KAAE,YAAa,KAAK,QAAQ,CAAC,CAOhG,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,gBAAiB,MAAM,MAAK,MAAM,KAAE,YAAY,QAAQ,CAMlF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,MAAM,MAAM,KAAE,YAAY,cAAc,CAM/F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,gBAAiB,MAAM,MAAK,MAAM,KAAE,YAAY,QAAQ,CAMpF,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,gBAAiB,MAAM,QAAO,UAAU,KAAE,YAAY,QAAQ,CAO3F,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,QAAM,cAAc,KAAE,YAAY,YAAY,CAOvG,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAQ,MAAM,KAAG,aAM5C,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,QAAQ,MAAM,KAAG,aAM7C,CAAA"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a command to get the user associated with the given accessToken
|
|
3
|
+
* @param accessToken the required accessToken
|
|
4
|
+
* @group HTTP Commands
|
|
5
|
+
*/
|
|
6
|
+
export const WhoAmICommand = (accessToken) => {
|
|
7
|
+
return {
|
|
8
|
+
method: "GET",
|
|
9
|
+
path: "/users/whoami",
|
|
10
|
+
accessToken
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Command to login a user
|
|
15
|
+
* @param username string
|
|
16
|
+
* @param password string
|
|
17
|
+
* @group HTTP Commands
|
|
18
|
+
*/
|
|
19
|
+
export const LoginUserCommand = (data) => {
|
|
20
|
+
return {
|
|
21
|
+
method: "POST",
|
|
22
|
+
path: "/users/login",
|
|
23
|
+
data
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Create command to register a user
|
|
28
|
+
* @param username string
|
|
29
|
+
* @param password string
|
|
30
|
+
* @group HTTP Commands
|
|
31
|
+
*/
|
|
32
|
+
export const RegisterUserCommand = (data) => {
|
|
33
|
+
return {
|
|
34
|
+
method: "POST",
|
|
35
|
+
path: "/users",
|
|
36
|
+
data
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Command to create a generated user
|
|
41
|
+
* @param basicUser an optional model
|
|
42
|
+
* @group HTTP Commands
|
|
43
|
+
*/
|
|
44
|
+
export const CreateGenerateBasicUserCommand = (data = {}) => {
|
|
45
|
+
return {
|
|
46
|
+
method: "POST",
|
|
47
|
+
path: "/users/generate/basic",
|
|
48
|
+
data
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Command to create a test user
|
|
53
|
+
* @param basicUser an optional model
|
|
54
|
+
* @group HTTP Commands
|
|
55
|
+
*/
|
|
56
|
+
export const CreateTestUserCommand = (username) => {
|
|
57
|
+
return {
|
|
58
|
+
method: "POST",
|
|
59
|
+
path: "/users/generate/test",
|
|
60
|
+
data: {
|
|
61
|
+
username
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* List Users command
|
|
67
|
+
* @param search search criteria for ysers
|
|
68
|
+
* @param accessToken the required accessToken
|
|
69
|
+
* @group HTTP Commands
|
|
70
|
+
*/
|
|
71
|
+
export const ListUsersCommand = (accessToken, search) => {
|
|
72
|
+
return {
|
|
73
|
+
method: "GET",
|
|
74
|
+
path: "/users",
|
|
75
|
+
params: search ? new URLSearchParams({ search }) : undefined,
|
|
76
|
+
accessToken
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Get a user command
|
|
81
|
+
* @param id the id of the user
|
|
82
|
+
* @param accessToken the required accessToken
|
|
83
|
+
* @group HTTP Commands
|
|
84
|
+
*/
|
|
85
|
+
export const GetUserCommand = (accessToken, id) => {
|
|
86
|
+
return {
|
|
87
|
+
method: "GET",
|
|
88
|
+
path: `/users/${id}`,
|
|
89
|
+
accessToken
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Refresh token command
|
|
94
|
+
* @param id the id of the user
|
|
95
|
+
* @param refreshToken the refresh token
|
|
96
|
+
* @group HTTP Commands
|
|
97
|
+
*/
|
|
98
|
+
export const RefreshTokenCommand = (refreshToken, id) => {
|
|
99
|
+
return {
|
|
100
|
+
method: "POST",
|
|
101
|
+
path: `/users/${id}/refresh_token`,
|
|
102
|
+
data: { refreshToken }
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Delete a user command
|
|
107
|
+
* @param id the id of the user
|
|
108
|
+
* @param accessToken the required accessToken
|
|
109
|
+
* @group HTTP Commands
|
|
110
|
+
*/
|
|
111
|
+
export const GetDeleteCommand = (accessToken, id) => {
|
|
112
|
+
return {
|
|
113
|
+
method: "DELETE",
|
|
114
|
+
path: `/users/${id}`,
|
|
115
|
+
accessToken
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Update the user command
|
|
120
|
+
* @param data the user needing to be updated, the _id of the user is used to select the user
|
|
121
|
+
* @param accessToken the required accessToken
|
|
122
|
+
* @group HTTP Commands
|
|
123
|
+
*/
|
|
124
|
+
export const UpdateUserCommand = (accessToken, data) => {
|
|
125
|
+
return {
|
|
126
|
+
method: "PUT",
|
|
127
|
+
path: `/users/${data._id}`,
|
|
128
|
+
data,
|
|
129
|
+
accessToken
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Add a bot property command
|
|
134
|
+
* @param data the property
|
|
135
|
+
* @param accessToken the required accessToken
|
|
136
|
+
* @group HTTP Commands
|
|
137
|
+
*/
|
|
138
|
+
export const AddUserPropertyCommand = (accessToken, data) => {
|
|
139
|
+
return {
|
|
140
|
+
method: "POST",
|
|
141
|
+
path: `/users/${data.parent_id}/properties`,
|
|
142
|
+
data,
|
|
143
|
+
accessToken
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* A command to join a users realtime socket
|
|
148
|
+
* @param _id the id of the user
|
|
149
|
+
* @group Socket Commands
|
|
150
|
+
*/
|
|
151
|
+
export const JoinUserCommand = (_id) => {
|
|
152
|
+
return {
|
|
153
|
+
method: "/users",
|
|
154
|
+
join: true,
|
|
155
|
+
id: _id
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A command to leave a users realtime socket
|
|
160
|
+
* @param _id the id of the user
|
|
161
|
+
* @group Socket Commands
|
|
162
|
+
*/
|
|
163
|
+
export const LeaveUserCommand = (_id) => {
|
|
164
|
+
return {
|
|
165
|
+
method: "/users",
|
|
166
|
+
join: false,
|
|
167
|
+
id: _id
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
//# sourceMappingURL=user.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user.js","sourceRoot":"","sources":["../../src/commands/user.ts"],"names":[],"mappings":"AA8DA;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAE,CAAC,WAAmB,EAAwB,EAAE;IACxE,OAAO;QACL,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,eAAe;QACrB,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAe,EAA0C,EAAE;IAC1F,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,cAAc;QACpB,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,IAAkB,EAA0C,EAAE;IAChG,OAAO;QACL,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,QAAQ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AU,EAAuB,EAAE;IACtF,OAAO;QACL,MAAM,EAAC,QAAQ;QACf,IAAI,EAAC,UAAU,EAAE,EAAE;QACnB,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,WAAmB,EAAC,IAAgB,EAAuB,EAAE;IAC7F,OAAO;QACL,MAAM,EAAC,KAAK;QACZ,IAAI,EAAC,UAAU,IAAI,CAAC,GAAG,EAAE;QACzB,IAAI;QACJ,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,WAAmB,EAAC,IAAmB,EAA2B,EAAE;IACzG,OAAO;QACL,MAAM,EAAC,MAAM;QACb,IAAI,EAAC,UAAU,IAAI,CAAC,SAAS,aAAa;QAC1C,IAAI;QACJ,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAU,EAAiB,EAAE;IAC3D,OAAO;QACL,MAAM,EAAC,QAAQ;QACf,IAAI,EAAC,IAAI;QACT,EAAE,EAAC,GAAG;KACP,CAAA;AACH,CAAC,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAU,EAAiB,EAAE;IAC5D,OAAO;QACL,MAAM,EAAC,QAAQ;QACf,IAAI,EAAC,KAAK;QACV,EAAE,EAAC,GAAG;KACP,CAAA;AACH,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Central Module that contains the methods to issue
|
|
3
|
+
* HTTPCommands and SocketCommands to a SAGA host
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
/// <reference types="node" />
|
|
7
|
+
import { URLSearchParams } from "url";
|
|
8
|
+
import { ReadMessage, ReadProperty } from "./lib/shared_types";
|
|
9
|
+
/**
|
|
10
|
+
* The APIError is thrown when a HTTPCommand or SocketCommands fails to execute
|
|
11
|
+
*/
|
|
12
|
+
export declare class APIError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* a saga status code as explained in the actual saga documentation,
|
|
15
|
+
* very much aligned to HTTP Status codes
|
|
16
|
+
*/
|
|
17
|
+
statusCode: number;
|
|
18
|
+
/**
|
|
19
|
+
* The path of the HTTPCommand or SocketCommand that caused the error
|
|
20
|
+
*/
|
|
21
|
+
path?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Details on what field were not permitted
|
|
24
|
+
*/
|
|
25
|
+
errors?: Record<string, string>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a
|
|
28
|
+
* @param message the error message
|
|
29
|
+
* @param statusCode a saga status code as explained in the actual saga documentation, very much aligned to HTTP Status codes
|
|
30
|
+
* @param errors list of field names and the reason why the field wasn't permitted
|
|
31
|
+
* @param path The path of the HTTPCommand or SocketCommand that caused the error
|
|
32
|
+
*/
|
|
33
|
+
constructor(message: string, statusCode: number, errors?: Record<string, string>, path?: string);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Encapsulates authentication tokens. An authentication object is returned i.e. from {@link LoginUserCommand} It's required for most HTTP Commands.
|
|
37
|
+
*/
|
|
38
|
+
export interface Authentication {
|
|
39
|
+
/**
|
|
40
|
+
* Required access token
|
|
41
|
+
*/
|
|
42
|
+
accessToken: string;
|
|
43
|
+
/**
|
|
44
|
+
* Used to retrieve a new access token using {@link RefreshTokenCommand}
|
|
45
|
+
*/
|
|
46
|
+
refreshToken: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Interface to represent the various mutations of a HTTP Command profile.
|
|
50
|
+
*/
|
|
51
|
+
export interface HTTPCommand<T> {
|
|
52
|
+
method: "GET" | "PUT" | "POST" | "DELETE";
|
|
53
|
+
path: string;
|
|
54
|
+
params?: URLSearchParams;
|
|
55
|
+
data?: any;
|
|
56
|
+
accessToken?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Send the HTTP Command to the host with the given baseURL
|
|
60
|
+
* @param baseURL the baseURL of the HTTP Api, i.e 'https://example.api.hexagram.io'
|
|
61
|
+
* @param command the actual command to send
|
|
62
|
+
* @return a promise containing the response from the command
|
|
63
|
+
* @throws an APIError if the operations fails
|
|
64
|
+
*/
|
|
65
|
+
export declare const sendHTTPCommand: <T>(baseURL: URL, command: HTTPCommand<T>) => Promise<T>;
|
|
66
|
+
/**
|
|
67
|
+
* The events a socket session can receive.
|
|
68
|
+
*/
|
|
69
|
+
export interface EventMap {
|
|
70
|
+
"/properties": ReadProperty;
|
|
71
|
+
"/messages": ReadMessage;
|
|
72
|
+
"authenticated": any;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A socket join command
|
|
76
|
+
*/
|
|
77
|
+
export interface SocketJoinCommand {
|
|
78
|
+
method: "/users" | "/bots" | "/globals" | "/jobs/runnable_calls" | "/jobs/versions" | "/scripts/runnable_calls" | "/scripts/versions" | "/system" | "/npm_packages";
|
|
79
|
+
id: string;
|
|
80
|
+
join: boolean;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The discriminating union type of socket commands,
|
|
84
|
+
* for it just contains the join commands, but the
|
|
85
|
+
* intent is to hold other socket commands as well
|
|
86
|
+
*/
|
|
87
|
+
export type SocketCommand = SocketJoinCommand;
|
|
88
|
+
/**
|
|
89
|
+
* Class that wraps saga socket connection logic and manages realtime saga socket events. The
|
|
90
|
+
*/
|
|
91
|
+
export declare class SocketSession {
|
|
92
|
+
private socket;
|
|
93
|
+
private readonly maxRetries;
|
|
94
|
+
private commandStack;
|
|
95
|
+
private ready;
|
|
96
|
+
/**
|
|
97
|
+
* Set connection parameters.
|
|
98
|
+
* @param host the host to connect to
|
|
99
|
+
* @param accessToken the access token to authenticate
|
|
100
|
+
* @param errorNotify callback function that will be called when errors occur
|
|
101
|
+
*/
|
|
102
|
+
constructor(host: URL, accessToken: string, errorNotify: (error: APIError) => any, options?: {
|
|
103
|
+
delayAuthentication?: number;
|
|
104
|
+
triggerDisconnectAndConnect?: number;
|
|
105
|
+
});
|
|
106
|
+
private emitStackedCommands;
|
|
107
|
+
on<E extends keyof EventMap>(type: E, listener: (ev: EventMap[E]) => undefined): void;
|
|
108
|
+
off<E extends keyof EventMap>(type: E, listener?: (ev: EventMap[E]) => undefined): void;
|
|
109
|
+
/**
|
|
110
|
+
* Send commands to the server
|
|
111
|
+
* @param command
|
|
112
|
+
* @throws APIError if error ack is send back from server
|
|
113
|
+
*/
|
|
114
|
+
emitCommand(command: SocketCommand): Promise<unknown>;
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;;AAIH,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AACpC,OAAO,EAAC,WAAW,EAAE,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAQ7D;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;OAEG;IAEH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAE/B;;;;;;OAMG;gBACS,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,EAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,IAAI,CAAC,EAAE,MAAM;CAM/F;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW,CAAC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