@hexagramio/saga-ts 0.9.293-2 → 0.9.293-4

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.
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Lit of user messages and functions to generate user commands
3
+ * @packageDocumentation
4
+ */
5
+ import { HTTPCommand } from "../senders/http";
6
+ import { SocketCommand } from "../senders/socket";
7
+ import { CreateProperty, Id, List, ReadProperty, Tags, TestData, TimeStamp } from "../shared/types";
8
+ /**
9
+ * used to update basic user
10
+ * @group User Types
11
+ */
12
+ export interface UpdateUser extends Id {
13
+ username?: string;
14
+ tags?: [string];
15
+ email?: string;
16
+ displayname?: string;
17
+ }
18
+ /**
19
+ *
20
+ * @group User Types
21
+ */
22
+ export interface ReadUser extends TimeStamp, Id, TestData, Tags {
23
+ username: string;
24
+ properties: Record<string, ReadProperty>;
25
+ tags?: [string];
26
+ }
27
+ /**
28
+ * Basic User Creation Message
29
+ * @group User Types
30
+ */
31
+ export interface BasicUser extends Tags {
32
+ prefix?: "";
33
+ }
34
+ /**
35
+ * Register User Message
36
+ * @group User Types
37
+ */
38
+ export interface RegisterUser extends Tags {
39
+ username: string;
40
+ password: string;
41
+ email?: string;
42
+ displayname?: string;
43
+ }
44
+ /**
45
+ * Login User Message
46
+ * @group User Types
47
+ */
48
+ export interface LoginUser extends Tags {
49
+ username: string;
50
+ password: string;
51
+ }
52
+ /**
53
+ * Creates a command to get the user associated with the given accessToken
54
+ * @param accessToken the required accessToken
55
+ * @group HTTP Commands
56
+ */
57
+ export declare const WhoAmICommand: (accessToken: string) => HTTPCommand<ReadUser>;
58
+ /**
59
+ * Encapsulates authentication tokens. An authentication object is returned i.e. from {@link LoginUserCommand} It's required for most HTTP Commands.
60
+ */
61
+ export interface Authentication {
62
+ /**
63
+ * Required access token
64
+ */
65
+ accessToken: string;
66
+ /**
67
+ * Used to retrieve a new access token using {@link RefreshTokenCommand}
68
+ */
69
+ refreshToken: string;
70
+ }
71
+ /**
72
+ * Command to login a user
73
+ * @param username string
74
+ * @param password string
75
+ * @group HTTP Commands
76
+ */
77
+ export declare const LoginUserCommand: (data: LoginUser) => HTTPCommand<ReadUser & Authentication>;
78
+ /**
79
+ * Create command to register a user
80
+ * @param username string
81
+ * @param password string
82
+ * @group HTTP Commands
83
+ */
84
+ export declare const RegisterUserCommand: (data: RegisterUser) => HTTPCommand<ReadUser & Authentication>;
85
+ /**
86
+ * Command to create a generated user
87
+ * @param basicUser an optional model
88
+ * @group HTTP Commands
89
+ */
90
+ export declare const CreateGenerateBasicUserCommand: (data?: BasicUser) => HTTPCommand<ReadUser>;
91
+ /**
92
+ * Command to create a test user
93
+ * @param basicUser an optional model
94
+ * @group HTTP Commands
95
+ */
96
+ export declare const CreateTestUserCommand: (username?: string) => HTTPCommand<ReadUser>;
97
+ /**
98
+ * List Users command
99
+ * @param search search criteria for ysers
100
+ * @param accessToken the required accessToken
101
+ * @group HTTP Commands
102
+ */
103
+ export declare const ListUsersCommand: (accessToken: string, search?: string) => HTTPCommand<List<ReadUser>>;
104
+ /**
105
+ * Get 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 GetUserCommand: (accessToken: string, id: string) => HTTPCommand<ReadUser>;
111
+ /**
112
+ * Refresh token command
113
+ * @param id the id of the user
114
+ * @param refreshToken the refresh token
115
+ * @group HTTP Commands
116
+ */
117
+ export declare const RefreshTokenCommand: (refreshToken: string, id: string) => HTTPCommand<Authentication>;
118
+ /**
119
+ * Delete a user command
120
+ * @param id the id of the user
121
+ * @param accessToken the required accessToken
122
+ * @group HTTP Commands
123
+ */
124
+ export declare const GetDeleteCommand: (accessToken: string, id: string) => HTTPCommand<ReadUser>;
125
+ /**
126
+ * Update the user command
127
+ * @param data the user needing to be updated, the _id of the user is used to select the user
128
+ * @param accessToken the required accessToken
129
+ * @group HTTP Commands
130
+ */
131
+ export declare const UpdateUserCommand: (accessToken: string, data: UpdateUser) => HTTPCommand<ReadUser>;
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 declare const AddUserPropertyCommand: (accessToken: string, data: CreateProperty) => HTTPCommand<ReadProperty>;
139
+ /**
140
+ * A command to join a users realtime socket
141
+ * @param _id the id of the user
142
+ * @group Socket Commands
143
+ */
144
+ export declare const JoinUserCommand: (_id: string) => SocketCommand;
145
+ /**
146
+ * A command to leave a users realtime socket
147
+ * @param _id the id of the user
148
+ * @group Socket Commands
149
+ */
150
+ export declare const LeaveUserCommand: (_id: string) => SocketCommand;
151
+ //# sourceMappingURL=users.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.d.ts","sourceRoot":"","sources":["../../../src/commands/users.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAC,cAAc,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAElG;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,EAAE;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AACD;;;GAGG;AACH,MAAM,WAAW,QAAS,SAAQ,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,S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AAc,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,186 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LeaveUserCommand = exports.JoinUserCommand = exports.AddUserPropertyCommand = exports.UpdateUserCommand = exports.GetDeleteCommand = exports.RefreshTokenCommand = exports.GetUserCommand = exports.ListUsersCommand = exports.CreateTestUserCommand = exports.CreateGenerateBasicUserCommand = exports.RegisterUserCommand = exports.LoginUserCommand = exports.WhoAmICommand = void 0;
4
+ /**
5
+ * Creates a command to get the user associated with the given accessToken
6
+ * @param accessToken the required accessToken
7
+ * @group HTTP Commands
8
+ */
9
+ const WhoAmICommand = (accessToken) => {
10
+ return {
11
+ method: "GET",
12
+ path: "/users/whoami",
13
+ accessToken
14
+ };
15
+ };
16
+ exports.WhoAmICommand = WhoAmICommand;
17
+ /**
18
+ * Command to login a user
19
+ * @param username string
20
+ * @param password string
21
+ * @group HTTP Commands
22
+ */
23
+ const LoginUserCommand = (data) => {
24
+ return {
25
+ method: "POST",
26
+ path: "/users/login",
27
+ data
28
+ };
29
+ };
30
+ exports.LoginUserCommand = LoginUserCommand;
31
+ /**
32
+ * Create command to register a user
33
+ * @param username string
34
+ * @param password string
35
+ * @group HTTP Commands
36
+ */
37
+ const RegisterUserCommand = (data) => {
38
+ return {
39
+ method: "POST",
40
+ path: "/users",
41
+ data
42
+ };
43
+ };
44
+ exports.RegisterUserCommand = RegisterUserCommand;
45
+ /**
46
+ * Command to create a generated user
47
+ * @param basicUser an optional model
48
+ * @group HTTP Commands
49
+ */
50
+ const CreateGenerateBasicUserCommand = (data = {}) => {
51
+ return {
52
+ method: "POST",
53
+ path: "/users/generate/basic",
54
+ data
55
+ };
56
+ };
57
+ exports.CreateGenerateBasicUserCommand = CreateGenerateBasicUserCommand;
58
+ /**
59
+ * Command to create a test user
60
+ * @param basicUser an optional model
61
+ * @group HTTP Commands
62
+ */
63
+ const CreateTestUserCommand = (username) => {
64
+ return {
65
+ method: "POST",
66
+ path: "/users/generate/test",
67
+ data: {
68
+ username
69
+ }
70
+ };
71
+ };
72
+ exports.CreateTestUserCommand = CreateTestUserCommand;
73
+ /**
74
+ * List Users command
75
+ * @param search search criteria for ysers
76
+ * @param accessToken the required accessToken
77
+ * @group HTTP Commands
78
+ */
79
+ const ListUsersCommand = (accessToken, search) => {
80
+ return {
81
+ method: "GET",
82
+ path: "/users",
83
+ params: search ? new URLSearchParams({ search }) : undefined,
84
+ accessToken
85
+ };
86
+ };
87
+ exports.ListUsersCommand = ListUsersCommand;
88
+ /**
89
+ * Get a user command
90
+ * @param id the id of the user
91
+ * @param accessToken the required accessToken
92
+ * @group HTTP Commands
93
+ */
94
+ const GetUserCommand = (accessToken, id) => {
95
+ return {
96
+ method: "GET",
97
+ path: `/users/${id}`,
98
+ accessToken
99
+ };
100
+ };
101
+ exports.GetUserCommand = GetUserCommand;
102
+ /**
103
+ * Refresh token command
104
+ * @param id the id of the user
105
+ * @param refreshToken the refresh token
106
+ * @group HTTP Commands
107
+ */
108
+ const RefreshTokenCommand = (refreshToken, id) => {
109
+ return {
110
+ method: "POST",
111
+ path: `/users/${id}/refresh_token`,
112
+ data: { refreshToken }
113
+ };
114
+ };
115
+ exports.RefreshTokenCommand = RefreshTokenCommand;
116
+ /**
117
+ * Delete a user command
118
+ * @param id the id of the user
119
+ * @param accessToken the required accessToken
120
+ * @group HTTP Commands
121
+ */
122
+ const GetDeleteCommand = (accessToken, id) => {
123
+ return {
124
+ method: "DELETE",
125
+ path: `/users/${id}`,
126
+ accessToken
127
+ };
128
+ };
129
+ exports.GetDeleteCommand = GetDeleteCommand;
130
+ /**
131
+ * Update the user command
132
+ * @param data the user needing to be updated, the _id of the user is used to select the user
133
+ * @param accessToken the required accessToken
134
+ * @group HTTP Commands
135
+ */
136
+ const UpdateUserCommand = (accessToken, data) => {
137
+ return {
138
+ method: "PUT",
139
+ path: `/users/${data._id}`,
140
+ data,
141
+ accessToken
142
+ };
143
+ };
144
+ exports.UpdateUserCommand = UpdateUserCommand;
145
+ /**
146
+ * Add a bot property command
147
+ * @param data the property
148
+ * @param accessToken the required accessToken
149
+ * @group HTTP Commands
150
+ */
151
+ const AddUserPropertyCommand = (accessToken, data) => {
152
+ return {
153
+ method: "POST",
154
+ path: `/users/${data.parent_id}/properties`,
155
+ data,
156
+ accessToken
157
+ };
158
+ };
159
+ exports.AddUserPropertyCommand = AddUserPropertyCommand;
160
+ /**
161
+ * A command to join a users realtime socket
162
+ * @param _id the id of the user
163
+ * @group Socket Commands
164
+ */
165
+ const JoinUserCommand = (_id) => {
166
+ return {
167
+ method: "/users",
168
+ join: true,
169
+ id: _id
170
+ };
171
+ };
172
+ exports.JoinUserCommand = JoinUserCommand;
173
+ /**
174
+ * A command to leave a users realtime socket
175
+ * @param _id the id of the user
176
+ * @group Socket Commands
177
+ */
178
+ const LeaveUserCommand = (_id) => {
179
+ return {
180
+ method: "/users",
181
+ join: false,
182
+ id: _id
183
+ };
184
+ };
185
+ exports.LeaveUserCommand = LeaveUserCommand;
186
+ //# sourceMappingURL=users.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"users.js","sourceRoot":"","sources":["../../../src/commands/users.ts"],"names":[],"mappings":";;;AA4DA;;;;GAIG;AACI,MAAM,aAAa,GAAE,CAAC,WAAmB,EA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,CAAC,GAAU,EAAiB,EAAE;IAC3D,OAAO;QACL,MAAM,EAAC,QAAQ;QACf,IAAI,EAAC,IAAI;QACT,EAAE,EAAC,GAAG;KACP,CAAA;AACH,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B;AAED;;;;GAIG;AACI,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;AANY,QAAA,gBAAgB,oBAM5B"}
@@ -1,116 +1,8 @@
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
- }
1
+ export * from './senders/http';
2
+ export * from './senders/socket';
3
+ export * from './commands/bots';
4
+ export * from './commands/users';
5
+ export * from './commands/system';
6
+ export * from './commands/test_data';
7
+ export * from './shared/types';
116
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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,CAAC;IAC5B,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB,IAAI,CAAC,EAAE,GAAG,CAAE;IACZ,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAGD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,eAAsB,GAAG,wCAw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