@greensecurity/javascript-sdk 0.45.0-beta.11 → 0.45.0-beta.13
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 +1 -4
- package/dist/commonjs/__tests__/lookups.test.js +0 -21
- package/dist/commonjs/__tests__/lookups.test.js.map +1 -1
- package/dist/commonjs/__tests__/vendors.test.js +1 -1
- package/dist/commonjs/__tests__/vendors.test.js.map +1 -1
- package/dist/commonjs/__tests__/webhooks.test.js +5 -6
- package/dist/commonjs/__tests__/webhooks.test.js.map +1 -1
- package/dist/commonjs/__tests__/zones.test.js +5 -11
- package/dist/commonjs/__tests__/zones.test.js.map +1 -1
- package/dist/commonjs/funcs/usersUpdateUser.d.ts +0 -6
- package/dist/commonjs/funcs/usersUpdateUser.d.ts.map +1 -1
- package/dist/commonjs/funcs/usersUpdateUser.js +0 -6
- package/dist/commonjs/funcs/usersUpdateUser.js.map +1 -1
- package/dist/commonjs/funcs/vendorsCreateVendor.d.ts +0 -4
- package/dist/commonjs/funcs/vendorsCreateVendor.d.ts.map +1 -1
- package/dist/commonjs/funcs/vendorsCreateVendor.js +0 -4
- package/dist/commonjs/funcs/vendorsCreateVendor.js.map +1 -1
- package/dist/commonjs/funcs/vendorsUpdateVendorDetails.d.ts +1 -9
- package/dist/commonjs/funcs/vendorsUpdateVendorDetails.d.ts.map +1 -1
- package/dist/commonjs/funcs/vendorsUpdateVendorDetails.js +1 -9
- package/dist/commonjs/funcs/vendorsUpdateVendorDetails.js.map +1 -1
- package/dist/commonjs/index.extras.d.ts +0 -6
- package/dist/commonjs/index.extras.d.ts.map +1 -1
- package/dist/commonjs/index.extras.js +0 -6
- package/dist/commonjs/index.extras.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +4 -4
- package/dist/commonjs/lib/config.js +4 -4
- package/dist/commonjs/models/operations/createvendorcompany.d.ts +1 -7
- package/dist/commonjs/models/operations/createvendorcompany.d.ts.map +1 -1
- package/dist/commonjs/models/operations/createvendorcompany.js.map +1 -1
- package/dist/commonjs/models/operations/index.d.ts +0 -1
- package/dist/commonjs/models/operations/index.d.ts.map +1 -1
- package/dist/commonjs/models/operations/index.js +0 -1
- package/dist/commonjs/models/operations/index.js.map +1 -1
- package/dist/commonjs/react-query/index.d.ts +0 -1
- package/dist/commonjs/react-query/index.d.ts.map +1 -1
- package/dist/commonjs/react-query/index.js +0 -1
- package/dist/commonjs/react-query/index.js.map +1 -1
- package/dist/commonjs/react-query/usersUpdateUser.d.ts +0 -6
- package/dist/commonjs/react-query/usersUpdateUser.d.ts.map +1 -1
- package/dist/commonjs/react-query/usersUpdateUser.js +0 -6
- package/dist/commonjs/react-query/usersUpdateUser.js.map +1 -1
- package/dist/commonjs/react-query/vendorsCreateVendor.d.ts +0 -4
- package/dist/commonjs/react-query/vendorsCreateVendor.d.ts.map +1 -1
- package/dist/commonjs/react-query/vendorsCreateVendor.js +0 -4
- package/dist/commonjs/react-query/vendorsCreateVendor.js.map +1 -1
- package/dist/commonjs/react-query/vendorsUpdateVendorDetails.d.ts +1 -9
- package/dist/commonjs/react-query/vendorsUpdateVendorDetails.d.ts.map +1 -1
- package/dist/commonjs/react-query/vendorsUpdateVendorDetails.js +1 -9
- package/dist/commonjs/react-query/vendorsUpdateVendorDetails.js.map +1 -1
- package/dist/commonjs/sdk/lookups.d.ts +0 -22
- package/dist/commonjs/sdk/lookups.d.ts.map +1 -1
- package/dist/commonjs/sdk/lookups.js +0 -25
- package/dist/commonjs/sdk/lookups.js.map +1 -1
- package/dist/commonjs/sdk/users.d.ts +0 -6
- package/dist/commonjs/sdk/users.d.ts.map +1 -1
- package/dist/commonjs/sdk/users.js +0 -6
- package/dist/commonjs/sdk/users.js.map +1 -1
- package/dist/commonjs/sdk/vendors.d.ts +1 -13
- package/dist/commonjs/sdk/vendors.d.ts.map +1 -1
- package/dist/commonjs/sdk/vendors.js +1 -13
- package/dist/commonjs/sdk/vendors.js.map +1 -1
- package/dist/esm/__tests__/lookups.test.js +0 -21
- package/dist/esm/__tests__/lookups.test.js.map +1 -1
- package/dist/esm/__tests__/vendors.test.js +1 -1
- package/dist/esm/__tests__/vendors.test.js.map +1 -1
- package/dist/esm/__tests__/webhooks.test.js +5 -6
- package/dist/esm/__tests__/webhooks.test.js.map +1 -1
- package/dist/esm/__tests__/zones.test.js +5 -11
- package/dist/esm/__tests__/zones.test.js.map +1 -1
- package/dist/esm/funcs/usersUpdateUser.d.ts +0 -6
- package/dist/esm/funcs/usersUpdateUser.d.ts.map +1 -1
- package/dist/esm/funcs/usersUpdateUser.js +0 -6
- package/dist/esm/funcs/usersUpdateUser.js.map +1 -1
- package/dist/esm/funcs/vendorsCreateVendor.d.ts +0 -4
- package/dist/esm/funcs/vendorsCreateVendor.d.ts.map +1 -1
- package/dist/esm/funcs/vendorsCreateVendor.js +0 -4
- package/dist/esm/funcs/vendorsCreateVendor.js.map +1 -1
- package/dist/esm/funcs/vendorsUpdateVendorDetails.d.ts +1 -9
- package/dist/esm/funcs/vendorsUpdateVendorDetails.d.ts.map +1 -1
- package/dist/esm/funcs/vendorsUpdateVendorDetails.js +1 -9
- package/dist/esm/funcs/vendorsUpdateVendorDetails.js.map +1 -1
- package/dist/esm/index.extras.d.ts +0 -6
- package/dist/esm/index.extras.d.ts.map +1 -1
- package/dist/esm/index.extras.js +0 -6
- package/dist/esm/index.extras.js.map +1 -1
- package/dist/esm/lib/config.d.ts +4 -4
- package/dist/esm/lib/config.js +4 -4
- package/dist/esm/models/operations/createvendorcompany.d.ts +1 -7
- package/dist/esm/models/operations/createvendorcompany.d.ts.map +1 -1
- package/dist/esm/models/operations/createvendorcompany.js.map +1 -1
- package/dist/esm/models/operations/index.d.ts +0 -1
- package/dist/esm/models/operations/index.d.ts.map +1 -1
- package/dist/esm/models/operations/index.js +0 -1
- package/dist/esm/models/operations/index.js.map +1 -1
- package/dist/esm/react-query/index.d.ts +0 -1
- package/dist/esm/react-query/index.d.ts.map +1 -1
- package/dist/esm/react-query/index.js +0 -1
- package/dist/esm/react-query/index.js.map +1 -1
- package/dist/esm/react-query/usersUpdateUser.d.ts +0 -6
- package/dist/esm/react-query/usersUpdateUser.d.ts.map +1 -1
- package/dist/esm/react-query/usersUpdateUser.js +0 -6
- package/dist/esm/react-query/usersUpdateUser.js.map +1 -1
- package/dist/esm/react-query/vendorsCreateVendor.d.ts +0 -4
- package/dist/esm/react-query/vendorsCreateVendor.d.ts.map +1 -1
- package/dist/esm/react-query/vendorsCreateVendor.js +0 -4
- package/dist/esm/react-query/vendorsCreateVendor.js.map +1 -1
- package/dist/esm/react-query/vendorsUpdateVendorDetails.d.ts +1 -9
- package/dist/esm/react-query/vendorsUpdateVendorDetails.d.ts.map +1 -1
- package/dist/esm/react-query/vendorsUpdateVendorDetails.js +1 -9
- package/dist/esm/react-query/vendorsUpdateVendorDetails.js.map +1 -1
- package/dist/esm/sdk/lookups.d.ts +0 -22
- package/dist/esm/sdk/lookups.d.ts.map +1 -1
- package/dist/esm/sdk/lookups.js +0 -25
- package/dist/esm/sdk/lookups.js.map +1 -1
- package/dist/esm/sdk/users.d.ts +0 -6
- package/dist/esm/sdk/users.d.ts.map +1 -1
- package/dist/esm/sdk/users.js +0 -6
- package/dist/esm/sdk/users.js.map +1 -1
- package/dist/esm/sdk/vendors.d.ts +1 -13
- package/dist/esm/sdk/vendors.d.ts.map +1 -1
- package/dist/esm/sdk/vendors.js +1 -13
- package/dist/esm/sdk/vendors.js.map +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/__tests__/lookups.test.ts +0 -24
- package/src/__tests__/vendors.test.ts +1 -1
- package/src/__tests__/webhooks.test.ts +5 -6
- package/src/__tests__/zones.test.ts +5 -11
- package/src/funcs/usersUpdateUser.ts +0 -6
- package/src/funcs/vendorsCreateVendor.ts +0 -4
- package/src/funcs/vendorsUpdateVendorDetails.ts +1 -9
- package/src/index.extras.ts +0 -8
- package/src/lib/config.ts +4 -4
- package/src/models/operations/createvendorcompany.ts +1 -7
- package/src/models/operations/index.ts +0 -1
- package/src/react-query/index.ts +0 -1
- package/src/react-query/usersUpdateUser.ts +0 -6
- package/src/react-query/vendorsCreateVendor.ts +0 -4
- package/src/react-query/vendorsUpdateVendorDetails.ts +1 -9
- package/src/sdk/lookups.ts +0 -33
- package/src/sdk/users.ts +0 -6
- package/src/sdk/vendors.ts +1 -13
- package/dist/commonjs/admin-funcs/dismissCommunication.d.ts +0 -3
- package/dist/commonjs/admin-funcs/dismissCommunication.d.ts.map +0 -1
- package/dist/commonjs/admin-funcs/dismissCommunication.js +0 -20
- package/dist/commonjs/admin-funcs/dismissCommunication.js.map +0 -1
- package/dist/commonjs/admin-funcs/listCommunications.d.ts +0 -3
- package/dist/commonjs/admin-funcs/listCommunications.d.ts.map +0 -1
- package/dist/commonjs/admin-funcs/listCommunications.js +0 -25
- package/dist/commonjs/admin-funcs/listCommunications.js.map +0 -1
- package/dist/commonjs/funcs/lookupsLookupPostalCode.d.ts +0 -35
- package/dist/commonjs/funcs/lookupsLookupPostalCode.d.ts.map +0 -1
- package/dist/commonjs/funcs/lookupsLookupPostalCode.js +0 -140
- package/dist/commonjs/funcs/lookupsLookupPostalCode.js.map +0 -1
- package/dist/commonjs/models/operations/lookuppostalcode.d.ts +0 -59
- package/dist/commonjs/models/operations/lookuppostalcode.d.ts.map +0 -1
- package/dist/commonjs/models/operations/lookuppostalcode.js +0 -81
- package/dist/commonjs/models/operations/lookuppostalcode.js.map +0 -1
- package/dist/commonjs/react-query/lookupsLookupPostalCode.core.d.ts +0 -16
- package/dist/commonjs/react-query/lookupsLookupPostalCode.core.d.ts.map +0 -1
- package/dist/commonjs/react-query/lookupsLookupPostalCode.core.js +0 -43
- package/dist/commonjs/react-query/lookupsLookupPostalCode.core.js.map +0 -1
- package/dist/commonjs/react-query/lookupsLookupPostalCode.d.ts +0 -71
- package/dist/commonjs/react-query/lookupsLookupPostalCode.d.ts.map +0 -1
- package/dist/commonjs/react-query/lookupsLookupPostalCode.js +0 -95
- package/dist/commonjs/react-query/lookupsLookupPostalCode.js.map +0 -1
- package/dist/esm/admin-funcs/dismissCommunication.d.ts +0 -3
- package/dist/esm/admin-funcs/dismissCommunication.d.ts.map +0 -1
- package/dist/esm/admin-funcs/dismissCommunication.js +0 -17
- package/dist/esm/admin-funcs/dismissCommunication.js.map +0 -1
- package/dist/esm/admin-funcs/listCommunications.d.ts +0 -3
- package/dist/esm/admin-funcs/listCommunications.d.ts.map +0 -1
- package/dist/esm/admin-funcs/listCommunications.js +0 -22
- package/dist/esm/admin-funcs/listCommunications.js.map +0 -1
- package/dist/esm/funcs/lookupsLookupPostalCode.d.ts +0 -35
- package/dist/esm/funcs/lookupsLookupPostalCode.d.ts.map +0 -1
- package/dist/esm/funcs/lookupsLookupPostalCode.js +0 -104
- package/dist/esm/funcs/lookupsLookupPostalCode.js.map +0 -1
- package/dist/esm/models/operations/lookuppostalcode.d.ts +0 -59
- package/dist/esm/models/operations/lookuppostalcode.d.ts.map +0 -1
- package/dist/esm/models/operations/lookuppostalcode.js +0 -43
- package/dist/esm/models/operations/lookuppostalcode.js.map +0 -1
- package/dist/esm/react-query/lookupsLookupPostalCode.core.d.ts +0 -16
- package/dist/esm/react-query/lookupsLookupPostalCode.core.d.ts.map +0 -1
- package/dist/esm/react-query/lookupsLookupPostalCode.core.js +0 -38
- package/dist/esm/react-query/lookupsLookupPostalCode.core.js.map +0 -1
- package/dist/esm/react-query/lookupsLookupPostalCode.d.ts +0 -71
- package/dist/esm/react-query/lookupsLookupPostalCode.d.ts.map +0 -1
- package/dist/esm/react-query/lookupsLookupPostalCode.js +0 -85
- package/dist/esm/react-query/lookupsLookupPostalCode.js.map +0 -1
- package/src/admin-funcs/dismissCommunication.ts +0 -20
- package/src/admin-funcs/listCommunications.ts +0 -29
- package/src/funcs/lookupsLookupPostalCode.ts +0 -193
- package/src/models/operations/lookuppostalcode.ts +0 -118
- package/src/react-query/lookupsLookupPostalCode.core.ts +0 -82
- package/src/react-query/lookupsLookupPostalCode.ts +0 -177
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import { GreenSecurityCore } from "../core.js";
|
|
6
|
-
import { encodeFormQuery } from "../lib/encodings.js";
|
|
7
|
-
import { matchStatusCode } from "../lib/http.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
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Check a postal code against a state and country
|
|
31
|
-
*
|
|
32
|
-
* @remarks
|
|
33
|
-
* Cross-checks a postal code against a state/province and country, the same check
|
|
34
|
-
* every write path that stores a US or Canadian address enforces server-side (e.g.
|
|
35
|
-
* `PUT /users/{id}`, `PUT /vendors/{vendor_id_or_me}`). Useful for validating an
|
|
36
|
-
* address before submitting it elsewhere.
|
|
37
|
-
*
|
|
38
|
-
* `status` is one of:
|
|
39
|
-
* - `ok` — the postal code belongs to the given state/province.
|
|
40
|
-
* - `invalid` — the postal code is not shaped like a real one for the given country.
|
|
41
|
-
* - `mismatch` — the postal code is well-formed but belongs to a different state or
|
|
42
|
-
* province. `expected_states` names the state(s) it actually maps to.
|
|
43
|
-
* - `unknown` — nothing to check against (an unsupported country, or a postal code
|
|
44
|
-
* absent from the US ZIP dataset). Treated as acceptable by every write path that
|
|
45
|
-
* uses this check.
|
|
46
|
-
*
|
|
47
|
-
* Only the US and Canada have a real code-to-subdivision map; every other country
|
|
48
|
-
* always returns `unknown`.
|
|
49
|
-
*
|
|
50
|
-
* If set, this operation will use {@link Security.bearerJwt} from the global security.
|
|
51
|
-
*/
|
|
52
|
-
export function lookupsLookupPostalCode(
|
|
53
|
-
client: GreenSecurityCore,
|
|
54
|
-
request: operations.LookupPostalCodeRequest,
|
|
55
|
-
options?: RequestOptions,
|
|
56
|
-
): APIPromise<
|
|
57
|
-
Result<
|
|
58
|
-
operations.LookupPostalCodeLookupPostalCodeOk,
|
|
59
|
-
| errors.ApiErrorResponse
|
|
60
|
-
| GreenSecurityError
|
|
61
|
-
| ResponseValidationError
|
|
62
|
-
| ConnectionError
|
|
63
|
-
| RequestAbortedError
|
|
64
|
-
| RequestTimeoutError
|
|
65
|
-
| InvalidRequestError
|
|
66
|
-
| UnexpectedClientError
|
|
67
|
-
| SDKValidationError
|
|
68
|
-
>
|
|
69
|
-
> {
|
|
70
|
-
return new APIPromise($do(
|
|
71
|
-
client,
|
|
72
|
-
request,
|
|
73
|
-
options,
|
|
74
|
-
));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
async function $do(
|
|
78
|
-
client: GreenSecurityCore,
|
|
79
|
-
request: operations.LookupPostalCodeRequest,
|
|
80
|
-
options?: RequestOptions,
|
|
81
|
-
): Promise<
|
|
82
|
-
[
|
|
83
|
-
Result<
|
|
84
|
-
operations.LookupPostalCodeLookupPostalCodeOk,
|
|
85
|
-
| errors.ApiErrorResponse
|
|
86
|
-
| GreenSecurityError
|
|
87
|
-
| ResponseValidationError
|
|
88
|
-
| ConnectionError
|
|
89
|
-
| RequestAbortedError
|
|
90
|
-
| RequestTimeoutError
|
|
91
|
-
| InvalidRequestError
|
|
92
|
-
| UnexpectedClientError
|
|
93
|
-
| SDKValidationError
|
|
94
|
-
>,
|
|
95
|
-
APICall,
|
|
96
|
-
]
|
|
97
|
-
> {
|
|
98
|
-
const parsed = safeParse(
|
|
99
|
-
request,
|
|
100
|
-
(value) => operations.LookupPostalCodeRequest$outboundSchema.parse(value),
|
|
101
|
-
"Input validation failed",
|
|
102
|
-
);
|
|
103
|
-
if (!parsed.ok) {
|
|
104
|
-
return [parsed, { status: "invalid" }];
|
|
105
|
-
}
|
|
106
|
-
const payload = parsed.value;
|
|
107
|
-
const body = null;
|
|
108
|
-
|
|
109
|
-
const path = pathToFunc("/lookups/postal-code")();
|
|
110
|
-
|
|
111
|
-
const query = encodeFormQuery({
|
|
112
|
-
"country": payload.country,
|
|
113
|
-
"postal_code": payload.postal_code,
|
|
114
|
-
"state": payload.state,
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const headers = new Headers(compactMap({
|
|
118
|
-
Accept: "application/json",
|
|
119
|
-
}));
|
|
120
|
-
|
|
121
|
-
const securityInput = await extractSecurity(client._options.security);
|
|
122
|
-
const requestSecurity = resolveGlobalSecurity(securityInput, [1]);
|
|
123
|
-
|
|
124
|
-
const context = {
|
|
125
|
-
options: client._options,
|
|
126
|
-
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
127
|
-
operationID: "lookupPostalCode",
|
|
128
|
-
oAuth2Scopes: null,
|
|
129
|
-
|
|
130
|
-
resolvedSecurity: requestSecurity,
|
|
131
|
-
|
|
132
|
-
securitySource: client._options.security,
|
|
133
|
-
retryConfig: options?.retries
|
|
134
|
-
|| client._options.retryConfig
|
|
135
|
-
|| { strategy: "none" },
|
|
136
|
-
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const requestRes = client._createRequest(context, {
|
|
140
|
-
security: requestSecurity,
|
|
141
|
-
method: "GET",
|
|
142
|
-
baseURL: options?.serverURL,
|
|
143
|
-
path: path,
|
|
144
|
-
headers: headers,
|
|
145
|
-
query: query,
|
|
146
|
-
body: body,
|
|
147
|
-
userAgent: client._options.userAgent,
|
|
148
|
-
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
149
|
-
}, options);
|
|
150
|
-
if (!requestRes.ok) {
|
|
151
|
-
return [requestRes, { status: "invalid" }];
|
|
152
|
-
}
|
|
153
|
-
const req = requestRes.value;
|
|
154
|
-
|
|
155
|
-
const doResult = await client._do(req, {
|
|
156
|
-
context,
|
|
157
|
-
isErrorStatusCode: (statusCode: number) =>
|
|
158
|
-
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
159
|
-
retryConfig: context.retryConfig,
|
|
160
|
-
retryCodes: context.retryCodes,
|
|
161
|
-
});
|
|
162
|
-
if (!doResult.ok) {
|
|
163
|
-
return [doResult, { status: "request-error", request: req }];
|
|
164
|
-
}
|
|
165
|
-
const response = doResult.value;
|
|
166
|
-
|
|
167
|
-
const responseFields = {
|
|
168
|
-
HttpMeta: { Response: response, Request: req },
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
const [result] = await M.match<
|
|
172
|
-
operations.LookupPostalCodeLookupPostalCodeOk,
|
|
173
|
-
| errors.ApiErrorResponse
|
|
174
|
-
| GreenSecurityError
|
|
175
|
-
| ResponseValidationError
|
|
176
|
-
| ConnectionError
|
|
177
|
-
| RequestAbortedError
|
|
178
|
-
| RequestTimeoutError
|
|
179
|
-
| InvalidRequestError
|
|
180
|
-
| UnexpectedClientError
|
|
181
|
-
| SDKValidationError
|
|
182
|
-
>(
|
|
183
|
-
M.json(200, operations.LookupPostalCodeLookupPostalCodeOk$inboundSchema),
|
|
184
|
-
M.jsonErr([400, 401, 422], errors.ApiErrorResponse$inboundSchema),
|
|
185
|
-
M.fail("4XX"),
|
|
186
|
-
M.fail([500, "5XX"]),
|
|
187
|
-
)(response, req, { extraFields: responseFields });
|
|
188
|
-
if (!result.ok) {
|
|
189
|
-
return [result, { status: "complete", request: req, response }];
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return [result, { status: "complete", request: req, response }];
|
|
193
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import * as z from "zod/v3";
|
|
6
|
-
import { remap as remap$ } from "../../lib/primitives.js";
|
|
7
|
-
import { safeParse } from "../../lib/schemas.js";
|
|
8
|
-
import * as openEnums from "../../types/enums.js";
|
|
9
|
-
import { OpenEnum } from "../../types/enums.js";
|
|
10
|
-
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
11
|
-
import * as types from "../../types/primitives.js";
|
|
12
|
-
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
13
|
-
|
|
14
|
-
export type LookupPostalCodeRequest = {
|
|
15
|
-
/**
|
|
16
|
-
* The zip / postal code to check.
|
|
17
|
-
*/
|
|
18
|
-
postalCode: string;
|
|
19
|
-
/**
|
|
20
|
-
* The state or province, as a code or full name, entered alongside the postal code.
|
|
21
|
-
*/
|
|
22
|
-
state: string;
|
|
23
|
-
/**
|
|
24
|
-
* The country entered alongside the postal code (e.g. US, CA).
|
|
25
|
-
*/
|
|
26
|
-
country: string;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const LookupPostalCodeStatus = {
|
|
30
|
-
Ok: "ok",
|
|
31
|
-
Invalid: "invalid",
|
|
32
|
-
Mismatch: "mismatch",
|
|
33
|
-
Unknown: "unknown",
|
|
34
|
-
} as const;
|
|
35
|
-
export type LookupPostalCodeStatus = OpenEnum<typeof LookupPostalCodeStatus>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* The request was successful, and the server has returned the check result in the response body.
|
|
39
|
-
*/
|
|
40
|
-
export type LookupPostalCodeLookupPostalCodeOk = {
|
|
41
|
-
status: LookupPostalCodeStatus;
|
|
42
|
-
/**
|
|
43
|
-
* The state(s)/province(s) the postal code actually belongs to. Populated whenever the
|
|
44
|
-
*
|
|
45
|
-
* @remarks
|
|
46
|
-
* postal code is well-formed and a state/province was checked against it — so this is
|
|
47
|
-
* non-empty for `ok` (it names the state that matched) as well as for `mismatch`, and
|
|
48
|
-
* empty for `invalid` and `unknown`.
|
|
49
|
-
*/
|
|
50
|
-
expectedStates: Array<string>;
|
|
51
|
-
/**
|
|
52
|
-
* A human-readable explanation of the problem. `null` unless `status` is `invalid` or `mismatch`.
|
|
53
|
-
*/
|
|
54
|
-
error: string | null;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/** @internal */
|
|
58
|
-
export type LookupPostalCodeRequest$Outbound = {
|
|
59
|
-
postal_code: string;
|
|
60
|
-
state: string;
|
|
61
|
-
country: string;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
/** @internal */
|
|
65
|
-
export const LookupPostalCodeRequest$outboundSchema: z.ZodType<
|
|
66
|
-
LookupPostalCodeRequest$Outbound,
|
|
67
|
-
z.ZodTypeDef,
|
|
68
|
-
LookupPostalCodeRequest
|
|
69
|
-
> = z.object({
|
|
70
|
-
postalCode: z.string(),
|
|
71
|
-
state: z.string(),
|
|
72
|
-
country: z.string(),
|
|
73
|
-
}).transform((v) => {
|
|
74
|
-
return remap$(v, {
|
|
75
|
-
postalCode: "postal_code",
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
export function lookupPostalCodeRequestToJSON(
|
|
80
|
-
lookupPostalCodeRequest: LookupPostalCodeRequest,
|
|
81
|
-
): string {
|
|
82
|
-
return JSON.stringify(
|
|
83
|
-
LookupPostalCodeRequest$outboundSchema.parse(lookupPostalCodeRequest),
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** @internal */
|
|
88
|
-
export const LookupPostalCodeStatus$inboundSchema: z.ZodType<
|
|
89
|
-
LookupPostalCodeStatus,
|
|
90
|
-
z.ZodTypeDef,
|
|
91
|
-
unknown
|
|
92
|
-
> = openEnums.inboundSchema(LookupPostalCodeStatus);
|
|
93
|
-
|
|
94
|
-
/** @internal */
|
|
95
|
-
export const LookupPostalCodeLookupPostalCodeOk$inboundSchema: z.ZodType<
|
|
96
|
-
LookupPostalCodeLookupPostalCodeOk,
|
|
97
|
-
z.ZodTypeDef,
|
|
98
|
-
unknown
|
|
99
|
-
> = z.object({
|
|
100
|
-
status: LookupPostalCodeStatus$inboundSchema,
|
|
101
|
-
expected_states: z.array(types.string()),
|
|
102
|
-
error: types.nullable(types.string()),
|
|
103
|
-
}).transform((v) => {
|
|
104
|
-
return remap$(v, {
|
|
105
|
-
"expected_states": "expectedStates",
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
export function lookupPostalCodeLookupPostalCodeOkFromJSON(
|
|
110
|
-
jsonString: string,
|
|
111
|
-
): SafeParseResult<LookupPostalCodeLookupPostalCodeOk, SDKValidationError> {
|
|
112
|
-
return safeParse(
|
|
113
|
-
jsonString,
|
|
114
|
-
(x) =>
|
|
115
|
-
LookupPostalCodeLookupPostalCodeOk$inboundSchema.parse(JSON.parse(x)),
|
|
116
|
-
`Failed to parse 'LookupPostalCodeLookupPostalCodeOk' from JSON`,
|
|
117
|
-
);
|
|
118
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
QueryClient,
|
|
7
|
-
QueryFunctionContext,
|
|
8
|
-
QueryKey,
|
|
9
|
-
} from "@tanstack/react-query";
|
|
10
|
-
import { GreenSecurityCore } from "../core.js";
|
|
11
|
-
import { lookupsLookupPostalCode } from "../funcs/lookupsLookupPostalCode.js";
|
|
12
|
-
import { combineSignals } from "../lib/primitives.js";
|
|
13
|
-
import { RequestOptions } from "../lib/sdks.js";
|
|
14
|
-
import * as operations from "../models/operations/index.js";
|
|
15
|
-
import { unwrapAsync } from "../types/fp.js";
|
|
16
|
-
export type LookupsLookupPostalCodeQueryData =
|
|
17
|
-
operations.LookupPostalCodeLookupPostalCodeOk;
|
|
18
|
-
|
|
19
|
-
export function prefetchLookupsLookupPostalCode(
|
|
20
|
-
queryClient: QueryClient,
|
|
21
|
-
client$: GreenSecurityCore,
|
|
22
|
-
request: operations.LookupPostalCodeRequest,
|
|
23
|
-
options?: RequestOptions,
|
|
24
|
-
): Promise<void> {
|
|
25
|
-
return queryClient.prefetchQuery({
|
|
26
|
-
...buildLookupsLookupPostalCodeQuery(
|
|
27
|
-
client$,
|
|
28
|
-
request,
|
|
29
|
-
options,
|
|
30
|
-
),
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function buildLookupsLookupPostalCodeQuery(
|
|
35
|
-
client$: GreenSecurityCore,
|
|
36
|
-
request: operations.LookupPostalCodeRequest,
|
|
37
|
-
options?: RequestOptions,
|
|
38
|
-
): {
|
|
39
|
-
queryKey: QueryKey;
|
|
40
|
-
queryFn: (
|
|
41
|
-
context: QueryFunctionContext,
|
|
42
|
-
) => Promise<LookupsLookupPostalCodeQueryData>;
|
|
43
|
-
} {
|
|
44
|
-
return {
|
|
45
|
-
queryKey: queryKeyLookupsLookupPostalCode({
|
|
46
|
-
postalCode: request.postalCode,
|
|
47
|
-
state: request.state,
|
|
48
|
-
country: request.country,
|
|
49
|
-
}),
|
|
50
|
-
queryFn: async function lookupsLookupPostalCodeQueryFn(
|
|
51
|
-
ctx,
|
|
52
|
-
): Promise<LookupsLookupPostalCodeQueryData> {
|
|
53
|
-
const sig = combineSignals(
|
|
54
|
-
ctx.signal,
|
|
55
|
-
options?.signal,
|
|
56
|
-
options?.fetchOptions?.signal,
|
|
57
|
-
);
|
|
58
|
-
const mergedOptions = {
|
|
59
|
-
...options?.fetchOptions,
|
|
60
|
-
...options,
|
|
61
|
-
signal: sig,
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
return unwrapAsync(lookupsLookupPostalCode(
|
|
65
|
-
client$,
|
|
66
|
-
request,
|
|
67
|
-
mergedOptions,
|
|
68
|
-
));
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function queryKeyLookupsLookupPostalCode(
|
|
74
|
-
parameters: { postalCode: string; state: string; country: string },
|
|
75
|
-
): QueryKey {
|
|
76
|
-
return [
|
|
77
|
-
"@greensecurity/javascript-sdk",
|
|
78
|
-
"lookups",
|
|
79
|
-
"lookupPostalCode",
|
|
80
|
-
parameters,
|
|
81
|
-
];
|
|
82
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
InvalidateQueryFilters,
|
|
7
|
-
QueryClient,
|
|
8
|
-
useQuery,
|
|
9
|
-
UseQueryResult,
|
|
10
|
-
useSuspenseQuery,
|
|
11
|
-
UseSuspenseQueryResult,
|
|
12
|
-
} from "@tanstack/react-query";
|
|
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 { useGreenSecurityContext } from "./_context.js";
|
|
26
|
-
import {
|
|
27
|
-
QueryHookOptions,
|
|
28
|
-
SuspenseQueryHookOptions,
|
|
29
|
-
TupleToPrefixes,
|
|
30
|
-
} from "./_types.js";
|
|
31
|
-
import {
|
|
32
|
-
buildLookupsLookupPostalCodeQuery,
|
|
33
|
-
LookupsLookupPostalCodeQueryData,
|
|
34
|
-
prefetchLookupsLookupPostalCode,
|
|
35
|
-
queryKeyLookupsLookupPostalCode,
|
|
36
|
-
} from "./lookupsLookupPostalCode.core.js";
|
|
37
|
-
export {
|
|
38
|
-
buildLookupsLookupPostalCodeQuery,
|
|
39
|
-
type LookupsLookupPostalCodeQueryData,
|
|
40
|
-
prefetchLookupsLookupPostalCode,
|
|
41
|
-
queryKeyLookupsLookupPostalCode,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export type LookupsLookupPostalCodeQueryError =
|
|
45
|
-
| errors.ApiErrorResponse
|
|
46
|
-
| GreenSecurityError
|
|
47
|
-
| ResponseValidationError
|
|
48
|
-
| ConnectionError
|
|
49
|
-
| RequestAbortedError
|
|
50
|
-
| RequestTimeoutError
|
|
51
|
-
| InvalidRequestError
|
|
52
|
-
| UnexpectedClientError
|
|
53
|
-
| SDKValidationError;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Check a postal code against a state and country
|
|
57
|
-
*
|
|
58
|
-
* @remarks
|
|
59
|
-
* Cross-checks a postal code against a state/province and country, the same check
|
|
60
|
-
* every write path that stores a US or Canadian address enforces server-side (e.g.
|
|
61
|
-
* `PUT /users/{id}`, `PUT /vendors/{vendor_id_or_me}`). Useful for validating an
|
|
62
|
-
* address before submitting it elsewhere.
|
|
63
|
-
*
|
|
64
|
-
* `status` is one of:
|
|
65
|
-
* - `ok` — the postal code belongs to the given state/province.
|
|
66
|
-
* - `invalid` — the postal code is not shaped like a real one for the given country.
|
|
67
|
-
* - `mismatch` — the postal code is well-formed but belongs to a different state or
|
|
68
|
-
* province. `expected_states` names the state(s) it actually maps to.
|
|
69
|
-
* - `unknown` — nothing to check against (an unsupported country, or a postal code
|
|
70
|
-
* absent from the US ZIP dataset). Treated as acceptable by every write path that
|
|
71
|
-
* uses this check.
|
|
72
|
-
*
|
|
73
|
-
* Only the US and Canada have a real code-to-subdivision map; every other country
|
|
74
|
-
* always returns `unknown`.
|
|
75
|
-
*/
|
|
76
|
-
export function useLookupsLookupPostalCode(
|
|
77
|
-
request: operations.LookupPostalCodeRequest,
|
|
78
|
-
options?: QueryHookOptions<
|
|
79
|
-
LookupsLookupPostalCodeQueryData,
|
|
80
|
-
LookupsLookupPostalCodeQueryError
|
|
81
|
-
>,
|
|
82
|
-
): UseQueryResult<
|
|
83
|
-
LookupsLookupPostalCodeQueryData,
|
|
84
|
-
LookupsLookupPostalCodeQueryError
|
|
85
|
-
> {
|
|
86
|
-
const client = useGreenSecurityContext();
|
|
87
|
-
return useQuery({
|
|
88
|
-
...buildLookupsLookupPostalCodeQuery(
|
|
89
|
-
client,
|
|
90
|
-
request,
|
|
91
|
-
options,
|
|
92
|
-
),
|
|
93
|
-
...options,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Check a postal code against a state and country
|
|
99
|
-
*
|
|
100
|
-
* @remarks
|
|
101
|
-
* Cross-checks a postal code against a state/province and country, the same check
|
|
102
|
-
* every write path that stores a US or Canadian address enforces server-side (e.g.
|
|
103
|
-
* `PUT /users/{id}`, `PUT /vendors/{vendor_id_or_me}`). Useful for validating an
|
|
104
|
-
* address before submitting it elsewhere.
|
|
105
|
-
*
|
|
106
|
-
* `status` is one of:
|
|
107
|
-
* - `ok` — the postal code belongs to the given state/province.
|
|
108
|
-
* - `invalid` — the postal code is not shaped like a real one for the given country.
|
|
109
|
-
* - `mismatch` — the postal code is well-formed but belongs to a different state or
|
|
110
|
-
* province. `expected_states` names the state(s) it actually maps to.
|
|
111
|
-
* - `unknown` — nothing to check against (an unsupported country, or a postal code
|
|
112
|
-
* absent from the US ZIP dataset). Treated as acceptable by every write path that
|
|
113
|
-
* uses this check.
|
|
114
|
-
*
|
|
115
|
-
* Only the US and Canada have a real code-to-subdivision map; every other country
|
|
116
|
-
* always returns `unknown`.
|
|
117
|
-
*/
|
|
118
|
-
export function useLookupsLookupPostalCodeSuspense(
|
|
119
|
-
request: operations.LookupPostalCodeRequest,
|
|
120
|
-
options?: SuspenseQueryHookOptions<
|
|
121
|
-
LookupsLookupPostalCodeQueryData,
|
|
122
|
-
LookupsLookupPostalCodeQueryError
|
|
123
|
-
>,
|
|
124
|
-
): UseSuspenseQueryResult<
|
|
125
|
-
LookupsLookupPostalCodeQueryData,
|
|
126
|
-
LookupsLookupPostalCodeQueryError
|
|
127
|
-
> {
|
|
128
|
-
const client = useGreenSecurityContext();
|
|
129
|
-
return useSuspenseQuery({
|
|
130
|
-
...buildLookupsLookupPostalCodeQuery(
|
|
131
|
-
client,
|
|
132
|
-
request,
|
|
133
|
-
options,
|
|
134
|
-
),
|
|
135
|
-
...options,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export function setLookupsLookupPostalCodeData(
|
|
140
|
-
client: QueryClient,
|
|
141
|
-
queryKeyBase: [
|
|
142
|
-
parameters: { postalCode: string; state: string; country: string },
|
|
143
|
-
],
|
|
144
|
-
data: LookupsLookupPostalCodeQueryData,
|
|
145
|
-
): LookupsLookupPostalCodeQueryData | undefined {
|
|
146
|
-
const key = queryKeyLookupsLookupPostalCode(...queryKeyBase);
|
|
147
|
-
|
|
148
|
-
return client.setQueryData<LookupsLookupPostalCodeQueryData>(key, data);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export function invalidateLookupsLookupPostalCode(
|
|
152
|
-
client: QueryClient,
|
|
153
|
-
queryKeyBase: TupleToPrefixes<
|
|
154
|
-
[parameters: { postalCode: string; state: string; country: string }]
|
|
155
|
-
>,
|
|
156
|
-
filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">,
|
|
157
|
-
): Promise<void> {
|
|
158
|
-
return client.invalidateQueries({
|
|
159
|
-
...filters,
|
|
160
|
-
queryKey: [
|
|
161
|
-
"@greensecurity/javascript-sdk",
|
|
162
|
-
"lookups",
|
|
163
|
-
"lookupPostalCode",
|
|
164
|
-
...queryKeyBase,
|
|
165
|
-
],
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
export function invalidateAllLookupsLookupPostalCode(
|
|
170
|
-
client: QueryClient,
|
|
171
|
-
filters?: Omit<InvalidateQueryFilters, "queryKey" | "predicate" | "exact">,
|
|
172
|
-
): Promise<void> {
|
|
173
|
-
return client.invalidateQueries({
|
|
174
|
-
...filters,
|
|
175
|
-
queryKey: ["@greensecurity/javascript-sdk", "lookups", "lookupPostalCode"],
|
|
176
|
-
});
|
|
177
|
-
}
|