@data-client/vue 0.15.2 → 0.15.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/CHANGELOG.md +6 -0
- package/README.md +11 -3
- package/package.json +2 -2
- package/src/__tests__/useQuery.web.ts +8 -8
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -36,6 +36,14 @@ npm install --save @data-client/vue @data-client/rest
|
|
|
36
36
|
|
|
37
37
|
For more details, see [the Installation docs page](https://dataclient.io/docs/getting-started/installation).
|
|
38
38
|
|
|
39
|
+
### Skills
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npx skills add reactive/data-client
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Then run [skill](https://agentskills.io) "data-client-setup"
|
|
46
|
+
|
|
39
47
|
## Usage
|
|
40
48
|
|
|
41
49
|
### Simple [TypeScript definition](https://dataclient.io/rest/api/Entity)
|
|
@@ -151,8 +159,8 @@ ctrl.set(Article, { id }, articleData);
|
|
|
151
159
|
### [Programmatic queries](https://dataclient.io/rest/api/Query)
|
|
152
160
|
|
|
153
161
|
```typescript
|
|
154
|
-
const queryTotalVotes = new
|
|
155
|
-
new
|
|
162
|
+
const queryTotalVotes = new Query(
|
|
163
|
+
new Collection([BlogPost]),
|
|
156
164
|
posts => posts.reduce((total, post) => total + post.votes, 0),
|
|
157
165
|
);
|
|
158
166
|
|
|
@@ -161,7 +169,7 @@ const totalVotesForUser = useQuery(queryTotalVotes, { userId });
|
|
|
161
169
|
```
|
|
162
170
|
|
|
163
171
|
```typescript
|
|
164
|
-
const groupTodoByUser = new
|
|
172
|
+
const groupTodoByUser = new Query(
|
|
165
173
|
TodoResource.getList.schema,
|
|
166
174
|
todos => Object.groupBy(todos, todo => todo.userId),
|
|
167
175
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@data-client/vue",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.3",
|
|
4
4
|
"description": "Async State Management without the Management. REST, GraphQL, SSE, Websockets, Fetch",
|
|
5
5
|
"homepage": "https://dataclient.io",
|
|
6
6
|
"repository": {
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@anansi/browserslist-config": "^1.4.2",
|
|
114
|
-
"@data-client/rest": "0.15.
|
|
114
|
+
"@data-client/rest": "0.15.6",
|
|
115
115
|
"@jest/globals": "^30.0.0",
|
|
116
116
|
"@js-temporal/polyfill": "^0.5.0",
|
|
117
117
|
"@types/jest": "30.0.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { schema } from '@data-client/endpoint';
|
|
1
|
+
import { schema, All, Collection } from '@data-client/endpoint';
|
|
2
2
|
import { resource } from '@data-client/rest';
|
|
3
3
|
import { reactive, computed } from 'vue';
|
|
4
4
|
|
|
@@ -59,7 +59,7 @@ describe('vue useQuery()', () => {
|
|
|
59
59
|
|
|
60
60
|
it('All should be undefined with empty state', async () => {
|
|
61
61
|
const { result } = await renderDataCompose(() => {
|
|
62
|
-
return useQuery(new
|
|
62
|
+
return useQuery(new All(ArticleWithSlug));
|
|
63
63
|
}, {});
|
|
64
64
|
// @ts-expect-error
|
|
65
65
|
result.value?.doesnotexist;
|
|
@@ -195,7 +195,7 @@ describe('vue useQuery()', () => {
|
|
|
195
195
|
|
|
196
196
|
static key = 'User';
|
|
197
197
|
static schema = {
|
|
198
|
-
todos: new
|
|
198
|
+
todos: new Collection(new schema.Array(Todo), {
|
|
199
199
|
nestKey: parent => ({
|
|
200
200
|
userId: parent.id,
|
|
201
201
|
}),
|
|
@@ -203,7 +203,7 @@ describe('vue useQuery()', () => {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
const userTodos = new
|
|
206
|
+
const userTodos = new Collection(new schema.Array(Todo), {
|
|
207
207
|
argsKey: ({ userId }: { userId: string }) => ({
|
|
208
208
|
userId,
|
|
209
209
|
}),
|
|
@@ -495,7 +495,7 @@ describe('vue useQuery()', () => {
|
|
|
495
495
|
|
|
496
496
|
static key = 'User';
|
|
497
497
|
static schema = {
|
|
498
|
-
todos: new
|
|
498
|
+
todos: new Collection(new schema.Array(Todo), {
|
|
499
499
|
nestKey: parent => ({
|
|
500
500
|
userId: parent.id,
|
|
501
501
|
}),
|
|
@@ -503,7 +503,7 @@ describe('vue useQuery()', () => {
|
|
|
503
503
|
};
|
|
504
504
|
}
|
|
505
505
|
|
|
506
|
-
const userTodos = new
|
|
506
|
+
const userTodos = new Collection(new schema.Array(Todo), {
|
|
507
507
|
argsKey: ({ userId }: { userId: string }) => ({
|
|
508
508
|
userId,
|
|
509
509
|
}),
|
|
@@ -588,7 +588,7 @@ describe('vue useQuery()', () => {
|
|
|
588
588
|
|
|
589
589
|
static key = 'User';
|
|
590
590
|
static schema = {
|
|
591
|
-
todos: new
|
|
591
|
+
todos: new Collection(new schema.Array(Todo), {
|
|
592
592
|
nestKey: parent => ({
|
|
593
593
|
userId: parent.id,
|
|
594
594
|
}),
|
|
@@ -596,7 +596,7 @@ describe('vue useQuery()', () => {
|
|
|
596
596
|
};
|
|
597
597
|
}
|
|
598
598
|
|
|
599
|
-
const userTodos = new
|
|
599
|
+
const userTodos = new Collection(new schema.Array(Todo), {
|
|
600
600
|
argsKey: ({ userId }: { userId: string }) => ({
|
|
601
601
|
userId,
|
|
602
602
|
}),
|