@spoosh/plugin-transform 0.1.0-beta.0 → 0.1.2
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 +5 -2
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -15,11 +15,14 @@ npm install @spoosh/plugin-transform
|
|
|
15
15
|
### Request Transforms
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
+
import { Spoosh } from "@spoosh/core";
|
|
18
19
|
import { transformPlugin } from "@spoosh/plugin-transform";
|
|
19
20
|
|
|
20
|
-
const
|
|
21
|
+
const client = new Spoosh<ApiSchema, Error>("/api")
|
|
22
|
+
.use([
|
|
23
|
+
transformPlugin(),
|
|
24
|
+
]);
|
|
21
25
|
|
|
22
|
-
// Transform query parameters
|
|
23
26
|
const { data } = useRead((api) => api.posts.$get({ query: { page: 1 } }), {
|
|
24
27
|
transform: {
|
|
25
28
|
query: (q) => ({ ...q, limit: 10 }),
|
package/dist/index.d.mts
CHANGED
|
@@ -96,6 +96,14 @@ declare module "@spoosh/core" {
|
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
98
|
* ```ts
|
|
99
|
+
* import { Spoosh } from "@spoosh/core";
|
|
100
|
+
*
|
|
101
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
102
|
+
* .use([
|
|
103
|
+
* // ... other plugins
|
|
104
|
+
* transformPlugin(),
|
|
105
|
+
* ]);
|
|
106
|
+
*
|
|
99
107
|
* // Per-request transforms with full type inference
|
|
100
108
|
* const { data, transformedData } = useRead(
|
|
101
109
|
* (api) => api.posts.$get(),
|
|
@@ -109,8 +117,6 @@ declare module "@spoosh/core" {
|
|
|
109
117
|
* },
|
|
110
118
|
* }
|
|
111
119
|
* );
|
|
112
|
-
* // data = original posts array (preserved)
|
|
113
|
-
* // transformedData = { count: number, hasMore: boolean }
|
|
114
120
|
*
|
|
115
121
|
* // useWrite with body transform
|
|
116
122
|
* trigger({
|
package/dist/index.d.ts
CHANGED
|
@@ -96,6 +96,14 @@ declare module "@spoosh/core" {
|
|
|
96
96
|
*
|
|
97
97
|
* @example
|
|
98
98
|
* ```ts
|
|
99
|
+
* import { Spoosh } from "@spoosh/core";
|
|
100
|
+
*
|
|
101
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
102
|
+
* .use([
|
|
103
|
+
* // ... other plugins
|
|
104
|
+
* transformPlugin(),
|
|
105
|
+
* ]);
|
|
106
|
+
*
|
|
99
107
|
* // Per-request transforms with full type inference
|
|
100
108
|
* const { data, transformedData } = useRead(
|
|
101
109
|
* (api) => api.posts.$get(),
|
|
@@ -109,8 +117,6 @@ declare module "@spoosh/core" {
|
|
|
109
117
|
* },
|
|
110
118
|
* }
|
|
111
119
|
* );
|
|
112
|
-
* // data = original posts array (preserved)
|
|
113
|
-
* // transformedData = { count: number, hasMore: boolean }
|
|
114
120
|
*
|
|
115
121
|
* // useWrite with body transform
|
|
116
122
|
* trigger({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-transform",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Data transformation plugin for Spoosh with sync/async support",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
40
|
-
"@spoosh/test-utils": "0.1.
|
|
39
|
+
"@spoosh/core": "0.3.0",
|
|
40
|
+
"@spoosh/test-utils": "0.1.3"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|