@spoosh/plugin-qs 0.1.1 → 0.1.3
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 +26 -10
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,13 +13,13 @@ npm install @spoosh/plugin-qs
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
+
import { Spoosh } from "@spoosh/core";
|
|
16
17
|
import { qsPlugin } from "@spoosh/plugin-qs";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
qsPlugin({ arrayFormat: "brackets" }),
|
|
20
|
-
]
|
|
19
|
+
const client = new Spoosh<ApiSchema, Error>("/api").use([
|
|
20
|
+
qsPlugin({ arrayFormat: "brackets" }),
|
|
21
|
+
]);
|
|
21
22
|
|
|
22
|
-
// Query object
|
|
23
23
|
const query = {
|
|
24
24
|
pagination: { limit: 10, offset: 0 },
|
|
25
25
|
filters: { status: "active", tags: ["a", "b"] },
|
|
@@ -67,28 +67,36 @@ useRead((api) => api.data.$get({ query }), { skipNulls: false });
|
|
|
67
67
|
### brackets (default)
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
|
-
{
|
|
70
|
+
{
|
|
71
|
+
tags: ["a", "b"];
|
|
72
|
+
}
|
|
71
73
|
// tags[]=a&tags[]=b
|
|
72
74
|
```
|
|
73
75
|
|
|
74
76
|
### indices
|
|
75
77
|
|
|
76
78
|
```typescript
|
|
77
|
-
{
|
|
79
|
+
{
|
|
80
|
+
tags: ["a", "b"];
|
|
81
|
+
}
|
|
78
82
|
// tags[0]=a&tags[1]=b
|
|
79
83
|
```
|
|
80
84
|
|
|
81
85
|
### repeat
|
|
82
86
|
|
|
83
87
|
```typescript
|
|
84
|
-
{
|
|
88
|
+
{
|
|
89
|
+
tags: ["a", "b"];
|
|
90
|
+
}
|
|
85
91
|
// tags=a&tags=b
|
|
86
92
|
```
|
|
87
93
|
|
|
88
94
|
### comma
|
|
89
95
|
|
|
90
96
|
```typescript
|
|
91
|
-
{
|
|
97
|
+
{
|
|
98
|
+
tags: ["a", "b"];
|
|
99
|
+
}
|
|
92
100
|
// tags=a,b
|
|
93
101
|
```
|
|
94
102
|
|
|
@@ -96,10 +104,18 @@ useRead((api) => api.data.$get({ query }), { skipNulls: false });
|
|
|
96
104
|
|
|
97
105
|
```typescript
|
|
98
106
|
// allowDots: false (default)
|
|
99
|
-
{
|
|
107
|
+
{
|
|
108
|
+
filters: {
|
|
109
|
+
status: "active";
|
|
110
|
+
}
|
|
111
|
+
}
|
|
100
112
|
// filters[status]=active
|
|
101
113
|
|
|
102
114
|
// allowDots: true
|
|
103
|
-
{
|
|
115
|
+
{
|
|
116
|
+
filters: {
|
|
117
|
+
status: "active";
|
|
118
|
+
}
|
|
119
|
+
}
|
|
104
120
|
// filters.status=active
|
|
105
121
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -43,7 +43,13 @@ type QsWriteResult = object;
|
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
-
*
|
|
46
|
+
* import { Spoosh } from "@spoosh/core";
|
|
47
|
+
*
|
|
48
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
49
|
+
* .use([
|
|
50
|
+
* // ... other plugins
|
|
51
|
+
* qsPlugin({ arrayFormat: "brackets" }),
|
|
52
|
+
* ]);
|
|
47
53
|
*
|
|
48
54
|
* // Query: { filters: { status: "active", tags: ["a", "b"] } }
|
|
49
55
|
* // Result: filters[status]=active&filters[tags][]=a&filters[tags][]=b
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,13 @@ type QsWriteResult = object;
|
|
|
43
43
|
*
|
|
44
44
|
* @example
|
|
45
45
|
* ```ts
|
|
46
|
-
*
|
|
46
|
+
* import { Spoosh } from "@spoosh/core";
|
|
47
|
+
*
|
|
48
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
49
|
+
* .use([
|
|
50
|
+
* // ... other plugins
|
|
51
|
+
* qsPlugin({ arrayFormat: "brackets" }),
|
|
52
|
+
* ]);
|
|
47
53
|
*
|
|
48
54
|
* // Query: { filters: { status: "active", tags: ["a", "b"] } }
|
|
49
55
|
* // Result: filters[status]=active&filters[tags][]=a&filters[tags][]=b
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-qs",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Query string serialization plugin for Spoosh with nested object support",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"qs": "^6.13.0"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@spoosh/core": ">=0.
|
|
40
|
+
"@spoosh/core": ">=0.4.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/qs": "^6.9.17",
|
|
44
|
-
"@spoosh/core": "0.
|
|
45
|
-
"@spoosh/test-utils": "0.1.
|
|
44
|
+
"@spoosh/core": "0.4.0",
|
|
45
|
+
"@spoosh/test-utils": "0.1.4"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"dev": "tsup --watch",
|