@factify/sdk 0.3.11 → 0.3.13-rc.1
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 +7 -0
- package/dist/commonjs/funcs/quotaGetOrganizationQuota.d.ts +18 -0
- package/dist/commonjs/funcs/quotaGetOrganizationQuota.d.ts.map +1 -0
- package/dist/commonjs/funcs/quotaGetOrganizationQuota.js +124 -0
- package/dist/commonjs/funcs/quotaGetOrganizationQuota.js.map +1 -0
- package/dist/commonjs/funcs/quotaGetUsageHistory.d.ts +18 -0
- package/dist/commonjs/funcs/quotaGetUsageHistory.d.ts.map +1 -0
- package/dist/commonjs/funcs/quotaGetUsageHistory.js +126 -0
- package/dist/commonjs/funcs/quotaGetUsageHistory.js.map +1 -0
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/lib/config.js.map +1 -1
- package/dist/commonjs/models/components/createorganizationrequest.d.ts +2 -2
- package/dist/commonjs/models/components/createorganizationrequest.d.ts.map +1 -1
- package/dist/commonjs/models/components/createorganizationrequest.js +1 -1
- package/dist/commonjs/models/components/createorganizationrequest.js.map +1 -1
- package/dist/commonjs/models/components/dailyusage.d.ts +20 -0
- package/dist/commonjs/models/components/dailyusage.d.ts.map +1 -0
- package/dist/commonjs/models/components/dailyusage.js +58 -0
- package/dist/commonjs/models/components/dailyusage.js.map +1 -0
- package/dist/commonjs/models/components/getorganizationquotaresponse.d.ts +17 -0
- package/dist/commonjs/models/components/getorganizationquotaresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/getorganizationquotaresponse.js +52 -0
- package/dist/commonjs/models/components/getorganizationquotaresponse.js.map +1 -0
- package/dist/commonjs/models/components/getusagehistoryresponse.d.ts +25 -0
- package/dist/commonjs/models/components/getusagehistoryresponse.d.ts.map +1 -0
- package/dist/commonjs/models/components/getusagehistoryresponse.js +61 -0
- package/dist/commonjs/models/components/getusagehistoryresponse.js.map +1 -0
- package/dist/commonjs/models/components/index.d.ts +5 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +5 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/organizationquota.d.ts +52 -0
- package/dist/commonjs/models/components/organizationquota.d.ts.map +1 -0
- package/dist/commonjs/models/components/organizationquota.js +71 -0
- package/dist/commonjs/models/components/organizationquota.js.map +1 -0
- package/dist/commonjs/models/components/quotatier.d.ts +17 -0
- package/dist/commonjs/models/components/quotatier.d.ts.map +1 -0
- package/dist/commonjs/models/components/quotatier.js +51 -0
- package/dist/commonjs/models/components/quotatier.js.map +1 -0
- package/dist/commonjs/models/operations/getorganizationquota.d.ts +34 -0
- package/dist/commonjs/models/operations/getorganizationquota.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getorganizationquota.js +73 -0
- package/dist/commonjs/models/operations/getorganizationquota.js.map +1 -0
- package/dist/commonjs/models/operations/getusagehistory.d.ts +41 -0
- package/dist/commonjs/models/operations/getusagehistory.d.ts.map +1 -0
- package/dist/commonjs/models/operations/getusagehistory.js +77 -0
- package/dist/commonjs/models/operations/getusagehistory.js.map +1 -0
- 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/sdk/quota.d.ts +19 -0
- package/dist/commonjs/sdk/quota.d.ts.map +1 -0
- package/dist/commonjs/sdk/quota.js +32 -0
- package/dist/commonjs/sdk/quota.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/funcs/quotaGetOrganizationQuota.d.ts +18 -0
- package/dist/esm/funcs/quotaGetOrganizationQuota.d.ts.map +1 -0
- package/dist/esm/funcs/quotaGetOrganizationQuota.js +88 -0
- package/dist/esm/funcs/quotaGetOrganizationQuota.js.map +1 -0
- package/dist/esm/funcs/quotaGetUsageHistory.d.ts +18 -0
- package/dist/esm/funcs/quotaGetUsageHistory.d.ts.map +1 -0
- package/dist/esm/funcs/quotaGetUsageHistory.js +90 -0
- package/dist/esm/funcs/quotaGetUsageHistory.js.map +1 -0
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/lib/config.js.map +1 -1
- package/dist/esm/models/components/createorganizationrequest.d.ts +2 -2
- package/dist/esm/models/components/createorganizationrequest.d.ts.map +1 -1
- package/dist/esm/models/components/createorganizationrequest.js +1 -1
- package/dist/esm/models/components/createorganizationrequest.js.map +1 -1
- package/dist/esm/models/components/dailyusage.d.ts +20 -0
- package/dist/esm/models/components/dailyusage.d.ts.map +1 -0
- package/dist/esm/models/components/dailyusage.js +21 -0
- package/dist/esm/models/components/dailyusage.js.map +1 -0
- package/dist/esm/models/components/getorganizationquotaresponse.d.ts +17 -0
- package/dist/esm/models/components/getorganizationquotaresponse.d.ts.map +1 -0
- package/dist/esm/models/components/getorganizationquotaresponse.js +15 -0
- package/dist/esm/models/components/getorganizationquotaresponse.js.map +1 -0
- package/dist/esm/models/components/getusagehistoryresponse.d.ts +25 -0
- package/dist/esm/models/components/getusagehistoryresponse.d.ts.map +1 -0
- package/dist/esm/models/components/getusagehistoryresponse.js +24 -0
- package/dist/esm/models/components/getusagehistoryresponse.js.map +1 -0
- package/dist/esm/models/components/index.d.ts +5 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +5 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/organizationquota.d.ts +52 -0
- package/dist/esm/models/components/organizationquota.d.ts.map +1 -0
- package/dist/esm/models/components/organizationquota.js +34 -0
- package/dist/esm/models/components/organizationquota.js.map +1 -0
- package/dist/esm/models/components/quotatier.d.ts +17 -0
- package/dist/esm/models/components/quotatier.d.ts.map +1 -0
- package/dist/esm/models/components/quotatier.js +15 -0
- package/dist/esm/models/components/quotatier.js.map +1 -0
- package/dist/esm/models/operations/getorganizationquota.d.ts +34 -0
- package/dist/esm/models/operations/getorganizationquota.d.ts.map +1 -0
- package/dist/esm/models/operations/getorganizationquota.js +35 -0
- package/dist/esm/models/operations/getorganizationquota.js.map +1 -0
- package/dist/esm/models/operations/getusagehistory.d.ts +41 -0
- package/dist/esm/models/operations/getusagehistory.d.ts.map +1 -0
- package/dist/esm/models/operations/getusagehistory.js +39 -0
- package/dist/esm/models/operations/getusagehistory.js.map +1 -0
- 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/sdk/quota.d.ts +19 -0
- package/dist/esm/sdk/quota.d.ts.map +1 -0
- package/dist/esm/sdk/quota.js +28 -0
- package/dist/esm/sdk/quota.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/openapi.json +483 -18
- package/package.json +1 -1
- package/src/funcs/quotaGetOrganizationQuota.ts +182 -0
- package/src/funcs/quotaGetUsageHistory.ts +184 -0
- package/src/lib/config.ts +3 -3
- package/src/models/components/createorganizationrequest.ts +3 -3
- package/src/models/components/dailyusage.ts +48 -0
- package/src/models/components/getorganizationquotaresponse.ts +41 -0
- package/src/models/components/getusagehistoryresponse.ts +58 -0
- package/src/models/components/index.ts +5 -0
- package/src/models/components/organizationquota.ts +95 -0
- package/src/models/components/quotatier.ts +24 -0
- package/src/models/operations/getorganizationquota.ts +93 -0
- package/src/models/operations/getusagehistory.ts +100 -0
- package/src/models/operations/index.ts +2 -0
- package/src/sdk/quota.ts +45 -0
- package/src/sdk/sdk.ts +6 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
import { FactifyCore } from "../core.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 { FactifyError } from "../models/errors/factifyerror.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
|
+
* Get organization quota status
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Returns the current quota status for an organization including usage, limits, tier, and reset date.
|
|
34
|
+
*/
|
|
35
|
+
export function quotaGetOrganizationQuota(
|
|
36
|
+
client: FactifyCore,
|
|
37
|
+
request?: operations.GetOrganizationQuotaRequest | undefined,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
operations.GetOrganizationQuotaResponse,
|
|
42
|
+
| errors.ErrorT
|
|
43
|
+
| FactifyError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: FactifyCore,
|
|
62
|
+
request?: operations.GetOrganizationQuotaRequest | undefined,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
operations.GetOrganizationQuotaResponse,
|
|
68
|
+
| errors.ErrorT
|
|
69
|
+
| FactifyError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) =>
|
|
84
|
+
z.parse(
|
|
85
|
+
z.optional(operations.GetOrganizationQuotaRequest$outboundSchema),
|
|
86
|
+
value,
|
|
87
|
+
),
|
|
88
|
+
"Input validation failed",
|
|
89
|
+
);
|
|
90
|
+
if (!parsed.ok) {
|
|
91
|
+
return [parsed, { status: "invalid" }];
|
|
92
|
+
}
|
|
93
|
+
const payload = parsed.value;
|
|
94
|
+
const body = null;
|
|
95
|
+
|
|
96
|
+
const path = pathToFunc("/v1beta/quota")();
|
|
97
|
+
|
|
98
|
+
const query = encodeFormQuery({
|
|
99
|
+
"organization_id": payload?.organization_id,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
const headers = new Headers(compactMap({
|
|
103
|
+
Accept: "application/json",
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
107
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
108
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
109
|
+
|
|
110
|
+
const context = {
|
|
111
|
+
options: client._options,
|
|
112
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
113
|
+
operationID: "getOrganizationQuota",
|
|
114
|
+
oAuth2Scopes: null,
|
|
115
|
+
|
|
116
|
+
resolvedSecurity: requestSecurity,
|
|
117
|
+
|
|
118
|
+
securitySource: client._options.bearerAuth,
|
|
119
|
+
retryConfig: options?.retries
|
|
120
|
+
|| client._options.retryConfig
|
|
121
|
+
|| { strategy: "none" },
|
|
122
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const requestRes = client._createRequest(context, {
|
|
126
|
+
security: requestSecurity,
|
|
127
|
+
method: "GET",
|
|
128
|
+
baseURL: options?.serverURL,
|
|
129
|
+
path: path,
|
|
130
|
+
headers: headers,
|
|
131
|
+
query: query,
|
|
132
|
+
body: body,
|
|
133
|
+
userAgent: client._options.userAgent,
|
|
134
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
135
|
+
}, options);
|
|
136
|
+
if (!requestRes.ok) {
|
|
137
|
+
return [requestRes, { status: "invalid" }];
|
|
138
|
+
}
|
|
139
|
+
const req = requestRes.value;
|
|
140
|
+
|
|
141
|
+
const doResult = await client._do(req, {
|
|
142
|
+
context,
|
|
143
|
+
errorCodes: ["400", "401", "403", "404", "429", "4XX", "500", "5XX"],
|
|
144
|
+
retryConfig: context.retryConfig,
|
|
145
|
+
retryCodes: context.retryCodes,
|
|
146
|
+
});
|
|
147
|
+
if (!doResult.ok) {
|
|
148
|
+
return [doResult, { status: "request-error", request: req }];
|
|
149
|
+
}
|
|
150
|
+
const response = doResult.value;
|
|
151
|
+
|
|
152
|
+
const responseFields = {
|
|
153
|
+
HttpMeta: { Response: response, Request: req },
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const [result] = await M.match<
|
|
157
|
+
operations.GetOrganizationQuotaResponse,
|
|
158
|
+
| errors.ErrorT
|
|
159
|
+
| FactifyError
|
|
160
|
+
| ResponseValidationError
|
|
161
|
+
| ConnectionError
|
|
162
|
+
| RequestAbortedError
|
|
163
|
+
| RequestTimeoutError
|
|
164
|
+
| InvalidRequestError
|
|
165
|
+
| UnexpectedClientError
|
|
166
|
+
| SDKValidationError
|
|
167
|
+
>(
|
|
168
|
+
M.json(200, operations.GetOrganizationQuotaResponse$inboundSchema, {
|
|
169
|
+
key: "GetOrganizationQuotaResponse",
|
|
170
|
+
}),
|
|
171
|
+
M.jsonErr([400, 401, 403, 404], errors.ErrorT$inboundSchema),
|
|
172
|
+
M.jsonErr(429, errors.ErrorT$inboundSchema, { hdrs: true }),
|
|
173
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
174
|
+
M.fail("4XX"),
|
|
175
|
+
M.fail("5XX"),
|
|
176
|
+
)(response, req, { extraFields: responseFields });
|
|
177
|
+
if (!result.ok) {
|
|
178
|
+
return [result, { status: "complete", request: req, response }];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return [result, { status: "complete", request: req, response }];
|
|
182
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
import { FactifyCore } from "../core.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 { FactifyError } from "../models/errors/factifyerror.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
|
+
* Get usage history
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Returns daily usage records for an organization within a specified date range.
|
|
34
|
+
*/
|
|
35
|
+
export function quotaGetUsageHistory(
|
|
36
|
+
client: FactifyCore,
|
|
37
|
+
request?: operations.GetUsageHistoryRequest | undefined,
|
|
38
|
+
options?: RequestOptions,
|
|
39
|
+
): APIPromise<
|
|
40
|
+
Result<
|
|
41
|
+
operations.GetUsageHistoryResponse,
|
|
42
|
+
| errors.ErrorT
|
|
43
|
+
| FactifyError
|
|
44
|
+
| ResponseValidationError
|
|
45
|
+
| ConnectionError
|
|
46
|
+
| RequestAbortedError
|
|
47
|
+
| RequestTimeoutError
|
|
48
|
+
| InvalidRequestError
|
|
49
|
+
| UnexpectedClientError
|
|
50
|
+
| SDKValidationError
|
|
51
|
+
>
|
|
52
|
+
> {
|
|
53
|
+
return new APIPromise($do(
|
|
54
|
+
client,
|
|
55
|
+
request,
|
|
56
|
+
options,
|
|
57
|
+
));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function $do(
|
|
61
|
+
client: FactifyCore,
|
|
62
|
+
request?: operations.GetUsageHistoryRequest | undefined,
|
|
63
|
+
options?: RequestOptions,
|
|
64
|
+
): Promise<
|
|
65
|
+
[
|
|
66
|
+
Result<
|
|
67
|
+
operations.GetUsageHistoryResponse,
|
|
68
|
+
| errors.ErrorT
|
|
69
|
+
| FactifyError
|
|
70
|
+
| ResponseValidationError
|
|
71
|
+
| ConnectionError
|
|
72
|
+
| RequestAbortedError
|
|
73
|
+
| RequestTimeoutError
|
|
74
|
+
| InvalidRequestError
|
|
75
|
+
| UnexpectedClientError
|
|
76
|
+
| SDKValidationError
|
|
77
|
+
>,
|
|
78
|
+
APICall,
|
|
79
|
+
]
|
|
80
|
+
> {
|
|
81
|
+
const parsed = safeParse(
|
|
82
|
+
request,
|
|
83
|
+
(value) =>
|
|
84
|
+
z.parse(
|
|
85
|
+
z.optional(operations.GetUsageHistoryRequest$outboundSchema),
|
|
86
|
+
value,
|
|
87
|
+
),
|
|
88
|
+
"Input validation failed",
|
|
89
|
+
);
|
|
90
|
+
if (!parsed.ok) {
|
|
91
|
+
return [parsed, { status: "invalid" }];
|
|
92
|
+
}
|
|
93
|
+
const payload = parsed.value;
|
|
94
|
+
const body = null;
|
|
95
|
+
|
|
96
|
+
const path = pathToFunc("/v1beta/quota/usage")();
|
|
97
|
+
|
|
98
|
+
const query = encodeFormQuery({
|
|
99
|
+
"end_date": payload?.end_date,
|
|
100
|
+
"organization_id": payload?.organization_id,
|
|
101
|
+
"start_date": payload?.start_date,
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
const headers = new Headers(compactMap({
|
|
105
|
+
Accept: "application/json",
|
|
106
|
+
}));
|
|
107
|
+
|
|
108
|
+
const secConfig = await extractSecurity(client._options.bearerAuth);
|
|
109
|
+
const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
|
|
110
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
111
|
+
|
|
112
|
+
const context = {
|
|
113
|
+
options: client._options,
|
|
114
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
115
|
+
operationID: "getUsageHistory",
|
|
116
|
+
oAuth2Scopes: null,
|
|
117
|
+
|
|
118
|
+
resolvedSecurity: requestSecurity,
|
|
119
|
+
|
|
120
|
+
securitySource: client._options.bearerAuth,
|
|
121
|
+
retryConfig: options?.retries
|
|
122
|
+
|| client._options.retryConfig
|
|
123
|
+
|| { strategy: "none" },
|
|
124
|
+
retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const requestRes = client._createRequest(context, {
|
|
128
|
+
security: requestSecurity,
|
|
129
|
+
method: "GET",
|
|
130
|
+
baseURL: options?.serverURL,
|
|
131
|
+
path: path,
|
|
132
|
+
headers: headers,
|
|
133
|
+
query: query,
|
|
134
|
+
body: body,
|
|
135
|
+
userAgent: client._options.userAgent,
|
|
136
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
137
|
+
}, options);
|
|
138
|
+
if (!requestRes.ok) {
|
|
139
|
+
return [requestRes, { status: "invalid" }];
|
|
140
|
+
}
|
|
141
|
+
const req = requestRes.value;
|
|
142
|
+
|
|
143
|
+
const doResult = await client._do(req, {
|
|
144
|
+
context,
|
|
145
|
+
errorCodes: ["400", "401", "403", "404", "429", "4XX", "500", "5XX"],
|
|
146
|
+
retryConfig: context.retryConfig,
|
|
147
|
+
retryCodes: context.retryCodes,
|
|
148
|
+
});
|
|
149
|
+
if (!doResult.ok) {
|
|
150
|
+
return [doResult, { status: "request-error", request: req }];
|
|
151
|
+
}
|
|
152
|
+
const response = doResult.value;
|
|
153
|
+
|
|
154
|
+
const responseFields = {
|
|
155
|
+
HttpMeta: { Response: response, Request: req },
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const [result] = await M.match<
|
|
159
|
+
operations.GetUsageHistoryResponse,
|
|
160
|
+
| errors.ErrorT
|
|
161
|
+
| FactifyError
|
|
162
|
+
| ResponseValidationError
|
|
163
|
+
| ConnectionError
|
|
164
|
+
| RequestAbortedError
|
|
165
|
+
| RequestTimeoutError
|
|
166
|
+
| InvalidRequestError
|
|
167
|
+
| UnexpectedClientError
|
|
168
|
+
| SDKValidationError
|
|
169
|
+
>(
|
|
170
|
+
M.json(200, operations.GetUsageHistoryResponse$inboundSchema, {
|
|
171
|
+
key: "GetUsageHistoryResponse",
|
|
172
|
+
}),
|
|
173
|
+
M.jsonErr([400, 401, 403, 404], errors.ErrorT$inboundSchema),
|
|
174
|
+
M.jsonErr(429, errors.ErrorT$inboundSchema, { hdrs: true }),
|
|
175
|
+
M.jsonErr(500, errors.ErrorT$inboundSchema),
|
|
176
|
+
M.fail("4XX"),
|
|
177
|
+
M.fail("5XX"),
|
|
178
|
+
)(response, req, { extraFields: responseFields });
|
|
179
|
+
if (!result.ok) {
|
|
180
|
+
return [result, { status: "complete", request: req, response }];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return [result, { status: "complete", request: req, response }];
|
|
184
|
+
}
|
package/src/lib/config.ts
CHANGED
|
@@ -65,7 +65,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
65
65
|
export const SDK_METADATA = {
|
|
66
66
|
language: "typescript",
|
|
67
67
|
openapiDocVersion: "1.0.0",
|
|
68
|
-
sdkVersion: "0.3.
|
|
69
|
-
genVersion: "2.
|
|
70
|
-
userAgent: "speakeasy-sdk/typescript 0.3.
|
|
68
|
+
sdkVersion: "0.3.13-rc.1",
|
|
69
|
+
genVersion: "2.799.0",
|
|
70
|
+
userAgent: "speakeasy-sdk/typescript 0.3.13-rc.1 2.799.0 1.0.0 @factify/sdk",
|
|
71
71
|
} as const;
|
|
@@ -21,13 +21,13 @@ export type CreateOrganizationRequest = {
|
|
|
21
21
|
* Required when the caller is a service account (service accounts cannot own organizations).
|
|
22
22
|
* Pattern: user_[0-9a-hjkmnp-tv-z]{26}
|
|
23
23
|
*/
|
|
24
|
-
ownerUserId?: string | undefined;
|
|
24
|
+
ownerUserId?: string | null | undefined;
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
/** @internal */
|
|
28
28
|
export type CreateOrganizationRequest$Outbound = {
|
|
29
29
|
name: string;
|
|
30
|
-
owner_user_id?: string | undefined;
|
|
30
|
+
owner_user_id?: string | null | undefined;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
/** @internal */
|
|
@@ -37,7 +37,7 @@ export const CreateOrganizationRequest$outboundSchema: z.ZodMiniType<
|
|
|
37
37
|
> = z.pipe(
|
|
38
38
|
z.object({
|
|
39
39
|
name: z.string(),
|
|
40
|
-
ownerUserId: z.optional(z.string()),
|
|
40
|
+
ownerUserId: z.optional(z.nullable(z.string())),
|
|
41
41
|
}),
|
|
42
42
|
z.transform((v) => {
|
|
43
43
|
return remap$(v, {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
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 * as types from "../../types/primitives.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* DailyUsage represents usage for a single day.
|
|
14
|
+
*/
|
|
15
|
+
export type DailyUsage = {
|
|
16
|
+
/**
|
|
17
|
+
* The date (YYYY-MM-DD format).
|
|
18
|
+
*/
|
|
19
|
+
date?: string | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Request count for this day.
|
|
22
|
+
*/
|
|
23
|
+
requestCount?: number | undefined;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/** @internal */
|
|
27
|
+
export const DailyUsage$inboundSchema: z.ZodMiniType<DailyUsage, unknown> = z
|
|
28
|
+
.pipe(
|
|
29
|
+
z.object({
|
|
30
|
+
date: types.optional(types.string()),
|
|
31
|
+
request_count: types.optional(types.number()),
|
|
32
|
+
}),
|
|
33
|
+
z.transform((v) => {
|
|
34
|
+
return remap$(v, {
|
|
35
|
+
"request_count": "requestCount",
|
|
36
|
+
});
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export function dailyUsageFromJSON(
|
|
41
|
+
jsonString: string,
|
|
42
|
+
): SafeParseResult<DailyUsage, SDKValidationError> {
|
|
43
|
+
return safeParse(
|
|
44
|
+
jsonString,
|
|
45
|
+
(x) => DailyUsage$inboundSchema.parse(JSON.parse(x)),
|
|
46
|
+
`Failed to parse 'DailyUsage' from JSON`,
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import * as types from "../../types/primitives.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
OrganizationQuota,
|
|
12
|
+
OrganizationQuota$inboundSchema,
|
|
13
|
+
} from "./organizationquota.js";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* GetOrganizationQuotaResponse returns the quota status.
|
|
17
|
+
*/
|
|
18
|
+
export type GetOrganizationQuotaResponse = {
|
|
19
|
+
/**
|
|
20
|
+
* OrganizationQuota represents the quota status for an organization.
|
|
21
|
+
*/
|
|
22
|
+
quota?: OrganizationQuota | undefined;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/** @internal */
|
|
26
|
+
export const GetOrganizationQuotaResponse$inboundSchema: z.ZodMiniType<
|
|
27
|
+
GetOrganizationQuotaResponse,
|
|
28
|
+
unknown
|
|
29
|
+
> = z.object({
|
|
30
|
+
quota: types.optional(OrganizationQuota$inboundSchema),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export function getOrganizationQuotaResponseFromJSON(
|
|
34
|
+
jsonString: string,
|
|
35
|
+
): SafeParseResult<GetOrganizationQuotaResponse, SDKValidationError> {
|
|
36
|
+
return safeParse(
|
|
37
|
+
jsonString,
|
|
38
|
+
(x) => GetOrganizationQuotaResponse$inboundSchema.parse(JSON.parse(x)),
|
|
39
|
+
`Failed to parse 'GetOrganizationQuotaResponse' from JSON`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
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 * as types from "../../types/primitives.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
import { DailyUsage, DailyUsage$inboundSchema } from "./dailyusage.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* GetUsageHistoryResponse returns usage history.
|
|
15
|
+
*/
|
|
16
|
+
export type GetUsageHistoryResponse = {
|
|
17
|
+
/**
|
|
18
|
+
* Daily usage records.
|
|
19
|
+
*/
|
|
20
|
+
dailyUsage?: Array<DailyUsage> | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The organization ID.
|
|
23
|
+
*/
|
|
24
|
+
organizationId?: string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Total requests in the period.
|
|
27
|
+
*/
|
|
28
|
+
totalRequests?: number | undefined;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/** @internal */
|
|
32
|
+
export const GetUsageHistoryResponse$inboundSchema: z.ZodMiniType<
|
|
33
|
+
GetUsageHistoryResponse,
|
|
34
|
+
unknown
|
|
35
|
+
> = z.pipe(
|
|
36
|
+
z.object({
|
|
37
|
+
daily_usage: types.optional(z.array(DailyUsage$inboundSchema)),
|
|
38
|
+
organization_id: types.optional(types.string()),
|
|
39
|
+
total_requests: types.optional(types.number()),
|
|
40
|
+
}),
|
|
41
|
+
z.transform((v) => {
|
|
42
|
+
return remap$(v, {
|
|
43
|
+
"daily_usage": "dailyUsage",
|
|
44
|
+
"organization_id": "organizationId",
|
|
45
|
+
"total_requests": "totalRequests",
|
|
46
|
+
});
|
|
47
|
+
}),
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
export function getUsageHistoryResponseFromJSON(
|
|
51
|
+
jsonString: string,
|
|
52
|
+
): SafeParseResult<GetUsageHistoryResponse, SDKValidationError> {
|
|
53
|
+
return safeParse(
|
|
54
|
+
jsonString,
|
|
55
|
+
(x) => GetUsageHistoryResponse$inboundSchema.parse(JSON.parse(x)),
|
|
56
|
+
`Failed to parse 'GetUsageHistoryResponse' from JSON`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -11,13 +11,16 @@ export * from "./createdocumentresponse.js";
|
|
|
11
11
|
export * from "./createorganizationrequest.js";
|
|
12
12
|
export * from "./createorganizationresponse.js";
|
|
13
13
|
export * from "./createversionrequest.js";
|
|
14
|
+
export * from "./dailyusage.js";
|
|
14
15
|
export * from "./document.js";
|
|
15
16
|
export * from "./documentpolicy.js";
|
|
16
17
|
export * from "./empty.js";
|
|
17
18
|
export * from "./error.js";
|
|
18
19
|
export * from "./generateentrypageresponse.js";
|
|
19
20
|
export * from "./getdocumentresponse.js";
|
|
21
|
+
export * from "./getorganizationquotaresponse.js";
|
|
20
22
|
export * from "./getorganizationresponse.js";
|
|
23
|
+
export * from "./getusagehistoryresponse.js";
|
|
21
24
|
export * from "./httpmetadata.js";
|
|
22
25
|
export * from "./listapikeysresponse.js";
|
|
23
26
|
export * from "./listdocumentpoliciesresponse.js";
|
|
@@ -25,9 +28,11 @@ export * from "./listdocumentsresponse.js";
|
|
|
25
28
|
export * from "./listorganizationsresponse.js";
|
|
26
29
|
export * from "./listversionsresponse.js";
|
|
27
30
|
export * from "./organization.js";
|
|
31
|
+
export * from "./organizationquota.js";
|
|
28
32
|
export * from "./pagination.js";
|
|
29
33
|
export * from "./policy.js";
|
|
30
34
|
export * from "./processingstatus.js";
|
|
35
|
+
export * from "./quotatier.js";
|
|
31
36
|
export * from "./revokeapikeyresponse.js";
|
|
32
37
|
export * from "./security.js";
|
|
33
38
|
export * from "./updatedocumentresponse.js";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v4-mini";
|
|
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 * as types from "../../types/primitives.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
import { QuotaTier, QuotaTier$inboundSchema } from "./quotatier.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* OrganizationQuota represents the quota status for an organization.
|
|
15
|
+
*/
|
|
16
|
+
export type OrganizationQuota = {
|
|
17
|
+
/**
|
|
18
|
+
* Current usage in the billing period.
|
|
19
|
+
*/
|
|
20
|
+
currentUsage?: number | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* The effective monthly limit (considers custom_limit if set).
|
|
23
|
+
*/
|
|
24
|
+
effectiveLimit?: number | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Whether quota is exceeded.
|
|
27
|
+
*/
|
|
28
|
+
isExceeded?: boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The organization ID.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Pattern: org_[0-9a-hjkmnp-tv-z]{26}
|
|
34
|
+
*/
|
|
35
|
+
organizationId?: string | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Start of current billing period.
|
|
38
|
+
*/
|
|
39
|
+
periodStart?: Date | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Remaining requests in the billing period.
|
|
42
|
+
*/
|
|
43
|
+
remaining?: number | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* When the quota resets (start of next billing period).
|
|
46
|
+
*/
|
|
47
|
+
resetAt?: Date | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* QuotaTier represents the organization's quota tier.
|
|
50
|
+
*/
|
|
51
|
+
tier?: QuotaTier | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Usage as a percentage (0-100+).
|
|
54
|
+
*/
|
|
55
|
+
usagePercent?: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** @internal */
|
|
59
|
+
export const OrganizationQuota$inboundSchema: z.ZodMiniType<
|
|
60
|
+
OrganizationQuota,
|
|
61
|
+
unknown
|
|
62
|
+
> = z.pipe(
|
|
63
|
+
z.object({
|
|
64
|
+
current_usage: types.optional(types.number()),
|
|
65
|
+
effective_limit: types.optional(types.number()),
|
|
66
|
+
is_exceeded: types.optional(types.boolean()),
|
|
67
|
+
organization_id: types.optional(types.string()),
|
|
68
|
+
period_start: types.optional(types.date()),
|
|
69
|
+
remaining: types.optional(types.number()),
|
|
70
|
+
reset_at: types.optional(types.date()),
|
|
71
|
+
tier: types.optional(QuotaTier$inboundSchema),
|
|
72
|
+
usage_percent: types.optional(types.number()),
|
|
73
|
+
}),
|
|
74
|
+
z.transform((v) => {
|
|
75
|
+
return remap$(v, {
|
|
76
|
+
"current_usage": "currentUsage",
|
|
77
|
+
"effective_limit": "effectiveLimit",
|
|
78
|
+
"is_exceeded": "isExceeded",
|
|
79
|
+
"organization_id": "organizationId",
|
|
80
|
+
"period_start": "periodStart",
|
|
81
|
+
"reset_at": "resetAt",
|
|
82
|
+
"usage_percent": "usagePercent",
|
|
83
|
+
});
|
|
84
|
+
}),
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
export function organizationQuotaFromJSON(
|
|
88
|
+
jsonString: string,
|
|
89
|
+
): SafeParseResult<OrganizationQuota, SDKValidationError> {
|
|
90
|
+
return safeParse(
|
|
91
|
+
jsonString,
|
|
92
|
+
(x) => OrganizationQuota$inboundSchema.parse(JSON.parse(x)),
|
|
93
|
+
`Failed to parse 'OrganizationQuota' from JSON`,
|
|
94
|
+
);
|
|
95
|
+
}
|