@simplix-react/react 0.0.2 → 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 +2 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -2
- package/package.json +20 -16
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ pnpm add @simplix-react/react
|
|
|
22
22
|
## Quick Example
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import { defineApi } from "@simplix-react/contract";
|
|
25
|
+
import { defineApi, simpleQueryBuilder } from "@simplix-react/contract";
|
|
26
26
|
import { deriveHooks } from "@simplix-react/react";
|
|
27
27
|
import { z } from "zod";
|
|
28
28
|
|
|
@@ -38,6 +38,7 @@ const projectContract = defineApi({
|
|
|
38
38
|
updateSchema: z.object({ title: z.string().optional(), status: z.string().optional() }),
|
|
39
39
|
},
|
|
40
40
|
},
|
|
41
|
+
queryBuilder: simpleQueryBuilder,
|
|
41
42
|
});
|
|
42
43
|
|
|
43
44
|
// 2. Derive hooks — one call generates everything
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ListParams, PageInfo,
|
|
2
|
-
import { z } from 'zod';
|
|
1
|
+
import { ListParams, PageInfo, AnyEntityDef, AnyOperationDef, ApiContractConfig, QueryKeyFactory, OperationDefinition } from '@simplix-react/contract';
|
|
3
2
|
import { UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult, UseInfiniteQueryResult } from '@tanstack/react-query';
|
|
3
|
+
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Represents a derived list query hook with overloaded call signatures.
|
|
@@ -223,8 +223,6 @@ interface OperationHooks<TInput extends z.ZodTypeAny, TOutput extends z.ZodTypeA
|
|
|
223
223
|
useMutation: OperationMutationHook<z.infer<TInput>, z.infer<TOutput>>;
|
|
224
224
|
}
|
|
225
225
|
|
|
226
|
-
type AnyEntityDef = EntityDefinition<z.ZodTypeAny, z.ZodTypeAny, z.ZodTypeAny>;
|
|
227
|
-
type AnyOperationDef = OperationDefinition<z.ZodTypeAny, z.ZodTypeAny>;
|
|
228
226
|
/**
|
|
229
227
|
* Derives type-safe React Query hooks from an API contract.
|
|
230
228
|
*
|
package/dist/index.js
CHANGED
|
@@ -131,11 +131,11 @@ function createEntityHooks(entity, entityClient, keys, _allQueryKeys, _config) {
|
|
|
131
131
|
return entityClient.list(listParams);
|
|
132
132
|
},
|
|
133
133
|
initialPageParam: 1,
|
|
134
|
-
getNextPageParam: (lastPage) => {
|
|
134
|
+
getNextPageParam: (lastPage, _allPages, lastPageParam) => {
|
|
135
135
|
const page = lastPage;
|
|
136
136
|
if (!page.meta?.hasNextPage) return void 0;
|
|
137
137
|
if (page.meta.nextCursor) return page.meta.nextCursor;
|
|
138
|
-
return void 0;
|
|
138
|
+
return typeof lastPageParam === "number" ? lastPageParam + 1 : void 0;
|
|
139
139
|
},
|
|
140
140
|
enabled: entity.parent ? !!parentId : true,
|
|
141
141
|
...options
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplix-react/react",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "React Query hooks derived from @simplix-react/contract",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
6
7
|
"exports": {
|
|
7
8
|
".": {
|
|
8
9
|
"types": "./dist/index.d.ts",
|
|
@@ -15,31 +16,34 @@
|
|
|
15
16
|
"publishConfig": {
|
|
16
17
|
"access": "public"
|
|
17
18
|
},
|
|
18
|
-
"scripts": {
|
|
19
|
-
"build": "tsup",
|
|
20
|
-
"dev": "tsup --watch",
|
|
21
|
-
"typecheck": "tsc --noEmit",
|
|
22
|
-
"lint": "eslint src",
|
|
23
|
-
"test": "vitest run --passWithNoTests",
|
|
24
|
-
"clean": "rm -rf dist .turbo"
|
|
25
|
-
},
|
|
26
19
|
"peerDependencies": {
|
|
27
|
-
"@simplix-react/contract": "workspace:*",
|
|
28
20
|
"@tanstack/react-query": ">=5.0.0",
|
|
29
21
|
"react": ">=18.0.0",
|
|
30
|
-
"zod": ">=4.0.0"
|
|
22
|
+
"zod": ">=4.0.0",
|
|
23
|
+
"@simplix-react/contract": "0.1.0"
|
|
31
24
|
},
|
|
32
25
|
"devDependencies": {
|
|
33
|
-
"@simplix-react/config-eslint": "workspace:*",
|
|
34
|
-
"@simplix-react/config-typescript": "workspace:*",
|
|
35
|
-
"@simplix-react/contract": "workspace:*",
|
|
36
26
|
"@tanstack/react-query": "^5.0.0",
|
|
27
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
28
|
+
"@testing-library/react": "^16.3.2",
|
|
37
29
|
"@types/react": "^19.0.0",
|
|
38
30
|
"eslint": "^9.39.2",
|
|
31
|
+
"jsdom": "^28.0.0",
|
|
39
32
|
"react": "^19.0.0",
|
|
40
33
|
"tsup": "^8.5.1",
|
|
41
34
|
"typescript": "^5.9.3",
|
|
42
35
|
"vitest": "^3.0.0",
|
|
43
|
-
"zod": "^4.0.0"
|
|
36
|
+
"zod": "^4.0.0",
|
|
37
|
+
"@simplix-react/config-eslint": "0.0.1",
|
|
38
|
+
"@simplix-react/contract": "0.1.0",
|
|
39
|
+
"@simplix-react/config-typescript": "0.0.1"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsup",
|
|
43
|
+
"dev": "tsup --watch",
|
|
44
|
+
"typecheck": "tsc --noEmit",
|
|
45
|
+
"lint": "eslint src",
|
|
46
|
+
"test": "vitest run --passWithNoTests",
|
|
47
|
+
"clean": "rm -rf dist .turbo"
|
|
44
48
|
}
|
|
45
|
-
}
|
|
49
|
+
}
|