@codewithagents/openapi-react-query 3.5.1 → 3.5.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/dist/plugins/hooks.js +7 -7
- package/dist/plugins/hooks.js.map +1 -1
- package/package.json +5 -2
- package/CHANGELOG.md +0 -161
- package/CLAUDE.md +0 -30
- package/__fixtures__/specs/task-hooks.json +0 -170
- package/src/__tests__/__snapshots__/hooks.test.ts.snap +0 -457
- package/src/__tests__/compat-matrix.test.ts +0 -25
- package/src/__tests__/config.test.ts +0 -291
- package/src/__tests__/hooks.property.test.ts +0 -310
- package/src/__tests__/hooks.test.ts +0 -1845
- package/src/__tests__/prettier-output.test.ts +0 -45
- package/src/__tests__/test-utils.test.ts +0 -69
- package/src/cli.ts +0 -27
- package/src/config.ts +0 -171
- package/src/generator.ts +0 -50
- package/src/plugins/hooks.ts +0 -823
- package/src/plugins/test-utils.ts +0 -77
- package/stryker.config.json +0 -19
- package/tsconfig.build.json +0 -10
- package/tsconfig.json +0 -9
- package/vitest.config.ts +0 -12
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { OpenAPIV3_1 } from 'openapi-types'
|
|
2
|
-
|
|
3
|
-
export interface GeneratedFile {
|
|
4
|
-
filename: string
|
|
5
|
-
content: string
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Generate `test-utils.ts` — a set of testing helpers for the generated hooks.
|
|
10
|
-
*
|
|
11
|
-
* Zero new dependencies: everything imported here is already a peer dependency
|
|
12
|
-
* that any consumer of `@codewithagents/openapi-react-query` must have:
|
|
13
|
-
* - `@tanstack/react-query` — QueryClient, QueryClientProvider
|
|
14
|
-
* - `react` — ReactNode, createElement
|
|
15
|
-
*
|
|
16
|
-
* Consumers bring their own test runner / MSW / @testing-library/react.
|
|
17
|
-
* This file just eliminates the boilerplate they'd write in every test suite.
|
|
18
|
-
*/
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
export function generateTestUtils(_spec: OpenAPIV3_1.Document): GeneratedFile {
|
|
21
|
-
const lines: string[] = []
|
|
22
|
-
|
|
23
|
-
lines.push('// This file is auto-generated by @codewithagents/openapi-react-query — do not edit')
|
|
24
|
-
lines.push('')
|
|
25
|
-
lines.push("import { QueryClient, QueryClientProvider } from '@tanstack/react-query'")
|
|
26
|
-
lines.push("import { createElement, type ReactNode } from 'react'")
|
|
27
|
-
lines.push('')
|
|
28
|
-
|
|
29
|
-
// createTestQueryClient
|
|
30
|
-
lines.push('/**')
|
|
31
|
-
lines.push(' * Creates a QueryClient pre-configured for testing.')
|
|
32
|
-
lines.push(' *')
|
|
33
|
-
lines.push(' * Differences from the production default:')
|
|
34
|
-
lines.push(' * - `retry: false` — tests should not retry on failure')
|
|
35
|
-
lines.push(' * - `gcTime: 0` — no garbage-collection delay between tests')
|
|
36
|
-
lines.push(' */')
|
|
37
|
-
lines.push('export function createTestQueryClient(): QueryClient {')
|
|
38
|
-
lines.push(' return new QueryClient({')
|
|
39
|
-
lines.push(' defaultOptions: {')
|
|
40
|
-
lines.push(' queries: {')
|
|
41
|
-
lines.push(' retry: false,')
|
|
42
|
-
lines.push(' gcTime: 0,')
|
|
43
|
-
lines.push(' },')
|
|
44
|
-
lines.push(' mutations: {')
|
|
45
|
-
lines.push(' retry: false,')
|
|
46
|
-
lines.push(' },')
|
|
47
|
-
lines.push(' },')
|
|
48
|
-
lines.push(' })')
|
|
49
|
-
lines.push('}')
|
|
50
|
-
lines.push('')
|
|
51
|
-
|
|
52
|
-
// createWrapper
|
|
53
|
-
lines.push('/**')
|
|
54
|
-
lines.push(' * Returns a wrapper component that provides a `QueryClientProvider`.')
|
|
55
|
-
lines.push(' * Pass it as the `wrapper` option to `renderHook` from `@testing-library/react`.')
|
|
56
|
-
lines.push(' *')
|
|
57
|
-
lines.push(' * @example')
|
|
58
|
-
lines.push(' * ```ts')
|
|
59
|
-
lines.push(' * const queryClient = createTestQueryClient()')
|
|
60
|
-
lines.push(' * const wrapper = createWrapper(queryClient)')
|
|
61
|
-
lines.push(' * const { result } = renderHook(() => useListTasks(), { wrapper })')
|
|
62
|
-
lines.push(' * ```')
|
|
63
|
-
lines.push(' */')
|
|
64
|
-
lines.push('export function createWrapper(')
|
|
65
|
-
lines.push(' queryClient: QueryClient,')
|
|
66
|
-
lines.push('): ({ children }: { children: ReactNode }) => ReactNode {')
|
|
67
|
-
lines.push(' return function Wrapper({ children }: { children: ReactNode }): ReactNode {')
|
|
68
|
-
lines.push(' return createElement(QueryClientProvider, { client: queryClient }, children)')
|
|
69
|
-
lines.push(' }')
|
|
70
|
-
lines.push('}')
|
|
71
|
-
lines.push('')
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
filename: 'test-utils.ts',
|
|
75
|
-
content: lines.join('\n'),
|
|
76
|
-
}
|
|
77
|
-
}
|
package/stryker.config.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
|
|
3
|
-
"testRunner": "vitest",
|
|
4
|
-
"plugins": ["@stryker-mutator/vitest-runner"],
|
|
5
|
-
"vitest": {
|
|
6
|
-
"configFile": "vitest.config.ts"
|
|
7
|
-
},
|
|
8
|
-
"mutate": ["src/**/*.ts", "!src/**/__tests__/**", "!src/**/*.d.ts"],
|
|
9
|
-
"coverageAnalysis": "perTest",
|
|
10
|
-
"thresholds": {
|
|
11
|
-
"high": 80,
|
|
12
|
-
"low": 60,
|
|
13
|
-
"break": 0
|
|
14
|
-
},
|
|
15
|
-
"reporters": ["html", "progress", "clear-text"],
|
|
16
|
-
"htmlReporter": {
|
|
17
|
-
"fileName": "reports/mutation/mutation.html"
|
|
18
|
-
}
|
|
19
|
-
}
|
package/tsconfig.build.json
DELETED
package/tsconfig.json
DELETED
package/vitest.config.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vitest/config'
|
|
2
|
-
|
|
3
|
-
export default defineConfig({
|
|
4
|
-
test: {
|
|
5
|
-
coverage: {
|
|
6
|
-
provider: 'v8',
|
|
7
|
-
include: ['src/**/*.ts'],
|
|
8
|
-
exclude: ['src/**/*.test.ts', 'src/cli.ts', 'src/generator.ts'],
|
|
9
|
-
reporter: ['text', ['lcov', { projectRoot: '../../' }]],
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
})
|