@outseta/api-client 0.1.1 → 0.2.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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # @outseta/api-client
2
2
 
3
- Generated API client for the [Outseta](https://www.outseta.com) REST API. Provides typed fetch functions, Zod validation schemas, and TypeScript types — all auto-generated from the Outseta OpenAPI spec.
3
+ > **Most users should install a higher-level package instead:**
4
+ >
5
+ > - **[`@outseta/node-sdk`](https://www.npmjs.com/package/@outseta/node-sdk)** — for Node.js / server-side usage
6
+ > - **[`@outseta/react`](https://www.npmjs.com/package/@outseta/react)** — for React apps (hooks, components, provider)
7
+
8
+ Low-level, generated API client for the [Outseta](https://www.outseta.com) REST API. Provides typed fetch functions, Zod validation schemas, and TypeScript types — all auto-generated from the Outseta OpenAPI spec. This package is the shared foundation that those packages build on. Use it directly only if you need fine-grained control or are targeting a runtime not covered by the SDKs above.
4
9
 
5
10
  ## Install
6
11
 
@@ -28,13 +33,6 @@ import { getAccounts } from "@outseta/api-client";
28
33
  const result = await getAccounts({ client });
29
34
  ```
30
35
 
31
- ## About
32
-
33
- This package is the low-level client. For a higher-level experience, see:
34
-
35
- - [`@outseta/node-sdk`](https://www.npmjs.com/package/@outseta/node-sdk) — Node.js SDK
36
- - [`@outseta/react`](https://www.npmjs.com/package/@outseta/react) — React hooks and components
37
-
38
36
  ## License
39
37
 
40
38
  [MIT](../../LICENSE)
package/dist/index.js CHANGED
@@ -1,10 +1,16 @@
1
1
  // src/client.ts
2
2
  import ky, { HTTPError } from "ky";
3
+ function getAuthorization(creds) {
4
+ if ("accessToken" in creds) {
5
+ return `Bearer ${creds.accessToken}`;
6
+ }
7
+ return `Outseta ${creds.apiKey}:${creds.apiSecret}`;
8
+ }
3
9
  function createClient(creds) {
4
10
  return ky.create({
5
11
  prefixUrl: `https://${creds.subdomain}.outseta.com/api/v1/`,
6
12
  headers: {
7
- Authorization: `Outseta ${creds.apiKey}:${creds.apiSecret}`
13
+ Authorization: getAuthorization(creds)
8
14
  },
9
15
  retry: { limit: 3, statusCodes: [408, 429, 500, 502, 503, 504] }
10
16
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@outseta/api-client",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Generated API client for the Outseta REST API",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/client.ts CHANGED
@@ -1,16 +1,32 @@
1
1
  import ky, { HTTPError, type KyInstance } from "ky";
2
2
 
3
- export type OutsetaCredentials = {
3
+ export type OutsetaApiKeyCredentials = {
4
4
  subdomain: string;
5
5
  apiKey: string;
6
6
  apiSecret: string;
7
7
  };
8
8
 
9
+ export type OutsetaBearerCredentials = {
10
+ subdomain: string;
11
+ accessToken: string;
12
+ };
13
+
14
+ export type OutsetaCredentials =
15
+ | OutsetaApiKeyCredentials
16
+ | OutsetaBearerCredentials;
17
+
18
+ function getAuthorization(creds: OutsetaCredentials): string {
19
+ if ("accessToken" in creds) {
20
+ return `Bearer ${creds.accessToken}`;
21
+ }
22
+ return `Outseta ${creds.apiKey}:${creds.apiSecret}`;
23
+ }
24
+
9
25
  export function createClient(creds: OutsetaCredentials): KyInstance {
10
26
  return ky.create({
11
27
  prefixUrl: `https://${creds.subdomain}.outseta.com/api/v1/`,
12
28
  headers: {
13
- Authorization: `Outseta ${creds.apiKey}:${creds.apiSecret}`,
29
+ Authorization: getAuthorization(creds),
14
30
  },
15
31
  retry: { limit: 3, statusCodes: [408, 429, 500, 502, 503, 504] },
16
32
  });
package/src/index.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  export { createClient, customFetch } from "./client.js";
2
- export type { OutsetaCredentials } from "./client.js";
2
+ export type {
3
+ OutsetaCredentials,
4
+ OutsetaApiKeyCredentials,
5
+ OutsetaBearerCredentials,
6
+ } from "./client.js";
3
7
 
4
8
  // Re-export generated types and functions once generated
5
9
  // export * from "./generated/index.js";