@porulle/sdk 0.64.0 → 0.65.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 CHANGED
@@ -2,16 +2,6 @@
2
2
 
3
3
  Typed TypeScript client for any Porulle server. Generated from the OpenAPI spec — every endpoint, request body, and response is type-checked at compile time.
4
4
 
5
- ## Two surfaces
6
-
7
- ```ts
8
- import { createClient } from "@porulle/sdk";
9
- import { createCommerceHooks } from "@porulle/sdk/react";
10
- ```
11
-
12
- - **`createClient<paths>`** — a vanilla `openapi-fetch` client. Use anywhere (Node, Bun, browser, Cloudflare Workers).
13
- - **`createCommerceHooks(client)`** — TanStack Query (React Query) hooks bound to that client.
14
-
15
5
  ## Usage
16
6
 
17
7
  ```ts
@@ -28,12 +18,12 @@ const { data, error } = await client.GET("/api/catalog/entities", {
28
18
  });
29
19
  ```
30
20
 
31
- React Query bindings:
21
+ React Query hooks bind directly to the same client via `openapi-react-query`:
32
22
 
33
23
  ```tsx
34
- import { createCommerceHooks } from "@porulle/sdk/react";
24
+ import createQueryHooks from "openapi-react-query";
35
25
 
36
- const commerce = createCommerceHooks(client);
26
+ const commerce = createQueryHooks(client);
37
27
 
38
28
  function ProductList() {
39
29
  const { data } = commerce.useQuery("get", "/api/catalog/entities", {
package/dist/client.d.ts CHANGED
@@ -27,66 +27,4 @@ export interface SDKOptions {
27
27
  * ```
28
28
  */
29
29
  export declare function createClient<TPaths extends {}>(options: SDKOptions): import("openapi-fetch").Client<TPaths, `${string}/${string}`>;
30
- /**
31
- * Creates a typed SDK with ergonomic domain namespaces.
32
- *
33
- * This is a convenience wrapper that creates an openapi-fetch client
34
- * and adds sdk.catalog.list(), sdk.cart.addItem(), etc. on top.
35
- *
36
- * For full type coverage (including plugin routes), use createClient()
37
- * with your own generated paths type instead.
38
- *
39
- * ```ts
40
- * import { createSDK } from "@porulle/sdk";
41
- * const sdk = createSDK({ baseUrl: "http://localhost:3000", auth: { ... } });
42
- * const { data } = await sdk.catalog.list();
43
- * ```
44
- */
45
- export declare function createSDK(options: SDKOptions): {
46
- raw: import("openapi-fetch").Client<Record<string, unknown>, `${string}/${string}`>;
47
- catalog: {
48
- list(query?: Record<string, string>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
49
- get(idOrSlug: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
50
- create(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
51
- };
52
- cart: {
53
- create(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
54
- get(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
55
- addItem(id: string, body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
56
- };
57
- checkout: {
58
- create(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
59
- };
60
- orders: {
61
- list(query?: Record<string, string>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
62
- get(idOrNumber: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
63
- create(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
64
- refund(id: string, body?: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
65
- capture(id: string, body?: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
66
- };
67
- search: {
68
- query(query: {
69
- q: string;
70
- [k: string]: string;
71
- }): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
72
- };
73
- me: {
74
- profile: {
75
- get(): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
76
- update(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
77
- };
78
- orders: {
79
- list(query?: Record<string, string>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
80
- get(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
81
- tracking(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
82
- reorder(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
83
- };
84
- };
85
- webhooks: {
86
- list(query?: Record<string, string>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
87
- get(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
88
- create(body: Record<string, unknown>): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
89
- delete(id: string): Promise<import("openapi-fetch").FetchResponse<unknown, never, `${string}/${string}`>>;
90
- };
91
- };
92
30
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,WAAW,UAAU;IACzB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAClC,kDAAkD;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,wDAAwD;IACxD,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,EAAE,EAAE,OAAO,EAAE,UAAU,iEAclE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,UAAU;;;q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U,CAAC,KAAK,GAAG,SAAS,CAAC;CAC7C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,EAAE,EAAE,OAAO,EAAE,UAAU,iEAclE"}
package/dist/client.js CHANGED
@@ -31,73 +31,4 @@ export function createClient(options) {
31
31
  }
32
32
  return client;
33
33
  }
34
- /**
35
- * Creates a typed SDK with ergonomic domain namespaces.
36
- *
37
- * This is a convenience wrapper that creates an openapi-fetch client
38
- * and adds sdk.catalog.list(), sdk.cart.addItem(), etc. on top.
39
- *
40
- * For full type coverage (including plugin routes), use createClient()
41
- * with your own generated paths type instead.
42
- *
43
- * ```ts
44
- * import { createSDK } from "@porulle/sdk";
45
- * const sdk = createSDK({ baseUrl: "http://localhost:3000", auth: { ... } });
46
- * const { data } = await sdk.catalog.list();
47
- * ```
48
- */
49
- export function createSDK(options) {
50
- const client = openapiCreateClient({ baseUrl: options.baseUrl, ...(options.headers ? { headers: options.headers } : {}), ...(options.fetch ? { fetch: options.fetch } : {}) });
51
- if (options.auth) {
52
- client.use(authMiddleware(options.auth));
53
- }
54
- // Untyped convenience wrappers for core routes.
55
- // These work without codegen but have no compile-time body/response validation.
56
- // For full types, use createClient<paths>() with your generated types.
57
- const raw = client;
58
- return {
59
- raw,
60
- catalog: {
61
- list(query) { return raw.GET("/api/catalog/entities", query ? { params: { query } } : undefined); },
62
- get(idOrSlug) { return raw.GET("/api/catalog/entities/{idOrSlug}", { params: { path: { idOrSlug } } }); },
63
- create(body) { return raw.POST("/api/catalog/entities", { body }); },
64
- },
65
- cart: {
66
- create(body) { return raw.POST("/api/carts", { body }); },
67
- get(id) { return raw.GET("/api/carts/{id}", { params: { path: { id } } }); },
68
- addItem(id, body) { return raw.POST("/api/carts/{id}/items", { params: { path: { id } }, body }); },
69
- },
70
- checkout: {
71
- create(body) { return raw.POST("/api/checkout", { body }); },
72
- },
73
- orders: {
74
- list(query) { return raw.GET("/api/orders", query ? { params: { query } } : undefined); },
75
- get(idOrNumber) { return raw.GET("/api/orders/{idOrNumber}", { params: { path: { idOrNumber } } }); },
76
- create(body) { return raw.POST("/api/orders", { body }); },
77
- refund(id, body) { return raw.POST("/api/orders/{id}/refund", { params: { path: { id } }, ...(body ? { body } : {}) }); },
78
- capture(id, body) { return raw.POST("/api/orders/{id}/capture", { params: { path: { id } }, ...(body ? { body } : {}) }); },
79
- },
80
- search: {
81
- query(query) { return raw.GET("/api/search", { params: { query } }); },
82
- },
83
- me: {
84
- profile: {
85
- get() { return raw.GET("/api/me/profile", undefined); },
86
- update(body) { return raw.PATCH("/api/me/profile", { body }); },
87
- },
88
- orders: {
89
- list(query) { return raw.GET("/api/me/orders", query ? { params: { query } } : undefined); },
90
- get(id) { return raw.GET("/api/me/orders/{id}", { params: { path: { id } } }); },
91
- tracking(id) { return raw.GET("/api/me/orders/{id}/tracking", { params: { path: { id } } }); },
92
- reorder(id) { return raw.POST("/api/me/orders/{id}/reorder", { params: { path: { id } } }); },
93
- },
94
- },
95
- webhooks: {
96
- list(query) { return raw.GET("/api/webhooks", query ? { params: { query } } : undefined); },
97
- get(id) { return raw.GET("/api/webhooks/{id}", { params: { path: { id } } }); },
98
- create(body) { return raw.POST("/api/webhooks", { body }); },
99
- delete(id) { return raw.DELETE("/api/webhooks/{id}", { params: { path: { id } } }); },
100
- },
101
- };
102
- }
103
34
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,eAAe,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AAatE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAoB,OAAmB;IACjE,MAAM,UAAU,GAAsD;QACpE,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;IACF,IAAI,OAAO,CAAC,OAAO;QAAE,UAAU,CAAC,OAAO,GAAG,OA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AAC,CAAC,CAAC;SAChH;KACF,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,cAAc,EAAuB,MAAM,iBAAiB,CAAC;AAatE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,YAAY,CAAoB,OAAmB;IACjE,MAAM,UAAU,GAAsD;QACpE,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;IACF,IAAI,OAAO,CAAC,OAAO;QAAE,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAC1D,IAAI,OAAO,CAAC,KAAK;QAAE,UAAU,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAEpD,MAAM,MAAM,GAAG,mBAAmB,CAAS,UAAU,CAAC,CAAC;IAEvD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createSDK, createClient, type SDKOptions } from "./client.js";
1
+ export { createClient, type SDKOptions } from "./client.js";
2
2
  export { OfflineQueue, memoryStorage, webStorage, type OfflineQueueOptions, type QueuedOperation, type QueueState, type QueueStorage, } from "./offline-queue.js";
3
3
  export { authMiddleware, type AuthCredential, type ApiKeyAuth, type BearerAuth } from "./middleware.js";
4
4
  export { isApiError, mapApiErrorToFields, type ApiErrorBody, type ValidationIssue, } from "./errors.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,YAAY,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxG,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { createSDK, createClient } from "./client.js";
1
+ export { createClient } from "./client.js";
2
2
  export { OfflineQueue, memoryStorage, webStorage, } from "./offline-queue.js";
3
3
  export { authMiddleware } from "./middleware.js";
4
4
  export { isApiError, mapApiErrorToFields, } from "./errors.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,GAKX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAyD,MAAM,iBAAiB,CAAC;AACxG,OAAO,EACL,UAAU,EACV,mBAAmB,GAGpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,YAAY,EACZ,aAAa,EACb,UAAU,GAKX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAyD,MAAM,iBAAiB,CAAC;AACxG,OAAO,EACL,UAAU,EACV,mBAAmB,GAGpB,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,18 @@
1
1
  {
2
2
  "name": "@porulle/sdk",
3
- "version": "0.64.0",
3
+ "version": "0.65.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
8
- "bun": "./src/index.ts",
9
- "import": "./dist/index.js",
10
- "types": "./dist/index.d.ts"
8
+ "@porulle/source": "./src/index.ts",
9
+ "types": "./dist/index.d.ts",
10
+ "default": "./dist/index.js"
11
11
  },
12
- "./react": {
13
- "bun": "./src/react.ts",
14
- "import": "./dist/react.js",
15
- "types": "./dist/react.d.ts"
16
- }
12
+ "./package.json": "./package.json"
13
+ },
14
+ "engines": {
15
+ "node": ">=20.19.0"
17
16
  },
18
17
  "bin": {
19
18
  "unifiedcommerce-sdk": "./dist/cli.js"
@@ -25,13 +24,11 @@
25
24
  "devDependencies": {
26
25
  "@types/node": "^24.5.2",
27
26
  "eslint": "^9.39.1",
28
- "openapi-react-query": "^0.5.4",
29
- "@tanstack/react-query": "^5.94.5",
30
27
  "openapi-typescript": "^7.13.0",
31
28
  "typescript": "5.9.2",
32
29
  "vitest": "^3.2.4",
33
- "@porulle/eslint-config": "0.1.0",
34
- "@porulle/typescript-config": "0.1.0"
30
+ "@porulle/typescript-config": "0.1.0",
31
+ "@porulle/eslint-config": "0.1.0"
35
32
  },
36
33
  "peerDependencies": {
37
34
  "@tanstack/react-query": ">=5.0.0",
package/src/client.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import openapiCreateClient from "openapi-fetch";
2
- import type { PathsWithMethod, MediaType } from "openapi-typescript-helpers";
3
2
  import { authMiddleware, type AuthCredential } from "./middleware.js";
4
3
 
5
4
  export interface SDKOptions {
@@ -45,85 +44,3 @@ export function createClient<TPaths extends {}>(options: SDKOptions) {
45
44
 
46
45
  return client;
47
46
  }
48
-
49
- /**
50
- * Creates a typed SDK with ergonomic domain namespaces.
51
- *
52
- * This is a convenience wrapper that creates an openapi-fetch client
53
- * and adds sdk.catalog.list(), sdk.cart.addItem(), etc. on top.
54
- *
55
- * For full type coverage (including plugin routes), use createClient()
56
- * with your own generated paths type instead.
57
- *
58
- * ```ts
59
- * import { createSDK } from "@porulle/sdk";
60
- * const sdk = createSDK({ baseUrl: "http://localhost:3000", auth: { ... } });
61
- * const { data } = await sdk.catalog.list();
62
- * ```
63
- */
64
- export function createSDK(options: SDKOptions) {
65
- const client = openapiCreateClient<Record<string, never>>(
66
- { baseUrl: options.baseUrl, ...(options.headers ? { headers: options.headers } : {}), ...(options.fetch ? { fetch: options.fetch } : {}) },
67
- );
68
-
69
- if (options.auth) {
70
- client.use(authMiddleware(options.auth));
71
- }
72
-
73
- // Untyped convenience wrappers for core routes.
74
- // These work without codegen but have no compile-time body/response validation.
75
- // For full types, use createClient<paths>() with your generated types.
76
- const raw = client as ReturnType<typeof openapiCreateClient<Record<string, unknown>>>;
77
-
78
- return {
79
- raw,
80
-
81
- catalog: {
82
- list(query?: Record<string, string>) { return raw.GET("/api/catalog/entities" as never, query ? { params: { query } } as never : undefined as never); },
83
- get(idOrSlug: string) { return raw.GET("/api/catalog/entities/{idOrSlug}" as never, { params: { path: { idOrSlug } } } as never); },
84
- create(body: Record<string, unknown>) { return raw.POST("/api/catalog/entities" as never, { body } as never); },
85
- },
86
-
87
- cart: {
88
- create(body: Record<string, unknown>) { return raw.POST("/api/carts" as never, { body } as never); },
89
- get(id: string) { return raw.GET("/api/carts/{id}" as never, { params: { path: { id } } } as never); },
90
- addItem(id: string, body: Record<string, unknown>) { return raw.POST("/api/carts/{id}/items" as never, { params: { path: { id } }, body } as never); },
91
- },
92
-
93
- checkout: {
94
- create(body: Record<string, unknown>) { return raw.POST("/api/checkout" as never, { body } as never); },
95
- },
96
-
97
- orders: {
98
- list(query?: Record<string, string>) { return raw.GET("/api/orders" as never, query ? { params: { query } } as never : undefined as never); },
99
- get(idOrNumber: string) { return raw.GET("/api/orders/{idOrNumber}" as never, { params: { path: { idOrNumber } } } as never); },
100
- create(body: Record<string, unknown>) { return raw.POST("/api/orders" as never, { body } as never); },
101
- refund(id: string, body?: Record<string, unknown>) { return raw.POST("/api/orders/{id}/refund" as never, { params: { path: { id } }, ...(body ? { body } : {}) } as never); },
102
- capture(id: string, body?: Record<string, unknown>) { return raw.POST("/api/orders/{id}/capture" as never, { params: { path: { id } }, ...(body ? { body } : {}) } as never); },
103
- },
104
-
105
- search: {
106
- query(query: { q: string; [k: string]: string }) { return raw.GET("/api/search" as never, { params: { query } } as never); },
107
- },
108
-
109
- me: {
110
- profile: {
111
- get() { return raw.GET("/api/me/profile" as never, undefined as never); },
112
- update(body: Record<string, unknown>) { return raw.PATCH("/api/me/profile" as never, { body } as never); },
113
- },
114
- orders: {
115
- list(query?: Record<string, string>) { return raw.GET("/api/me/orders" as never, query ? { params: { query } } as never : undefined as never); },
116
- get(id: string) { return raw.GET("/api/me/orders/{id}" as never, { params: { path: { id } } } as never); },
117
- tracking(id: string) { return raw.GET("/api/me/orders/{id}/tracking" as never, { params: { path: { id } } } as never); },
118
- reorder(id: string) { return raw.POST("/api/me/orders/{id}/reorder" as never, { params: { path: { id } } } as never); },
119
- },
120
- },
121
-
122
- webhooks: {
123
- list(query?: Record<string, string>) { return raw.GET("/api/webhooks" as never, query ? { params: { query } } as never : undefined as never); },
124
- get(id: string) { return raw.GET("/api/webhooks/{id}" as never, { params: { path: { id } } } as never); },
125
- create(body: Record<string, unknown>) { return raw.POST("/api/webhooks" as never, { body } as never); },
126
- delete(id: string) { return raw.DELETE("/api/webhooks/{id}" as never, { params: { path: { id } } } as never); },
127
- },
128
- };
129
- }
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createSDK, createClient, type SDKOptions } from "./client.js";
1
+ export { createClient, type SDKOptions } from "./client.js";
2
2
  export {
3
3
  OfflineQueue,
4
4
  memoryStorage,
package/dist/react.d.ts DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * React Query integration for the UnifiedCommerce SDK.
3
- *
4
- * Wraps any openapi-fetch client in TanStack Query hooks.
5
- * Generic — works with any generated paths type.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { createClient } from "@porulle/sdk";
10
- * import { createCommerceHooks } from "@porulle/sdk/react";
11
- * import type { paths } from "./generated/api-types";
12
- *
13
- * const client = createClient<paths>({ baseUrl: "http://localhost:3000" });
14
- * const commerce = createCommerceHooks(client);
15
- *
16
- * function ProductList() {
17
- * const { data } = commerce.useQuery("get", "/api/catalog/entities", {
18
- * params: { query: { type: "product" } },
19
- * });
20
- * }
21
- * ```
22
- */
23
- import type createOpenapiClient from "openapi-fetch";
24
- /**
25
- * Creates TanStack Query hooks from any typed openapi-fetch client.
26
- *
27
- * @param client - A typed openapi-fetch client (from createClient<paths>())
28
- * @returns useQuery, useMutation, useSuspenseQuery hooks typed against your paths
29
- */
30
- export declare function createCommerceHooks<TPaths extends {}>(client: ReturnType<typeof createOpenapiClient<TPaths>>): import("openapi-react-query").OpenapiQueryClient<TPaths, `${string}/${string}`>;
31
- /** Type alias for the hooks object returned by createCommerceHooks. */
32
- export type CommerceHooks<TPaths extends {} = {}> = ReturnType<typeof createCommerceHooks<TPaths>>;
33
- //# sourceMappingURL=react.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAGH,OAAO,KAAK,mBAAmB,MAAM,eAAe,CAAC;AAErD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,EAAE,EACnD,MAAM,EAAE,UAAU,CAAC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,mFAGvD;AAED,uEAAuE;AACvE,MAAM,MAAM,aAAa,CAAC,MAAM,SAAS,EAAE,GAAG,EAAE,IAAI,UAAU,CAAC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/dist/react.js DELETED
@@ -1,33 +0,0 @@
1
- /**
2
- * React Query integration for the UnifiedCommerce SDK.
3
- *
4
- * Wraps any openapi-fetch client in TanStack Query hooks.
5
- * Generic — works with any generated paths type.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { createClient } from "@porulle/sdk";
10
- * import { createCommerceHooks } from "@porulle/sdk/react";
11
- * import type { paths } from "./generated/api-types";
12
- *
13
- * const client = createClient<paths>({ baseUrl: "http://localhost:3000" });
14
- * const commerce = createCommerceHooks(client);
15
- *
16
- * function ProductList() {
17
- * const { data } = commerce.useQuery("get", "/api/catalog/entities", {
18
- * params: { query: { type: "product" } },
19
- * });
20
- * }
21
- * ```
22
- */
23
- import createQueryHooks from "openapi-react-query";
24
- /**
25
- * Creates TanStack Query hooks from any typed openapi-fetch client.
26
- *
27
- * @param client - A typed openapi-fetch client (from createClient<paths>())
28
- * @returns useQuery, useMutation, useSuspenseQuery hooks typed against your paths
29
- */
30
- export function createCommerceHooks(client) {
31
- return createQueryHooks(client);
32
- }
33
- //# sourceMappingURL=react.js.map
package/dist/react.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAsD;IAEtD,OAAO,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAClC,CAAC"}
package/src/react.ts DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * React Query integration for the UnifiedCommerce SDK.
3
- *
4
- * Wraps any openapi-fetch client in TanStack Query hooks.
5
- * Generic — works with any generated paths type.
6
- *
7
- * @example
8
- * ```typescript
9
- * import { createClient } from "@porulle/sdk";
10
- * import { createCommerceHooks } from "@porulle/sdk/react";
11
- * import type { paths } from "./generated/api-types";
12
- *
13
- * const client = createClient<paths>({ baseUrl: "http://localhost:3000" });
14
- * const commerce = createCommerceHooks(client);
15
- *
16
- * function ProductList() {
17
- * const { data } = commerce.useQuery("get", "/api/catalog/entities", {
18
- * params: { query: { type: "product" } },
19
- * });
20
- * }
21
- * ```
22
- */
23
-
24
- import createQueryHooks from "openapi-react-query";
25
- import type createOpenapiClient from "openapi-fetch";
26
-
27
- /**
28
- * Creates TanStack Query hooks from any typed openapi-fetch client.
29
- *
30
- * @param client - A typed openapi-fetch client (from createClient<paths>())
31
- * @returns useQuery, useMutation, useSuspenseQuery hooks typed against your paths
32
- */
33
- export function createCommerceHooks<TPaths extends {}>(
34
- client: ReturnType<typeof createOpenapiClient<TPaths>>,
35
- ) {
36
- return createQueryHooks(client);
37
- }
38
-
39
- /** Type alias for the hooks object returned by createCommerceHooks. */
40
- export type CommerceHooks<TPaths extends {} = {}> = ReturnType<typeof createCommerceHooks<TPaths>>;