@vindentech/api-client 0.1.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 ADDED
@@ -0,0 +1,91 @@
1
+ # @vindentech/api-client
2
+
3
+ TypeScript SDK for the Vinden Core API.
4
+
5
+ Generated from the Core API's OpenAPI spec using [orval](https://orval.dev) and wrapped in a thin factory that owns per-instance config — no global state. Safe in SSR and multi-tenant servers.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @vindentech/api-client
11
+ # or
12
+ pnpm add @vindentech/api-client
13
+ ```
14
+
15
+ Zero runtime dependencies. Uses native `fetch`. Works in Node 18+, modern browsers, React Native, Cloudflare Workers, and Deno.
16
+
17
+ ## Quick start
18
+
19
+ ```ts
20
+ import { createVindenClient } from "@vindentech/api-client";
21
+
22
+ const client = createVindenClient({
23
+ baseUrl: "https://api.dev.vinden.io",
24
+ getToken: async () => session.accessToken, // bearer token, however you mint it
25
+ });
26
+
27
+ const { data: me } = await client.getMe();
28
+ const { data: orders } = await client.listOrders();
29
+ const { data: health } = await client.health(); // no token needed
30
+ ```
31
+
32
+ ## API
33
+
34
+ ### `createVindenClient(options)`
35
+
36
+ Returns a fully-isolated client. Each call to `createVindenClient` creates an independent instance — concurrent clients with different tokens send different `Authorization` headers without any cross-contamination.
37
+
38
+ ```ts
39
+ type CreateVindenClientOptions = {
40
+ /** Tenant API base URL, e.g. `https://api.dev.vinden.io`. Trailing slash is normalized. */
41
+ baseUrl: string;
42
+ /**
43
+ * Returns the bearer token for the next request. Called fresh on every request.
44
+ * Returning null / undefined / "" omits the Authorization header (useful for
45
+ * public endpoints like /health).
46
+ */
47
+ getToken?: () => string | null | undefined | Promise<string | null | undefined>;
48
+ /** Override the global fetch. Useful for tests, MSW, or non-standard runtimes. */
49
+ fetch?: typeof globalThis.fetch;
50
+ };
51
+ ```
52
+
53
+ ### Errors
54
+
55
+ Non-2xx responses throw `VindenApiError` with `status`, `statusText`, `url`, and parsed `body`.
56
+
57
+ ```ts
58
+ import { VindenApiError } from "@vindentech/api-client";
59
+
60
+ try {
61
+ await client.getMe();
62
+ } catch (err) {
63
+ if (err instanceof VindenApiError && err.status === 401) {
64
+ // refresh token + retry
65
+ }
66
+ throw err;
67
+ }
68
+ ```
69
+
70
+ ## How to authenticate
71
+
72
+ The SDK is bearer-token agnostic — *how* you get the token is up to the consumer.
73
+
74
+ | Consumer type | How to get a token |
75
+ |---|---|
76
+ | Web app with NextAuth | `getToken: async () => (await getSession())?.accessToken` |
77
+ | React Native (Keycloak PKCE) | `getToken: async () => await SecureStore.getItemAsync("access_token")` |
78
+ | Server-to-server (ERP / cron) | Use Keycloak `client_credentials` grant in your tenant's realm |
79
+ | End-user app (3PL customer) | Keycloak Authorization Code flow against your tenant's realm |
80
+
81
+ `getToken` is awaited on every request, so it's a natural place to refresh expired tokens.
82
+
83
+ ## Versioning
84
+
85
+ This SDK is regenerated from the Core API's OpenAPI spec. Versioning:
86
+
87
+ | Bump | When |
88
+ |---|---|
89
+ | **Patch** (`0.1.0 → 0.1.1`) | Generated bugfix, README, build config. No OpenAPI change. |
90
+ | **Minor** (`0.1.0 → 0.2.0`) | New endpoints, new optional fields, new optional params. |
91
+ | **Major** (`0.x → 1.0`) | Removed endpoint, renamed field, changed response type, newly-required param. |
@@ -0,0 +1,30 @@
1
+ export type GetTokenFn = () => string | null | undefined | Promise<string | null | undefined>;
2
+ export type CreateVindenClientOptions = {
3
+ /** The tenant API base URL, e.g. `https://api.dev.vinden.io`. */
4
+ baseUrl: string;
5
+ /**
6
+ * Returns the bearer token for the next request. Called once per request.
7
+ * If undefined or returns null/undefined/"", no Authorization header is sent.
8
+ */
9
+ getToken?: GetTokenFn;
10
+ /** Override the global fetch — useful for tests, MSW, or non-browser runtimes. */
11
+ fetch?: typeof globalThis.fetch;
12
+ };
13
+ /**
14
+ * Create a fully-isolated Vinden API client.
15
+ *
16
+ * Each call to `createVindenClient` returns an independent client — no
17
+ * shared global state. Two clients with different tokens called concurrently
18
+ * send different `Authorization` headers. Safe in SSR (Next.js Route
19
+ * Handlers/RSCs) and multi-tenant server contexts.
20
+ */
21
+ export declare function createVindenClient(opts: CreateVindenClientOptions): {
22
+ /** GET /health — public, no auth required. */
23
+ health: () => Promise<import("./generated/health/health.js").healthControllerCheckResponseSuccess>;
24
+ /** GET /me — bootstraps user_profile + organization_member on first call. */
25
+ getMe: () => Promise<import("./generated/me/me.js").meControllerGetMeResponseSuccess>;
26
+ /** GET /orders — RLS-filtered to the caller's tenant/org. */
27
+ listOrders: () => Promise<import("./generated/orders/orders.js").ordersControllerFindAllResponseSuccess>;
28
+ };
29
+ export type VindenClient = ReturnType<typeof createVindenClient>;
30
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,MACrB,MAAM,GACN,IAAI,GACJ,SAAS,GACT,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEvC,MAAM,MAAM,yBAAyB,GAAG;IACtC,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,kFAAkF;IAClF,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,yBAAyB;IAE9D,8CAA8C;;IAE9C,6EAA6E;;IAE7E,6DAA6D;;EAGhE;AAED,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,35 @@
1
+ import { healthControllerCheck } from "./generated/health/health.js";
2
+ import { meControllerGetMe } from "./generated/me/me.js";
3
+ import { ordersControllerFindAll } from "./generated/orders/orders.js";
4
+ /**
5
+ * Create a fully-isolated Vinden API client.
6
+ *
7
+ * Each call to `createVindenClient` returns an independent client — no
8
+ * shared global state. Two clients with different tokens called concurrently
9
+ * send different `Authorization` headers. Safe in SSR (Next.js Route
10
+ * Handlers/RSCs) and multi-tenant server contexts.
11
+ */
12
+ export function createVindenClient(opts) {
13
+ return {
14
+ /** GET /health — public, no auth required. */
15
+ health: () => callApi(opts, healthControllerCheck),
16
+ /** GET /me — bootstraps user_profile + organization_member on first call. */
17
+ getMe: () => callApi(opts, meControllerGetMe),
18
+ /** GET /orders — RLS-filtered to the caller's tenant/org. */
19
+ listOrders: () => callApi(opts, ordersControllerFindAll),
20
+ };
21
+ }
22
+ async function callApi(opts, fn) {
23
+ const token = opts.getToken ? await opts.getToken() : undefined;
24
+ const headers = {};
25
+ if (token) {
26
+ headers.Authorization = `Bearer ${token}`;
27
+ }
28
+ const init = {
29
+ baseUrl: opts.baseUrl,
30
+ fetch: opts.fetch,
31
+ headers,
32
+ };
33
+ return fn(init);
34
+ }
35
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAqBvE;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAA+B;IAChE,OAAO;QACL,8CAA8C;QAC9C,MAAM,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,qBAAqB,CAAC;QAClD,6EAA6E;QAC7E,KAAK,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC;QAC7C,6DAA6D;QAC7D,UAAU,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,uBAAuB,CAAC;KACzD,CAAC;AACJ,CAAC;AAID,KAAK,UAAU,OAAO,CACpB,IAA+B,EAC/B,EAAyC;IAEzC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAChE,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;IAC5C,CAAC;IAED,MAAM,IAAI,GAAuB;QAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,OAAO;KACR,CAAC;IAEF,OAAO,EAAE,CAAC,IAAmB,CAAC,CAAC;AACjC,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generated by orval v7.21.0 🍺
3
+ * Do not edit manually.
4
+ * Vinden Core API
5
+ * Core API for the Vinden Platform
6
+ * OpenAPI spec version: 0.1.0
7
+ */
8
+ import type { HealthResponseDto } from '../index.schemas.js';
9
+ /**
10
+ * @summary Health check
11
+ */
12
+ export type healthControllerCheckResponse200 = {
13
+ data: HealthResponseDto;
14
+ status: 200;
15
+ };
16
+ export type healthControllerCheckResponseSuccess = (healthControllerCheckResponse200) & {
17
+ headers: Headers;
18
+ };
19
+ export type healthControllerCheckResponse = (healthControllerCheckResponseSuccess);
20
+ export declare const getHealthControllerCheckUrl: () => string;
21
+ export declare const healthControllerCheck: (options?: RequestInit) => Promise<healthControllerCheckResponse>;
22
+ //# sourceMappingURL=health.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/generated/health/health.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,MAAM,MAAM,gCAAgC,GAAG;IAC7C,IAAI,EAAE,iBAAiB,CAAA;IACvB,MAAM,EAAE,GAAG,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,oCAAoC,GAAG,CAAC,gCAAgC,CAAC,GAAG;IACtF,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,6BAA6B,GAAG,CAAC,oCAAoC,CAAC,CAAA;AAElF,eAAO,MAAM,2BAA2B,cAMvC,CAAA;AAED,eAAO,MAAM,qBAAqB,GAAW,UAAU,WAAW,KAAG,OAAO,CAAC,6BAA6B,CASvG,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { customFetch } from '../../mutator.js';
2
+ ;
3
+ export const getHealthControllerCheckUrl = () => {
4
+ return `/health`;
5
+ };
6
+ export const healthControllerCheck = async (options) => {
7
+ return customFetch(getHealthControllerCheckUrl(), {
8
+ ...options,
9
+ method: 'GET'
10
+ });
11
+ };
12
+ //# sourceMappingURL=health.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"health.js","sourceRoot":"","sources":["../../../src/generated/health/health.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAa/C,CAAC;AAID,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,EAAE;IAK9C,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,EAAG,OAAqB,EAA0C,EAAE;IAE5G,OAAO,WAAW,CAAgC,2BAA2B,EAAE,EAC/E;QACE,GAAG,OAAO;QACV,MAAM,EAAE,KAAK;KAGd,CACF,CAAC;AAAA,CAAC,CAAA"}
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Generated by orval v7.21.0 🍺
3
+ * Do not edit manually.
4
+ * Vinden Core API
5
+ * Core API for the Vinden Platform
6
+ * OpenAPI spec version: 0.1.0
7
+ */
8
+ export interface HealthResponseDto {
9
+ status: string;
10
+ timestamp: string;
11
+ }
12
+ /**
13
+ * Arbitrary JSON metadata (object, array, or primitive). Shape is tenant-defined.
14
+ * @nullable
15
+ */
16
+ export type OrderDtoMetadata = {
17
+ [key: string]: unknown;
18
+ } | null;
19
+ export interface OrderDto {
20
+ orderId: string;
21
+ tenantId: string;
22
+ organizationId: string;
23
+ warehouseId: string;
24
+ /** @nullable */
25
+ assignedCarrierId: string | null;
26
+ type: string;
27
+ status: string;
28
+ /** @nullable */
29
+ reference: string | null;
30
+ /** @nullable */
31
+ notes: string | null;
32
+ /** @nullable */
33
+ scheduledAt: string | null;
34
+ /** @nullable */
35
+ completedAt: string | null;
36
+ createdAt: string;
37
+ updatedAt: string;
38
+ /**
39
+ * Arbitrary JSON metadata (object, array, or primitive). Shape is tenant-defined.
40
+ * @nullable
41
+ */
42
+ metadata: OrderDtoMetadata;
43
+ }
44
+ export interface MembershipDto {
45
+ organizationId: string;
46
+ role: string;
47
+ }
48
+ export interface MeResponseDto {
49
+ /** Keycloak subject identifier */
50
+ sub: string;
51
+ /**
52
+ * Legacy Cognito subject identifier, set for federated users
53
+ * @nullable
54
+ */
55
+ cognitoSub: string | null;
56
+ /**
57
+ * Resolved tenant id; null for platform-admin without a tenant context
58
+ * @nullable
59
+ */
60
+ tenantId: string | null;
61
+ /** @nullable */
62
+ email: string | null;
63
+ /** @nullable */
64
+ displayName: string | null;
65
+ memberships: MembershipDto[];
66
+ /** Realm + client roles flattened — used for client-side capability checks */
67
+ capabilities: string[];
68
+ }
69
+ //# sourceMappingURL=index.schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.schemas.d.ts","sourceRoot":"","sources":["../../src/generated/index.schemas.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAAG,IAAI,CAAC;AAEjE,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,gBAAgB;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,aAAa;IAC5B,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gBAAgB;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB;IAChB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,aAAa,EAAE,CAAC;IAC7B,8EAA8E;IAC9E,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.schemas.js","sourceRoot":"","sources":["../../src/generated/index.schemas.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generated by orval v7.21.0 🍺
3
+ * Do not edit manually.
4
+ * Vinden Core API
5
+ * Core API for the Vinden Platform
6
+ * OpenAPI spec version: 0.1.0
7
+ */
8
+ import type { MeResponseDto } from '../index.schemas.js';
9
+ /**
10
+ * @summary Get current user — bootstraps user_profile + organization_member on first call
11
+ */
12
+ export type meControllerGetMeResponse200 = {
13
+ data: MeResponseDto;
14
+ status: 200;
15
+ };
16
+ export type meControllerGetMeResponseSuccess = (meControllerGetMeResponse200) & {
17
+ headers: Headers;
18
+ };
19
+ export type meControllerGetMeResponse = (meControllerGetMeResponseSuccess);
20
+ export declare const getMeControllerGetMeUrl: () => string;
21
+ export declare const meControllerGetMe: (options?: RequestInit) => Promise<meControllerGetMeResponse>;
22
+ //# sourceMappingURL=me.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.d.ts","sourceRoot":"","sources":["../../../src/generated/me/me.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,aAAa,EACd,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,EAAE,GAAG,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,gCAAgC,GAAG,CAAC,4BAA4B,CAAC,GAAG;IAC9E,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,yBAAyB,GAAG,CAAC,gCAAgC,CAAC,CAAA;AAE1E,eAAO,MAAM,uBAAuB,cAMnC,CAAA;AAED,eAAO,MAAM,iBAAiB,GAAW,UAAU,WAAW,KAAG,OAAO,CAAC,yBAAyB,CAS/F,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { customFetch } from '../../mutator.js';
2
+ ;
3
+ export const getMeControllerGetMeUrl = () => {
4
+ return `/me`;
5
+ };
6
+ export const meControllerGetMe = async (options) => {
7
+ return customFetch(getMeControllerGetMeUrl(), {
8
+ ...options,
9
+ method: 'GET'
10
+ });
11
+ };
12
+ //# sourceMappingURL=me.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"me.js","sourceRoot":"","sources":["../../../src/generated/me/me.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAa/C,CAAC;AAID,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,EAAE;IAK1C,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EAAG,OAAqB,EAAsC,EAAE;IAEpG,OAAO,WAAW,CAA4B,uBAAuB,EAAE,EACvE;QACE,GAAG,OAAO;QACV,MAAM,EAAE,KAAK;KAGd,CACF,CAAC;AAAA,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Generated by orval v7.21.0 🍺
3
+ * Do not edit manually.
4
+ * Vinden Core API
5
+ * Core API for the Vinden Platform
6
+ * OpenAPI spec version: 0.1.0
7
+ */
8
+ import type { OrderDto } from '../index.schemas.js';
9
+ /**
10
+ * @summary List orders
11
+ */
12
+ export type ordersControllerFindAllResponse200 = {
13
+ data: OrderDto[];
14
+ status: 200;
15
+ };
16
+ export type ordersControllerFindAllResponseSuccess = (ordersControllerFindAllResponse200) & {
17
+ headers: Headers;
18
+ };
19
+ export type ordersControllerFindAllResponse = (ordersControllerFindAllResponseSuccess);
20
+ export declare const getOrdersControllerFindAllUrl: () => string;
21
+ export declare const ordersControllerFindAll: (options?: RequestInit) => Promise<ordersControllerFindAllResponse>;
22
+ //# sourceMappingURL=orders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.d.ts","sourceRoot":"","sources":["../../../src/generated/orders/orders.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,QAAQ,EACT,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,QAAQ,EAAE,CAAA;IAChB,MAAM,EAAE,GAAG,CAAA;CACZ,CAAA;AAED,MAAM,MAAM,sCAAsC,GAAG,CAAC,kCAAkC,CAAC,GAAG;IAC1F,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAGF,MAAM,MAAM,+BAA+B,GAAG,CAAC,sCAAsC,CAAC,CAAA;AAEtF,eAAO,MAAM,6BAA6B,cAMzC,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAW,UAAU,WAAW,KAAG,OAAO,CAAC,+BAA+B,CAS3G,CAAA"}
@@ -0,0 +1,12 @@
1
+ import { customFetch } from '../../mutator.js';
2
+ ;
3
+ export const getOrdersControllerFindAllUrl = () => {
4
+ return `/orders`;
5
+ };
6
+ export const ordersControllerFindAll = async (options) => {
7
+ return customFetch(getOrdersControllerFindAllUrl(), {
8
+ ...options,
9
+ method: 'GET'
10
+ });
11
+ };
12
+ //# sourceMappingURL=orders.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders.js","sourceRoot":"","sources":["../../../src/generated/orders/orders.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAa/C,CAAC;AAID,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,EAAE;IAKhD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAAG,OAAqB,EAA4C,EAAE;IAEhH,OAAO,WAAW,CAAkC,6BAA6B,EAAE,EACnF;QACE,GAAG,OAAO;QACV,MAAM,EAAE,KAAK;KAGd,CACF,CAAC;AAAA,CAAC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export { createVindenClient, type CreateVindenClientOptions, type GetTokenFn, type VindenClient, } from "./client.js";
2
+ export { VindenApiError } from "./mutator.js";
3
+ export type { healthControllerCheckResponse as HealthCheckResponse, } from "./generated/health/health.js";
4
+ export type { meControllerGetMeResponse as GetMeResponse, } from "./generated/me/me.js";
5
+ export type { ordersControllerFindAllResponse as ListOrdersResponse, } from "./generated/orders/orders.js";
6
+ export type { HealthResponseDto, MeResponseDto, MembershipDto, OrderDto, OrderDtoMetadata, } from "./generated/index.schemas.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,KAAK,yBAAyB,EAC9B,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,YAAY,EACV,6BAA6B,IAAI,mBAAmB,GACrD,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,yBAAyB,IAAI,aAAa,GAC3C,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,+BAA+B,IAAI,kBAAkB,GACtD,MAAM,8BAA8B,CAAC;AAGtC,YAAY,EACV,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,QAAQ,EACR,gBAAgB,GACjB,MAAM,8BAA8B,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { createVindenClient, } from "./client.js";
2
+ export { VindenApiError } from "./mutator.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,GAInB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The request-time hook orval's generated code calls. Receives the
3
+ * relative URL (from the OpenAPI spec) plus a `RequestInit` that
4
+ * `createVindenClient` extends with `baseUrl` and `fetch`. Reads those
5
+ * extras off the options for THIS call — no module-level state, safe
6
+ * for SSR and multi-tenant servers.
7
+ */
8
+ export type CustomFetchOptions = RequestInit & {
9
+ baseUrl?: string;
10
+ fetch?: typeof globalThis.fetch;
11
+ };
12
+ export type CustomFetchResponse<T> = {
13
+ data: T;
14
+ status: number;
15
+ headers: Headers;
16
+ };
17
+ export declare function customFetch<TResponse>(url: string, options?: RequestInit): Promise<TResponse>;
18
+ export declare class VindenApiError extends Error {
19
+ readonly status: number;
20
+ readonly statusText: string;
21
+ readonly url: string;
22
+ readonly body: unknown;
23
+ constructor(status: number, statusText: string, url: string, body: unknown);
24
+ }
25
+ //# sourceMappingURL=mutator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutator.d.ts","sourceRoot":"","sources":["../src/mutator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACnC,IAAI,EAAE,CAAC,CAAC;IACR,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAsB,WAAW,CAAC,SAAS,EACzC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,SAAS,CAAC,CAkBpB;AAED,qBAAa,cAAe,SAAQ,KAAK;aAErB,MAAM,EAAE,MAAM;aACd,UAAU,EAAE,MAAM;aAClB,GAAG,EAAE,MAAM;aACX,IAAI,EAAE,OAAO;gBAHb,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,OAAO;CAKhC"}
@@ -0,0 +1,65 @@
1
+ export async function customFetch(url, options) {
2
+ const { baseUrl = "", fetch: fetchImpl, ...init } = (options ?? {});
3
+ const f = fetchImpl ?? globalThis.fetch;
4
+ const fullUrl = isAbsoluteUrl(url) ? url : `${stripTrailingSlash(baseUrl)}${url}`;
5
+ const response = await f(fullUrl, init);
6
+ if (!response.ok) {
7
+ const body = await safeReadBody(response);
8
+ throw new VindenApiError(response.status, response.statusText, fullUrl, body);
9
+ }
10
+ const data = (await readJsonBody(response));
11
+ return {
12
+ data,
13
+ status: response.status,
14
+ headers: response.headers,
15
+ };
16
+ }
17
+ export class VindenApiError extends Error {
18
+ status;
19
+ statusText;
20
+ url;
21
+ body;
22
+ constructor(status, statusText, url, body) {
23
+ super(`HTTP ${status} ${statusText} for ${url}`);
24
+ this.status = status;
25
+ this.statusText = statusText;
26
+ this.url = url;
27
+ this.body = body;
28
+ this.name = "VindenApiError";
29
+ }
30
+ }
31
+ function stripTrailingSlash(s) {
32
+ return s.endsWith("/") ? s.slice(0, -1) : s;
33
+ }
34
+ function isAbsoluteUrl(url) {
35
+ return /^https?:\/\//i.test(url);
36
+ }
37
+ async function readJsonBody(response) {
38
+ if (response.status === 204)
39
+ return undefined;
40
+ const text = await response.text();
41
+ if (text === "")
42
+ return undefined;
43
+ const contentType = response.headers.get("content-type") ?? "";
44
+ if (contentType.includes("application/json")) {
45
+ return JSON.parse(text);
46
+ }
47
+ return text;
48
+ }
49
+ async function safeReadBody(response) {
50
+ try {
51
+ const text = await response.text();
52
+ if (text === "")
53
+ return undefined;
54
+ try {
55
+ return JSON.parse(text);
56
+ }
57
+ catch {
58
+ return text;
59
+ }
60
+ }
61
+ catch {
62
+ return undefined;
63
+ }
64
+ }
65
+ //# sourceMappingURL=mutator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutator.js","sourceRoot":"","sources":["../src/mutator.ts"],"names":[],"mappings":"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"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@vindentech/api-client",
3
+ "version": "0.1.0",
4
+ "description": "TypeScript SDK for the Vinden Core API. Generated from OpenAPI via orval.",
5
+ "license": "UNLICENSED",
6
+ "type": "module",
7
+ "sideEffects": false,
8
+ "publishConfig": {
9
+ "access": "public"
10
+ },
11
+ "main": "./dist/index.js",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md"
22
+ ],
23
+ "scripts": {
24
+ "generate": "orval --config ./orval.config.ts",
25
+ "build": "tsc --build",
26
+ "lint": "tsc --noEmit",
27
+ "test:isolation": "node --conditions development --import @swc-node/register/esm-register scripts/spike-isolation.ts",
28
+ "prepublishOnly": "pnpm build"
29
+ },
30
+ "devDependencies": {
31
+ "@swc-node/register": "^1.10.0",
32
+ "@swc/core": "^1.11.0",
33
+ "@types/node": "^24.0.0",
34
+ "orval": "^7.0.0",
35
+ "typescript": "^5.6.0"
36
+ }
37
+ }