@greensecurity/javascript-sdk 0.40.8-beta.3 → 0.40.8-beta.5
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 +9 -0
- package/dist/commonjs/__tests__/alerts.test.d.ts +2 -0
- package/dist/commonjs/__tests__/alerts.test.d.ts.map +1 -0
- package/dist/commonjs/__tests__/alerts.test.js +51 -0
- package/dist/commonjs/__tests__/alerts.test.js.map +1 -0
- package/dist/commonjs/funcs/alertsListAlerts.d.ts +21 -0
- package/dist/commonjs/funcs/alertsListAlerts.d.ts.map +1 -0
- package/dist/commonjs/funcs/alertsListAlerts.js +154 -0
- package/dist/commonjs/funcs/alertsListAlerts.js.map +1 -0
- package/dist/commonjs/funcs/alertsUpdateUserAlerts.d.ts +18 -0
- package/dist/commonjs/funcs/alertsUpdateUserAlerts.d.ts.map +1 -0
- package/dist/commonjs/funcs/alertsUpdateUserAlerts.js +117 -0
- package/dist/commonjs/funcs/alertsUpdateUserAlerts.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/models/components/alert.d.ts +48 -0
- package/dist/commonjs/models/components/alert.d.ts.map +1 -0
- package/dist/commonjs/models/components/alert.js +101 -0
- package/dist/commonjs/models/components/alert.js.map +1 -0
- package/dist/commonjs/models/components/index.d.ts +1 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +1 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/operations/index.d.ts +2 -0
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +2 -0
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/models/operations/listalerts.d.ts +106 -0
- package/dist/commonjs/models/operations/listalerts.d.ts.map +1 -0
- package/dist/commonjs/models/operations/listalerts.js +149 -0
- package/dist/commonjs/models/operations/listalerts.js.map +1 -0
- package/dist/commonjs/models/operations/updateuseralerts.d.ts +57 -0
- package/dist/commonjs/models/operations/updateuseralerts.d.ts.map +1 -0
- package/dist/commonjs/models/operations/updateuseralerts.js +105 -0
- package/dist/commonjs/models/operations/updateuseralerts.js.map +1 -0
- package/dist/commonjs/react-query/alertsListAlerts.d.ts +75 -0
- package/dist/commonjs/react-query/alertsListAlerts.d.ts.map +1 -0
- package/dist/commonjs/react-query/alertsListAlerts.js +150 -0
- package/dist/commonjs/react-query/alertsListAlerts.js.map +1 -0
- package/dist/commonjs/react-query/alertsUpdateUserAlerts.d.ts +23 -0
- package/dist/commonjs/react-query/alertsUpdateUserAlerts.d.ts.map +1 -0
- package/dist/commonjs/react-query/alertsUpdateUserAlerts.js +47 -0
- package/dist/commonjs/react-query/alertsUpdateUserAlerts.js.map +1 -0
- package/dist/commonjs/react-query/index.d.ts +2 -0
- package/dist/commonjs/react-query/index.d.ts.map +1 -1
- package/dist/commonjs/react-query/index.js +2 -0
- package/dist/commonjs/react-query/index.js.map +1 -1
- package/dist/commonjs/sdk/alerts.d.ts +22 -0
- package/dist/commonjs/sdk/alerts.d.ts.map +1 -0
- package/dist/commonjs/sdk/alerts.js +33 -0
- package/dist/commonjs/sdk/alerts.js.map +1 -0
- package/dist/commonjs/sdk/sdk.d.ts +3 -0
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +4 -0
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/esm/__tests__/alerts.test.d.ts +2 -0
- package/dist/esm/__tests__/alerts.test.d.ts.map +1 -0
- package/dist/esm/__tests__/alerts.test.js +49 -0
- package/dist/esm/__tests__/alerts.test.js.map +1 -0
- package/dist/esm/funcs/alertsListAlerts.d.ts +21 -0
- package/dist/esm/funcs/alertsListAlerts.d.ts.map +1 -0
- package/dist/esm/funcs/alertsListAlerts.js +118 -0
- package/dist/esm/funcs/alertsListAlerts.js.map +1 -0
- package/dist/esm/funcs/alertsUpdateUserAlerts.d.ts +18 -0
- package/dist/esm/funcs/alertsUpdateUserAlerts.d.ts.map +1 -0
- package/dist/esm/funcs/alertsUpdateUserAlerts.js +81 -0
- package/dist/esm/funcs/alertsUpdateUserAlerts.js.map +1 -0
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/models/components/alert.d.ts +48 -0
- package/dist/esm/models/components/alert.d.ts.map +1 -0
- package/dist/esm/models/components/alert.js +63 -0
- package/dist/esm/models/components/alert.js.map +1 -0
- package/dist/esm/models/components/index.d.ts +1 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +1 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/operations/index.d.ts +2 -0
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +2 -0
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/models/operations/listalerts.d.ts +106 -0
- package/dist/esm/models/operations/listalerts.d.ts.map +1 -0
- package/dist/esm/models/operations/listalerts.js +107 -0
- package/dist/esm/models/operations/listalerts.js.map +1 -0
- package/dist/esm/models/operations/updateuseralerts.d.ts +57 -0
- package/dist/esm/models/operations/updateuseralerts.d.ts.map +1 -0
- package/dist/esm/models/operations/updateuseralerts.js +65 -0
- package/dist/esm/models/operations/updateuseralerts.js.map +1 -0
- package/dist/esm/react-query/alertsListAlerts.d.ts +75 -0
- package/dist/esm/react-query/alertsListAlerts.d.ts.map +1 -0
- package/dist/esm/react-query/alertsListAlerts.js +137 -0
- package/dist/esm/react-query/alertsListAlerts.js.map +1 -0
- package/dist/esm/react-query/alertsUpdateUserAlerts.d.ts +23 -0
- package/dist/esm/react-query/alertsUpdateUserAlerts.d.ts.map +1 -0
- package/dist/esm/react-query/alertsUpdateUserAlerts.js +42 -0
- package/dist/esm/react-query/alertsUpdateUserAlerts.js.map +1 -0
- package/dist/esm/react-query/index.d.ts +2 -0
- package/dist/esm/react-query/index.d.ts.map +1 -1
- package/dist/esm/react-query/index.js +2 -0
- package/dist/esm/react-query/index.js.map +1 -1
- package/dist/esm/sdk/alerts.d.ts +22 -0
- package/dist/esm/sdk/alerts.d.ts.map +1 -0
- package/dist/esm/sdk/alerts.js +29 -0
- package/dist/esm/sdk/alerts.js.map +1 -0
- package/dist/esm/sdk/sdk.d.ts +3 -0
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +4 -0
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/__tests__/alerts.test.ts +55 -0
- package/src/funcs/alertsListAlerts.ts +245 -0
- package/src/funcs/alertsUpdateUserAlerts.ts +170 -0
- package/src/lib/config.ts +2 -2
- package/src/models/components/alert.ts +109 -0
- package/src/models/components/index.ts +1 -0
- package/src/models/operations/index.ts +2 -0
- package/src/models/operations/listalerts.ts +234 -0
- package/src/models/operations/updateuseralerts.ts +140 -0
- package/src/react-query/alertsListAlerts.ts +308 -0
- package/src/react-query/alertsUpdateUserAlerts.ts +89 -0
- package/src/react-query/index.ts +2 -0
- package/src/sdk/alerts.ts +46 -0
- package/src/sdk/sdk.ts +6 -0
package/package.json
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { expect, test } from "vitest";
|
|
6
|
+
import { GreenSecurity } from "../index.js";
|
|
7
|
+
import { createTestHTTPClient } from "./testclient.js";
|
|
8
|
+
|
|
9
|
+
test("Alerts List Alerts", async () => {
|
|
10
|
+
const testHttpClient = createTestHTTPClient("listAlerts");
|
|
11
|
+
|
|
12
|
+
const greenSecurity = new GreenSecurity({
|
|
13
|
+
serverURL: process.env["TEST_SERVER_URL"] ?? "https://localhost:3000/api",
|
|
14
|
+
httpClient: testHttpClient,
|
|
15
|
+
security: {
|
|
16
|
+
token: process.env["GREEN_SECURITY_TOKEN"] ?? "value",
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const result = await greenSecurity.alerts.listAlerts({
|
|
21
|
+
sort: "job",
|
|
22
|
+
desc: true,
|
|
23
|
+
itemsPerPage: 25,
|
|
24
|
+
});
|
|
25
|
+
expect(result).toBeDefined();
|
|
26
|
+
expect(result.result).toBeDefined();
|
|
27
|
+
expect(result.result).toEqual({
|
|
28
|
+
pager: {
|
|
29
|
+
baseUrl: "api/vendors/job_titles",
|
|
30
|
+
sort: "job,title",
|
|
31
|
+
desc: 0,
|
|
32
|
+
itemCount: 228,
|
|
33
|
+
itemsPerPage: 562526,
|
|
34
|
+
page: 1,
|
|
35
|
+
useUrlParams: true,
|
|
36
|
+
},
|
|
37
|
+
items: [],
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("Alerts Update User Alerts", async () => {
|
|
42
|
+
const testHttpClient = createTestHTTPClient("updateUserAlerts");
|
|
43
|
+
|
|
44
|
+
const greenSecurity = new GreenSecurity({
|
|
45
|
+
serverURL: process.env["TEST_SERVER_URL"] ?? "https://localhost:3000/api",
|
|
46
|
+
httpClient: testHttpClient,
|
|
47
|
+
security: {
|
|
48
|
+
token: process.env["GREEN_SECURITY_TOKEN"] ?? "value",
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const result = await greenSecurity.alerts.updateUserAlerts({});
|
|
53
|
+
expect(result).toBeDefined();
|
|
54
|
+
expect(result).toEqual({});
|
|
55
|
+
});
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { GreenSecurityCore } from "../core.js";
|
|
6
|
+
import { dlv } from "../lib/dlv.js";
|
|
7
|
+
import { encodeFormQuery } from "../lib/encodings.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import { GreenSecurityError } from "../models/errors/greensecurityerror.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
import {
|
|
29
|
+
createPageIterator,
|
|
30
|
+
haltIterator,
|
|
31
|
+
PageIterator,
|
|
32
|
+
Paginator,
|
|
33
|
+
} from "../types/operations.js";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* List alerts
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* List alerts for user.
|
|
40
|
+
*/
|
|
41
|
+
export function alertsListAlerts(
|
|
42
|
+
client: GreenSecurityCore,
|
|
43
|
+
request: operations.ListAlertsRequest,
|
|
44
|
+
options?: RequestOptions,
|
|
45
|
+
): APIPromise<
|
|
46
|
+
PageIterator<
|
|
47
|
+
Result<
|
|
48
|
+
operations.ListAlertsResponse,
|
|
49
|
+
| errors.ApiErrorResponse
|
|
50
|
+
| GreenSecurityError
|
|
51
|
+
| ResponseValidationError
|
|
52
|
+
| ConnectionError
|
|
53
|
+
| RequestAbortedError
|
|
54
|
+
| RequestTimeoutError
|
|
55
|
+
| InvalidRequestError
|
|
56
|
+
| UnexpectedClientError
|
|
57
|
+
| SDKValidationError
|
|
58
|
+
>,
|
|
59
|
+
{ page: number }
|
|
60
|
+
>
|
|
61
|
+
> {
|
|
62
|
+
return new APIPromise($do(
|
|
63
|
+
client,
|
|
64
|
+
request,
|
|
65
|
+
options,
|
|
66
|
+
));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function $do(
|
|
70
|
+
client: GreenSecurityCore,
|
|
71
|
+
request: operations.ListAlertsRequest,
|
|
72
|
+
options?: RequestOptions,
|
|
73
|
+
): Promise<
|
|
74
|
+
[
|
|
75
|
+
PageIterator<
|
|
76
|
+
Result<
|
|
77
|
+
operations.ListAlertsResponse,
|
|
78
|
+
| errors.ApiErrorResponse
|
|
79
|
+
| GreenSecurityError
|
|
80
|
+
| ResponseValidationError
|
|
81
|
+
| ConnectionError
|
|
82
|
+
| RequestAbortedError
|
|
83
|
+
| RequestTimeoutError
|
|
84
|
+
| InvalidRequestError
|
|
85
|
+
| UnexpectedClientError
|
|
86
|
+
| SDKValidationError
|
|
87
|
+
>,
|
|
88
|
+
{ page: number }
|
|
89
|
+
>,
|
|
90
|
+
APICall,
|
|
91
|
+
]
|
|
92
|
+
> {
|
|
93
|
+
const parsed = safeParse(
|
|
94
|
+
request,
|
|
95
|
+
(value) => operations.ListAlertsRequest$outboundSchema.parse(value),
|
|
96
|
+
"Input validation failed",
|
|
97
|
+
);
|
|
98
|
+
if (!parsed.ok) {
|
|
99
|
+
return [haltIterator(parsed), { status: "invalid" }];
|
|
100
|
+
}
|
|
101
|
+
const payload = parsed.value;
|
|
102
|
+
const body = null;
|
|
103
|
+
|
|
104
|
+
const path = pathToFunc("/alerts")();
|
|
105
|
+
|
|
106
|
+
const query = encodeFormQuery({
|
|
107
|
+
"desc": payload.desc,
|
|
108
|
+
"items_per_page": payload.items_per_page,
|
|
109
|
+
"page": payload.page,
|
|
110
|
+
"sort": payload.sort,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const headers = new Headers(compactMap({
|
|
114
|
+
Accept: "application/json",
|
|
115
|
+
}));
|
|
116
|
+
|
|
117
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
118
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
119
|
+
|
|
120
|
+
const context = {
|
|
121
|
+
options: client._options,
|
|
122
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
123
|
+
operationID: "listAlerts",
|
|
124
|
+
oAuth2Scopes: [],
|
|
125
|
+
|
|
126
|
+
resolvedSecurity: requestSecurity,
|
|
127
|
+
|
|
128
|
+
securitySource: client._options.security,
|
|
129
|
+
retryConfig: options?.retries
|
|
130
|
+
|| client._options.retryConfig
|
|
131
|
+
|| { strategy: "none" },
|
|
132
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const requestRes = client._createRequest(context, {
|
|
136
|
+
security: requestSecurity,
|
|
137
|
+
method: "GET",
|
|
138
|
+
baseURL: options?.serverURL,
|
|
139
|
+
path: path,
|
|
140
|
+
headers: headers,
|
|
141
|
+
query: query,
|
|
142
|
+
body: body,
|
|
143
|
+
userAgent: client._options.userAgent,
|
|
144
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
145
|
+
}, options);
|
|
146
|
+
if (!requestRes.ok) {
|
|
147
|
+
return [haltIterator(requestRes), { status: "invalid" }];
|
|
148
|
+
}
|
|
149
|
+
const req = requestRes.value;
|
|
150
|
+
|
|
151
|
+
const doResult = await client._do(req, {
|
|
152
|
+
context,
|
|
153
|
+
errorCodes: ["400", "401", "403", "4XX", "500", "5XX"],
|
|
154
|
+
retryConfig: context.retryConfig,
|
|
155
|
+
retryCodes: context.retryCodes,
|
|
156
|
+
});
|
|
157
|
+
if (!doResult.ok) {
|
|
158
|
+
return [haltIterator(doResult), { status: "request-error", request: req }];
|
|
159
|
+
}
|
|
160
|
+
const response = doResult.value;
|
|
161
|
+
|
|
162
|
+
const responseFields = {
|
|
163
|
+
HttpMeta: { Response: response, Request: req },
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const [result, raw] = await M.match<
|
|
167
|
+
operations.ListAlertsResponse,
|
|
168
|
+
| errors.ApiErrorResponse
|
|
169
|
+
| GreenSecurityError
|
|
170
|
+
| ResponseValidationError
|
|
171
|
+
| ConnectionError
|
|
172
|
+
| RequestAbortedError
|
|
173
|
+
| RequestTimeoutError
|
|
174
|
+
| InvalidRequestError
|
|
175
|
+
| UnexpectedClientError
|
|
176
|
+
| SDKValidationError
|
|
177
|
+
>(
|
|
178
|
+
M.json(200, operations.ListAlertsResponse$inboundSchema, { key: "Result" }),
|
|
179
|
+
M.jsonErr([400, 401, 403], errors.ApiErrorResponse$inboundSchema),
|
|
180
|
+
M.jsonErr(500, errors.ApiErrorResponse$inboundSchema),
|
|
181
|
+
M.fail("4XX"),
|
|
182
|
+
M.fail("5XX"),
|
|
183
|
+
)(response, req, { extraFields: responseFields });
|
|
184
|
+
if (!result.ok) {
|
|
185
|
+
return [haltIterator(result), {
|
|
186
|
+
status: "complete",
|
|
187
|
+
request: req,
|
|
188
|
+
response,
|
|
189
|
+
}];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const nextFunc = (
|
|
193
|
+
responseData: unknown,
|
|
194
|
+
): {
|
|
195
|
+
next: Paginator<
|
|
196
|
+
Result<
|
|
197
|
+
operations.ListAlertsResponse,
|
|
198
|
+
| errors.ApiErrorResponse
|
|
199
|
+
| GreenSecurityError
|
|
200
|
+
| ResponseValidationError
|
|
201
|
+
| ConnectionError
|
|
202
|
+
| RequestAbortedError
|
|
203
|
+
| RequestTimeoutError
|
|
204
|
+
| InvalidRequestError
|
|
205
|
+
| UnexpectedClientError
|
|
206
|
+
| SDKValidationError
|
|
207
|
+
>
|
|
208
|
+
>;
|
|
209
|
+
"~next"?: { page: number };
|
|
210
|
+
} => {
|
|
211
|
+
const page = request?.page ?? 1;
|
|
212
|
+
const nextPage = page + 1;
|
|
213
|
+
|
|
214
|
+
if (!responseData) {
|
|
215
|
+
return { next: () => null };
|
|
216
|
+
}
|
|
217
|
+
const results = dlv(responseData, "items");
|
|
218
|
+
if (!Array.isArray(results) || !results.length) {
|
|
219
|
+
return { next: () => null };
|
|
220
|
+
}
|
|
221
|
+
const limit = request?.itemsPerPage ?? 0;
|
|
222
|
+
if (results.length < limit) {
|
|
223
|
+
return { next: () => null };
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const nextVal = () =>
|
|
227
|
+
alertsListAlerts(
|
|
228
|
+
client,
|
|
229
|
+
{
|
|
230
|
+
...request,
|
|
231
|
+
page: nextPage,
|
|
232
|
+
},
|
|
233
|
+
options,
|
|
234
|
+
);
|
|
235
|
+
|
|
236
|
+
return { next: nextVal, "~next": { page: nextPage } };
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
const page = { ...result, ...nextFunc(raw) };
|
|
240
|
+
return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
|
|
241
|
+
status: "complete",
|
|
242
|
+
request: req,
|
|
243
|
+
response,
|
|
244
|
+
}];
|
|
245
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { GreenSecurityCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import { GreenSecurityError } from "../models/errors/greensecurityerror.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import * as operations from "../models/operations/index.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Update user alerts
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Update user alerts
|
|
33
|
+
*/
|
|
34
|
+
export function alertsUpdateUserAlerts(
|
|
35
|
+
client: GreenSecurityCore,
|
|
36
|
+
request: operations.UpdateUserAlertsRequestBody,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.UpdateUserAlertsResponseBody,
|
|
41
|
+
| errors.ApiErrorResponse
|
|
42
|
+
| GreenSecurityError
|
|
43
|
+
| ResponseValidationError
|
|
44
|
+
| ConnectionError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| InvalidRequestError
|
|
48
|
+
| UnexpectedClientError
|
|
49
|
+
| SDKValidationError
|
|
50
|
+
>
|
|
51
|
+
> {
|
|
52
|
+
return new APIPromise($do(
|
|
53
|
+
client,
|
|
54
|
+
request,
|
|
55
|
+
options,
|
|
56
|
+
));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function $do(
|
|
60
|
+
client: GreenSecurityCore,
|
|
61
|
+
request: operations.UpdateUserAlertsRequestBody,
|
|
62
|
+
options?: RequestOptions,
|
|
63
|
+
): Promise<
|
|
64
|
+
[
|
|
65
|
+
Result<
|
|
66
|
+
operations.UpdateUserAlertsResponseBody,
|
|
67
|
+
| errors.ApiErrorResponse
|
|
68
|
+
| GreenSecurityError
|
|
69
|
+
| ResponseValidationError
|
|
70
|
+
| ConnectionError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| InvalidRequestError
|
|
74
|
+
| UnexpectedClientError
|
|
75
|
+
| SDKValidationError
|
|
76
|
+
>,
|
|
77
|
+
APICall,
|
|
78
|
+
]
|
|
79
|
+
> {
|
|
80
|
+
const parsed = safeParse(
|
|
81
|
+
request,
|
|
82
|
+
(value) =>
|
|
83
|
+
operations.UpdateUserAlertsRequestBody$outboundSchema.parse(value),
|
|
84
|
+
"Input validation failed",
|
|
85
|
+
);
|
|
86
|
+
if (!parsed.ok) {
|
|
87
|
+
return [parsed, { status: "invalid" }];
|
|
88
|
+
}
|
|
89
|
+
const payload = parsed.value;
|
|
90
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
91
|
+
|
|
92
|
+
const path = pathToFunc("/user-alerts")();
|
|
93
|
+
|
|
94
|
+
const headers = new Headers(compactMap({
|
|
95
|
+
"Content-Type": "application/json",
|
|
96
|
+
Accept: "application/json",
|
|
97
|
+
}));
|
|
98
|
+
|
|
99
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
100
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
101
|
+
|
|
102
|
+
const context = {
|
|
103
|
+
options: client._options,
|
|
104
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
105
|
+
operationID: "updateUserAlerts",
|
|
106
|
+
oAuth2Scopes: [],
|
|
107
|
+
|
|
108
|
+
resolvedSecurity: requestSecurity,
|
|
109
|
+
|
|
110
|
+
securitySource: client._options.security,
|
|
111
|
+
retryConfig: options?.retries
|
|
112
|
+
|| client._options.retryConfig
|
|
113
|
+
|| { strategy: "none" },
|
|
114
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const requestRes = client._createRequest(context, {
|
|
118
|
+
security: requestSecurity,
|
|
119
|
+
method: "PUT",
|
|
120
|
+
baseURL: options?.serverURL,
|
|
121
|
+
path: path,
|
|
122
|
+
headers: headers,
|
|
123
|
+
body: body,
|
|
124
|
+
userAgent: client._options.userAgent,
|
|
125
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
126
|
+
}, options);
|
|
127
|
+
if (!requestRes.ok) {
|
|
128
|
+
return [requestRes, { status: "invalid" }];
|
|
129
|
+
}
|
|
130
|
+
const req = requestRes.value;
|
|
131
|
+
|
|
132
|
+
const doResult = await client._do(req, {
|
|
133
|
+
context,
|
|
134
|
+
errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
|
|
135
|
+
retryConfig: context.retryConfig,
|
|
136
|
+
retryCodes: context.retryCodes,
|
|
137
|
+
});
|
|
138
|
+
if (!doResult.ok) {
|
|
139
|
+
return [doResult, { status: "request-error", request: req }];
|
|
140
|
+
}
|
|
141
|
+
const response = doResult.value;
|
|
142
|
+
|
|
143
|
+
const responseFields = {
|
|
144
|
+
HttpMeta: { Response: response, Request: req },
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const [result] = await M.match<
|
|
148
|
+
operations.UpdateUserAlertsResponseBody,
|
|
149
|
+
| errors.ApiErrorResponse
|
|
150
|
+
| GreenSecurityError
|
|
151
|
+
| ResponseValidationError
|
|
152
|
+
| ConnectionError
|
|
153
|
+
| RequestAbortedError
|
|
154
|
+
| RequestTimeoutError
|
|
155
|
+
| InvalidRequestError
|
|
156
|
+
| UnexpectedClientError
|
|
157
|
+
| SDKValidationError
|
|
158
|
+
>(
|
|
159
|
+
M.json(200, operations.UpdateUserAlertsResponseBody$inboundSchema),
|
|
160
|
+
M.jsonErr([400, 401, 403, 404], errors.ApiErrorResponse$inboundSchema),
|
|
161
|
+
M.jsonErr(500, errors.ApiErrorResponse$inboundSchema),
|
|
162
|
+
M.fail("4XX"),
|
|
163
|
+
M.fail("5XX"),
|
|
164
|
+
)(response, req, { extraFields: responseFields });
|
|
165
|
+
if (!result.ok) {
|
|
166
|
+
return [result, { status: "complete", request: req, response }];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
return [result, { status: "complete", request: req, response }];
|
|
170
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -80,8 +80,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
80
80
|
export const SDK_METADATA = {
|
|
81
81
|
language: "typescript",
|
|
82
82
|
openapiDocVersion: "0.0.4",
|
|
83
|
-
sdkVersion: "0.40.8-beta.
|
|
83
|
+
sdkVersion: "0.40.8-beta.4",
|
|
84
84
|
genVersion: "2.687.1",
|
|
85
85
|
userAgent:
|
|
86
|
-
"speakeasy-sdk/typescript 0.40.8-beta.
|
|
86
|
+
"speakeasy-sdk/typescript 0.40.8-beta.4 2.687.1 0.0.4 @greensecurity/javascript-sdk",
|
|
87
87
|
} as const;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A simplified representation of a Alert, typically used in list views.
|
|
13
|
+
*/
|
|
14
|
+
export type Alert = {
|
|
15
|
+
id?: number | undefined;
|
|
16
|
+
dateAdded?: string | null | undefined;
|
|
17
|
+
dateStarts?: string | null | undefined;
|
|
18
|
+
message?: string | null | undefined;
|
|
19
|
+
status?: string | null | undefined;
|
|
20
|
+
title?: string | null | undefined;
|
|
21
|
+
plainText?: string | null | undefined;
|
|
22
|
+
viewed?: boolean | null | undefined;
|
|
23
|
+
dateViewed?: string | null | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
27
|
+
export const Alert$inboundSchema: z.ZodType<Alert, z.ZodTypeDef, unknown> = z
|
|
28
|
+
.object({
|
|
29
|
+
id: z.number().int().optional(),
|
|
30
|
+
date_added: z.nullable(z.string()).optional(),
|
|
31
|
+
date_starts: z.nullable(z.string()).optional(),
|
|
32
|
+
message: z.nullable(z.string()).optional(),
|
|
33
|
+
status: z.nullable(z.string()).optional(),
|
|
34
|
+
title: z.nullable(z.string()).optional(),
|
|
35
|
+
plain_text: z.nullable(z.string()).optional(),
|
|
36
|
+
viewed: z.nullable(z.boolean()).optional(),
|
|
37
|
+
date_viewed: z.nullable(z.string()).optional(),
|
|
38
|
+
}).transform((v) => {
|
|
39
|
+
return remap$(v, {
|
|
40
|
+
"date_added": "dateAdded",
|
|
41
|
+
"date_starts": "dateStarts",
|
|
42
|
+
"plain_text": "plainText",
|
|
43
|
+
"date_viewed": "dateViewed",
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/** @internal */
|
|
48
|
+
export type Alert$Outbound = {
|
|
49
|
+
id?: number | undefined;
|
|
50
|
+
date_added?: string | null | undefined;
|
|
51
|
+
date_starts?: string | null | undefined;
|
|
52
|
+
message?: string | null | undefined;
|
|
53
|
+
status?: string | null | undefined;
|
|
54
|
+
title?: string | null | undefined;
|
|
55
|
+
plain_text?: string | null | undefined;
|
|
56
|
+
viewed?: boolean | null | undefined;
|
|
57
|
+
date_viewed?: string | null | undefined;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** @internal */
|
|
61
|
+
export const Alert$outboundSchema: z.ZodType<
|
|
62
|
+
Alert$Outbound,
|
|
63
|
+
z.ZodTypeDef,
|
|
64
|
+
Alert
|
|
65
|
+
> = z.object({
|
|
66
|
+
id: z.number().int().optional(),
|
|
67
|
+
dateAdded: z.nullable(z.string()).optional(),
|
|
68
|
+
dateStarts: z.nullable(z.string()).optional(),
|
|
69
|
+
message: z.nullable(z.string()).optional(),
|
|
70
|
+
status: z.nullable(z.string()).optional(),
|
|
71
|
+
title: z.nullable(z.string()).optional(),
|
|
72
|
+
plainText: z.nullable(z.string()).optional(),
|
|
73
|
+
viewed: z.nullable(z.boolean()).optional(),
|
|
74
|
+
dateViewed: z.nullable(z.string()).optional(),
|
|
75
|
+
}).transform((v) => {
|
|
76
|
+
return remap$(v, {
|
|
77
|
+
dateAdded: "date_added",
|
|
78
|
+
dateStarts: "date_starts",
|
|
79
|
+
plainText: "plain_text",
|
|
80
|
+
dateViewed: "date_viewed",
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* @internal
|
|
86
|
+
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
|
|
87
|
+
*/
|
|
88
|
+
export namespace Alert$ {
|
|
89
|
+
/** @deprecated use `Alert$inboundSchema` instead. */
|
|
90
|
+
export const inboundSchema = Alert$inboundSchema;
|
|
91
|
+
/** @deprecated use `Alert$outboundSchema` instead. */
|
|
92
|
+
export const outboundSchema = Alert$outboundSchema;
|
|
93
|
+
/** @deprecated use `Alert$Outbound` instead. */
|
|
94
|
+
export type Outbound = Alert$Outbound;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function alertToJSON(alert: Alert): string {
|
|
98
|
+
return JSON.stringify(Alert$outboundSchema.parse(alert));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function alertFromJSON(
|
|
102
|
+
jsonString: string,
|
|
103
|
+
): SafeParseResult<Alert, SDKValidationError> {
|
|
104
|
+
return safeParse(
|
|
105
|
+
jsonString,
|
|
106
|
+
(x) => Alert$inboundSchema.parse(JSON.parse(x)),
|
|
107
|
+
`Failed to parse 'Alert' from JSON`,
|
|
108
|
+
);
|
|
109
|
+
}
|
|
@@ -39,6 +39,7 @@ export * from "./getvendorinvoicereceipt.js";
|
|
|
39
39
|
export * from "./getvendorlegalname.js";
|
|
40
40
|
export * from "./getvendorsdetails.js";
|
|
41
41
|
export * from "./getwebhookendpoint.js";
|
|
42
|
+
export * from "./listalerts.js";
|
|
42
43
|
export * from "./listallwebhookendpoints.js";
|
|
43
44
|
export * from "./listfeed.js";
|
|
44
45
|
export * from "./listlocations.js";
|
|
@@ -82,6 +83,7 @@ export * from "./updateevent.js";
|
|
|
82
83
|
export * from "./updatefhirconfigbyid.js";
|
|
83
84
|
export * from "./updateinvoice.js";
|
|
84
85
|
export * from "./updatesthewebhookendpointwiththegivenid.js";
|
|
86
|
+
export * from "./updateuseralerts.js";
|
|
85
87
|
export * from "./updatevendorcredentialdata.js";
|
|
86
88
|
export * from "./updatevendorcredentialfile.js";
|
|
87
89
|
export * from "./updatevendordetails.js";
|