@spfn/cms 0.1.0-alpha.64 → 0.1.0-alpha.66

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.
Files changed (104) hide show
  1. package/README.md +75 -31
  2. package/dist/actions-BpTAYuBA.d.ts +195 -0
  3. package/dist/actions.d.ts +2 -143
  4. package/dist/actions.js +5 -5
  5. package/dist/actions.js.map +1 -1
  6. package/dist/api.d.ts +376 -0
  7. package/dist/api.js +364 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/client.d.ts +116 -141
  10. package/dist/client.js +860 -63
  11. package/dist/client.js.map +1 -1
  12. package/dist/{types.d.ts → index-Dh5FjWzR.d.ts} +32 -1
  13. package/dist/index.d.ts +21 -43
  14. package/dist/index.js +556 -1061
  15. package/dist/index.js.map +1 -1
  16. package/dist/label-sync-generator-B0EmvtWM.d.ts +32 -0
  17. package/dist/{contracts → lib/contracts}/labels.d.ts +13 -12
  18. package/dist/{contracts → lib/contracts}/labels.js +7 -7
  19. package/dist/lib/contracts/labels.js.map +1 -0
  20. package/dist/{contracts → lib/contracts}/published-cache.d.ts +3 -2
  21. package/dist/{contracts → lib/contracts}/published-cache.js +2 -2
  22. package/dist/lib/contracts/published-cache.js.map +1 -0
  23. package/dist/{contracts → lib/contracts}/values.d.ts +6 -4
  24. package/dist/{contracts → lib/contracts}/values.js +3 -3
  25. package/dist/lib/contracts/values.js.map +1 -0
  26. package/dist/locale.constants-BMBK70YM.d.ts +104 -0
  27. package/dist/{entities → server/entities}/cms-audit-logs.js +3 -3
  28. package/dist/server/entities/cms-audit-logs.js.map +1 -0
  29. package/dist/{entities → server/entities}/cms-draft-cache.js +1 -1
  30. package/dist/server/entities/cms-draft-cache.js.map +1 -0
  31. package/dist/{entities → server/entities}/cms-label-values.js +3 -3
  32. package/dist/server/entities/cms-label-values.js.map +1 -0
  33. package/dist/{entities → server/entities}/cms-label-versions.js +3 -3
  34. package/dist/server/entities/cms-label-versions.js.map +1 -0
  35. package/dist/{entities → server/entities}/cms-labels.js +1 -1
  36. package/dist/server/entities/cms-labels.js.map +1 -0
  37. package/dist/{entities → server/entities}/cms-published-cache.js +1 -1
  38. package/dist/server/entities/cms-published-cache.js.map +1 -0
  39. package/dist/{entities → server/entities}/index.js +6 -6
  40. package/dist/server/entities/index.js.map +1 -0
  41. package/dist/{generators → server/generators}/index.d.ts +1 -2
  42. package/dist/{generators → server/generators}/index.js +169 -75
  43. package/dist/server/generators/index.js.map +1 -0
  44. package/dist/server/labels/index.d.ts +1 -0
  45. package/dist/{labels → server/labels}/index.js +1 -1
  46. package/dist/server/labels/index.js.map +1 -0
  47. package/dist/{repositories → server/repositories}/index.js +11 -11
  48. package/dist/server/repositories/index.js.map +1 -0
  49. package/dist/{routes → server/routes}/labels/[id]/index.js +20 -20
  50. package/dist/server/routes/labels/[id]/index.js.map +1 -0
  51. package/dist/{routes → server/routes}/labels/by-key/[key]/index.js +20 -20
  52. package/dist/server/routes/labels/by-key/[key]/index.js.map +1 -0
  53. package/dist/{routes → server/routes}/labels/index.d.ts +2 -2
  54. package/dist/{routes → server/routes}/labels/index.js +21 -22
  55. package/dist/server/routes/labels/index.js.map +1 -0
  56. package/dist/{routes → server/routes}/published-cache/index.js +14 -14
  57. package/dist/server/routes/published-cache/index.js.map +1 -0
  58. package/dist/{routes → server/routes}/values/[labelId]/[version]/index.js +16 -16
  59. package/dist/server/routes/values/[labelId]/[version]/index.js.map +1 -0
  60. package/dist/{routes → server/routes}/values/[labelId]/index.js +16 -16
  61. package/dist/server/routes/values/[labelId]/index.js.map +1 -0
  62. package/dist/server.d.ts +68 -7
  63. package/dist/server.js +1483 -10
  64. package/dist/server.js.map +1 -1
  65. package/package.json +37 -35
  66. package/dist/contracts/labels.js.map +0 -1
  67. package/dist/contracts/published-cache.js.map +0 -1
  68. package/dist/contracts/values.js.map +0 -1
  69. package/dist/entities/cms-audit-logs.js.map +0 -1
  70. package/dist/entities/cms-draft-cache.js.map +0 -1
  71. package/dist/entities/cms-label-values.js.map +0 -1
  72. package/dist/entities/cms-label-versions.js.map +0 -1
  73. package/dist/entities/cms-labels.js.map +0 -1
  74. package/dist/entities/cms-published-cache.js.map +0 -1
  75. package/dist/entities/index.js.map +0 -1
  76. package/dist/generators/index.js.map +0 -1
  77. package/dist/label-sync-generator-lQrcVfja.d.ts +0 -36
  78. package/dist/labels/index.d.ts +0 -34
  79. package/dist/labels/index.js.map +0 -1
  80. package/dist/repositories/index.js.map +0 -1
  81. package/dist/routes/labels/[id]/index.js.map +0 -1
  82. package/dist/routes/labels/by-key/[key]/index.js.map +0 -1
  83. package/dist/routes/labels/index.js.map +0 -1
  84. package/dist/routes/published-cache/index.js.map +0 -1
  85. package/dist/routes/values/[labelId]/[version]/index.js.map +0 -1
  86. package/dist/routes/values/[labelId]/index.js.map +0 -1
  87. package/dist/store.d.ts +0 -81
  88. package/dist/store.js +0 -403
  89. package/dist/store.js.map +0 -1
  90. package/dist/types.js +0 -1
  91. package/dist/types.js.map +0 -1
  92. package/dist/{entities → server/entities}/cms-audit-logs.d.ts +0 -0
  93. package/dist/{entities → server/entities}/cms-draft-cache.d.ts +0 -0
  94. package/dist/{entities → server/entities}/cms-label-values.d.ts +0 -0
  95. package/dist/{entities → server/entities}/cms-label-versions.d.ts +0 -0
  96. package/dist/{entities → server/entities}/cms-labels.d.ts +0 -0
  97. package/dist/{entities → server/entities}/cms-published-cache.d.ts +0 -0
  98. package/dist/{entities → server/entities}/index.d.ts +0 -0
  99. package/dist/{repositories → server/repositories}/index.d.ts +14 -14
  100. /package/dist/{routes → server/routes}/labels/_id_/index.d.ts +0 -0
  101. /package/dist/{routes → server/routes}/labels/by-key/_key_/index.d.ts +0 -0
  102. /package/dist/{routes → server/routes}/published-cache/index.d.ts +0 -0
  103. /package/dist/{routes → server/routes}/values/_labelId_/_version_/index.d.ts +0 -0
  104. /package/dist/{routes → server/routes}/values/_labelId_/index.d.ts +0 -0
package/README.md CHANGED
@@ -16,7 +16,7 @@ Content Management System for Next.js with JSON-based labels and automatic datab
16
16
 
17
17
  ## Installation
18
18
 
19
- ### Recommended: Using SPFN CLI (Automatic Database Setup)
19
+ ### Recommended: Using Superfunction CLI (Automatic Database Setup)
20
20
 
21
21
  ```bash
22
22
  pnpm spfn add @spfn/cms
@@ -59,7 +59,7 @@ pnpm spfn db migrate # Apply migrations
59
59
  Create JSON files organized by sections and categories:
60
60
 
61
61
  ```
62
- src/cms/labels/
62
+ src/lib/labels/
63
63
  layout/ ← Section name
64
64
  nav.json ← Category
65
65
  footer.json
@@ -68,7 +68,7 @@ src/cms/labels/
68
68
  features.json
69
69
  ```
70
70
 
71
- **Example:** `src/cms/labels/layout/nav.json`
71
+ **Example:** `src/lib/labels/layout/nav.json`
72
72
 
73
73
  ```json
74
74
  {
@@ -89,7 +89,7 @@ src/cms/labels/
89
89
  }
90
90
  ```
91
91
 
92
- **Multi-language example:** `src/cms/labels/home/hero.json`
92
+ **Multi-language example:** `src/lib/labels/home/hero.json`
93
93
 
94
94
  ```json
95
95
  {
@@ -110,7 +110,7 @@ src/cms/labels/
110
110
  }
111
111
  ```
112
112
 
113
- **Variable substitution:** `src/cms/labels/layout/footer.json`
113
+ **Variable substitution:** `src/lib/labels/layout/footer.json`
114
114
 
115
115
  ```json
116
116
  {
@@ -127,13 +127,14 @@ Configure `src/server/server.config.ts`:
127
127
 
128
128
  ```typescript
129
129
  import type { ServerConfig } from '@spfn/core/server';
130
- import { initLabelSync } from '@spfn/cms';
130
+ import { initLabelSync } from '@spfn/cms/server';
131
+ import { DEFAULT_LABELS_DIR } from '@spfn/cms';
131
132
 
132
133
  export default {
133
134
  beforeRoutes: async (app) => {
134
135
  await initLabelSync({
135
136
  verbose: true,
136
- labelsDir: 'src/cms/labels' // Optional, this is the default
137
+ // labelsDir: DEFAULT_LABELS_DIR // Optional, this is the default
137
138
  });
138
139
  },
139
140
  } satisfies ServerConfig;
@@ -205,7 +206,7 @@ export default function Nav() {
205
206
  ## File Structure
206
207
 
207
208
  ```
208
- src/cms/labels/
209
+ src/lib/labels/
209
210
  layout/ # Section: layout
210
211
  nav.json # Category: nav
211
212
  footer.json # Category: footer
@@ -221,7 +222,7 @@ src/cms/labels/
221
222
 
222
223
  Example:
223
224
  ```
224
- src/cms/labels/layout/nav.json:
225
+ src/lib/labels/layout/nav.json:
225
226
  key: "layout.nav.team" → t('nav.team') in code
226
227
  ```
227
228
 
@@ -279,6 +280,18 @@ t('greeting', undefined, { name: 'John' })
279
280
 
280
281
  ## Configuration
281
282
 
283
+ ### Default Paths
284
+
285
+ The default label directory path is defined as a constant:
286
+
287
+ ```typescript
288
+ import { DEFAULT_LABELS_DIR } from '@spfn/cms';
289
+
290
+ console.log(DEFAULT_LABELS_DIR); // 'src/lib/labels'
291
+ ```
292
+
293
+ This constant is used throughout the CMS package and can be referenced in your code to avoid hardcoding paths.
294
+
282
295
  ### Environment Variables
283
296
 
284
297
  Configure CMS behavior via environment variables in `.env.local`:
@@ -344,7 +357,7 @@ export default async function RootLayout({ children }) {
344
357
  ```typescript
345
358
  // Client Component
346
359
  'use client';
347
- import { getLocale } from '@spfn/cms/actions';
360
+ import { getLocale } from '@spfn/cms/client';
348
361
  import { useEffect, useState } from 'react';
349
362
 
350
363
  export default function LanguageSwitcher() {
@@ -393,13 +406,20 @@ const { t: tEn } = await getSection('home', 'en');
393
406
 
394
407
  ## Documentation
395
408
 
396
- - **[Label Auto-Sync Guide](./LABEL_SYNC_GUIDE.md)** - Detailed configuration guide
409
+ ### Getting Started
410
+ - **[Label Auto-Sync Guide](./LABEL_SYNC_GUIDE.md)** - Detailed sync configuration and options
397
411
  - **[Examples](./examples/)** - Usage examples
398
412
 
413
+ ### Advanced Guides
414
+ - **[Advanced Features](./ADVANCED_FEATURES.md)** - Breakpoints, value types, InitCms, Draft Mode
415
+ - **[Locale Management](./LOCALE_GUIDE.md)** - Complete locale guide with 50+ languages
416
+ - **[API Reference](./API_REFERENCE.md)** - Complete API documentation and repository functions
417
+ - **[Draft & Versioning](./DRAFT_AND_VERSIONING.md)** - Draft system, version control, audit logs
418
+
399
419
  ## Architecture
400
420
 
401
421
  ```
402
- JSON Files (src/cms/labels/**/*.json)
422
+ JSON Files (src/lib/labels/**/*.json)
403
423
 
404
424
  loadLabelsFromJson()
405
425
 
@@ -425,49 +445,73 @@ JSON Files (src/cms/labels/**/*.json)
425
445
 
426
446
  ## API Reference
427
447
 
428
- ### Server-side API
448
+ ### Common API (`@spfn/cms`)
429
449
 
450
+ **Configuration:**
451
+ - `getCmsConfig()` - Get current CMS configuration
452
+ - `configureCms(config)` - Update configuration (runtime)
453
+ - `resetCmsConfig()` - Reset configuration to defaults
454
+
455
+ **Constants:**
456
+ - `DEFAULT_LABELS_DIR` - Default label directory path (`'src/lib/labels'`)
457
+ - `LOCALE_COOKIE_KEY` - Locale cookie key constant
458
+ - Locale helpers: `getLocaleInfo()`, `getSupportedLocales()`, `getFlag()`, `getDialCode()`, `isRTL()`
459
+
460
+ **Types:**
461
+ - `SectionData`, `SectionAPI`, `CmsConfig`, `LocaleInfo`, `SupportedLocale`
462
+
463
+ ### Server-side API (`@spfn/cms/server`)
464
+
465
+ **Server Components:**
430
466
  - `getSection(section, locale?)` - Get section labels (auto-detects locale if not specified)
431
467
  - `getSections(sections, locale?)` - Get multiple sections (auto-detects locale if not specified)
468
+
469
+ **Backend/Sync:**
432
470
  - `initLabelSync(options?)` - Sync labels on server startup
471
+ - `syncAll(sections, options?)` - Sync all sections
472
+ - `syncSection(definition, options?)` - Sync specific section
473
+ - `loadLabelsFromJson(labelsDir)` - Load labels from JSON files
433
474
 
434
- ### Server Actions API (`@spfn/cms/actions`)
475
+ **Repositories & Entities:**
476
+ - All repository and entity exports
435
477
 
436
- Available for both server and client components:
478
+ **Codegen:**
479
+ - `createLabelSyncGenerator(config?)` - Generator factory
480
+ - `LabelSyncGenerator` - Generator class
437
481
 
482
+ **Locale (Server Actions):**
438
483
  - `getLocale()` - Get current locale (cookie → browser → default)
439
484
  - `setLocale(locale)` - Set locale (saves to cookie)
440
485
  - `getLocales()` - Get supported locale list
441
- - `LOCALE_COOKIE_KEY` - Locale cookie key constant
486
+ - `getLocaleWithInfo()`, `getLocalesWithInfo()`, `isValidLocale()`
442
487
 
443
- ### Configuration API
488
+ ### Server Actions API (`@spfn/cms/actions`)
444
489
 
445
- - `getCmsConfig()` - Get current CMS configuration
446
- - `configureCms(config)` - Update configuration (runtime)
447
- - `resetCmsConfig()` - Reset configuration to defaults
490
+ *Alias for `@spfn/cms/server` locale functions - available for both server and client components*
448
491
 
449
492
  ### Client-side API (`@spfn/cms/client`)
450
493
 
451
494
  - `useSection(section, options?)` - Section labels hook
452
495
  - `useSections(sections)` - Multiple sections hook
453
496
  - `useCmsStore()` - CMS store hook
454
- - `cmsApi` - CMS API client
455
497
  - `InitCms` - Client initialization component
456
498
 
457
- ### Sync API
458
-
459
- - `loadLabelsFromJson(labelsDir)` - Load labels from JSON files
460
- - `syncAll(sections, options?)` - Sync all sections
461
- - `syncSection(definition, options?)` - Sync specific section
499
+ ### Management API (`@spfn/cms/api`)
462
500
 
463
- ### Codegen Integration
501
+ ⚠️ **Admin only** - Use with proper authentication
464
502
 
465
- - `createLabelSyncGenerator(config?)` - Generator factory
466
- - `LabelSyncGenerator` - Generator class
503
+ - `cmsApi.cmsLabels.get(options?)` - List labels with filters
504
+ - `cmsApi.cmsLabels.getById(options)` - Get label by ID
505
+ - `cmsApi.cmsLabels.post(options)` - Create new label
506
+ - `cmsApi.cmsLabels.update(options)` - Update label
507
+ - `cmsApi.cmsLabels.delete(options)` - Delete label
508
+ - `cmsApi.cmsLabelsByKey` - Get labels by key
509
+ - `cmsApi.cmsValues` - Manage label values
510
+ - `cmsApi.cmsPublishedCache.get(options)` - Get published cache
467
511
 
468
512
  ## Development Workflow
469
513
 
470
- 1. **Create/Edit JSON files** in `src/cms/labels/`
514
+ 1. **Create/Edit JSON files** in `src/lib/labels/`
471
515
  2. **Auto-sync happens** (if dev server is running)
472
516
  3. **Labels immediately available** via `getSection()` or `useSection()`
473
517
 
@@ -478,7 +522,7 @@ Available for both server and client components:
478
522
  pnpm dev
479
523
 
480
524
  # Terminal 2: Edit label file
481
- echo '{"test": {"key": "layout.test", "defaultValue": "Test"}}' > src/cms/labels/layout/test.json
525
+ echo '{"test": {"key": "layout.test", "defaultValue": "Test"}}' > src/lib/labels/layout/test.json
482
526
 
483
527
  # Auto-sync triggers
484
528
  # ✅ Label sync completed
@@ -0,0 +1,195 @@
1
+ import { e as LocaleInfo } from './locale.constants-BMBK70YM.js';
2
+
3
+ /**
4
+ * 현재 locale 가져오기 (Server Action)
5
+ *
6
+ * 서버/클라이언트 컴포넌트 모두에서 사용 가능
7
+ *
8
+ * 우선순위:
9
+ * 1. 쿠키 (사용자가 명시적으로 선택한 언어)
10
+ * 2. 브라우저 언어 감지 (설정에서 활성화된 경우)
11
+ * 3. 시스템 기본 언어 (CMS 설정)
12
+ *
13
+ * @returns 현재 locale (예: 'ko', 'en')
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * // Server Component
18
+ * import { getLocale } from '@spfn/cms/actions';
19
+ *
20
+ * export default async function Page()
21
+ * {
22
+ * const locale = await getLocale();
23
+ * return <div>Current locale: {locale}</div>;
24
+ * }
25
+ * ```
26
+ *
27
+ * @example
28
+ * ```tsx
29
+ * // Client Component
30
+ * 'use client';
31
+ * import { getLocale } from '@spfn/cms/client';
32
+ *
33
+ * export default function LanguageSwitcher()
34
+ * {
35
+ * const [locale, setLocale] = useState('');
36
+ *
37
+ * useEffect(() => {
38
+ * getLocale().then(setLocale);
39
+ * }, []);
40
+ *
41
+ * return <div>Current locale: {locale}</div>;
42
+ * }
43
+ * ```
44
+ */
45
+ declare function getLocale(): Promise<string>;
46
+ /**
47
+ * Locale 설정하기 (Server Action)
48
+ *
49
+ * 서버/클라이언트 컴포넌트 모두에서 사용 가능
50
+ * 쿠키에 locale을 저장합니다.
51
+ *
52
+ * @param locale - 설정할 locale (예: 'ko', 'en')
53
+ * @throws {Error} 지원하지 않는 locale인 경우
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * // Server Component (Server Action)
58
+ * import { setLocale } from '@spfn/cms/actions';
59
+ *
60
+ * export default async function Page()
61
+ * {
62
+ * await setLocale('en');
63
+ * return <div>Locale changed</div>;
64
+ * }
65
+ * ```
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * // Client Component (Server Action)
70
+ * 'use client';
71
+ * import { setLocale } from '@spfn/cms/client';
72
+ *
73
+ * export default function LanguageSwitcher()
74
+ * {
75
+ * const handleChange = async (newLocale: string) =>
76
+ * {
77
+ * await setLocale(newLocale);
78
+ * window.location.reload(); // 페이지 새로고침
79
+ * };
80
+ *
81
+ * return (
82
+ * <button onClick={() => handleChange('en')}>
83
+ * Switch to English
84
+ * </button>
85
+ * );
86
+ * }
87
+ * ```
88
+ */
89
+ declare function setLocale(locale: string): Promise<void>;
90
+ /**
91
+ * 지원하는 locale 목록 가져오기 (Server Action)
92
+ *
93
+ * 서버/클라이언트 컴포넌트 모두에서 사용 가능
94
+ *
95
+ * @returns 지원하는 locale 배열 (예: ['ko', 'en', 'ja'])
96
+ *
97
+ * @example
98
+ * ```tsx
99
+ * // Server Component
100
+ * import { getLocales } from '@spfn/cms/actions';
101
+ *
102
+ * export default async function Page()
103
+ * {
104
+ * const locales = await getLocales();
105
+ * return <div>Supported: {locales.join(', ')}</div>;
106
+ * }
107
+ * ```
108
+ *
109
+ * @example
110
+ * ```tsx
111
+ * // Client Component
112
+ * 'use client';
113
+ * import { getLocales } from '@spfn/cms/client';
114
+ *
115
+ * export default function LanguageSwitcher()
116
+ * {
117
+ * const [locales, setLocales] = useState<string[]>([]);
118
+ *
119
+ * useEffect(() => {
120
+ * getLocales().then(setLocales);
121
+ * }, []);
122
+ *
123
+ * return (
124
+ * <div>
125
+ * {locales.map(locale => (
126
+ * <button key={locale}>{locale}</button>
127
+ * ))}
128
+ * </div>
129
+ * );
130
+ * }
131
+ * ```
132
+ */
133
+ declare function getLocales(): Promise<string[]>;
134
+ /**
135
+ * 현재 locale과 상세 정보 함께 가져오기 (Server Action)
136
+ *
137
+ * locale 코드와 함께 국가 코드, 국기, 전화번호 코드 등의 상세 정보를 반환합니다.
138
+ *
139
+ * @returns Locale 코드와 LocaleInfo 객체
140
+ *
141
+ * @example
142
+ * ```tsx
143
+ * // Server Component
144
+ * import { getLocaleWithInfo } from '@spfn/cms/actions';
145
+ *
146
+ * export default async function Page()
147
+ * {
148
+ * const { locale, info } = await getLocaleWithInfo();
149
+ *
150
+ * return (
151
+ * <div>
152
+ * <span>{info?.flag}</span>
153
+ * <span>{info?.nativeName}</span>
154
+ * <span>{info?.dialCode}</span>
155
+ * </div>
156
+ * );
157
+ * }
158
+ * ```
159
+ */
160
+ declare function getLocaleWithInfo(): Promise<{
161
+ locale: string;
162
+ info: LocaleInfo | undefined;
163
+ }>;
164
+ /**
165
+ * 지원하는 모든 locale과 상세 정보 가져오기 (Server Action)
166
+ *
167
+ * 시스템이 지원하는 모든 locale의 상세 정보를 배열로 반환합니다.
168
+ * 언어 선택 UI를 만들 때 유용합니다.
169
+ *
170
+ * @returns LocaleInfo 배열
171
+ *
172
+ * @example
173
+ * ```tsx
174
+ * // Server Component
175
+ * import { getLocalesWithInfo } from '@spfn/cms/actions';
176
+ *
177
+ * export default async function LanguageSelector()
178
+ * {
179
+ * const locales = await getLocalesWithInfo();
180
+ *
181
+ * return (
182
+ * <select>
183
+ * {locales.map(info => (
184
+ * <option key={info.locale} value={info.locale}>
185
+ * {info.flag} {info.nativeName}
186
+ * </option>
187
+ * ))}
188
+ * </select>
189
+ * );
190
+ * }
191
+ * ```
192
+ */
193
+ declare function getLocalesWithInfo(): Promise<LocaleInfo[]>;
194
+
195
+ export { getLocales as a, getLocaleWithInfo as b, getLocalesWithInfo as c, getLocale as g, setLocale as s };
package/dist/actions.d.ts CHANGED
@@ -1,143 +1,2 @@
1
- /**
2
- * 현재 locale 가져오기 (Server Action)
3
- *
4
- * 서버/클라이언트 컴포넌트 모두에서 사용 가능
5
- *
6
- * 우선순위:
7
- * 1. 쿠키 (사용자가 명시적으로 선택한 언어)
8
- * 2. 브라우저 언어 감지 (설정에서 활성화된 경우)
9
- * 3. 시스템 기본 언어 (CMS 설정)
10
- *
11
- * @returns 현재 locale (예: 'ko', 'en')
12
- *
13
- * @example
14
- * ```tsx
15
- * // Server Component
16
- * import { getLocale } from '@spfn/cms';
17
- *
18
- * export default async function Page()
19
- * {
20
- * const locale = await getLocale();
21
- * return <div>Current locale: {locale}</div>;
22
- * }
23
- * ```
24
- *
25
- * @example
26
- * ```tsx
27
- * // Client Component
28
- * 'use client';
29
- * import { getLocale } from '@spfn/cms/client';
30
- *
31
- * export default function LanguageSwitcher()
32
- * {
33
- * const [locale, setLocale] = useState('');
34
- *
35
- * useEffect(() => {
36
- * getLocale().then(setLocale);
37
- * }, []);
38
- *
39
- * return <div>Current locale: {locale}</div>;
40
- * }
41
- * ```
42
- */
43
- declare function getLocale(): Promise<string>;
44
- /**
45
- * Locale 설정하기 (Server Action)
46
- *
47
- * 서버/클라이언트 컴포넌트 모두에서 사용 가능
48
- * 쿠키에 locale을 저장합니다.
49
- *
50
- * @param locale - 설정할 locale (예: 'ko', 'en')
51
- * @throws {Error} 지원하지 않는 locale인 경우
52
- *
53
- * @example
54
- * ```tsx
55
- * // Server Component (Server Action)
56
- * import { setLocale } from '@spfn/cms';
57
- *
58
- * export default async function Page()
59
- * {
60
- * await setLocale('en');
61
- * return <div>Locale changed</div>;
62
- * }
63
- * ```
64
- *
65
- * @example
66
- * ```tsx
67
- * // Client Component (Server Action)
68
- * 'use client';
69
- * import { setLocale } from '@spfn/cms/client';
70
- *
71
- * export default function LanguageSwitcher()
72
- * {
73
- * const handleChange = async (newLocale: string) =>
74
- * {
75
- * await setLocale(newLocale);
76
- * window.location.reload(); // 페이지 새로고침
77
- * };
78
- *
79
- * return (
80
- * <button onClick={() => handleChange('en')}>
81
- * Switch to English
82
- * </button>
83
- * );
84
- * }
85
- * ```
86
- */
87
- declare function setLocale(locale: string): Promise<void>;
88
- /**
89
- * 지원하는 locale 목록 가져오기 (Server Action)
90
- *
91
- * 서버/클라이언트 컴포넌트 모두에서 사용 가능
92
- *
93
- * @returns 지원하는 locale 배열 (예: ['ko', 'en', 'ja'])
94
- *
95
- * @example
96
- * ```tsx
97
- * // Server Component
98
- * import { getLocales } from '@spfn/cms';
99
- *
100
- * export default async function Page()
101
- * {
102
- * const locales = await getLocales();
103
- * return <div>Supported: {locales.join(', ')}</div>;
104
- * }
105
- * ```
106
- *
107
- * @example
108
- * ```tsx
109
- * // Client Component
110
- * 'use client';
111
- * import { getLocales } from '@spfn/cms/client';
112
- *
113
- * export default function LanguageSwitcher()
114
- * {
115
- * const [locales, setLocales] = useState<string[]>([]);
116
- *
117
- * useEffect(() => {
118
- * getLocales().then(setLocales);
119
- * }, []);
120
- *
121
- * return (
122
- * <div>
123
- * {locales.map(locale => (
124
- * <button key={locale}>{locale}</button>
125
- * ))}
126
- * </div>
127
- * );
128
- * }
129
- * ```
130
- */
131
- declare function getLocales(): Promise<string[]>;
132
-
133
- /**
134
- * Locale Constants
135
- *
136
- * Server/Client 양쪽에서 사용 가능한 locale 관련 상수
137
- */
138
- /**
139
- * Locale 쿠키 키
140
- */
141
- declare const LOCALE_COOKIE_KEY = "spfn-locale";
142
-
143
- export { LOCALE_COOKIE_KEY, getLocale, getLocales, setLocale };
1
+ export { g as getLocale, a as getLocales, s as setLocale } from './actions-BpTAYuBA.js';
2
+ export { L as LOCALE_COOKIE_KEY } from './locale.constants-BMBK70YM.js';
package/dist/actions.js CHANGED
@@ -1,7 +1,7 @@
1
- // src/helpers/locale.actions.ts
2
- import { cookies, headers } from "next/headers.js";
1
+ // src/server/helpers/locale.actions.ts
2
+ import { cookies, headers } from "next/headers";
3
3
 
4
- // src/cms.config.ts
4
+ // src/server/config/cms.config.ts
5
5
  function getEnvVar(key, defaultValue) {
6
6
  return process.env[key] || defaultValue;
7
7
  }
@@ -29,10 +29,10 @@ function getCmsConfig() {
29
29
  return currentConfig;
30
30
  }
31
31
 
32
- // src/helpers/locale.constants.ts
32
+ // src/lib/constants/locale.constants.ts
33
33
  var LOCALE_COOKIE_KEY = "spfn-locale";
34
34
 
35
- // src/helpers/locale.actions.ts
35
+ // src/server/helpers/locale.actions.ts
36
36
  async function detectBrowserLanguage() {
37
37
  try {
38
38
  const headersList = await headers();