@uiwwsw/react-query-helper 1.3.0 โ†’ 2.0.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/CHANGELOG.md ADDED
@@ -0,0 +1,50 @@
1
+ # Changelog
2
+
3
+ ## 2.0.2
4
+
5
+ - Shorten the README to what works, what is not done, and how it compares with OpenAPI-based generators; move the details into docs/GUIDE.md. No code changes.
6
+
7
+ ## 2.0.1
8
+
9
+ The v2.0.0 tag was not published to npm. This release includes all of the 2.0.0
10
+ changes below, including the breaking changes for applications upgrading from 1.x.
11
+
12
+ - Simplify Korean/English onboarding and move detailed configuration and recipes into reference guides.
13
+ - Introduce the Q symbol, light/dark README banners, and documented brand assets.
14
+ - Add regression tests for documentation links, SVG assets, and generated/typechecked README examples.
15
+ - Refresh release guidance and source-install examples for 2.0.1.
16
+
17
+ ## 2.0.0
18
+
19
+ ### Breaking Changes
20
+
21
+ - Require TanStack Query >=5.102.8 <6. Node 22 remains the minimum CLI runtime.
22
+ - Generated path keys now include filenames. Query/infinite keys use separate kind segments and nested argument tuples. Invalidate persisted 1.x caches and update manually constructed keys.
23
+ - Remove forced infinite cache/stale times and disabled focus refetching. QueryClient defaults now apply.
24
+ - Single-array mutation payloads are passed intact. Direct multi-argument helpers require an explicit mapper or tuple mode.
25
+ - Refuse to overwrite output without this generator's ownership marker. Move legacy generated files aside and regenerate.
26
+ - Built-in generation rejects private imports, invalid identifiers, duplicate names and invalid configuration.
27
+
28
+ ### Fixed
29
+
30
+ - Starter configs no longer reference missing plugins or assume an application alias.
31
+ - Correct InfiniteData, pageParam, select, default error, cache data-tag and optimistic rollback inference.
32
+ - Forward query/mutation context, including QueryClient and AbortSignal, to custom callbacks.
33
+ - Convert synchronous callback failures to rejected promises.
34
+ - Support default/local alias exports, skip ambient declarations and duplicate overload signatures.
35
+ - Preserve optional multi-argument mutation fields and handle rest/destructured parameters using tuples.
36
+ - Include source filenames in cache prefixes and avoid unused/colliding helper imports.
37
+ - Honor empty artifact lists and provide per-function artifact selection.
38
+ - Load TypeScript/CommonJS configs and plugins with relative imports through Jiti; validate options and plugin contracts.
39
+ - Exclude output directories from source scans; support standard ignore globs; detect symlink and output collisions.
40
+ - Reconcile only owned stale files after a successful analysis, avoid unchanged writes, serialize watch passes and recover after errors.
41
+ - Wait for watcher readiness and reconcile startup edits before announcing that watch is active.
42
+ - Report generation failures with nonzero exit codes; add explicit config selection and read-only output checks.
43
+
44
+ ### Maintenance
45
+
46
+ - Replace the Bun-only build with a Node/esbuild build; preserve a browser-safe runtime and NodeNext-compatible declarations.
47
+ - Use one npm lockfile; remove obsolete scripts, the fs placeholder dependency and Bun ambient types.
48
+ - Add runtime, CLI, emitted-code, type-inference and installed-package tests.
49
+ - Add Node 22/24 CI and pre-publish tests, consumer checks, tag/version validation and provenance.
50
+ - Rewrite Korean/English documentation with usage, limitations and migration steps.
package/README.md CHANGED
@@ -1,418 +1,165 @@
1
1
  <p align="center">
2
- <img src="https://raw.githubusercontent.com/uiwwsw/react-query-helper/main/assets/logo.svg" alt="React Query Helper Logo" width="160" />
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/uiwwsw/react-query-helper/main/assets/readme-hero-dark.svg" />
4
+ <img src="https://raw.githubusercontent.com/uiwwsw/react-query-helper/main/assets/readme-hero.svg" alt="React Query Helper logo" width="1120" />
5
+ </picture>
3
6
  </p>
4
7
 
5
8
  <h1 align="center">React Query Helper</h1>
6
9
 
7
10
  <p align="center">
8
- <a href="README_EN.md">๐Ÿ‡บ๐Ÿ‡ธ English</a> ยท <strong>๐Ÿ‡ฐ๐Ÿ‡ท ํ•œ๊ตญ์–ด</strong>
11
+ TypeScript API ํ•จ์ˆ˜ ํŒŒ์ผ์—์„œ ์ฟผ๋ฆฌ ํ‚ค์™€ TanStack Query v5 ์˜ต์…˜ ํŒฉํ† ๋ฆฌ(<code>queryOptions</code>, <code>infiniteQueryOptions</code>, <code>mutationOptions</code> ํ˜ธ์ถœ ์ฝ”๋“œ)๋ฅผ ์ƒ์„ฑํ•˜๋Š” CLI์™€ ๋Ÿฐํƒ€์ž„ ํ—ฌํผ์ž…๋‹ˆ๋‹ค.
9
12
  </p>
10
13
 
11
14
  <p align="center">
12
- <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/v/@uiwwsw/react-query-helper.svg?color=2563eb" alt="npm version" /></a>
13
- <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/dm/@uiwwsw/react-query-helper.svg?color=9333ea" alt="npm downloads" /></a>
14
- <a href="https://bundlephobia.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/bundlephobia/minzip/@uiwwsw/react-query-helper.svg?color=10b981" alt="bundle size" /></a>
15
- <a href="https://github.com/uiwwsw/react-query-helper/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-10b981.svg" alt="license" /></a>
16
- <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/types/@uiwwsw/react-query-helper.svg?color=3178c6" alt="types" /></a>
17
- </p>
18
- <p align="center">
19
- <a href="https://github.com/uiwwsw/react-query-helper"><img src="https://img.shields.io/github/stars/uiwwsw/react-query-helper?style=social" alt="github stars" /></a>
15
+ <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/v/@uiwwsw/react-query-helper?style=flat-square" alt="npm ๋ฒ„์ „" /></a>
16
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@uiwwsw/react-query-helper?style=flat-square" alt="๋ผ์ด์„ ์Šค" /></a>
17
+ <a href="https://github.com/uiwwsw/react-query-helper/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/uiwwsw/react-query-helper/ci.yml?branch=main&amp;style=flat-square&amp;label=CI" alt="main ๋ธŒ๋žœ์น˜ CI ์ƒํƒœ" /></a>
18
+ <a href="https://tanstack.com/query"><img src="https://img.shields.io/npm/dependency-version/@uiwwsw/react-query-helper/peer/@tanstack/react-query?style=flat-square&amp;label=TanStack%20Query" alt="TanStack Query peer ์˜์กด์„ฑ ๋ฒ”์œ„" /></a>
19
+ <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/node/v/@uiwwsw/react-query-helper?style=flat-square" alt="Node.js ์š”๊ตฌ ๋ฒ„์ „" /></a>
20
+ <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/types/@uiwwsw/react-query-helper?style=flat-square" alt="ํฌํ•จ๋œ TypeScript ํƒ€์ž…" /></a>
20
21
  </p>
22
+
21
23
  <p align="center">
22
- <img src="https://img.shields.io/badge/Node.js-%3E%3D18.0-000000.svg?logo=node.js" alt="node version" />
23
- <img src="https://img.shields.io/badge/Bun-ready-f97316.svg?logo=bun" alt="bun ready" />
24
+ <a href="https://react-query-helper.vercel.app/">๋ฐ๋ชจ</a> ยท
25
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/docs/ARCHITECTURE.md">๊ตฌ์„ฑ๊ณผ ์˜์กด์„ฑ</a> ยท
26
+ <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper">npm</a> ยท
27
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/CHANGELOG.md">๋ณ€๊ฒฝ ์ด๋ ฅ</a> ยท
28
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/README_EN.md">English</a>
24
29
  </p>
25
30
 
26
- > React Query Helper๋Š” TypeScript API ํ•จ์ˆ˜๋กœ๋ถ€ํ„ฐ React Query ํ›…๊ณผ ์˜ต์…˜ ๊ฐ์ฒด๋ฅผ ์ž๋™ ์ƒ์„ฑํ•ด ์ฃผ๋Š” CLI ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์„ค์ •๋งŒ ํ•ด๋‘๋ฉด ๋ฐ˜๋ณต์ ์ธ ํ›… ์ž‘์„ฑ ์‹œ๊ฐ„์„ ์ ˆ์•ฝํ•˜๊ณ  ํ”„๋กœ์ ํŠธ ์ „์ฒด์— ๊ฑธ์ณ ์ผ๊ด€๋œ ๋ฐ์ดํ„ฐ ํŒจ์นญ ๊ทœ์น™์„ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
27
-
28
- ๊ธฐ๋ณธ์ ์œผ๋กœ ๊ฐ ํŒŒ์ผ์˜ `export`๋œ ํ•จ์ˆ˜๋งŒ ์ƒ์„ฑ ๋Œ€์ƒ์œผ๋กœ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค.
29
-
30
- ---
31
-
32
- ## ๋ชฉ์ฐจ
33
-
34
- - [์ฃผ์š” ํŠน์ง•](#์ฃผ์š”-ํŠน์ง•)
35
- - [๋น ๋ฅธ ์‹œ์ž‘](#๋น ๋ฅธ-์‹œ์ž‘)
36
- - [์„ค์น˜](#์„ค์น˜)
37
- - [์ดˆ๊ธฐ ์„ค์ • ํŒŒ์ผ ์ƒ์„ฑ](#์ดˆ๊ธฐ-์„ค์ •-ํŒŒ์ผ-์ƒ์„ฑ)
38
- - [์ฝ”๋“œ ์ƒ์„ฑ ์‹คํ–‰](#์ฝ”๋“œ-์ƒ์„ฑ-์‹คํ–‰)
39
- - [CLI ๋ช…๋ น์–ด](#cli-๋ช…๋ น์–ด)
40
- - [์„ค์ • ์˜ต์…˜](#์„ค์ •-์˜ต์…˜)
41
- - [์ƒ์„ฑ ๊ฒฐ๊ณผ ์˜ˆ์‹œ](#์ƒ์„ฑ-๊ฒฐ๊ณผ-์˜ˆ์‹œ)
42
- - [ํ—ฌํผ ๊ฒฝ๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•](#ํ—ฌํผ-๊ฒฝ๋กœ-์ปค์Šคํ„ฐ๋งˆ์ด์ง•)
43
- - [๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค](#๋ฒ ์ŠคํŠธ-ํ”„๋ž™ํ‹ฐ์Šค)
44
- - [์Šคํƒ€ ํžˆ์Šคํ† ๋ฆฌ](#์Šคํƒ€-ํžˆ์Šคํ† ๋ฆฌ)
45
- - [๊ธฐ์—ฌ](#๊ธฐ์—ฌ)
46
- - [๋ผ์ด์„ ์Šค](#๋ผ์ด์„ ์Šค)
47
-
48
- ## ์ฃผ์š” ํŠน์ง•
49
-
50
- - **์„ค์ • ๊ธฐ๋ฐ˜ ์ž๋™ํ™”**: `rqh.config.ts`๋งŒ ๊ตฌ์„ฑํ•˜๋ฉด API ๋””๋ ‰ํ† ๋ฆฌ ๊ฐ์ง€๋ถ€ํ„ฐ ์ถœ๋ ฅ ๋””๋ ‰ํ† ๋ฆฌ ์ง€์ •๊นŒ์ง€ ๋ชจ๋‘ ์ž๋™ํ™”๋ฉ๋‹ˆ๋‹ค.
51
- - **์ดˆ๊ธฐํ™” ์ง€์›**: `react-query-helper --init`์œผ๋กœ ๊ธฐ๋ณธ ์„ค์ • ํŒŒ์ผ์„ ๋ฐ”๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
52
- - **๋Ÿฐํƒ€์ž„/๊ฐœ๋ฐœ ๋ถ„๋ฆฌ**: generate/watch/config ๋กœ๋”ฉ์€ ๊ฐœ๋ฐœ ์‹œ์  ์ „์šฉ์ด๊ณ , ์ƒ์„ฑ๋œ ๊ฒฐ๊ณผ๊ฐ€ ์ฐธ์กฐํ•˜๋Š” ๋Ÿฐํƒ€์ž„ helper ์—”ํŠธ๋ฆฌ์—๋Š” `fs` ๊ฐ™์€ Node ์ „์šฉ ์ฝ”๋“œ๊ฐ€ ํฌํ•จ๋˜์ง€ ์•Š๋„๋ก ๋ถ„๋ฆฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
53
- - **Watch & Generate ๋ชจ๋“œ**: ๊ฐœ๋ฐœ ์ค‘ ์‹ค์‹œ๊ฐ„ ๊ฐ์‹œ(`--watch`), ์ดˆ๊ธฐ ์„ธํŒ…์ด๋‚˜ ์žฌ์ƒ์„ฑ ์‹œ ์ผ๊ด„ ์ƒ์„ฑ(`--generate`)์„ ๋ชจ๋‘ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
54
- - **์ผ๊ด€๋œ ์˜ต์…˜ ๊ด€๋ฆฌ**: `queryOption`, `mutationOption`, `infiniteOption` ์œ ํ‹ธ๋ฆฌํ‹ฐ๋กœ ์ „์—ญ ์บ์‹ฑ ์ „๋žต๊ณผ ์—๋Ÿฌ ํ•ธ๋“ค๋ง์„ ํ†ต์ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
55
- - **๋Ÿฐํƒ€์ž„ override ์ง€์›**: ์ƒ์„ฑ๋œ ์˜ต์…˜ ํŒฉํ† ๋ฆฌ์˜ `.withOptions(...)`๋กœ ํ—ค๋”, queryKey, pageParam ๋งคํ•‘, mutation ๋ณ€์ˆ˜ ๋ณ€ํ™˜ ๋“ฑ์„ ํ˜ธ์ถœ๋ถ€์—์„œ ์•ˆ์ „ํ•˜๊ฒŒ ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
56
- - **Prettier ํ†ตํ•ฉ**: ์ƒ์„ฑ๋œ ํŒŒ์ผ์€ ์ž๋™์œผ๋กœ ํฌ๋งทํŒ…๋˜์–ด ์ฝ”๋“œ ๋ฆฌ๋ทฐ ์‹œ ๋ถˆํ•„์š”ํ•œ ๋ณ€๊ฒฝ์„ ์ค„์ž…๋‹ˆ๋‹ค.
57
- - **ํ—ฌํผ import ๊ฒฝ๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•**: `templateDir`๋กœ ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ ์ฐธ์กฐํ•  ํ—ฌํผ ๋ชจ๋“ˆ ๊ฒฝ๋กœ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
58
- - **์Šค๋งˆํŠธ ์•„ํ‹ฐํŒฉํŠธ ์ถ”๋ก **: ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ํ•จ์ˆ˜ ์ด๋ฆ„์„ ๋ณด๊ณ  query / mutation / infinite ์ƒ์„ฑ์„ ๊ตฌ๋ถ„ํ•ด `createUserQueryOption` ๊ฐ™์€ ์–ด์ƒ‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ค„์ž…๋‹ˆ๋‹ค.
59
- - **๋ณด์ˆ˜์ ์ธ infinite ๊ธฐ๋ณธ๊ฐ’**: `infiniteOption`์€ ์•ˆ์ „ํ•œ ๊ธฐ๋ณธ ์˜ต์…˜๋งŒ ์ œ๊ณตํ•˜๊ณ , ์‹ค์ œ `pageParam` ์ฒ˜๋ฆฌ ๊ทœ์น™์€ ํ˜ธ์ถœ๋ถ€์—์„œ override ํ•˜๋„๋ก ์„ค๊ณ„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
60
-
61
- ## ๋น ๋ฅธ ์‹œ์ž‘
62
-
63
- ### ์„ค์น˜
64
-
65
- ```bash
66
- bun add @uiwwsw/react-query-helper
67
- # ๋˜๋Š”
68
- npm install --save-dev @uiwwsw/react-query-helper
69
- ```
31
+ > **๋ฒ„์ „ ์•ˆ๋‚ด:** ์ด ๋ฌธ์„œ๋Š” **2.x** ๊ธฐ์ค€์ž…๋‹ˆ๋‹ค. ์‹ค์ œ ๊ฒŒ์‹œ ๋ฒ„์ „์€ ์œ„ npm ๋ฐฐ์ง€์—์„œ ํ™•์ธํ•˜์„ธ์š”. 1.x๋ฅผ ์‚ฌ์šฉ ์ค‘์ด๋ผ๋ฉด [1.3.0 ๋ฌธ์„œ](https://github.com/uiwwsw/react-query-helper/blob/v1.3.0/README.md)์™€ [๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ๊ฐ€์ด๋“œ](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#1x์—์„œ-์ด์ „)๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”. ์•„์ง ๊ฒŒ์‹œ๋˜์ง€ ์•Š์€ ๋ณ€๊ฒฝ์€ [์†Œ์Šค์—์„œ ์„ค์น˜](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#npm-๊ฒŒ์‹œ-์ „-์†Œ์Šค์—์„œ-์„ค์น˜ํ•˜๊ธฐ)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
70
32
 
71
- ### ์ดˆ๊ธฐ ์„ค์ • ํŒŒ์ผ ์ƒ์„ฑ
33
+ TypeScript API ํ•จ์ˆ˜ ํŒŒ์ผ์„ ์ฝ์–ด ์ฟผ๋ฆฌ ํ‚ค์™€ TanStack Query v5 ์˜ต์…˜ ํŒฉํ† ๋ฆฌ(`queryOptions`, `infiniteQueryOptions`, `mutationOptions`๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์ฝ”๋“œ)๋ฅผ ์ƒ์„ฑํ•˜๋Š” CLI์™€ ๋Ÿฐํƒ€์ž„ ํ—ฌํผ์ž…๋‹ˆ๋‹ค. ์ž…๋ ฅ์€ ์ด๋ฏธ ์žˆ๋Š” TypeScript ํ•จ์ˆ˜์ž…๋‹ˆ๋‹ค. OpenAPI ๋ช…์„ธ๋Š” ์ฝ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ œ์ž‘์ž๋Š” ํ•œ ๋ช…์ด๊ณ , ์•„์ง ๋„๋ฆฌ ์“ฐ์ด์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
72
34
 
73
- ์„ค์น˜ ํ›„ ์•„๋ž˜ ๋ช…๋ น์œผ๋กœ ๋ฃจํŠธ์— `rqh.config.ts`๋ฅผ ์ž๋™ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
35
+ ## ์ง€๊ธˆ ๋˜๋Š” ๊ฒƒ
74
36
 
75
- ```bash
76
- npx @uiwwsw/react-query-helper --init
77
- # ๋˜๋Š”
78
- bunx @uiwwsw/react-query-helper --init
79
- ```
37
+ - `generate`: `sourceDir`์˜ ์ตœ์ƒ์œ„ ํ•จ์ˆ˜๋งˆ๋‹ค ํ‚ค ์ƒ์ˆ˜์™€ query, infinite query, mutation ์˜ต์…˜ ํŒฉํ† ๋ฆฌ๋ฅผ `*Options.ts`๋กœ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
38
+ - ํ‚ค๋Š” ์†Œ์Šค ๊ฒฝ๋กœ์˜ ๋””๋ ‰ํ† ๋ฆฌ, ํŒŒ์ผ๋ช…, ํ•จ์ˆ˜๋ช…์œผ๋กœ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
39
+ - ํ•จ์ˆ˜ ์ด๋ฆ„ ์ ‘๋‘์‚ฌ(`get`, `list`, `create` ๋“ฑ)๋กœ ์ƒ์„ฑ ์ข…๋ฅ˜๋ฅผ ๊ณ ๋ฆ…๋‹ˆ๋‹ค. ์„ค์ •์œผ๋กœ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
40
+ - ์ธ์ž๊ฐ€ ๋‘˜ ์ด์ƒ์ธ ํ•จ์ˆ˜์˜ mutation์— ๋ณ€์ˆ˜ ๊ฐ์ฒด ํƒ€์ž…๊ณผ `mapVariablesToArgs`๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
41
+ - `withOptions`๋กœ `staleTime`, `select` ๋“ฑ์„ ๋ฎ์–ด์“ฐ๊ณ , ์ธ์žยท๋ฐ˜ํ™˜ยท`select` ๊ฒฐ๊ณผ ํƒ€์ž…์ด ์ถ”๋ก ๋ฉ๋‹ˆ๋‹ค.
42
+ - `generate --check`: ํŒŒ์ผ์„ ์“ฐ์ง€ ์•Š๊ณ  ๋ˆ„๋ฝยท๋ณ€๊ฒฝยท์˜ค๋ž˜๋œ ๊ฒฐ๊ณผ๊ฐ€ ์žˆ์œผ๋ฉด ์ข…๋ฃŒ ์ฝ”๋“œ 1์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
43
+ - `watch`: ์†Œ์Šค, ์„ค์ • ํŒŒ์ผ, ์ง€์ •ํ•œ ๋กœ์ปฌ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ๋ฐ”๋€Œ๋ฉด ๋‹ค์‹œ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
44
+ - ์ƒ์„ฑ ํŒŒ์ผ ์ฒซ ์ค„์˜ ์†Œ์œ  ํ‘œ์‹œ๋กœ ๊ตฌ๋ถ„ํ•ด, ํ‘œ์‹œ ์—†๋Š” ๊ธฐ์กด ํŒŒ์ผ์€ ๋ฎ์–ด์“ฐ์ง€ ์•Š๊ณ  ์˜ค๋ฅ˜๋กœ ์ฒ˜๋ฆฌํ•ฉ๋‹ˆ๋‹ค.
45
+ - `customAnalyzerPath`, `customTemplatePath`๋กœ ๋ถ„์„๊ธฐ์™€ ํ…œํ”Œ๋ฆฟ์„ ๊ต์ฒดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
80
46
 
81
- ์ด๋ฏธ ํ”„๋กœ์ ํŠธ์— ์„ค์น˜ํ•œ ๋’ค๋ผ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์‹คํ–‰ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.
47
+ ## ์•„์ง ์•ˆ ๋˜๋Š” ๊ฒƒ / ์ง„ํ–‰ ์˜ˆ์ •
82
48
 
83
- ```bash
84
- npx react-query-helper --init
85
- # ๋˜๋Š”
86
- npm exec react-query-helper -- --init
87
- ```
49
+ - OpenAPI, Swagger ๋“ฑ ๋ช…์„ธ ํŒŒ์ผ ์ฝ๊ธฐ.
50
+ - ํ›… ์ƒ์„ฑ. `useQuery` ๋“ฑ์€ TanStack Query์˜ ๊ฒƒ์„ ์ง์ ‘ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.
51
+ - HTTP ํด๋ผ์ด์–ธํŠธ ์ƒ์„ฑ. ๊ธฐ์กด API ํ•จ์ˆ˜๋ฅผ ๊ทธ๋Œ€๋กœ ํ˜ธ์ถœํ•ฉ๋‹ˆ๋‹ค.
52
+ - React ์™ธ ํด๋ผ์ด์–ธํŠธ(Vue, Svelte, Solid ๋“ฑ). TanStack Query v5 React๋งŒ ๋Œ€์ƒ์ž…๋‹ˆ๋‹ค.
53
+ - ๋ชฉ(mock) ์ƒ์„ฑ.
54
+ - ํŽ˜์ด์ง€๋„ค์ด์…˜ ์ปค์„œ์™€ `AbortSignal` ์ „๋‹ฌ์˜ ์ž๋™ ์ถ”์ธก. API๋งˆ๋‹ค ์ง์ ‘ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
55
+ - re-export barrel, ํด๋ž˜์Šคยท๊ฐ์ฒด ๋ฉ”์„œ๋“œ, ๊ณ ์ฐจ ํ•จ์ˆ˜๊ฐ€ ๋ฐ˜ํ™˜ํ•œ ํ•จ์ˆ˜ ๋ถ„์„.
56
+ - ๋ชจ๋“  generic/overload ๊ด€๊ณ„๋ฅผ ์˜ต์…˜ ํŒฉํ† ๋ฆฌ ํƒ€์ž…์œผ๋กœ ๋ณด์กดํ•˜๋Š” ๋ณ€ํ™˜.
57
+ - ํ•จ์ˆ˜ ์ด๋ฆ„๋งŒ์œผ๋กœ HTTP ์˜๋ฏธ๋ฅผ ํŒ๋‹จํ•˜๋Š” ๊ฒƒ. ์ ‘๋‘์‚ฌ ๊ทœ์น™์— ๋งž์ง€ ์•Š์œผ๋ฉด `artifactsByName`์œผ๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
58
+ - `watch`๊ฐ€ ์„ค์ •์ด importํ•˜๋Š” ์™ธ๋ถ€ ํŒŒ์ผ์˜ ๋ณ€๊ฒฝ์„ ๊ฐ์ง€ํ•˜๋Š” ๊ฒƒ. ์žฌ์‹œ์ž‘์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.
59
+ - ๋””๋ ‰ํ† ๋ฆฌ ์ „์ฒด ๋‹จ์œ„์˜ ํŠธ๋žœ์žญ์…˜. ํŒŒ์ผ ๋‹จ์œ„๋กœ๋งŒ ์›์ž์ ์œผ๋กœ ์”๋‹ˆ๋‹ค.
60
+ - ์ƒ์„ฑ ํŒŒ์ผ์„ Node ESM์—์„œ ์ง์ ‘ ์‹คํ–‰ํ•˜๋Š” ๊ฒƒ. TS ๋ฒˆ๋“ค๋Ÿฌ์šฉ์ž…๋‹ˆ๋‹ค.
61
+ - ํ‘œ์‹œ ์—†๋Š” 1.x ์ƒ์„ฑ ํŒŒ์ผ์˜ ์ž๋™ ์ด์ „. ์ˆ˜๋™์œผ๋กœ ์˜ฎ๊ฒจ์•ผ ํ•ฉ๋‹ˆ๋‹ค.
88
62
 
89
- ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
63
+ ## ํ˜„์žฌ ์œ„์น˜
90
64
 
91
- ```ts
92
- // rqh.config.ts
93
- import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
65
+ ์ฃผ๊ฐ„ npm ๋‹ค์šด๋กœ๋“œ(์ตœ๊ทผ 1์ฃผ, api.npmjs.org ๊ธฐ์ค€):
94
66
 
95
- const config: AutoQueryConfig = {
96
- sourceDir: "./libs", // API ํ•จ์ˆ˜๋“ค์ด ์œ„์น˜ํ•œ ๊ฒฝ๋กœ
97
- outputDir: "./src/options", // ์ƒ์„ฑ๋œ ์ฝ”๋“œ๊ฐ€ ์ €์žฅ๋  ๊ฒฝ๋กœ
98
- ignoredFiles: ["domain.ts", "adaptor.ts"],
99
- templateDir: "@uiwwsw/react-query-helper",
100
- sourceImportAlias: "@/libs",
101
- analyzer: {
102
- exportFilter: "exported-only",
103
- functionMatchMode: "all",
104
- includeNames: [],
105
- excludeNames: [],
106
- },
107
- template: {
108
- enabledArtifacts: ["query", "mutation", "infinite"],
109
- artifactStrategy: "smart",
110
- keyStyle: "path",
111
- },
112
- };
113
-
114
- export default config;
115
- ```
67
+ | ํŒจํ‚ค์ง€ | ๋‹ค์šด๋กœ๋“œ |
68
+ | --------------------------------------- | ------------: |
69
+ | `@hey-api/openapi-ts` | 8,305,092 |
70
+ | `orval` | 4,328,761 |
71
+ | `openapi-react-query` | 956,262 |
72
+ | `@lukemorales/query-key-factory` | 493,363 |
73
+ | `@kubb/plugin-react-query` | 140,067 |
74
+ | `@uiwwsw/react-query-helper` (์ด ํŒจํ‚ค์ง€) | 202 |
116
75
 
117
- ### ์ฝ”๋“œ ์ƒ์„ฑ ์‹คํ–‰
76
+ - ์‚ฌ์šฉ์ž๊ฐ€ ์‚ฌ์‹ค์ƒ ์—†์Šต๋‹ˆ๋‹ค. ๊ด€๋ฆฌ์ž๋Š” ํ•œ ๋ช…์ž…๋‹ˆ๋‹ค. ์œ„ ๋„๊ตฌ๋“ค๊ณผ ๋น„๊ตํ•  ๋งŒํ•œ ์ฑ„ํƒ ์‚ฌ๋ก€๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค.
77
+ - ๊ทœ๋ชจ๊ฐ€ ํฐ ๋„๊ตฌ๋Š” OpenAPI ๋ช…์„ธ์—์„œ ํƒ€์ž…, ํด๋ผ์ด์–ธํŠธ, ํ›…, ์—ฌ๋Ÿฌ ํ”„๋ ˆ์ž„์›Œํฌ์šฉ ์ถœ๋ ฅ, ๋ชฉ๊นŒ์ง€ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ์ด ํŒจํ‚ค์ง€๋Š” ๊ทธ์ค‘ ์–ด๋А ๊ฒƒ๋„ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
78
+ - OpenAPI ๋ช…์„ธ๊ฐ€ ์žˆ์œผ๋ฉด ์œ„ ๋„๊ตฌ๋ฅผ ์“ฐ๋Š” ๊ฒƒ์ด ๋งž์Šต๋‹ˆ๋‹ค.
79
+ - ์ด ํŒจํ‚ค์ง€๊ฐ€ ๋งž๋Š” ๊ฒฝ์šฐ๋Š” ํ•˜๋‚˜์ž…๋‹ˆ๋‹ค. ๋ช…์„ธ ์—†์ด ์†์œผ๋กœ ์“ด TypeScript API ํ•จ์ˆ˜๊ฐ€ ์žˆ๊ณ , ๊ทธ ํ•จ์ˆ˜์—์„œ ํ‚ค์™€ ์˜ต์…˜ ํŒฉํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ณ  ์‹ถ์„ ๋•Œ์ž…๋‹ˆ๋‹ค.
80
+ - `@lukemorales/query-key-factory`๋Š” ํ‚ค๋งŒ ๋‹ค๋ฃจ๊ณ , ํ‚ค ๊ตฌ์กฐ๋ฅผ ์†์œผ๋กœ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค. ์ด ํŒจํ‚ค์ง€๋Š” ํ‚ค์™€ ์˜ต์…˜ ํŒฉํ† ๋ฆฌ๋ฅผ ํŒŒ์ผ ๊ฒฝ๋กœ์™€ ํ•จ์ˆ˜๋ช…์—์„œ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
81
+ - ์ฟผ๋ฆฌ๊ฐ€ ๋ช‡ ๊ฐœ๋ฟ์ด๋ฉด `queryOptions`๋ฅผ ์ง์ ‘ ์“ฐ๋Š” ํŽธ์ด ๋‹จ์ˆœํ•ฉ๋‹ˆ๋‹ค. ๋น„๊ต๋Š” [๊ตฌ์„ฑ๊ณผ ์˜์กด์„ฑ](docs/ARCHITECTURE.md#๋น„์Šทํ•œ-๋„๊ตฌ)์— ์žˆ์Šต๋‹ˆ๋‹ค.
118
82
 
119
- `package.json`์— ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ถ”๊ฐ€ํ•œ ๋’ค CLI๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
83
+ <a id="quick-start"></a>
120
84
 
121
- ```jsonc
122
- // package.json
123
- {
124
- "scripts": {
125
- "init:rqh": "react-query-helper --init",
126
- "watch": "react-query-helper --watch",
127
- "generate": "react-query-helper --generate"
128
- }
129
- }
130
- ```
85
+ ## ์„ค์น˜์™€ ์‚ฌ์šฉ
131
86
 
132
- ```bash
133
- bun run watch # ์‹ค์‹œ๊ฐ„ ๋ณ€๊ฒฝ ๊ฐ์ง€
134
- bun run generate # ์ „์ฒด ํŒŒ์ผ ์ผ๊ด„ ์ƒ์„ฑ
135
- # ๋˜๋Š”
136
- npm exec react-query-helper -- --generate
87
+ ```sh
88
+ npm install @uiwwsw/react-query-helper@^2 @tanstack/react-query react
89
+ npx @uiwwsw/react-query-helper init
137
90
  ```
138
91
 
139
- ## CLI ๋ช…๋ น์–ด
140
-
141
- | ๋ช…๋ น์–ด | ์„ค๋ช… |
142
- | --- | --- |
143
- | `react-query-helper --init` | ๋ฃจํŠธ์— ๊ธฐ๋ณธ `rqh.config.ts` ํŒŒ์ผ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฏธ ์žˆ์œผ๋ฉด ๋ฎ์–ด์“ฐ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. |
144
- | `react-query-helper --watch` | `sourceDir`๋ฅผ ๊ฐ์‹œํ•˜์—ฌ ๋ณ€๊ฒฝ๋  ๋•Œ๋งˆ๋‹ค ์ฝ”๋“œ๋ฅผ ๊ฐฑ์‹ ํ•ฉ๋‹ˆ๋‹ค. |
145
- | `react-query-helper --generate` | `sourceDir` ๋‚ด ๋ชจ๋“  API ํŒŒ์ผ์„ ๋ถ„์„ํ•˜๊ณ  ํ•œ ๋ฒˆ์— ์ฝ”๋“œ๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. |
146
- | `react-query-helper --help` | ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ์˜ต์…˜์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. |
147
-
148
- ## ์„ค์ • ์˜ต์…˜
149
-
150
- | ์˜ต์…˜ | ํ•„์ˆ˜ | ์„ค๋ช… |
151
- | --- | --- | --- |
152
- | `sourceDir` | โœ… | API ํ•จ์ˆ˜๊ฐ€ ํฌํ•จ๋œ TypeScript ๋””๋ ‰ํ† ๋ฆฌ (๋ฃจํŠธ ๊ธฐ์ค€ ๊ฒฝ๋กœ) |
153
- | `outputDir` | โœ… | ์ƒ์„ฑ๋œ ํ›…๊ณผ ์˜ต์…˜ ํŒŒ์ผ์ด ์ €์žฅ๋  ๋””๋ ‰ํ† ๋ฆฌ |
154
- | `ignoredFiles` | โŒ | ์ฝ”๋“œ ์ƒ์„ฑ์—์„œ ์ œ์™ธํ•  ํŒŒ์ผ/๊ฒฝ๋กœ ํŒจํ„ด ๋ฐฐ์—ด (`domain.ts`, `**/*.spec.ts`, `admin/internal/**`) |
155
- | `templateDir` | โŒ | ์ƒ์„ฑ๋œ ์ฝ”๋“œ์—์„œ `queryOption` ๊ณ„์—ด์„ import ํ•  ๋ชจ๋“ˆ ๊ฒฝ๋กœ ๋˜๋Š” ์ƒ๋Œ€ ๋””๋ ‰ํ† ๋ฆฌ |
156
- | `sourceImportAlias` | โŒ | API ํ•จ์ˆ˜ import๋ฅผ ์ƒ๋Œ€๊ฒฝ๋กœ ๋Œ€์‹  alias๋กœ ์ƒ์„ฑํ•  ๋•Œ ์‚ฌ์šฉํ•  prefix (`@/apis` ๋“ฑ) |
157
- | `analyzer` | โŒ | ์–ด๋–ค ํ•จ์ˆ˜๋ฅผ ์ฝ์„์ง€ ํ•„ํ„ฐ๋งํ•˜๋Š” ์„ค์ • (`exported-only`, `async-only`, include/exclude ๋“ฑ) |
158
- | `template` | โŒ | ์–ด๋–ค ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ์ƒ์„ฑํ• ์ง€์™€ ์ด๋ฆ„ ๊ทœ์น™์„ ์ œ์–ดํ•˜๋Š” ์„ค์ • |
159
-
160
- ### ์Šค๋งˆํŠธ ์ƒ์„ฑ ๊ทœ์น™
161
-
162
- ๊ธฐ๋ณธ `artifactStrategy: "smart"`๋Š” ํ•จ์ˆ˜ ์ด๋ฆ„์„ ๋ณด๊ณ  ์ƒ์„ฑ ๋Œ€์ƒ์„ ์ถ”๋ก ํ•ฉ๋‹ˆ๋‹ค.
163
-
164
- - `getUsers`, `fetchPost`, `listComments` โ†’ `query` + `infinite`
165
- - `createUser`, `updateProfile`, `deleteComment` โ†’ `mutation`
166
- - ๊ทธ ์™ธ ์• ๋งคํ•œ ์ด๋ฆ„ โ†’ `query` + `mutation` (`infinite` ์ œ์™ธ)
167
-
168
- ์›ํ•œ๋‹ค๋ฉด `artifactStrategy: "all"`๋กœ ์˜ˆ์ „์ฒ˜๋Ÿผ ๋ชจ๋“  ์•„ํ‹ฐํŒฉํŠธ๋ฅผ ๊ฐ•์ œ๋กœ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
169
-
170
- ## Infinite Query ๊ธฐ๋ณธ๊ฐ’
171
-
172
- `infiniteOption`์€ API๋งˆ๋‹ค ํŽ˜์ด์ง€๋„ค์ด์…˜ ๊ทœ์น™์ด ๋‹ค๋ฅด๊ธฐ ๋•Œ๋ฌธ์—, ๊ธฐ๋ณธ ๊ตฌํ˜„์—์„œ๋Š” `pageParam`์„ ์ž๋™ ๋ณ‘ํ•ฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
173
-
174
- ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์ƒ์„ฑ๋œ ์˜ต์…˜์„ ํŽผ์นœ ๋’ค `queryFn`, `getNextPageParam`, `initialPageParam`์„ ์ง์ ‘ override ํ•ด์„œ ์‚ฌ์šฉํ•˜์„ธ์š”.
175
-
176
- ```ts
177
- const usersInfinite = {
178
- ...getUsersInfiniteQueryOption({ page: 1 }),
179
- initialPageParam: 1,
180
- queryFn: ({ pageParam }) => getUsers({ page: pageParam }),
181
- getNextPageParam: (lastPage) => lastPage.nextPage,
182
- };
183
- ```
184
-
185
- ๋” ๋ณต์žกํ•œ ์ผ€์ด์Šค์—์„œ๋Š” `.withOptions(...)`๋ฅผ ์“ฐ๋ฉด ํ—ค๋”๋‚˜ `pageParam` ๋งคํ•‘๋„ ํ•œ ๊ณณ์—์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
186
-
187
- ```ts
188
- const usersInfinite = getUsersInfiniteQueryOption.withOptions(
189
- {
190
- initialPageParam: 1,
191
- pageParamToArgs: (pageParam, [params]) => [{
192
- ...params,
193
- page: pageParam,
194
- headers: {
195
- ...params.headers,
196
- Authorization: `Bearer ${token}`,
197
- },
198
- }],
199
- getNextPageParam: (lastPage) => lastPage.nextPage,
200
- },
201
- { page: 1, headers: {} }
202
- );
203
- ```
204
-
205
- Mutation๋„ ํ˜ธ์ถœ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋งž์ถฐ์ง‘๋‹ˆ๋‹ค.
206
-
207
- - API ํ•จ์ˆ˜๊ฐ€ ์ธ์ž 1๊ฐœ๋ฉด ๊ธฐ์กด์ฒ˜๋Ÿผ `mutate(body)` / `mutateAsync(body)`
208
- - API ํ•จ์ˆ˜๊ฐ€ ์ธ์ž ์—ฌ๋Ÿฌ ๊ฐœ๋ฉด ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ object payload ํƒ€์ž…์„ ๋งŒ๋“ค์–ด `mutate({ body, headers })` / `mutateAsync({ body, headers })`
209
-
210
- ๊ฐ„๋‹จํ•œ ์ปค์Šคํ…€ ๋งคํ•‘์ด ํ•„์š”ํ•˜๋ฉด `withOptions(...)`๋กœ๋„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
92
+ ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ ์ด ํŒจํ‚ค์ง€๋ฅผ importํ•˜๋ฏ€๋กœ ์ผ๋ฐ˜ dependency๋กœ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค(`-D` ์‚ฌ์šฉ ๊ธˆ์ง€).
211
93
 
212
94
  ```ts
213
- const updateUserMutation = updateUserMutationOption.withOptions({
214
- mapVariablesToArgs: ({ id, body }) => [
215
- id,
216
- body,
217
- { Authorization: `Bearer ${token}` },
218
- ],
219
- });
220
- ```
221
-
222
- API ํ•จ์ˆ˜๊ฐ€ ์—ฌ๋Ÿฌ ์ธ์ž๋ฅผ ๋ฐ›์œผ๋ฉด, ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ `mutate` / `mutateAsync`์—์„œ ๋ฐ”๋กœ ์“ฐ๊ธฐ ์ข‹์€ object payload ํƒ€์ž…๋„ ํ•จ๊ป˜ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค.
223
-
224
- ```ts
225
- export type createUserMutationVariables = {
226
- body: Parameters<typeof createUser>[0];
227
- headers: Parameters<typeof createUser>[1];
228
- };
229
-
230
- export const createUserMutationOption = mutationOption<
231
- Parameters<typeof createUser>,
232
- Awaited<ReturnType<typeof createUser>>,
233
- createUserMutationVariables
234
- >(createUserKey, createUser, {
235
- mapVariablesToArgs: (variables) => [variables.body, variables.headers],
236
- });
237
-
238
- mutate({
239
- body: { name: "matthew" },
240
- headers: { Authorization: `Bearer ${token}` },
241
- });
242
-
243
- await mutateAsync({
244
- body: { name: "matthew" },
245
- headers: { Authorization: `Bearer ${token}` },
246
- });
247
- ```
248
-
249
- ## ๋ฐฐํฌ ๋ฐฉ์‹
250
-
251
- GitHub Actions์˜ npm ๋ฐฐํฌ๋Š” ์ด์ œ `main` ํ‘ธ์‹œ๊ฐ€ ์•„๋‹ˆ๋ผ `v*` ํƒœ๊ทธ ํ‘ธ์‹œ ๋˜๋Š” ์ˆ˜๋™ ์‹คํ–‰์—์„œ๋งŒ ๋™์ž‘ํ•ฉ๋‹ˆ๋‹ค.
252
-
253
- ์˜ˆ์‹œ:
95
+ // rqh.config.ts
96
+ import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
254
97
 
255
- ```bash
256
- git tag v1.0.3
257
- git push origin v1.0.3
98
+ export default {
99
+ sourceDir: "./libs",
100
+ outputDir: "./src/options",
101
+ template: { artifactStrategy: "smart" },
102
+ } satisfies AutoQueryConfig;
258
103
  ```
259
104
 
260
- ## ์ƒ์„ฑ ๊ฒฐ๊ณผ ์˜ˆ์‹œ
261
-
262
105
  ```ts
263
106
  // libs/users/api.ts
264
- export const getUser = async (id: string) => {
265
- return { id, name: `User ${id}` };
266
- };
267
-
268
- export const createUser = async (
269
- body: { name: string },
270
- headers?: Record<string, string>
271
- ) => {
272
- return { id: Date.now().toString(), name: body.name, headers };
273
- };
107
+ export const getUser = async (id: string) => ({ id, name: "Ada" });
274
108
  ```
275
109
 
110
+ `npx @uiwwsw/react-query-helper generate`๋ฅผ ์‹คํ–‰ํ•˜๋ฉด `src/options/users/apiOptions.ts`๊ฐ€ ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
111
+
276
112
  ```ts
277
- // src/options/users/apiOptions.ts (์ž๋™ ์ƒ์„ฑ)
278
- import { createUser, getUser } from "../../../libs/users/api";
113
+ // Generated by @uiwwsw/react-query-helper. DO NOT EDIT.
114
+ // Source root: "../../libs"
115
+ import { getUser } from "../../../libs/users/api";
279
116
  import {
280
- infiniteOption,
281
- mutationOption,
282
- queryOption,
117
+ queryOption as __rqh_query,
118
+ infiniteOption as __rqh_infinite,
283
119
  } from "@uiwwsw/react-query-helper";
284
120
 
285
- export const getUserKey = ["users", "getUser"] as const;
286
- export const getUserQueryOption = queryOption(getUserKey, getUser);
287
- export const getUserInfiniteQueryOption = infiniteOption(getUserKey, getUser);
288
-
289
- export const createUserKey = ["users", "createUser"] as const;
290
- export type createUserMutationVariables = {
291
- body: Parameters<typeof createUser>[0];
292
- headers: Parameters<typeof createUser>[1];
293
- };
294
-
295
- export const createUserMutationOption = mutationOption<
296
- Parameters<typeof createUser>,
297
- Awaited<ReturnType<typeof createUser>>,
298
- createUserMutationVariables
299
- >(
300
- createUserKey,
301
- createUser,
302
- {
303
- mapVariablesToArgs: (variables) => [variables.body, variables.headers],
304
- }
305
- );
121
+ export const getUserKey = ["users", "api", "getUser"] as const;
122
+ export const getUserQueryOption = __rqh_query(getUserKey, getUser);
123
+ export const getUserInfiniteQueryOption = __rqh_infinite(getUserKey, getUser);
306
124
  ```
307
125
 
308
- ## ํ—ฌํผ ๊ฒฝ๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•
309
-
310
- ์กฐ์ง ๊ณต์šฉ ํ—ฌํผ๋ฅผ ๋”ฐ๋กœ ๋‘๊ณ  ์žˆ๋‹ค๋ฉด `templateDir`๋กœ ์ƒ์„ฑ ์ฝ”๋“œ์˜ import ๊ฒฝ๋กœ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
311
-
312
- ๋˜ํ•œ `template` / `analyzer` ์„ค์ •์œผ๋กœ ํ˜„์žฌ ํŒ€ ๊ตฌ์กฐ์— ๋งž๊ฒŒ ์ƒ์„ฑ ๊ทœ์น™์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
313
-
314
- ```ts
315
- const config: AutoQueryConfig = {
316
- sourceDir: "./libs",
317
- outputDir: "./src/options",
318
- analyzer: {
319
- functionMatchMode: "async-only",
320
- excludeNames: ["debugHelper"],
321
- },
322
- template: {
323
- enabledArtifacts: ["query"],
324
- keyStyle: "function-only",
325
- outputNames: {
326
- query: "CustomQueryOption",
327
- },
328
- },
329
- };
330
- ```
331
-
332
- ๋” ๊ฐ•ํ•˜๊ฒŒ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•˜๋ ค๋ฉด ์™ธ๋ถ€ ๋ชจ๋“ˆ๋„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
333
-
334
- ```ts
335
- const config: AutoQueryConfig = {
336
- sourceDir: "./libs",
337
- outputDir: "./src/options",
338
- customAnalyzerPath: "./rqh.analyzer.mjs",
339
- customTemplatePath: "./rqh.template.mjs",
340
- };
341
- ```
126
+ ์ƒ์„ฑ ํŒŒ์ผ์€ ์ˆ˜์ •ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ณ ์น  ๋•Œ๋Š” ์›๋ณธ API๋ฅผ ์ˆ˜์ •ํ•ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ:
342
127
 
343
- - `customAnalyzerPath`: ํŒŒ์ผ์„ ์ฝ๊ณ  ์›ํ•˜๋Š” ํ•จ์ˆ˜ ๋ฉ”ํƒ€ ๋ชฉ๋ก์„ ์ง์ ‘ ๋ฐ˜ํ™˜
344
- - `customTemplatePath`: ์ตœ์ข… ์ƒ์„ฑ ์ฝ”๋“œ ๋ฌธ์ž์—ด์„ ์ง์ ‘ ๋ฐ˜ํ™˜
345
-
346
- ์˜ˆ์‹œ `rqh.analyzer.mjs`:
347
-
348
- ```js
349
- export function analyzeFile(filePath, config) {
350
- // ์—ฌ๊ธฐ์„œ AST๋ฅผ ์ง์ ‘ ํŒŒ์‹ฑํ•˜๊ฑฐ๋‚˜,
351
- // ํŒŒ์ผ๋ช… ๊ทœ์น™ / ํ•จ์ˆ˜๋ช… ๊ทœ์น™์„ ์ž์œ ๋กญ๊ฒŒ ์ ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
352
- return [
353
- {
354
- name: "getUser",
355
- parameters: ["params"],
356
- isAsync: true,
357
- isExported: true,
358
- },
359
- ];
360
- }
361
- ```
128
+ ```tsx
129
+ // src/UserName.tsx
130
+ import { useQuery } from "@tanstack/react-query";
131
+ import { getUserQueryOption } from "./options/users/apiOptions";
362
132
 
363
- ์˜ˆ์‹œ `rqh.template.mjs`:
133
+ export function UserName({ id }: { id: string }) {
134
+ const user = useQuery(
135
+ getUserQueryOption.withOptions(
136
+ { staleTime: 60_000, select: (data) => data.name },
137
+ id,
138
+ ),
139
+ );
364
140
 
365
- ```js
366
- export function generateOptionsCode({ functionInfos, importPath }) {
367
- const names = functionInfos.map((info) => info.name).join(", ");
368
- return `import { ${names} } from "${importPath}";\nexport const customGenerated = true;\n`;
141
+ if (user.isPending) return <p>Loading...</p>;
142
+ if (user.isError) return <p>{user.error.message}</p>;
143
+ return <p>{user.data}</p>;
369
144
  }
370
145
  ```
371
146
 
372
- ์–ธ์ œ custom analyzer๋ฅผ ์“ฐ๋ฉด ๋˜๋ƒ๋ฉด:
373
- - built-in analyzer ์„ค์ •๋งŒ์œผ๋กœ ์ถฉ๋ถ„ํ•œ ๊ฒฝ์šฐ
374
- - `exported-only`, `async-only`, ์ด๋ฆ„ include/exclude, ์•„ํ‹ฐํŒฉํŠธ on/off ์ •๋„
375
- - custom analyzer๊ฐ€ ํ•„์š”ํ•œ ๊ฒฝ์šฐ
376
- - ํ•จ์ˆ˜ ์„ ์–ธ์ด ๋ž˜ํ•‘๋˜์–ด ์žˆ๊ฑฐ๋‚˜
377
- - factory/higher-order ๊ตฌ์กฐ๋ฅผ ์“ฐ๊ฑฐ๋‚˜
378
- - ํŒ€ ์ „์šฉ ๊ทœ์น™์œผ๋กœ ํ•จ์ˆ˜ ํ›„๋ณด๋ฅผ ๋ฝ‘์•„์•ผ ํ•˜๊ฑฐ๋‚˜
379
- - ๊ธฐ๋ณธ AST ๊ทœ์น™๋ณด๋‹ค ๋” ๋ณต์žกํ•œ generic ํŒจํ„ด์„ ๊ฐ•์ œํ•˜๊ณ  ์‹ถ์„ ๋•Œ
380
-
381
- ์ฆ‰ ์ด์ œ๋Š” ๊ธฐ๋ณธ ๊ทœ์น™์„ ์กฐ๊ธˆ ๋ฐ”๊พธ๋Š” ์ˆ˜์ค€์ด ์•„๋‹ˆ๋ผ, ํŒ€ ์ „์šฉ ์ƒ์„ฑ๊ธฐ์ฒ˜๋Ÿผ ํ™•์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
382
-
383
- ```ts
384
- const config: AutoQueryConfig = {
385
- sourceDir: "./libs",
386
- outputDir: "./src/options",
387
- templateDir: "./src/query-helpers",
388
- };
389
- ```
390
-
391
- ์˜ˆ๋ฅผ ๋“ค์–ด ์ƒ์„ฑ ํŒŒ์ผ์€ ๊ธฐ๋ณธ ํŒจํ‚ค์ง€ ๋Œ€์‹  ์•„๋ž˜์ฒ˜๋Ÿผ ์ง€์ •ํ•œ ๊ฒฝ๋กœ๋ฅผ import ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
392
-
393
147
  ```ts
394
- import {
395
- queryOption,
396
- mutationOption,
397
- infiniteOption,
398
- } from "./src/query-helpers";
148
+ // ๊ธฐ์กด QueryClient ์ธ์Šคํ„ด์Šค client์—์„œ
149
+ await client.prefetchQuery(getUserQueryOption("u1"));
150
+ const cached = client.getQueryData(getUserQueryOption("u1").queryKey);
151
+ // { id: string; name: string } | undefined
399
152
  ```
400
153
 
401
- ## ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค
402
-
403
- - **ํ•˜๋‚˜์˜ API = ํ•˜๋‚˜์˜ ํ›…** ๊ตฌ์กฐ๋ฅผ ์œ ์ง€ํ•˜๋ฉด ์บ์‹œ ํ‚ค ๊ด€๋ฆฌ๊ฐ€ ์‰ฌ์›Œ์ง‘๋‹ˆ๋‹ค.
404
- - ์ƒ์„ฑ๋œ ํŒŒ์ผ์€ ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ(Git)์— ์ปค๋ฐ‹ํ•˜์—ฌ ๋ฐฐํฌ ์‹œ ์ž๋™ ์ƒ์„ฑ ๊ณผ์ •์„ ํ”ผํ•˜์„ธ์š”.
405
- - `queryOption` ์œ ํ‹ธ ํ•จ์ˆ˜์—์„œ ๊ธ€๋กœ๋ฒŒ ์˜ต์…˜(`staleTime`, `retry`, `refetchOnWindowFocus`)์„ ์ •์˜ํ•˜๋ฉด ํŒ€ ์ „์ฒด ๊ทœ์น™์„ ์†์‰ฝ๊ฒŒ ํ†ต์ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
406
- - Watch ๋ชจ๋“œ ์‚ฌ์šฉ ์‹œ IDE ์ €์žฅ ํฌ๋งทํ„ฐ์™€ ์ถฉ๋Œ์ด ์—†๋„๋ก ์ €์žฅ ์‹œ์  ํฌ๋งทํŒ…์„ ๋งž์ถฐ ์ฃผ์„ธ์š”.
407
-
408
- ## ์Šคํƒ€ ํžˆ์Šคํ† ๋ฆฌ
409
-
410
- [![Star History Chart](https://api.star-history.com/svg?repos=uiwwsw/react-query-helper&type=Date)](https://star-history.com/#uiwwsw/react-query-helper&Date)
154
+ API ์ธ์ž๋Š” ์บ์‹œ ํ‚ค์— ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ํ† ํฐ์ด๋‚˜ ์ธ์ฆ ํ—ค๋”๋ฅผ ์ธ์ž๋กœ ๋„˜๊ธฐ์ง€ ๋งˆ์„ธ์š”.
411
155
 
412
- ## ๊ธฐ์—ฌ
156
+ ## ๋ฌธ์„œ
413
157
 
414
- ๋ฒ„๊ทธ ์ œ๋ณด, ๊ธฐ๋Šฅ ์ œ์•ˆ, ๋ฌธ์„œ ๊ฐœ์„  ๋“ฑ ๋ชจ๋“  ๊ธฐ์—ฌ๋ฅผ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค. ์ด์Šˆ๋ฅผ ๋“ฑ๋กํ•˜๊ฑฐ๋‚˜ Pull Request๋ฅผ ๋ณด๋‚ด ์ฃผ์„ธ์š”.
158
+ - [์„ค์ •๊ณผ ์‚ฌ์šฉ ๊ฐ€์ด๋“œ](docs/REFERENCE.md): CLI, ์„ค์ •, ์ƒ์„ฑ ๊ทœ์น™, ๋Ÿฐํƒ€์ž„ ์˜ต์…˜, ๋ฌดํ•œ ์ฟผ๋ฆฌ, 1.x ์ด์ „
159
+ - [README์—์„œ ์˜ฎ๊ธด ์ƒ์„ธ](docs/GUIDE.md): ์ „์ฒด ๊ธฐ๋Šฅ ๋ชฉ๋ก, ์„ค์น˜ ๋‹จ๊ณ„๋ณ„ ์„ค๋ช…, ์˜ˆ์ œ ์ฐพ๊ธฐ ํ‘œ, ์ง€์› ํ™˜๊ฒฝ, ์˜์กด์„ฑ, ๋ฐ๋ชจ
160
+ - [๊ตฌ์„ฑ๊ณผ ์˜์กด์„ฑ](docs/ARCHITECTURE.md): ๋ชจ๋“ˆ ๊ตฌ์กฐ, ๋น„์Šทํ•œ ๋„๊ตฌ์™€์˜ ๋น„๊ต
161
+ - [์ €์žฅ์†Œ ๊ฒ€ํ†  ๊ธฐ๋ก](docs/REVIEW.md) ยท [๋ณ€๊ฒฝ ์ด๋ ฅ](CHANGELOG.md) ยท [๋ฐ๋ชจ](https://react-query-helper.vercel.app/)
415
162
 
416
163
  ## ๋ผ์ด์„ ์Šค
417
164
 
418
- ์ด ํ”„๋กœ์ ํŠธ๋Š” [MIT ๋ผ์ด์„ ์Šค](LICENSE)๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.
165
+ [MIT License](LICENSE)