@greensecurity/javascript-sdk 0.9.1 → 0.11.0
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 +81 -16
- package/bin/mcp-server.js +39384 -0
- package/bin/mcp-server.js.map +301 -0
- package/funcs/organizationsGetFacility.d.ts +2 -1
- package/funcs/organizationsGetFacility.d.ts.map +1 -1
- package/funcs/organizationsGetFacility.js +11 -7
- package/funcs/organizationsGetFacility.js.map +1 -1
- package/funcs/organizationsListOrSearchFacilities.d.ts +2 -1
- package/funcs/organizationsListOrSearchFacilities.d.ts.map +1 -1
- package/funcs/organizationsListOrSearchFacilities.js +11 -7
- package/funcs/organizationsListOrSearchFacilities.js.map +1 -1
- package/funcs/userGetCurrentUser.d.ts +2 -1
- package/funcs/userGetCurrentUser.d.ts.map +1 -1
- package/funcs/userGetCurrentUser.js +10 -6
- package/funcs/userGetCurrentUser.js.map +1 -1
- package/funcs/userGetUserById.d.ts +2 -1
- package/funcs/userGetUserById.d.ts.map +1 -1
- package/funcs/userGetUserById.js +11 -7
- package/funcs/userGetUserById.js.map +1 -1
- package/funcs/userLogsUserIntoTheSystem.d.ts +2 -1
- package/funcs/userLogsUserIntoTheSystem.d.ts.map +1 -1
- package/funcs/userLogsUserIntoTheSystem.js +11 -7
- package/funcs/userLogsUserIntoTheSystem.js.map +1 -1
- package/funcs/userMagiclink.d.ts +17 -0
- package/funcs/userMagiclink.d.ts.map +1 -0
- package/funcs/userMagiclink.js +115 -0
- package/funcs/userMagiclink.js.map +1 -0
- package/funcs/userPassword.d.ts +18 -0
- package/funcs/userPassword.d.ts.map +1 -0
- package/funcs/userPassword.js +116 -0
- package/funcs/userPassword.js.map +1 -0
- package/funcs/userPasswordResetRequest.d.ts +17 -0
- package/funcs/userPasswordResetRequest.d.ts.map +1 -0
- package/funcs/userPasswordResetRequest.js +115 -0
- package/funcs/userPasswordResetRequest.js.map +1 -0
- package/funcs/vendorsCreateVendorRegistration.d.ts +2 -1
- package/funcs/vendorsCreateVendorRegistration.d.ts.map +1 -1
- package/funcs/vendorsCreateVendorRegistration.js +11 -7
- package/funcs/vendorsCreateVendorRegistration.js.map +1 -1
- package/funcs/vendorsListVendorJobTitles.d.ts +2 -1
- package/funcs/vendorsListVendorJobTitles.d.ts.map +1 -1
- package/funcs/vendorsListVendorJobTitles.js +11 -7
- package/funcs/vendorsListVendorJobTitles.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +5 -5
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/lib/files.js.map +1 -1
- package/lib/sdks.d.ts +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/mcp-server/build.d.mts.map +1 -0
- package/mcp-server/build.mjs +14 -0
- package/mcp-server/build.mjs.map +1 -0
- package/mcp-server/cli/start/command.d.ts +2 -0
- package/mcp-server/cli/start/command.d.ts.map +1 -0
- package/mcp-server/cli/start/command.js +99 -0
- package/mcp-server/cli/start/command.js.map +1 -0
- package/mcp-server/cli/start/impl.d.ts +15 -0
- package/mcp-server/cli/start/impl.d.ts.map +1 -0
- package/mcp-server/cli/start/impl.js +97 -0
- package/mcp-server/cli/start/impl.js.map +1 -0
- package/mcp-server/cli.d.ts +6 -0
- package/mcp-server/cli.d.ts.map +1 -0
- package/mcp-server/cli.js +10 -0
- package/mcp-server/cli.js.map +1 -0
- package/mcp-server/console-logger.d.ts +7 -0
- package/mcp-server/console-logger.d.ts.map +1 -0
- package/mcp-server/console-logger.js +59 -0
- package/mcp-server/console-logger.js.map +1 -0
- package/mcp-server/mcp-server.d.ts +2 -0
- package/mcp-server/mcp-server.d.ts.map +1 -0
- package/mcp-server/mcp-server.js +29 -0
- package/mcp-server/mcp-server.js.map +1 -0
- package/mcp-server/resources.d.ts +27 -0
- package/mcp-server/resources.d.ts.map +1 -0
- package/mcp-server/resources.js +51 -0
- package/mcp-server/resources.js.map +1 -0
- package/mcp-server/scopes.d.ts +3 -0
- package/mcp-server/scopes.d.ts.map +1 -0
- package/mcp-server/scopes.js +8 -0
- package/mcp-server/scopes.js.map +1 -0
- package/mcp-server/server.d.ts +11 -0
- package/mcp-server/server.d.ts.map +1 -0
- package/mcp-server/server.js +44 -0
- package/mcp-server/server.js.map +1 -0
- package/mcp-server/shared.d.ts +7 -0
- package/mcp-server/shared.d.ts.map +1 -0
- package/mcp-server/shared.js +98 -0
- package/mcp-server/shared.js.map +1 -0
- package/mcp-server/tools/organizationsGetFacility.d.ts +8 -0
- package/mcp-server/tools/organizationsGetFacility.d.ts.map +1 -0
- package/mcp-server/tools/organizationsGetFacility.js +64 -0
- package/mcp-server/tools/organizationsGetFacility.js.map +1 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts +8 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.d.ts.map +1 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.js +77 -0
- package/mcp-server/tools/organizationsListOrSearchFacilities.js.map +1 -0
- package/mcp-server/tools/userGetCurrentUser.d.ts +3 -0
- package/mcp-server/tools/userGetCurrentUser.d.ts.map +1 -0
- package/mcp-server/tools/userGetCurrentUser.js +26 -0
- package/mcp-server/tools/userGetCurrentUser.js.map +1 -0
- package/mcp-server/tools/userGetUserById.d.ts +8 -0
- package/mcp-server/tools/userGetUserById.d.ts.map +1 -0
- package/mcp-server/tools/userGetUserById.js +64 -0
- package/mcp-server/tools/userGetUserById.js.map +1 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts +8 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.d.ts.map +1 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.js +94 -0
- package/mcp-server/tools/userLogsUserIntoTheSystem.js.map +1 -0
- package/mcp-server/tools/userMagiclink.d.ts +8 -0
- package/mcp-server/tools/userMagiclink.d.ts.map +1 -0
- package/mcp-server/tools/userMagiclink.js +64 -0
- package/mcp-server/tools/userMagiclink.js.map +1 -0
- package/mcp-server/tools/userPassword.d.ts +8 -0
- package/mcp-server/tools/userPassword.d.ts.map +1 -0
- package/mcp-server/tools/userPassword.js +65 -0
- package/mcp-server/tools/userPassword.js.map +1 -0
- package/mcp-server/tools/userPasswordResetRequest.d.ts +8 -0
- package/mcp-server/tools/userPasswordResetRequest.d.ts.map +1 -0
- package/mcp-server/tools/userPasswordResetRequest.js +64 -0
- package/mcp-server/tools/userPasswordResetRequest.js.map +1 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts +8 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.d.ts.map +1 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.js +64 -0
- package/mcp-server/tools/vendorsCreateVendorRegistration.js.map +1 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.d.ts +8 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.d.ts.map +1 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.js +64 -0
- package/mcp-server/tools/vendorsListVendorJobTitles.js.map +1 -0
- package/mcp-server/tools.d.ts +25 -0
- package/mcp-server/tools.d.ts.map +1 -0
- package/mcp-server/tools.js +74 -0
- package/mcp-server/tools.js.map +1 -0
- package/models/operations/index.d.ts +3 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +3 -0
- package/models/operations/index.js.map +1 -1
- package/models/operations/magiclink.d.ts +57 -0
- package/models/operations/magiclink.d.ts.map +1 -0
- package/models/operations/magiclink.js +96 -0
- package/models/operations/magiclink.js.map +1 -0
- package/models/operations/password.d.ts +59 -0
- package/models/operations/password.d.ts.map +1 -0
- package/models/operations/password.js +107 -0
- package/models/operations/password.js.map +1 -0
- package/models/operations/passwordresetrequest.d.ts +57 -0
- package/models/operations/passwordresetrequest.d.ts.map +1 -0
- package/models/operations/passwordresetrequest.js +96 -0
- package/models/operations/passwordresetrequest.js.map +1 -0
- package/package.json +14 -2
- package/react-query/index.d.ts +3 -0
- package/react-query/index.d.ts.map +1 -1
- package/react-query/index.js +3 -0
- package/react-query/index.js.map +1 -1
- package/react-query/userMagiclink.d.ts +23 -0
- package/react-query/userMagiclink.d.ts.map +1 -0
- package/react-query/userMagiclink.js +47 -0
- package/react-query/userMagiclink.js.map +1 -0
- package/react-query/userPassword.d.ts +24 -0
- package/react-query/userPassword.d.ts.map +1 -0
- package/react-query/userPassword.js +48 -0
- package/react-query/userPassword.js.map +1 -0
- package/react-query/userPasswordResetRequest.d.ts +23 -0
- package/react-query/userPasswordResetRequest.d.ts.map +1 -0
- package/react-query/userPasswordResetRequest.js +47 -0
- package/react-query/userPasswordResetRequest.js.map +1 -0
- package/sdk/user.d.ts +22 -0
- package/sdk/user.d.ts.map +1 -1
- package/sdk/user.js +31 -0
- package/sdk/user.js.map +1 -1
- package/src/funcs/organizationsGetFacility.ts +37 -8
- package/src/funcs/organizationsListOrSearchFacilities.ts +35 -8
- package/src/funcs/userGetCurrentUser.ts +33 -7
- package/src/funcs/userGetUserById.ts +36 -8
- package/src/funcs/userLogsUserIntoTheSystem.ts +36 -8
- package/src/funcs/userMagiclink.ts +162 -0
- package/src/funcs/userPassword.ts +163 -0
- package/src/funcs/userPasswordResetRequest.ts +163 -0
- package/src/funcs/vendorsCreateVendorRegistration.ts +36 -8
- package/src/funcs/vendorsListVendorJobTitles.ts +37 -8
- package/src/lib/config.ts +5 -5
- package/src/lib/files.ts +1 -1
- package/src/lib/sdks.ts +1 -1
- package/src/mcp-server/cli/start/command.ts +67 -0
- package/src/mcp-server/cli/start/impl.ts +123 -0
- package/src/mcp-server/cli.ts +13 -0
- package/src/mcp-server/console-logger.ts +71 -0
- package/src/mcp-server/mcp-server.ts +26 -0
- package/src/mcp-server/resources.ts +96 -0
- package/src/mcp-server/scopes.ts +7 -0
- package/src/mcp-server/server.ts +52 -0
- package/src/mcp-server/shared.ts +75 -0
- package/src/mcp-server/tools/organizationsGetFacility.ts +37 -0
- package/src/mcp-server/tools/organizationsListOrSearchFacilities.ts +52 -0
- package/src/mcp-server/tools/userGetCurrentUser.ts +30 -0
- package/src/mcp-server/tools/userGetUserById.ts +37 -0
- package/src/mcp-server/tools/userLogsUserIntoTheSystem.ts +67 -0
- package/src/mcp-server/tools/userMagiclink.ts +37 -0
- package/src/mcp-server/tools/userPassword.ts +38 -0
- package/src/mcp-server/tools/userPasswordResetRequest.ts +37 -0
- package/src/mcp-server/tools/vendorsCreateVendorRegistration.ts +38 -0
- package/src/mcp-server/tools/vendorsListVendorJobTitles.ts +37 -0
- package/src/mcp-server/tools.ts +116 -0
- package/src/models/operations/index.ts +3 -0
- package/src/models/operations/magiclink.ts +127 -0
- package/src/models/operations/password.ts +140 -0
- package/src/models/operations/passwordresetrequest.ts +131 -0
- package/src/react-query/index.ts +3 -0
- package/src/react-query/userMagiclink.ts +88 -0
- package/src/react-query/userPassword.ts +89 -0
- package/src/react-query/userPasswordResetRequest.ts +89 -0
- package/src/sdk/user.ts +55 -0
- package/src/types/async.ts +68 -0
- package/types/async.d.ts +23 -0
- package/types/async.d.ts.map +1 -0
- package/types/async.js +44 -0
- package/types/async.js.map +1 -0
- package/.devcontainer/README.md +0 -35
- package/docs/sdks/greensecurity/README.md +0 -14
- package/docs/sdks/organizations/README.md +0 -252
- package/docs/sdks/user/README.md +0 -348
- package/docs/sdks/vendors/README.md +0 -219
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import * as errors from "../models/errors/index.js";
|
|
21
21
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
22
22
|
import * as operations from "../models/operations/index.js";
|
|
23
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
23
24
|
import { Result } from "../types/fp.js";
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -58,11 +59,11 @@ import { Result } from "../types/fp.js";
|
|
|
58
59
|
* 4. The `user_token` will be appended as a query string parameter to your `return_url` - you must parse this token and store it
|
|
59
60
|
* 5. Fetch the user object from `/users/me` using the token
|
|
60
61
|
*/
|
|
61
|
-
export
|
|
62
|
+
export function userLogsUserIntoTheSystem(
|
|
62
63
|
client: GreenSecurityCore,
|
|
63
64
|
request: operations.LogsUserIntoTheSystemRequestBody,
|
|
64
65
|
options?: RequestOptions,
|
|
65
|
-
):
|
|
66
|
+
): APIPromise<
|
|
66
67
|
Result<
|
|
67
68
|
operations.LogsUserIntoTheSystemResponse,
|
|
68
69
|
| errors.ApiErrorResponse
|
|
@@ -74,6 +75,33 @@ export async function userLogsUserIntoTheSystem(
|
|
|
74
75
|
| RequestTimeoutError
|
|
75
76
|
| ConnectionError
|
|
76
77
|
>
|
|
78
|
+
> {
|
|
79
|
+
return new APIPromise($do(
|
|
80
|
+
client,
|
|
81
|
+
request,
|
|
82
|
+
options,
|
|
83
|
+
));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
async function $do(
|
|
87
|
+
client: GreenSecurityCore,
|
|
88
|
+
request: operations.LogsUserIntoTheSystemRequestBody,
|
|
89
|
+
options?: RequestOptions,
|
|
90
|
+
): Promise<
|
|
91
|
+
[
|
|
92
|
+
Result<
|
|
93
|
+
operations.LogsUserIntoTheSystemResponse,
|
|
94
|
+
| errors.ApiErrorResponse
|
|
95
|
+
| APIError
|
|
96
|
+
| SDKValidationError
|
|
97
|
+
| UnexpectedClientError
|
|
98
|
+
| InvalidRequestError
|
|
99
|
+
| RequestAbortedError
|
|
100
|
+
| RequestTimeoutError
|
|
101
|
+
| ConnectionError
|
|
102
|
+
>,
|
|
103
|
+
APICall,
|
|
104
|
+
]
|
|
77
105
|
> {
|
|
78
106
|
const parsed = safeParse(
|
|
79
107
|
request,
|
|
@@ -82,7 +110,7 @@ export async function userLogsUserIntoTheSystem(
|
|
|
82
110
|
"Input validation failed",
|
|
83
111
|
);
|
|
84
112
|
if (!parsed.ok) {
|
|
85
|
-
return parsed;
|
|
113
|
+
return [parsed, { status: "invalid" }];
|
|
86
114
|
}
|
|
87
115
|
const payload = parsed.value;
|
|
88
116
|
const body = encodeJSON("body", payload, { explode: true });
|
|
@@ -95,7 +123,7 @@ export async function userLogsUserIntoTheSystem(
|
|
|
95
123
|
}));
|
|
96
124
|
|
|
97
125
|
const context = {
|
|
98
|
-
baseURL: options?.serverURL ?? "",
|
|
126
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
99
127
|
operationID: "logsUserIntoTheSystem",
|
|
100
128
|
oAuth2Scopes: [],
|
|
101
129
|
|
|
@@ -117,7 +145,7 @@ export async function userLogsUserIntoTheSystem(
|
|
|
117
145
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
118
146
|
}, options);
|
|
119
147
|
if (!requestRes.ok) {
|
|
120
|
-
return requestRes;
|
|
148
|
+
return [requestRes, { status: "invalid" }];
|
|
121
149
|
}
|
|
122
150
|
const req = requestRes.value;
|
|
123
151
|
|
|
@@ -128,7 +156,7 @@ export async function userLogsUserIntoTheSystem(
|
|
|
128
156
|
retryCodes: context.retryCodes,
|
|
129
157
|
});
|
|
130
158
|
if (!doResult.ok) {
|
|
131
|
-
return doResult;
|
|
159
|
+
return [doResult, { status: "request-error", request: req }];
|
|
132
160
|
}
|
|
133
161
|
const response = doResult.value;
|
|
134
162
|
|
|
@@ -154,8 +182,8 @@ export async function userLogsUserIntoTheSystem(
|
|
|
154
182
|
M.fail("5XX"),
|
|
155
183
|
)(response, { extraFields: responseFields });
|
|
156
184
|
if (!result.ok) {
|
|
157
|
-
return result;
|
|
185
|
+
return [result, { status: "complete", request: req, response }];
|
|
158
186
|
}
|
|
159
187
|
|
|
160
|
-
return result;
|
|
188
|
+
return [result, { status: "complete", request: req, response }];
|
|
161
189
|
}
|
|
@@ -0,0 +1,162 @@
|
|
|
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 { APIError } from "../models/errors/apierror.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 { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Magic link
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* It sends an email with a magic link to allow the user to log in.
|
|
32
|
+
*/
|
|
33
|
+
export function userMagiclink(
|
|
34
|
+
client: GreenSecurityCore,
|
|
35
|
+
request: operations.MagiclinkRequestBody,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.MagiclinkResponseBody,
|
|
40
|
+
| errors.ApiErrorResponse
|
|
41
|
+
| APIError
|
|
42
|
+
| SDKValidationError
|
|
43
|
+
| UnexpectedClientError
|
|
44
|
+
| InvalidRequestError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| ConnectionError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
request,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: GreenSecurityCore,
|
|
59
|
+
request: operations.MagiclinkRequestBody,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.MagiclinkResponseBody,
|
|
65
|
+
| errors.ApiErrorResponse
|
|
66
|
+
| APIError
|
|
67
|
+
| SDKValidationError
|
|
68
|
+
| UnexpectedClientError
|
|
69
|
+
| InvalidRequestError
|
|
70
|
+
| RequestAbortedError
|
|
71
|
+
| RequestTimeoutError
|
|
72
|
+
| ConnectionError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const parsed = safeParse(
|
|
78
|
+
request,
|
|
79
|
+
(value) => operations.MagiclinkRequestBody$outboundSchema.parse(value),
|
|
80
|
+
"Input validation failed",
|
|
81
|
+
);
|
|
82
|
+
if (!parsed.ok) {
|
|
83
|
+
return [parsed, { status: "invalid" }];
|
|
84
|
+
}
|
|
85
|
+
const payload = parsed.value;
|
|
86
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
87
|
+
|
|
88
|
+
const path = pathToFunc("/users/magiclink")();
|
|
89
|
+
|
|
90
|
+
const headers = new Headers(compactMap({
|
|
91
|
+
"Content-Type": "application/json",
|
|
92
|
+
Accept: "application/json",
|
|
93
|
+
}));
|
|
94
|
+
|
|
95
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
96
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
97
|
+
|
|
98
|
+
const context = {
|
|
99
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
100
|
+
operationID: "magiclink",
|
|
101
|
+
oAuth2Scopes: [],
|
|
102
|
+
|
|
103
|
+
resolvedSecurity: requestSecurity,
|
|
104
|
+
|
|
105
|
+
securitySource: client._options.security,
|
|
106
|
+
retryConfig: options?.retries
|
|
107
|
+
|| client._options.retryConfig
|
|
108
|
+
|| { strategy: "none" },
|
|
109
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const requestRes = client._createRequest(context, {
|
|
113
|
+
security: requestSecurity,
|
|
114
|
+
method: "POST",
|
|
115
|
+
baseURL: options?.serverURL,
|
|
116
|
+
path: path,
|
|
117
|
+
headers: headers,
|
|
118
|
+
body: body,
|
|
119
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
120
|
+
}, options);
|
|
121
|
+
if (!requestRes.ok) {
|
|
122
|
+
return [requestRes, { status: "invalid" }];
|
|
123
|
+
}
|
|
124
|
+
const req = requestRes.value;
|
|
125
|
+
|
|
126
|
+
const doResult = await client._do(req, {
|
|
127
|
+
context,
|
|
128
|
+
errorCodes: ["404", "4XX", "5XX"],
|
|
129
|
+
retryConfig: context.retryConfig,
|
|
130
|
+
retryCodes: context.retryCodes,
|
|
131
|
+
});
|
|
132
|
+
if (!doResult.ok) {
|
|
133
|
+
return [doResult, { status: "request-error", request: req }];
|
|
134
|
+
}
|
|
135
|
+
const response = doResult.value;
|
|
136
|
+
|
|
137
|
+
const responseFields = {
|
|
138
|
+
HttpMeta: { Response: response, Request: req },
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const [result] = await M.match<
|
|
142
|
+
operations.MagiclinkResponseBody,
|
|
143
|
+
| errors.ApiErrorResponse
|
|
144
|
+
| APIError
|
|
145
|
+
| SDKValidationError
|
|
146
|
+
| UnexpectedClientError
|
|
147
|
+
| InvalidRequestError
|
|
148
|
+
| RequestAbortedError
|
|
149
|
+
| RequestTimeoutError
|
|
150
|
+
| ConnectionError
|
|
151
|
+
>(
|
|
152
|
+
M.json(200, operations.MagiclinkResponseBody$inboundSchema),
|
|
153
|
+
M.jsonErr(404, errors.ApiErrorResponse$inboundSchema),
|
|
154
|
+
M.fail("4XX"),
|
|
155
|
+
M.fail("5XX"),
|
|
156
|
+
)(response, { extraFields: responseFields });
|
|
157
|
+
if (!result.ok) {
|
|
158
|
+
return [result, { status: "complete", request: req, response }];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return [result, { status: "complete", request: req, response }];
|
|
162
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { APIError } from "../models/errors/apierror.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 { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Password reset
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Resets the a user's password using a password_reset_id that was sent to them via email.
|
|
32
|
+
* See /users/passwordresetrequest to initiate a password reset flow.
|
|
33
|
+
*/
|
|
34
|
+
export function userPassword(
|
|
35
|
+
client: GreenSecurityCore,
|
|
36
|
+
request: operations.PasswordRequestBody,
|
|
37
|
+
options?: RequestOptions,
|
|
38
|
+
): APIPromise<
|
|
39
|
+
Result<
|
|
40
|
+
operations.PasswordResponseBody,
|
|
41
|
+
| errors.ApiErrorResponse
|
|
42
|
+
| APIError
|
|
43
|
+
| SDKValidationError
|
|
44
|
+
| UnexpectedClientError
|
|
45
|
+
| InvalidRequestError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| ConnectionError
|
|
49
|
+
>
|
|
50
|
+
> {
|
|
51
|
+
return new APIPromise($do(
|
|
52
|
+
client,
|
|
53
|
+
request,
|
|
54
|
+
options,
|
|
55
|
+
));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function $do(
|
|
59
|
+
client: GreenSecurityCore,
|
|
60
|
+
request: operations.PasswordRequestBody,
|
|
61
|
+
options?: RequestOptions,
|
|
62
|
+
): Promise<
|
|
63
|
+
[
|
|
64
|
+
Result<
|
|
65
|
+
operations.PasswordResponseBody,
|
|
66
|
+
| errors.ApiErrorResponse
|
|
67
|
+
| APIError
|
|
68
|
+
| SDKValidationError
|
|
69
|
+
| UnexpectedClientError
|
|
70
|
+
| InvalidRequestError
|
|
71
|
+
| RequestAbortedError
|
|
72
|
+
| RequestTimeoutError
|
|
73
|
+
| ConnectionError
|
|
74
|
+
>,
|
|
75
|
+
APICall,
|
|
76
|
+
]
|
|
77
|
+
> {
|
|
78
|
+
const parsed = safeParse(
|
|
79
|
+
request,
|
|
80
|
+
(value) => operations.PasswordRequestBody$outboundSchema.parse(value),
|
|
81
|
+
"Input validation failed",
|
|
82
|
+
);
|
|
83
|
+
if (!parsed.ok) {
|
|
84
|
+
return [parsed, { status: "invalid" }];
|
|
85
|
+
}
|
|
86
|
+
const payload = parsed.value;
|
|
87
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
88
|
+
|
|
89
|
+
const path = pathToFunc("/users/password")();
|
|
90
|
+
|
|
91
|
+
const headers = new Headers(compactMap({
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
Accept: "application/json",
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
97
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
98
|
+
|
|
99
|
+
const context = {
|
|
100
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
101
|
+
operationID: "password",
|
|
102
|
+
oAuth2Scopes: [],
|
|
103
|
+
|
|
104
|
+
resolvedSecurity: requestSecurity,
|
|
105
|
+
|
|
106
|
+
securitySource: client._options.security,
|
|
107
|
+
retryConfig: options?.retries
|
|
108
|
+
|| client._options.retryConfig
|
|
109
|
+
|| { strategy: "none" },
|
|
110
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const requestRes = client._createRequest(context, {
|
|
114
|
+
security: requestSecurity,
|
|
115
|
+
method: "POST",
|
|
116
|
+
baseURL: options?.serverURL,
|
|
117
|
+
path: path,
|
|
118
|
+
headers: headers,
|
|
119
|
+
body: body,
|
|
120
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
121
|
+
}, options);
|
|
122
|
+
if (!requestRes.ok) {
|
|
123
|
+
return [requestRes, { status: "invalid" }];
|
|
124
|
+
}
|
|
125
|
+
const req = requestRes.value;
|
|
126
|
+
|
|
127
|
+
const doResult = await client._do(req, {
|
|
128
|
+
context,
|
|
129
|
+
errorCodes: ["404", "4XX", "5XX"],
|
|
130
|
+
retryConfig: context.retryConfig,
|
|
131
|
+
retryCodes: context.retryCodes,
|
|
132
|
+
});
|
|
133
|
+
if (!doResult.ok) {
|
|
134
|
+
return [doResult, { status: "request-error", request: req }];
|
|
135
|
+
}
|
|
136
|
+
const response = doResult.value;
|
|
137
|
+
|
|
138
|
+
const responseFields = {
|
|
139
|
+
HttpMeta: { Response: response, Request: req },
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const [result] = await M.match<
|
|
143
|
+
operations.PasswordResponseBody,
|
|
144
|
+
| errors.ApiErrorResponse
|
|
145
|
+
| APIError
|
|
146
|
+
| SDKValidationError
|
|
147
|
+
| UnexpectedClientError
|
|
148
|
+
| InvalidRequestError
|
|
149
|
+
| RequestAbortedError
|
|
150
|
+
| RequestTimeoutError
|
|
151
|
+
| ConnectionError
|
|
152
|
+
>(
|
|
153
|
+
M.json(200, operations.PasswordResponseBody$inboundSchema),
|
|
154
|
+
M.jsonErr(404, errors.ApiErrorResponse$inboundSchema),
|
|
155
|
+
M.fail("4XX"),
|
|
156
|
+
M.fail("5XX"),
|
|
157
|
+
)(response, { extraFields: responseFields });
|
|
158
|
+
if (!result.ok) {
|
|
159
|
+
return [result, { status: "complete", request: req, response }];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return [result, { status: "complete", request: req, response }];
|
|
163
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
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 { APIError } from "../models/errors/apierror.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 { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
23
|
+
import * as operations from "../models/operations/index.js";
|
|
24
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
25
|
+
import { Result } from "../types/fp.js";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Password reset request
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* It sends an email with a link for resetting a user's password.
|
|
32
|
+
*/
|
|
33
|
+
export function userPasswordResetRequest(
|
|
34
|
+
client: GreenSecurityCore,
|
|
35
|
+
request: operations.PasswordResetRequestRequestBody,
|
|
36
|
+
options?: RequestOptions,
|
|
37
|
+
): APIPromise<
|
|
38
|
+
Result<
|
|
39
|
+
operations.PasswordResetRequestResponseBody,
|
|
40
|
+
| errors.ApiErrorResponse
|
|
41
|
+
| APIError
|
|
42
|
+
| SDKValidationError
|
|
43
|
+
| UnexpectedClientError
|
|
44
|
+
| InvalidRequestError
|
|
45
|
+
| RequestAbortedError
|
|
46
|
+
| RequestTimeoutError
|
|
47
|
+
| ConnectionError
|
|
48
|
+
>
|
|
49
|
+
> {
|
|
50
|
+
return new APIPromise($do(
|
|
51
|
+
client,
|
|
52
|
+
request,
|
|
53
|
+
options,
|
|
54
|
+
));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function $do(
|
|
58
|
+
client: GreenSecurityCore,
|
|
59
|
+
request: operations.PasswordResetRequestRequestBody,
|
|
60
|
+
options?: RequestOptions,
|
|
61
|
+
): Promise<
|
|
62
|
+
[
|
|
63
|
+
Result<
|
|
64
|
+
operations.PasswordResetRequestResponseBody,
|
|
65
|
+
| errors.ApiErrorResponse
|
|
66
|
+
| APIError
|
|
67
|
+
| SDKValidationError
|
|
68
|
+
| UnexpectedClientError
|
|
69
|
+
| InvalidRequestError
|
|
70
|
+
| RequestAbortedError
|
|
71
|
+
| RequestTimeoutError
|
|
72
|
+
| ConnectionError
|
|
73
|
+
>,
|
|
74
|
+
APICall,
|
|
75
|
+
]
|
|
76
|
+
> {
|
|
77
|
+
const parsed = safeParse(
|
|
78
|
+
request,
|
|
79
|
+
(value) =>
|
|
80
|
+
operations.PasswordResetRequestRequestBody$outboundSchema.parse(value),
|
|
81
|
+
"Input validation failed",
|
|
82
|
+
);
|
|
83
|
+
if (!parsed.ok) {
|
|
84
|
+
return [parsed, { status: "invalid" }];
|
|
85
|
+
}
|
|
86
|
+
const payload = parsed.value;
|
|
87
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
88
|
+
|
|
89
|
+
const path = pathToFunc("/users/passwordresetrequest")();
|
|
90
|
+
|
|
91
|
+
const headers = new Headers(compactMap({
|
|
92
|
+
"Content-Type": "application/json",
|
|
93
|
+
Accept: "application/json",
|
|
94
|
+
}));
|
|
95
|
+
|
|
96
|
+
const securityInput = await extractSecurity(client._options.security);
|
|
97
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
98
|
+
|
|
99
|
+
const context = {
|
|
100
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
101
|
+
operationID: "passwordResetRequest",
|
|
102
|
+
oAuth2Scopes: [],
|
|
103
|
+
|
|
104
|
+
resolvedSecurity: requestSecurity,
|
|
105
|
+
|
|
106
|
+
securitySource: client._options.security,
|
|
107
|
+
retryConfig: options?.retries
|
|
108
|
+
|| client._options.retryConfig
|
|
109
|
+
|| { strategy: "none" },
|
|
110
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const requestRes = client._createRequest(context, {
|
|
114
|
+
security: requestSecurity,
|
|
115
|
+
method: "POST",
|
|
116
|
+
baseURL: options?.serverURL,
|
|
117
|
+
path: path,
|
|
118
|
+
headers: headers,
|
|
119
|
+
body: body,
|
|
120
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
121
|
+
}, options);
|
|
122
|
+
if (!requestRes.ok) {
|
|
123
|
+
return [requestRes, { status: "invalid" }];
|
|
124
|
+
}
|
|
125
|
+
const req = requestRes.value;
|
|
126
|
+
|
|
127
|
+
const doResult = await client._do(req, {
|
|
128
|
+
context,
|
|
129
|
+
errorCodes: ["404", "4XX", "5XX"],
|
|
130
|
+
retryConfig: context.retryConfig,
|
|
131
|
+
retryCodes: context.retryCodes,
|
|
132
|
+
});
|
|
133
|
+
if (!doResult.ok) {
|
|
134
|
+
return [doResult, { status: "request-error", request: req }];
|
|
135
|
+
}
|
|
136
|
+
const response = doResult.value;
|
|
137
|
+
|
|
138
|
+
const responseFields = {
|
|
139
|
+
HttpMeta: { Response: response, Request: req },
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const [result] = await M.match<
|
|
143
|
+
operations.PasswordResetRequestResponseBody,
|
|
144
|
+
| errors.ApiErrorResponse
|
|
145
|
+
| APIError
|
|
146
|
+
| SDKValidationError
|
|
147
|
+
| UnexpectedClientError
|
|
148
|
+
| InvalidRequestError
|
|
149
|
+
| RequestAbortedError
|
|
150
|
+
| RequestTimeoutError
|
|
151
|
+
| ConnectionError
|
|
152
|
+
>(
|
|
153
|
+
M.json(200, operations.PasswordResetRequestResponseBody$inboundSchema),
|
|
154
|
+
M.jsonErr(404, errors.ApiErrorResponse$inboundSchema),
|
|
155
|
+
M.fail("4XX"),
|
|
156
|
+
M.fail("5XX"),
|
|
157
|
+
)(response, { extraFields: responseFields });
|
|
158
|
+
if (!result.ok) {
|
|
159
|
+
return [result, { status: "complete", request: req, response }];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return [result, { status: "complete", request: req, response }];
|
|
163
|
+
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
import * as errors from "../models/errors/index.js";
|
|
21
21
|
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
22
22
|
import * as operations from "../models/operations/index.js";
|
|
23
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
23
24
|
import { Result } from "../types/fp.js";
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -28,11 +29,11 @@ import { Result } from "../types/fp.js";
|
|
|
28
29
|
* @remarks
|
|
29
30
|
* Create an initial vendor registration. Once successful, the vendor will be able to continue to filling out the rest of their onboarding profile.
|
|
30
31
|
*/
|
|
31
|
-
export
|
|
32
|
+
export function vendorsCreateVendorRegistration(
|
|
32
33
|
client: GreenSecurityCore,
|
|
33
34
|
request: operations.CreateVendorRegistrationRequestBody,
|
|
34
35
|
options?: RequestOptions,
|
|
35
|
-
):
|
|
36
|
+
): APIPromise<
|
|
36
37
|
Result<
|
|
37
38
|
operations.CreateVendorRegistrationResponseBody,
|
|
38
39
|
| errors.ApiErrorResponse
|
|
@@ -44,6 +45,33 @@ export async function vendorsCreateVendorRegistration(
|
|
|
44
45
|
| RequestTimeoutError
|
|
45
46
|
| ConnectionError
|
|
46
47
|
>
|
|
48
|
+
> {
|
|
49
|
+
return new APIPromise($do(
|
|
50
|
+
client,
|
|
51
|
+
request,
|
|
52
|
+
options,
|
|
53
|
+
));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async function $do(
|
|
57
|
+
client: GreenSecurityCore,
|
|
58
|
+
request: operations.CreateVendorRegistrationRequestBody,
|
|
59
|
+
options?: RequestOptions,
|
|
60
|
+
): Promise<
|
|
61
|
+
[
|
|
62
|
+
Result<
|
|
63
|
+
operations.CreateVendorRegistrationResponseBody,
|
|
64
|
+
| errors.ApiErrorResponse
|
|
65
|
+
| APIError
|
|
66
|
+
| SDKValidationError
|
|
67
|
+
| UnexpectedClientError
|
|
68
|
+
| InvalidRequestError
|
|
69
|
+
| RequestAbortedError
|
|
70
|
+
| RequestTimeoutError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
>,
|
|
73
|
+
APICall,
|
|
74
|
+
]
|
|
47
75
|
> {
|
|
48
76
|
const parsed = safeParse(
|
|
49
77
|
request,
|
|
@@ -54,7 +82,7 @@ export async function vendorsCreateVendorRegistration(
|
|
|
54
82
|
"Input validation failed",
|
|
55
83
|
);
|
|
56
84
|
if (!parsed.ok) {
|
|
57
|
-
return parsed;
|
|
85
|
+
return [parsed, { status: "invalid" }];
|
|
58
86
|
}
|
|
59
87
|
const payload = parsed.value;
|
|
60
88
|
const body = encodeJSON("body", payload, { explode: true });
|
|
@@ -67,7 +95,7 @@ export async function vendorsCreateVendorRegistration(
|
|
|
67
95
|
}));
|
|
68
96
|
|
|
69
97
|
const context = {
|
|
70
|
-
baseURL: options?.serverURL ?? "",
|
|
98
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
71
99
|
operationID: "createVendorRegistration",
|
|
72
100
|
oAuth2Scopes: [],
|
|
73
101
|
|
|
@@ -89,7 +117,7 @@ export async function vendorsCreateVendorRegistration(
|
|
|
89
117
|
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
90
118
|
}, options);
|
|
91
119
|
if (!requestRes.ok) {
|
|
92
|
-
return requestRes;
|
|
120
|
+
return [requestRes, { status: "invalid" }];
|
|
93
121
|
}
|
|
94
122
|
const req = requestRes.value;
|
|
95
123
|
|
|
@@ -100,7 +128,7 @@ export async function vendorsCreateVendorRegistration(
|
|
|
100
128
|
retryCodes: context.retryCodes,
|
|
101
129
|
});
|
|
102
130
|
if (!doResult.ok) {
|
|
103
|
-
return doResult;
|
|
131
|
+
return [doResult, { status: "request-error", request: req }];
|
|
104
132
|
}
|
|
105
133
|
const response = doResult.value;
|
|
106
134
|
|
|
@@ -125,8 +153,8 @@ export async function vendorsCreateVendorRegistration(
|
|
|
125
153
|
M.fail("5XX"),
|
|
126
154
|
)(response, { extraFields: responseFields });
|
|
127
155
|
if (!result.ok) {
|
|
128
|
-
return result;
|
|
156
|
+
return [result, { status: "complete", request: req, response }];
|
|
129
157
|
}
|
|
130
158
|
|
|
131
|
-
return result;
|
|
159
|
+
return [result, { status: "complete", request: req, response }];
|
|
132
160
|
}
|