@uiwwsw/react-query-helper 1.3.0 โ†’ 2.0.1

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,46 @@
1
+ # Changelog
2
+
3
+ ## 2.0.1
4
+
5
+ The v2.0.0 tag was not published to npm. This release includes all of the 2.0.0
6
+ changes below, including the breaking changes for applications upgrading from 1.x.
7
+
8
+ - Simplify Korean/English onboarding and move detailed configuration and recipes into reference guides.
9
+ - Introduce the Q symbol, light/dark README banners, and documented brand assets.
10
+ - Add regression tests for documentation links, SVG assets, and generated/typechecked README examples.
11
+ - Refresh release guidance and source-install examples for 2.0.1.
12
+
13
+ ## 2.0.0
14
+
15
+ ### Breaking Changes
16
+
17
+ - Require TanStack Query >=5.102.8 <6. Node 22 remains the minimum CLI runtime.
18
+ - 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.
19
+ - Remove forced infinite cache/stale times and disabled focus refetching. QueryClient defaults now apply.
20
+ - Single-array mutation payloads are passed intact. Direct multi-argument helpers require an explicit mapper or tuple mode.
21
+ - Refuse to overwrite output without this generator's ownership marker. Move legacy generated files aside and regenerate.
22
+ - Built-in generation rejects private imports, invalid identifiers, duplicate names and invalid configuration.
23
+
24
+ ### Fixed
25
+
26
+ - Starter configs no longer reference missing plugins or assume an application alias.
27
+ - Correct InfiniteData, pageParam, select, default error, cache data-tag and optimistic rollback inference.
28
+ - Forward query/mutation context, including QueryClient and AbortSignal, to custom callbacks.
29
+ - Convert synchronous callback failures to rejected promises.
30
+ - Support default/local alias exports, skip ambient declarations and duplicate overload signatures.
31
+ - Preserve optional multi-argument mutation fields and handle rest/destructured parameters using tuples.
32
+ - Include source filenames in cache prefixes and avoid unused/colliding helper imports.
33
+ - Honor empty artifact lists and provide per-function artifact selection.
34
+ - Load TypeScript/CommonJS configs and plugins with relative imports through Jiti; validate options and plugin contracts.
35
+ - Exclude output directories from source scans; support standard ignore globs; detect symlink and output collisions.
36
+ - Reconcile only owned stale files after a successful analysis, avoid unchanged writes, serialize watch passes and recover after errors.
37
+ - Wait for watcher readiness and reconcile startup edits before announcing that watch is active.
38
+ - Report generation failures with nonzero exit codes; add explicit config selection and read-only output checks.
39
+
40
+ ### Maintenance
41
+
42
+ - Replace the Bun-only build with a Node/esbuild build; preserve a browser-safe runtime and NodeNext-compatible declarations.
43
+ - Use one npm lockfile; remove obsolete scripts, the fs placeholder dependency and Bun ambient types.
44
+ - Add runtime, CLI, emitted-code, type-inference and installed-package tests.
45
+ - Add Node 22/24 CI and pre-publish tests, consumer checks, tag/version validation and provenance.
46
+ - Rewrite Korean/English documentation with usage, limitations and migration steps.
package/README.md CHANGED
@@ -1,418 +1,168 @@
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: Your API. Query-ready. TypeScript in, reusable options out." 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
+ API ํ•จ์ˆ˜๋Š” ๊ทธ๋Œ€๋กœ. ๋ฐ˜๋ณต๋˜๋Š” ์ฟผ๋ฆฌ ์„ค์ •์€ ์ƒ์„ฑํ•˜์„ธ์š”.<br />
12
+ TypeScript ํ•จ์ˆ˜์—์„œ TanStack Query v5์˜ ํƒ€์ž… ์•ˆ์ „ํ•œ ์˜ต์…˜ ํŒฉํ† ๋ฆฌ๋ฅผ ๋งŒ๋“ญ๋‹ˆ๋‹ค.
9
13
  </p>
10
14
 
11
15
  <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>
16
+ <a href="https://www.npmjs.com/package/@uiwwsw/react-query-helper"><img src="https://img.shields.io/npm/v/%40uiwwsw%2Freact-query-helper?style=flat-square&amp;label=npm&amp;color=133c35" alt="Published npm version" /></a>
17
+ <a href="https://github.com/uiwwsw/react-query-helper/actions/workflows/ci.yml"><img src="https://github.com/uiwwsw/react-query-helper/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI status on main" /></a>
18
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-MIT-f38466?style=flat-square" alt="MIT license" /></a>
20
19
  </p>
20
+
21
21
  <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" />
22
+ <a href="#quick-start">๋น ๋ฅธ ์‹œ์ž‘</a> ยท
23
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md">์„ค์ •๊ณผ ์˜ˆ์ œ</a> ยท
24
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#1x์—์„œ-์ด์ „">1.x์—์„œ ์ด์ „</a> ยท
25
+ <a href="https://github.com/uiwwsw/react-query-helper/blob/main/README_EN.md">English</a>
24
26
  </p>
25
27
 
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
- ```
70
-
71
- ### ์ดˆ๊ธฐ ์„ค์ • ํŒŒ์ผ ์ƒ์„ฑ
72
-
73
- ์„ค์น˜ ํ›„ ์•„๋ž˜ ๋ช…๋ น์œผ๋กœ ๋ฃจํŠธ์— `rqh.config.ts`๋ฅผ ์ž๋™ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
28
+ > **๋ฒ„์ „ ์•ˆ๋‚ด:** ์ด ๋ฌธ์„œ๋Š” **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-๊ฒŒ์‹œ-์ „-์†Œ์Šค์—์„œ-์„ค์น˜ํ•˜๊ธฐ)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
74
29
 
75
- ```bash
76
- npx @uiwwsw/react-query-helper --init
77
- # ๋˜๋Š”
78
- bunx @uiwwsw/react-query-helper --init
79
- ```
80
-
81
- ์ด๋ฏธ ํ”„๋กœ์ ํŠธ์— ์„ค์น˜ํ•œ ๋’ค๋ผ๋ฉด ์•„๋ž˜์ฒ˜๋Ÿผ ์‹คํ–‰ํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.
82
-
83
- ```bash
84
- npx react-query-helper --init
85
- # ๋˜๋Š”
86
- npm exec react-query-helper -- --init
87
- ```
88
-
89
- ์ƒ์„ฑ๋˜๋Š” ํŒŒ์ผ ์˜ˆ์‹œ๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค.
30
+ ## ๋ฌด์—‡์„ ์ค„์—ฌ์ฃผ๋‚˜์š”?
90
31
 
91
- ```ts
92
- // rqh.config.ts
93
- import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
32
+ ๊ฐ™์€ API๋ฅผ ์ปดํฌ๋„ŒํŠธ, prefetch, ์บ์‹œ ์กฐํšŒ์—์„œ ์‚ฌ์šฉํ•  ๋•Œ ๋ฐ˜๋ณต๋˜๋Š” ํ‚ค์™€ ์˜ต์…˜ ๊ตฌ์„ฑ์„ ์ค„์ž…๋‹ˆ๋‹ค.
33
+ **ํ›…์ด๋‚˜ HTTP ํด๋ผ์ด์–ธํŠธ๋ฅผ ์ƒˆ๋กœ ๋งŒ๋“ค์ง€ ์•Š์Šต๋‹ˆ๋‹ค.** ๊ธฐ์กด API ํ•จ์ˆ˜์™€ TanStack Query๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
94
34
 
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
- ```
35
+ | ์ง์ ‘ ๊ด€๋ฆฌํ•˜๋˜ ๊ฒƒ | ์ƒ์„ฑ ํ›„ |
36
+ | -------------------------- | --------------------------------------------------------- |
37
+ | ๊ณณ๊ณณ์— ํฉ์–ด์ง„ ์ฟผ๋ฆฌ ํ‚ค | ํŒŒ์ผ ๊ฒฝ๋กœยทํ•จ์ˆ˜๋ช…ยท์ธ์ž๋ฅผ ๋ฐ˜์˜ํ•œ ํ‚ค |
38
+ | ๊ฐ™์€ ์š”์ฒญ์„ ์œ„ํ•œ ๋ฐ˜๋ณต ์˜ต์…˜ | `useQuery`, `useSuspenseQuery`, fetch/prefetch์—์„œ ์žฌ์‚ฌ์šฉ |
39
+ | API์™€ ๋ณ„๋„๋กœ ์œ ์ง€ํ•˜๋Š” ํƒ€์ž… | ์ธ์žยท์‘๋‹ตยท`select`ยท์บ์‹œ ๋ฐ์ดํ„ฐ ํƒ€์ž… ์ถ”๋ก  |
40
+ | API ๋ณ€๊ฒฝ ํ›„ ์ƒ์„ฑ ํŒŒ์ผ ์ •๋ฆฌ | watch ์žฌ์ƒ์„ฑ, ์˜ค๋ž˜๋œ ์†Œ์œ  ํŒŒ์ผ ์ •๋ฆฌ, CI์˜ `--check` |
116
41
 
117
- ### ์ฝ”๋“œ ์ƒ์„ฑ ์‹คํ–‰
42
+ ๊ธฐ๋ณธ ์บ์‹ฑ ์ •์ฑ…๊ณผ ์žฌ์‹œ๋„๋Š” TanStack Query/`QueryClient`๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.
43
+ ์ด๋ฆ„ ๊ธฐ๋ฐ˜ ์ƒ์„ฑ ๊ทœ์น™์€ [์„ค์ •์œผ๋กœ ์žฌ์ •์˜](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#์ƒ์„ฑ-๊ทœ์น™)ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
118
44
 
119
- `package.json`์— ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ถ”๊ฐ€ํ•œ ๋’ค CLI๋ฅผ ์‹คํ–‰ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.
45
+ <a id="quick-start"></a>
120
46
 
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
- ```
131
-
132
- ```bash
133
- bun run watch # ์‹ค์‹œ๊ฐ„ ๋ณ€๊ฒฝ ๊ฐ์ง€
134
- bun run generate # ์ „์ฒด ํŒŒ์ผ ์ผ๊ด„ ์ƒ์„ฑ
135
- # ๋˜๋Š”
136
- npm exec react-query-helper -- --generate
137
- ```
138
-
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
- ```
47
+ ## ๋น ๋ฅธ ์‹œ์ž‘
184
48
 
185
- ๋” ๋ณต์žกํ•œ ์ผ€์ด์Šค์—์„œ๋Š” `.withOptions(...)`๋ฅผ ์“ฐ๋ฉด ํ—ค๋”๋‚˜ `pageParam` ๋งคํ•‘๋„ ํ•œ ๊ณณ์—์„œ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
49
+ ### 1. ์„ค์น˜ํ•˜๊ณ  ์ดˆ๊ธฐํ™”
186
50
 
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
- );
51
+ ```sh
52
+ npm install @uiwwsw/react-query-helper@^2 @tanstack/react-query react
53
+ npx @uiwwsw/react-query-helper init
203
54
  ```
204
55
 
205
- Mutation๋„ ํ˜ธ์ถœ ๋ฐฉ์‹์— ๋”ฐ๋ผ ์ž์—ฐ์Šค๋Ÿฝ๊ฒŒ ๋งž์ถฐ์ง‘๋‹ˆ๋‹ค.
206
-
207
- - API ํ•จ์ˆ˜๊ฐ€ ์ธ์ž 1๊ฐœ๋ฉด ๊ธฐ์กด์ฒ˜๋Ÿผ `mutate(body)` / `mutateAsync(body)`
208
- - API ํ•จ์ˆ˜๊ฐ€ ์ธ์ž ์—ฌ๋Ÿฌ ๊ฐœ๋ฉด ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ object payload ํƒ€์ž…์„ ๋งŒ๋“ค์–ด `mutate({ body, headers })` / `mutateAsync({ body, headers })`
209
-
210
- ๊ฐ„๋‹จํ•œ ์ปค์Šคํ…€ ๋งคํ•‘์ด ํ•„์š”ํ•˜๋ฉด `withOptions(...)`๋กœ๋„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
56
+ ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ ์ด ํŒจํ‚ค์ง€๋ฅผ importํ•˜๋ฏ€๋กœ `-D`๊ฐ€ ์•„๋‹Œ ์ผ๋ฐ˜ dependency๋กœ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.
57
+ React์™€ TanStack Query๊ฐ€ ์ด๋ฏธ ์„ค์น˜๋˜์–ด ์žˆ๋‹ค๋ฉด ํ•„์š”ํ•œ ์˜์กด์„ฑ๋งŒ ์ถ”๊ฐ€ํ•˜์„ธ์š”.
211
58
 
212
- ```ts
213
- const updateUserMutation = updateUserMutationOption.withOptions({
214
- mapVariablesToArgs: ({ id, body }) => [
215
- id,
216
- body,
217
- { Authorization: `Bearer ${token}` },
218
- ],
219
- });
220
- ```
59
+ ### 2. API ๊ฒฝ๋กœ ์ง€์ •
221
60
 
222
- API ํ•จ์ˆ˜๊ฐ€ ์—ฌ๋Ÿฌ ์ธ์ž๋ฅผ ๋ฐ›์œผ๋ฉด, ์ƒ์„ฑ ์ฝ”๋“œ๊ฐ€ `mutate` / `mutateAsync`์—์„œ ๋ฐ”๋กœ ์“ฐ๊ธฐ ์ข‹์€ object payload ํƒ€์ž…๋„ ํ•จ๊ป˜ ๋งŒ๋“ค์–ด ์ค๋‹ˆ๋‹ค.
61
+ `init`์ด ๋งŒ๋“  `rqh.config.ts`์˜ ๊ฒฝ๋กœ๋ฅผ ์•ฑ ๊ตฌ์กฐ์— ๋งž์ถฅ๋‹ˆ๋‹ค.
62
+ ๋ณ„๋„ ํ”Œ๋Ÿฌ๊ทธ์ธ์ด๋‚˜ alias ์„ค์ • ์—†์ด ์‹œ์ž‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
223
63
 
224
64
  ```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
- ์˜ˆ์‹œ:
65
+ // rqh.config.ts
66
+ import type { AutoQueryConfig } from "@uiwwsw/react-query-helper/config";
254
67
 
255
- ```bash
256
- git tag v1.0.3
257
- git push origin v1.0.3
68
+ export default {
69
+ sourceDir: "./libs",
70
+ outputDir: "./src/options",
71
+ ignoredFiles: ["domain.ts", "adaptor.ts", "**/*.test.ts", "**/*.spec.ts"],
72
+ template: { artifactStrategy: "smart" },
73
+ } satisfies AutoQueryConfig;
258
74
  ```
259
75
 
260
- ## ์ƒ์„ฑ ๊ฒฐ๊ณผ ์˜ˆ์‹œ
76
+ ์‹ค์ œ API ํ•จ์ˆ˜๋ฅผ ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ์— ๋‘์„ธ์š”. ์•„๋ž˜๋Š” ํ๋ฆ„์„ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค.
261
77
 
262
78
  ```ts
263
79
  // 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
- };
80
+ export const getUser = async (id: string) => ({ id, name: "Ada" });
274
81
  ```
275
82
 
276
- ```ts
277
- // src/options/users/apiOptions.ts (์ž๋™ ์ƒ์„ฑ)
278
- import { createUser, getUser } from "../../../libs/users/api";
279
- import {
280
- infiniteOption,
281
- mutationOption,
282
- queryOption,
283
- } from "@uiwwsw/react-query-helper";
284
-
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
- );
306
- ```
307
-
308
- ## ํ—ฌํผ ๊ฒฝ๋กœ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•
309
-
310
- ์กฐ์ง ๊ณต์šฉ ํ—ฌํผ๋ฅผ ๋”ฐ๋กœ ๋‘๊ณ  ์žˆ๋‹ค๋ฉด `templateDir`๋กœ ์ƒ์„ฑ ์ฝ”๋“œ์˜ import ๊ฒฝ๋กœ๋ฅผ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
83
+ ### 3. ์ƒ์„ฑํ•˜๊ณ  ์‚ฌ์šฉ
311
84
 
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
- };
85
+ ```sh
86
+ npx @uiwwsw/react-query-helper generate
330
87
  ```
331
88
 
332
- ๋” ๊ฐ•ํ•˜๊ฒŒ ์ปค์Šคํ„ฐ๋งˆ์ด์ง•ํ•˜๋ ค๋ฉด ์™ธ๋ถ€ ๋ชจ๋“ˆ๋„ ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
89
+ `src/options/users/apiOptions.ts`์— `getUserKey`, `getUserQueryOption`,
90
+ `getUserInfiniteQueryOption`์ด ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค. **์ƒ์„ฑ ํŒŒ์ผ ๋Œ€์‹  ์›๋ณธ API๋ฅผ ์ˆ˜์ •ํ•˜์„ธ์š”.**
91
+ ๋ฌดํ•œ ์ฟผ๋ฆฌ ํŒฉํ† ๋ฆฌ๋„ ์ƒ์„ฑ๋˜์ง€๋งŒ ์‹ค์ œ ํŽ˜์ด์ง€๋„ค์ด์…˜ ์„ค์ •์€ API์— ๋งž๊ฒŒ ๋ณ„๋„๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.
333
92
 
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
- ```
93
+ ```tsx
94
+ // src/UserName.tsx
95
+ import { useQuery } from "@tanstack/react-query";
96
+ import { getUserQueryOption } from "./options/users/apiOptions";
342
97
 
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
- ```
98
+ export function UserName({ id }: { id: string }) {
99
+ const user = useQuery(
100
+ getUserQueryOption.withOptions(
101
+ { staleTime: 60_000, select: (data) => data.name },
102
+ id,
103
+ ),
104
+ );
362
105
 
363
- ์˜ˆ์‹œ `rqh.template.mjs`:
364
-
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`;
106
+ if (user.isPending) return <p>Loading...</p>;
107
+ if (user.isError) return <p>{user.error.message}</p>;
108
+ return <p>{user.data}</p>;
369
109
  }
370
110
  ```
371
111
 
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
- ์ฆ‰ ์ด์ œ๋Š” ๊ธฐ๋ณธ ๊ทœ์น™์„ ์กฐ๊ธˆ ๋ฐ”๊พธ๋Š” ์ˆ˜์ค€์ด ์•„๋‹ˆ๋ผ, ํŒ€ ์ „์šฉ ์ƒ์„ฑ๊ธฐ์ฒ˜๋Ÿผ ํ™•์žฅํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
112
+ ์•ฑ ์ƒ์œ„์— `QueryClientProvider`๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ์œ„์˜ `user.data`๋Š” `select`์— ๋”ฐ๋ผ
113
+ `string`์œผ๋กœ ์ถ”๋ก ๋ฉ๋‹ˆ๋‹ค. ์˜ต์…˜์€ ํ›… ๋ฐ”๊นฅ์—์„œ๋„ ์žฌ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
382
114
 
383
115
  ```ts
384
- const config: AutoQueryConfig = {
385
- sourceDir: "./libs",
386
- outputDir: "./src/options",
387
- templateDir: "./src/query-helpers",
388
- };
116
+ // ๊ธฐ์กด QueryClient ์ธ์Šคํ„ด์Šค client์—์„œ
117
+ await client.prefetchQuery(getUserQueryOption("u1"));
118
+ const cached = client.getQueryData(getUserQueryOption("u1").queryKey);
119
+ // { id: string; name: string } | undefined
389
120
  ```
390
121
 
391
- ์˜ˆ๋ฅผ ๋“ค์–ด ์ƒ์„ฑ ํŒŒ์ผ์€ ๊ธฐ๋ณธ ํŒจํ‚ค์ง€ ๋Œ€์‹  ์•„๋ž˜์ฒ˜๋Ÿผ ์ง€์ •ํ•œ ๊ฒฝ๋กœ๋ฅผ import ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.
122
+ ### 4. ๊ฐœ๋ฐœ ํ๋ฆ„์— ์—ฐ๊ฒฐ
392
123
 
393
- ```ts
394
- import {
395
- queryOption,
396
- mutationOption,
397
- infiniteOption,
398
- } from "./src/query-helpers";
124
+ ```json
125
+ {
126
+ "scripts": {
127
+ "query:generate": "react-query-helper generate",
128
+ "query:watch": "react-query-helper watch",
129
+ "query:check": "react-query-helper generate --check"
130
+ }
131
+ }
399
132
  ```
400
133
 
401
- ## ๋ฒ ์ŠคํŠธ ํ”„๋ž™ํ‹ฐ์Šค
134
+ ๊ฐœ๋ฐœํ•  ๋•Œ๋Š” `npm run query:watch`, ์•ฑ CI์—์„œ๋Š” `npm run query:check`๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”.
135
+ check๋Š” ํŒŒ์ผ์„ ์ˆ˜์ •ํ•˜์ง€ ์•Š๊ณ  ๋ˆ„๋ฝยท๋ณ€๊ฒฝยท์˜ค๋ž˜๋œ ๊ฒฐ๊ณผ๋ฅผ ๋ฐœ๊ฒฌํ•˜๋ฉด ์ข…๋ฃŒ ์ฝ”๋“œ 1์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.
136
+ ์ƒ์„ฑ๋ฌผ์„ ์ปค๋ฐ‹ํ•˜์ง€ ์•Š๋Š” ํ”„๋กœ์ ํŠธ๋ผ๋ฉด CI์—์„œ `query:generate` ํ›„ ์•ฑ ํƒ€์ž… ๊ฒ€์‚ฌ๋ฅผ ์‹คํ–‰ํ•˜์„ธ์š”.
402
137
 
403
- - **ํ•˜๋‚˜์˜ API = ํ•˜๋‚˜์˜ ํ›…** ๊ตฌ์กฐ๋ฅผ ์œ ์ง€ํ•˜๋ฉด ์บ์‹œ ํ‚ค ๊ด€๋ฆฌ๊ฐ€ ์‰ฌ์›Œ์ง‘๋‹ˆ๋‹ค.
404
- - ์ƒ์„ฑ๋œ ํŒŒ์ผ์€ ๋ฒ„์ „ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ(Git)์— ์ปค๋ฐ‹ํ•˜์—ฌ ๋ฐฐํฌ ์‹œ ์ž๋™ ์ƒ์„ฑ ๊ณผ์ •์„ ํ”ผํ•˜์„ธ์š”.
405
- - `queryOption` ์œ ํ‹ธ ํ•จ์ˆ˜์—์„œ ๊ธ€๋กœ๋ฒŒ ์˜ต์…˜(`staleTime`, `retry`, `refetchOnWindowFocus`)์„ ์ •์˜ํ•˜๋ฉด ํŒ€ ์ „์ฒด ๊ทœ์น™์„ ์†์‰ฝ๊ฒŒ ํ†ต์ผํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
406
- - Watch ๋ชจ๋“œ ์‚ฌ์šฉ ์‹œ IDE ์ €์žฅ ํฌ๋งทํ„ฐ์™€ ์ถฉ๋Œ์ด ์—†๋„๋ก ์ €์žฅ ์‹œ์  ํฌ๋งทํŒ…์„ ๋งž์ถฐ ์ฃผ์„ธ์š”.
138
+ ## ํ•„์š”ํ•œ ์˜ˆ์ œ ์ฐพ๊ธฐ
407
139
 
408
- ## ์Šคํƒ€ ํžˆ์Šคํ† ๋ฆฌ
140
+ | ํ•˜๊ณ  ์‹ถ์€ ์ผ | ๊ฐ€์ด๋“œ |
141
+ | ----------------------------------- | --------------------------------------------------------------------------------------------------------------- |
142
+ | ์„ค์ • ํŒŒ์ผ, ๊ฒฝ๋กœ, ignore glob ๋ณ€๊ฒฝ | [์„ค์ •](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#์„ค์ •) |
143
+ | ํ•จ์ˆ˜๋ณ„ query/mutation ์ƒ์„ฑ ์ œ์–ด | [์ƒ์„ฑ ๊ทœ์น™๊ณผ ์บ์‹œ ํ‚ค](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#์ƒ์„ฑ-๊ทœ์น™) |
144
+ | mutation ์ธ์ž, ์ทจ์†Œ, ์˜ต์…˜ ํ™•์žฅ | [๋Ÿฐํƒ€์ž„ ์˜ต์…˜](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#๋Ÿฐํƒ€์ž„-์˜ต์…˜) |
145
+ | ์ปค์„œ ํŽ˜์ด์ง€๋„ค์ด์…˜๊ณผ `maxPages` | [๋ฌดํ•œ ์ฟผ๋ฆฌ](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#๋ฌดํ•œ-์ฟผ๋ฆฌ) |
146
+ | ๊ธฐ์กด 1.x ํ”„๋กœ์ ํŠธ ์—…๊ทธ๋ ˆ์ด๋“œ | [๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ ์ฒดํฌ๋ฆฌ์ŠคํŠธ](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#1x์—์„œ-์ด์ „) |
147
+ | ์ง€์›ํ•˜์ง€ ์•Š๋Š” ๋ฌธ๋ฒ•, ์ปค์Šคํ…€ ํ”Œ๋Ÿฌ๊ทธ์ธ | [์ง€์› ๋ฒ”์œ„์™€ ํ™•์žฅ](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#๋ฒ”์œ„์™€-ํ™•์žฅ) |
148
+ | ํ…Œ์ŠคํŠธ, ๋กœ์ปฌ ์„ค์น˜, npm ๋ฐฐํฌ ์„ค์ • | [๊ฐœ๋ฐœ๊ณผ ๋ฐฐํฌ](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REFERENCE.md#๊ฐœ๋ฐœ๊ณผ-๋ฐฐํฌ) |
149
+ | ์ด๋ฒˆ ๊ฐœ์„ ์˜ ๊ทผ๊ฑฐ์™€ ๋‚จ์€ ํ•œ๊ณ„ | [์ €์žฅ์†Œ ๊ฒ€ํ†  ๊ธฐ๋ก](https://github.com/uiwwsw/react-query-helper/blob/main/docs/REVIEW.md) |
409
150
 
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)
151
+ ## ์ง€์› ํ™˜๊ฒฝ๊ณผ ์ฃผ์˜์ 
411
152
 
412
- ## ๊ธฐ์—ฌ
153
+ | ๊ตฌ๋ถ„ | ์ง€์› ๊ธฐ์ค€ |
154
+ | -------------- | -------------------------------------------------- |
155
+ | Node.js | CLI/๋นŒ๋“œ์— 22 ์ด์ƒ, CI๋Š” 22/24 |
156
+ | React | 18/19 |
157
+ | TanStack Query | `>=5.102.8 <6` |
158
+ | TypeScript | 5.8 ์ด์ƒ, ์ƒ์„ฑ ์ฝ”๋“œ๋Š” TS ๋ฒˆ๋“ค๋Ÿฌ์šฉ |
159
+ | ๋ธŒ๋ผ์šฐ์ € | ๋ฃจํŠธ import๋Š” ๋ธŒ๋ผ์šฐ์ €์šฉ, Node ๋„๊ตฌ๋Š” ๋ณ„๋„ subpath |
413
160
 
414
- ๋ฒ„๊ทธ ์ œ๋ณด, ๊ธฐ๋Šฅ ์ œ์•ˆ, ๋ฌธ์„œ ๊ฐœ์„  ๋“ฑ ๋ชจ๋“  ๊ธฐ์—ฌ๋ฅผ ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค. ์ด์Šˆ๋ฅผ ๋“ฑ๋กํ•˜๊ฑฐ๋‚˜ Pull Request๋ฅผ ๋ณด๋‚ด ์ฃผ์„ธ์š”.
161
+ - **2.x๋Š” ํ˜ธํ™˜์„ฑ์„ ๊นจ๋Š” ๋ณ€๊ฒฝ์ž…๋‹ˆ๋‹ค.** ๊ธฐ์กด ์ƒ์„ฑ ํŒŒ์ผ์„ ์˜ฎ๊ธด ๋’ค ์žฌ์ƒ์„ฑํ•˜๊ณ , ์ˆ˜๋™ ํ‚ค์™€ persisted cache๋ฅผ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜ํ•˜์„ธ์š”.
162
+ - API ์ธ์ž๋Š” ์บ์‹œ ํ‚ค์— ํฌํ•จ๋ฉ๋‹ˆ๋‹ค. ์ง๋ ฌํ™” ๊ฐ€๋Šฅํ•œ ๊ฐ’๋งŒ ์ „๋‹ฌํ•˜๊ณ  ํ† ํฐยท์ธ์ฆ ํ—ค๋”๋Š” ๋„ฃ์ง€ ๋งˆ์„ธ์š”.
163
+ - ํŽ˜์ด์ง€๋„ค์ด์…˜๊ณผ ์š”์ฒญ ์ทจ์†Œ๋Š” ์ž๋™ ์ถ”์ธกํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ์ปค์„œ ๋งคํ•‘๊ณผ `AbortSignal` ์ „๋‹ฌ์€ API์— ๋งž์ถฐ ์„ค์ •ํ•˜์„ธ์š”.
164
+ - ์ตœ์ƒ์œ„ ํ•จ์ˆ˜๊ฐ€ ๊ธฐ๋ณธ ๋Œ€์ƒ์ž…๋‹ˆ๋‹ค. re-export barrel, ๋ฉ”์„œ๋“œ, ๋ชจ๋“  generic/overload ๊ด€๊ณ„๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” ๋ฒ”์šฉ TypeScript ๋ณ€ํ™˜๊ธฐ๋Š” ์•„๋‹™๋‹ˆ๋‹ค.
415
165
 
416
- ## ๋ผ์ด์„ ์Šค
166
+ [๋ณ€๊ฒฝ ์ด๋ ฅ](https://github.com/uiwwsw/react-query-helper/blob/main/CHANGELOG.md) ยท [๋กœ๊ณ ์™€ ๋ธŒ๋žœ๋“œ ์ž์‚ฐ](https://github.com/uiwwsw/react-query-helper/blob/main/assets/README.md) ยท [MIT License](https://github.com/uiwwsw/react-query-helper/blob/main/LICENSE)
417
167
 
418
- ์ด ํ”„๋กœ์ ํŠธ๋Š” [MIT ๋ผ์ด์„ ์Šค](LICENSE)๋ฅผ ๋”ฐ๋ฆ…๋‹ˆ๋‹ค.
168
+ ๋…๋ฆฝ์ ์ธ ์ปค๋ฎค๋‹ˆํ‹ฐ ๋„๊ตฌ์ด๋ฉฐ React ๋˜๋Š” TanStack์˜ ๊ณต์‹ ํ”„๋กœ์ ํŠธ๊ฐ€ ์•„๋‹™๋‹ˆ๋‹ค.