@unified-api/typescript-sdk 2.9.4 → 2.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FUNCTIONS.md +108 -0
- package/README.md +36 -15
- package/RUNTIMES.md +22 -0
- package/docs/sdks/account/README.md +501 -0
- package/docs/sdks/accounting/README.md +3629 -0
- package/docs/sdks/activity/README.md +501 -0
- package/docs/sdks/apicall/README.md +165 -0
- package/docs/sdks/application/README.md +501 -0
- package/docs/sdks/applicationstatus/README.md +88 -0
- package/docs/sdks/ats/README.md +3710 -0
- package/docs/sdks/auth/README.md +173 -0
- package/docs/sdks/branch/README.md +501 -0
- package/docs/sdks/call/README.md +88 -0
- package/docs/sdks/candidate/README.md +501 -0
- package/docs/sdks/channel/README.md +171 -0
- package/docs/sdks/class/README.md +501 -0
- package/docs/sdks/collection/README.md +501 -0
- package/docs/sdks/commerce/README.md +2477 -0
- package/docs/sdks/commit/README.md +501 -0
- package/docs/sdks/company/README.md +1240 -0
- package/docs/sdks/connection/README.md +485 -0
- package/docs/sdks/contact/README.md +1489 -0
- package/docs/sdks/course/README.md +501 -0
- package/docs/sdks/crm/README.md +2971 -0
- package/docs/sdks/customer/README.md +501 -0
- package/docs/sdks/deal/README.md +501 -0
- package/docs/sdks/document/README.md +501 -0
- package/docs/sdks/employee/README.md +501 -0
- package/docs/sdks/enrich/README.md +169 -0
- package/docs/sdks/event/README.md +501 -0
- package/docs/sdks/file/README.md +501 -0
- package/docs/sdks/genai/README.md +169 -0
- package/docs/sdks/group/README.md +995 -0
- package/docs/sdks/hris/README.md +2311 -0
- package/docs/sdks/instructor/README.md +501 -0
- package/docs/sdks/integration/README.md +248 -0
- package/docs/sdks/interview/README.md +501 -0
- package/docs/sdks/inventory/README.md +501 -0
- package/docs/sdks/invoice/README.md +501 -0
- package/docs/sdks/issue/README.md +84 -0
- package/docs/sdks/item/README.md +501 -0
- package/docs/sdks/job/README.md +501 -0
- package/docs/sdks/journal/README.md +501 -0
- package/docs/sdks/kms/README.md +995 -0
- package/docs/sdks/lead/README.md +501 -0
- package/docs/sdks/link/README.md +501 -0
- package/docs/sdks/list/README.md +501 -0
- package/docs/sdks/lms/README.md +1983 -0
- package/docs/sdks/location/README.md +995 -0
- package/docs/sdks/login/README.md +90 -0
- package/docs/sdks/martech/README.md +995 -0
- package/docs/sdks/member/README.md +501 -0
- package/docs/sdks/message/README.md +501 -0
- package/docs/sdks/messaging/README.md +665 -0
- package/docs/sdks/metadata/README.md +501 -0
- package/docs/sdks/model/README.md +88 -0
- package/docs/sdks/note/README.md +501 -0
- package/docs/sdks/order/README.md +501 -0
- package/docs/sdks/organization/README.md +665 -0
- package/docs/sdks/page/README.md +501 -0
- package/docs/sdks/passthrough/README.md +671 -0
- package/docs/sdks/payment/README.md +1323 -0
- package/docs/sdks/payout/README.md +171 -0
- package/docs/sdks/payslip/README.md +171 -0
- package/docs/sdks/person/README.md +88 -0
- package/docs/sdks/pipeline/README.md +501 -0
- package/docs/sdks/project/README.md +501 -0
- package/docs/sdks/prompt/README.md +88 -0
- package/docs/sdks/pullrequest/README.md +501 -0
- package/docs/sdks/refund/README.md +171 -0
- package/docs/sdks/repo/README.md +2477 -0
- package/docs/sdks/repository/README.md +501 -0
- package/docs/sdks/scim/README.md +995 -0
- package/docs/sdks/scorecard/README.md +501 -0
- package/docs/sdks/space/README.md +501 -0
- package/docs/sdks/storage/README.md +501 -0
- package/docs/sdks/student/README.md +501 -0
- package/docs/sdks/task/README.md +995 -0
- package/docs/sdks/taxrate/README.md +501 -0
- package/docs/sdks/ticket/README.md +501 -0
- package/docs/sdks/ticketing/README.md +1489 -0
- package/docs/sdks/timeoff/README.md +171 -0
- package/docs/sdks/transaction/README.md +501 -0
- package/docs/sdks/uc/README.md +582 -0
- package/docs/sdks/unified/README.md +1601 -0
- package/docs/sdks/unifiedto/README.md +7 -0
- package/docs/sdks/user/README.md +501 -0
- package/docs/sdks/webhook/README.md +647 -0
- package/lib/config.d.ts +3 -3
- package/lib/config.js +3 -3
- package/lib/primitives.d.ts +2 -0
- package/lib/primitives.d.ts.map +1 -1
- package/lib/primitives.js +53 -0
- package/lib/primitives.js.map +1 -1
- package/package.json +3 -1
- package/sdk/models/shared/index.d.ts +1 -0
- package/sdk/models/shared/index.d.ts.map +1 -1
- package/sdk/models/shared/index.js +1 -0
- package/sdk/models/shared/index.js.map +1 -1
- package/sdk/models/shared/kmspage.d.ts +5 -0
- package/sdk/models/shared/kmspage.d.ts.map +1 -1
- package/sdk/models/shared/kmspage.js +7 -0
- package/sdk/models/shared/kmspage.js.map +1 -1
- package/sdk/models/shared/kmspagemetadata.d.ts +37 -0
- package/sdk/models/shared/kmspagemetadata.d.ts.map +1 -0
- package/sdk/models/shared/kmspagemetadata.js +63 -0
- package/sdk/models/shared/kmspagemetadata.js.map +1 -0
- package/sdk/models/shared/kmsspace.d.ts +2 -0
- package/sdk/models/shared/kmsspace.d.ts.map +1 -1
- package/sdk/models/shared/kmsspace.js +4 -0
- package/sdk/models/shared/kmsspace.js.map +1 -1
- package/sdk/models/shared/security.d.ts +2 -2
- package/sdk/models/shared/security.d.ts.map +1 -1
- package/sdk/models/shared/security.js +2 -2
- package/sdk/models/shared/security.js.map +1 -1
- package/sdk/types/operations.d.ts +5 -3
- package/sdk/types/operations.d.ts.map +1 -1
- package/sdk/types/operations.js +3 -0
- package/sdk/types/operations.js.map +1 -1
- package/src/lib/config.ts +3 -3
- package/src/lib/primitives.ts +62 -0
- package/src/sdk/models/shared/index.ts +1 -0
- package/src/sdk/models/shared/kmspage.ts +16 -0
- package/src/sdk/models/shared/kmspagemetadata.ts +72 -0
- package/src/sdk/models/shared/kmsspace.ts +6 -0
- package/src/sdk/models/shared/security.ts +4 -4
- package/src/sdk/types/operations.ts +11 -5
package/FUNCTIONS.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Standalone Functions
|
|
2
|
+
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This section is useful if you are using a bundler and targetting browsers and
|
|
5
|
+
> runtimes where the size of an application affects performance and load times.
|
|
6
|
+
|
|
7
|
+
Every method in this SDK is also available as a standalone function. This
|
|
8
|
+
alternative API is suitable when targetting the browser or serverless runtimes
|
|
9
|
+
and using a bundler to build your application since all unused functionality
|
|
10
|
+
will be tree-shaken away. This includes code for unused methods, Zod schemas,
|
|
11
|
+
encoding helpers and response handlers. The result is dramatically smaller
|
|
12
|
+
impact on the application's final bundle size which grows very slowly as you use
|
|
13
|
+
more and more functionality from this SDK.
|
|
14
|
+
|
|
15
|
+
Calling methods through the main SDK class remains a valid and generally more
|
|
16
|
+
more ergonomic option. Standalone functions represent an optimisation for a
|
|
17
|
+
specific category of applications.
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { UnifiedToCore } from "@unified-api/typescript-sdk/core.js";
|
|
23
|
+
import { accountingCreateAccountingAccount } from "@unified-api/typescript-sdk/funcs/accountingCreateAccountingAccount.js";
|
|
24
|
+
import { SDKValidationError } from "@unified-api/typescript-sdk/sdk/models/errors/sdkvalidationerror.js";
|
|
25
|
+
|
|
26
|
+
// Use `UnifiedToCore` for best tree-shaking performance.
|
|
27
|
+
// You can create one instance of it to use across an application.
|
|
28
|
+
const unifiedTo = new UnifiedToCore({
|
|
29
|
+
security: {
|
|
30
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
async function run() {
|
|
35
|
+
const res = await accountingCreateAccountingAccount(unifiedTo, {
|
|
36
|
+
connectionId: "<value>",
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
switch (true) {
|
|
40
|
+
case res.ok:
|
|
41
|
+
// The success case will be handled outside of the switch block
|
|
42
|
+
break;
|
|
43
|
+
case res.error instanceof SDKValidationError:
|
|
44
|
+
// Pretty-print validation errors.
|
|
45
|
+
return console.log(res.error.pretty());
|
|
46
|
+
case res.error instanceof Error:
|
|
47
|
+
return console.log(res.error);
|
|
48
|
+
default:
|
|
49
|
+
// TypeScript's type checking will fail on the following line if the above
|
|
50
|
+
// cases were not exhaustive.
|
|
51
|
+
res.error satisfies never;
|
|
52
|
+
throw new Error("Assertion failed: expected error checks to be exhaustive: " + res.error);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
const { value: result } = res;
|
|
57
|
+
|
|
58
|
+
// Handle the result
|
|
59
|
+
console.log(result);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
run();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Result types
|
|
66
|
+
|
|
67
|
+
Standalone functions differ from SDK methods in that they return a
|
|
68
|
+
`Result<Value, Error>` type to capture _known errors_ and document them using
|
|
69
|
+
the type system. By avoiding throwing errors, application code maintains clear
|
|
70
|
+
control flow and error-handling become part of the regular flow of application
|
|
71
|
+
code.
|
|
72
|
+
|
|
73
|
+
> We use the term "known errors" because standalone functions, and JavaScript
|
|
74
|
+
> code in general, can still throw unexpected errors such as `TypeError`s,
|
|
75
|
+
> `RangeError`s and `DOMException`s. Exhaustively catching all errors may be
|
|
76
|
+
> something this SDK addresses in the future. Nevertheless, there is still a lot
|
|
77
|
+
> of benefit from capturing most errors and turning them into values.
|
|
78
|
+
|
|
79
|
+
The second reason for this style of programming is because these functions will
|
|
80
|
+
typically be used in front-end applications where exception throwing is
|
|
81
|
+
sometimes discouraged or considered unidiomatic. React and similar ecosystems
|
|
82
|
+
and libraries tend to promote this style of programming so that components
|
|
83
|
+
render useful content under all states (loading, success, error and so on).
|
|
84
|
+
|
|
85
|
+
The general pattern when calling standalone functions looks like this:
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { Core } from "<sdk-package-name>";
|
|
89
|
+
import { fetchSomething } from "<sdk-package-name>/funcs/fetchSomething.js";
|
|
90
|
+
|
|
91
|
+
const client = new Core();
|
|
92
|
+
|
|
93
|
+
async function run() {
|
|
94
|
+
const result = await fetchSomething(client, { id: "123" });
|
|
95
|
+
if (!result.ok) {
|
|
96
|
+
// You can throw the error or handle it. It's your choice now.
|
|
97
|
+
throw result.error;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log(result.value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
run();
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Notably, `result.error` above will have an explicit type compared to a try-catch
|
|
107
|
+
variation where the error in the catch block can only be of type `unknown` (or
|
|
108
|
+
`any` depending on your TypeScript settings).
|
package/README.md
CHANGED
|
@@ -9,19 +9,19 @@ Unified.to API: One API to Rule Them All
|
|
|
9
9
|
|
|
10
10
|
<!-- Start Table of Contents [toc] -->
|
|
11
11
|
## Table of Contents
|
|
12
|
+
<!-- $toc-max-depth=2 -->
|
|
13
|
+
* [Installation](#installation)
|
|
14
|
+
* [SDK Example Usage](#sdk-example-usage)
|
|
15
|
+
* [Server Selection](#server-selection)
|
|
16
|
+
* [Custom HTTP Client](#custom-http-client)
|
|
17
|
+
* [Authentication](#authentication)
|
|
18
|
+
* [Error Handling](#error-handling)
|
|
19
|
+
* [Requirements](#requirements)
|
|
20
|
+
* [File uploads](#file-uploads)
|
|
21
|
+
* [Retries](#retries)
|
|
22
|
+
* [Debugging](#debugging)
|
|
23
|
+
* [Standalone functions](#standalone-functions)
|
|
12
24
|
|
|
13
|
-
* [SDK Installation](#sdk-installation)
|
|
14
|
-
* [Requirements](#requirements)
|
|
15
|
-
* [SDK Example Usage](#sdk-example-usage)
|
|
16
|
-
* [Available Resources and Operations](#available-resources-and-operations)
|
|
17
|
-
* [Standalone functions](#standalone-functions)
|
|
18
|
-
* [File uploads](#file-uploads)
|
|
19
|
-
* [Retries](#retries)
|
|
20
|
-
* [Error Handling](#error-handling)
|
|
21
|
-
* [Server Selection](#server-selection)
|
|
22
|
-
* [Custom HTTP Client](#custom-http-client)
|
|
23
|
-
* [Authentication](#authentication)
|
|
24
|
-
* [Debugging](#debugging)
|
|
25
25
|
<!-- End Table of Contents [toc] -->
|
|
26
26
|
|
|
27
27
|
<!-- Start SDK Installation [installation] -->
|
|
@@ -89,6 +89,9 @@ import { UnifiedTo } from "@unified-api/typescript-sdk";
|
|
|
89
89
|
|
|
90
90
|
const unifiedTo = new UnifiedTo({
|
|
91
91
|
serverIdx: 1,
|
|
92
|
+
security: {
|
|
93
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
94
|
+
},
|
|
92
95
|
});
|
|
93
96
|
|
|
94
97
|
async function run() {
|
|
@@ -112,6 +115,9 @@ import { UnifiedTo } from "@unified-api/typescript-sdk";
|
|
|
112
115
|
|
|
113
116
|
const unifiedTo = new UnifiedTo({
|
|
114
117
|
serverURL: "https://api.unified.to",
|
|
118
|
+
security: {
|
|
119
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
120
|
+
},
|
|
115
121
|
});
|
|
116
122
|
|
|
117
123
|
async function run() {
|
|
@@ -244,7 +250,11 @@ In addition, when custom error responses are specified for an operation, the SDK
|
|
|
244
250
|
import { UnifiedTo } from "@unified-api/typescript-sdk";
|
|
245
251
|
import { SDKValidationError } from "@unified-api/typescript-sdk/sdk/models/errors";
|
|
246
252
|
|
|
247
|
-
const unifiedTo = new UnifiedTo(
|
|
253
|
+
const unifiedTo = new UnifiedTo({
|
|
254
|
+
security: {
|
|
255
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
256
|
+
},
|
|
257
|
+
});
|
|
248
258
|
|
|
249
259
|
async function run() {
|
|
250
260
|
let result;
|
|
@@ -301,7 +311,11 @@ Certain SDK methods accept files as part of a multi-part request. It is possible
|
|
|
301
311
|
```typescript
|
|
302
312
|
import { UnifiedTo } from "@unified-api/typescript-sdk";
|
|
303
313
|
|
|
304
|
-
const unifiedTo = new UnifiedTo(
|
|
314
|
+
const unifiedTo = new UnifiedTo({
|
|
315
|
+
security: {
|
|
316
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
317
|
+
},
|
|
318
|
+
});
|
|
305
319
|
|
|
306
320
|
async function run() {
|
|
307
321
|
const result = await unifiedTo.passthrough.createPassthroughRaw({
|
|
@@ -327,7 +341,11 @@ To change the default retry strategy for a single API call, simply provide a ret
|
|
|
327
341
|
```typescript
|
|
328
342
|
import { UnifiedTo } from "@unified-api/typescript-sdk";
|
|
329
343
|
|
|
330
|
-
const unifiedTo = new UnifiedTo(
|
|
344
|
+
const unifiedTo = new UnifiedTo({
|
|
345
|
+
security: {
|
|
346
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
347
|
+
},
|
|
348
|
+
});
|
|
331
349
|
|
|
332
350
|
async function run() {
|
|
333
351
|
const result = await unifiedTo.accounting.createAccountingAccount({
|
|
@@ -368,6 +386,9 @@ const unifiedTo = new UnifiedTo({
|
|
|
368
386
|
},
|
|
369
387
|
retryConnectionErrors: false,
|
|
370
388
|
},
|
|
389
|
+
security: {
|
|
390
|
+
jwt: "<YOUR_API_KEY_HERE>",
|
|
391
|
+
},
|
|
371
392
|
});
|
|
372
393
|
|
|
373
394
|
async function run() {
|
package/RUNTIMES.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Supported JavaScript runtimes
|
|
2
|
+
|
|
3
|
+
This SDK is intended to be used in JavaScript runtimes that support the following features:
|
|
4
|
+
|
|
5
|
+
* [Web Fetch API][web-fetch]
|
|
6
|
+
* [Web Streams API][web-streams] and in particular `ReadableStream`
|
|
7
|
+
* [Async iterables][async-iter] using `Symbol.asyncIterator`
|
|
8
|
+
|
|
9
|
+
[web-fetch]: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
|
|
10
|
+
[web-streams]: https://developer.mozilla.org/en-US/docs/Web/API/Streams_API
|
|
11
|
+
[async-iter]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
|
|
12
|
+
|
|
13
|
+
Runtime environments that are explicitly supported are:
|
|
14
|
+
|
|
15
|
+
- Evergreen browsers which include: Chrome, Safari, Edge, Firefox
|
|
16
|
+
- Node.js active and maintenance LTS releases
|
|
17
|
+
- Currently, this is v18 and v20
|
|
18
|
+
- Bun v1 and above
|
|
19
|
+
- Deno v1.39
|
|
20
|
+
- Note that Deno does not currently have native support for streaming file uploads backed by the filesystem ([issue link][deno-file-streaming])
|
|
21
|
+
|
|
22
|
+
[deno-file-streaming]: https://github.com/denoland/deno/issues/11018
|