@spfn/cms 0.1.0-alpha.7 → 0.1.0-alpha.70

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 (224) hide show
  1. package/README.md +28 -416
  2. package/dist/{helpers/locale.actions.d.ts → actions-BpTAYuBA.d.ts} +70 -7
  3. package/dist/actions.d.ts +2 -9
  4. package/dist/actions.js +97 -10
  5. package/dist/actions.js.map +1 -1
  6. package/dist/api.d.ts +214 -0
  7. package/dist/api.js +353 -0
  8. package/dist/api.js.map +1 -0
  9. package/dist/client.d.ts +136 -127
  10. package/dist/client.js +1199 -59
  11. package/dist/client.js.map +1 -1
  12. package/dist/{types.d.ts → index-Dh5FjWzR.d.ts} +45 -7
  13. package/dist/index.d.ts +108 -16
  14. package/dist/index.js +610 -23
  15. package/dist/index.js.map +1 -1
  16. package/dist/label-sync-generator-B0EmvtWM.d.ts +32 -0
  17. package/dist/lib/contracts/labels.d.ts +151 -0
  18. package/dist/lib/contracts/labels.js +168 -0
  19. package/dist/lib/contracts/labels.js.map +1 -0
  20. package/dist/lib/contracts/published-cache.d.ts +48 -0
  21. package/dist/lib/contracts/published-cache.js +49 -0
  22. package/dist/lib/contracts/published-cache.js.map +1 -0
  23. package/dist/lib/contracts/values.d.ts +71 -0
  24. package/dist/lib/contracts/values.js +103 -0
  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.d.ts +15 -70
  28. package/dist/server/entities/cms-audit-logs.js +78 -0
  29. package/dist/server/entities/cms-audit-logs.js.map +1 -0
  30. package/dist/{entities → server/entities}/cms-draft-cache.d.ts +13 -73
  31. package/dist/server/entities/cms-draft-cache.js +38 -0
  32. package/dist/server/entities/cms-draft-cache.js.map +1 -0
  33. package/dist/{entities → server/entities}/cms-label-values.d.ts +16 -67
  34. package/dist/server/entities/cms-label-values.js +81 -0
  35. package/dist/server/entities/cms-label-values.js.map +1 -0
  36. package/dist/{entities → server/entities}/cms-label-versions.d.ts +16 -49
  37. package/dist/server/entities/cms-label-versions.js +76 -0
  38. package/dist/server/entities/cms-label-versions.js.map +1 -0
  39. package/dist/{entities → server/entities}/cms-labels.d.ts +17 -14
  40. package/dist/server/entities/cms-labels.js +42 -0
  41. package/dist/server/entities/cms-labels.js.map +1 -0
  42. package/dist/{entities → server/entities}/cms-published-cache.d.ts +14 -69
  43. package/dist/server/entities/cms-published-cache.js +36 -0
  44. package/dist/server/entities/cms-published-cache.js.map +1 -0
  45. package/dist/server/entities/index.d.ts +7 -0
  46. package/dist/server/entities/index.js +218 -0
  47. package/dist/server/entities/index.js.map +1 -0
  48. package/dist/server/generators/index.d.ts +19 -0
  49. package/dist/server/generators/index.js +753 -0
  50. package/dist/server/generators/index.js.map +1 -0
  51. package/dist/server/labels/index.d.ts +1 -0
  52. package/dist/server/labels/index.js +32 -0
  53. package/dist/server/labels/index.js.map +1 -0
  54. package/dist/server/repositories/index.d.ts +209 -0
  55. package/dist/server/repositories/index.js +441 -0
  56. package/dist/server/repositories/index.js.map +1 -0
  57. package/dist/server/routes/labels/[id]/index.js +508 -0
  58. package/dist/server/routes/labels/[id]/index.js.map +1 -0
  59. package/dist/{routes/labels/[id] → server/routes/labels/_id_}/index.d.ts +5 -3
  60. package/dist/server/routes/labels/by-key/[key]/index.js +458 -0
  61. package/dist/server/routes/labels/by-key/[key]/index.js.map +1 -0
  62. package/dist/server/routes/labels/by-key/_key_/index.d.ts +10 -0
  63. package/dist/server/routes/labels/index.d.ts +12 -0
  64. package/dist/server/routes/labels/index.js +617 -0
  65. package/dist/server/routes/labels/index.js.map +1 -0
  66. package/dist/server/routes/published-cache/index.d.ts +11 -0
  67. package/dist/server/routes/published-cache/index.js +369 -0
  68. package/dist/server/routes/published-cache/index.js.map +1 -0
  69. package/dist/server/routes/values/[labelId]/[version]/index.js +479 -0
  70. package/dist/server/routes/values/[labelId]/[version]/index.js.map +1 -0
  71. package/dist/server/routes/values/[labelId]/index.js +474 -0
  72. package/dist/server/routes/values/[labelId]/index.js.map +1 -0
  73. package/dist/server/routes/values/_labelId_/_version_/index.d.ts +10 -0
  74. package/dist/server/routes/values/_labelId_/index.d.ts +10 -0
  75. package/dist/server.d.ts +78 -7
  76. package/dist/server.js +1752 -247
  77. package/dist/server.js.map +1 -1
  78. package/migrations/0000_init.sql +3 -0
  79. package/migrations/0001_far_lady_vermin.sql +86 -0
  80. package/migrations/0002_heavy_the_enforcers.sql +2 -0
  81. package/migrations/meta/0000_snapshot.json +15 -0
  82. package/migrations/meta/0001_snapshot.json +687 -0
  83. package/migrations/meta/0002_snapshot.json +686 -0
  84. package/migrations/meta/_journal.json +27 -0
  85. package/package.json +55 -36
  86. package/dist/actions.d.ts.map +0 -1
  87. package/dist/client.d.ts.map +0 -1
  88. package/dist/cms.config.d.ts +0 -77
  89. package/dist/cms.config.d.ts.map +0 -1
  90. package/dist/cms.config.js +0 -111
  91. package/dist/cms.config.js.map +0 -1
  92. package/dist/entities/cms-audit-logs.d.ts.map +0 -1
  93. package/dist/entities/cms-audit-logs.js +0 -103
  94. package/dist/entities/cms-audit-logs.js.map +0 -1
  95. package/dist/entities/cms-draft-cache.d.ts.map +0 -1
  96. package/dist/entities/cms-draft-cache.js +0 -112
  97. package/dist/entities/cms-draft-cache.js.map +0 -1
  98. package/dist/entities/cms-label-values.d.ts.map +0 -1
  99. package/dist/entities/cms-label-values.js +0 -105
  100. package/dist/entities/cms-label-values.js.map +0 -1
  101. package/dist/entities/cms-label-versions.d.ts.map +0 -1
  102. package/dist/entities/cms-label-versions.js +0 -80
  103. package/dist/entities/cms-label-versions.js.map +0 -1
  104. package/dist/entities/cms-labels.d.ts.map +0 -1
  105. package/dist/entities/cms-labels.js +0 -48
  106. package/dist/entities/cms-labels.js.map +0 -1
  107. package/dist/entities/cms-published-cache.d.ts.map +0 -1
  108. package/dist/entities/cms-published-cache.js +0 -103
  109. package/dist/entities/cms-published-cache.js.map +0 -1
  110. package/dist/entities/index.d.ts +0 -10
  111. package/dist/entities/index.d.ts.map +0 -1
  112. package/dist/entities/index.js +0 -10
  113. package/dist/entities/index.js.map +0 -1
  114. package/dist/generators/index.d.ts +0 -19
  115. package/dist/generators/index.d.ts.map +0 -1
  116. package/dist/generators/index.js +0 -19
  117. package/dist/generators/index.js.map +0 -1
  118. package/dist/generators/label-sync-generator.d.ts +0 -33
  119. package/dist/generators/label-sync-generator.d.ts.map +0 -1
  120. package/dist/generators/label-sync-generator.js +0 -87
  121. package/dist/generators/label-sync-generator.js.map +0 -1
  122. package/dist/helpers/locale.actions.d.ts.map +0 -1
  123. package/dist/helpers/locale.actions.js +0 -210
  124. package/dist/helpers/locale.actions.js.map +0 -1
  125. package/dist/helpers/locale.constants.d.ts +0 -10
  126. package/dist/helpers/locale.constants.d.ts.map +0 -1
  127. package/dist/helpers/locale.constants.js +0 -10
  128. package/dist/helpers/locale.constants.js.map +0 -1
  129. package/dist/helpers/locale.d.ts +0 -17
  130. package/dist/helpers/locale.d.ts.map +0 -1
  131. package/dist/helpers/locale.js +0 -20
  132. package/dist/helpers/locale.js.map +0 -1
  133. package/dist/helpers/sync.d.ts +0 -41
  134. package/dist/helpers/sync.d.ts.map +0 -1
  135. package/dist/helpers/sync.js +0 -309
  136. package/dist/helpers/sync.js.map +0 -1
  137. package/dist/index.d.ts.map +0 -1
  138. package/dist/init.d.ts +0 -31
  139. package/dist/init.d.ts.map +0 -1
  140. package/dist/init.js +0 -36
  141. package/dist/init.js.map +0 -1
  142. package/dist/labels/helpers.d.ts +0 -31
  143. package/dist/labels/helpers.d.ts.map +0 -1
  144. package/dist/labels/helpers.js +0 -60
  145. package/dist/labels/helpers.js.map +0 -1
  146. package/dist/labels/index.d.ts +0 -7
  147. package/dist/labels/index.d.ts.map +0 -1
  148. package/dist/labels/index.js +0 -7
  149. package/dist/labels/index.js.map +0 -1
  150. package/dist/repositories/cms-draft-cache.repository.d.ts +0 -62
  151. package/dist/repositories/cms-draft-cache.repository.d.ts.map +0 -1
  152. package/dist/repositories/cms-draft-cache.repository.js +0 -56
  153. package/dist/repositories/cms-draft-cache.repository.js.map +0 -1
  154. package/dist/repositories/cms-label-values.repository.d.ts +0 -32
  155. package/dist/repositories/cms-label-values.repository.d.ts.map +0 -1
  156. package/dist/repositories/cms-label-values.repository.js +0 -72
  157. package/dist/repositories/cms-label-values.repository.js.map +0 -1
  158. package/dist/repositories/cms-labels.repository.d.ts +0 -53
  159. package/dist/repositories/cms-labels.repository.d.ts.map +0 -1
  160. package/dist/repositories/cms-labels.repository.js +0 -77
  161. package/dist/repositories/cms-labels.repository.js.map +0 -1
  162. package/dist/repositories/cms-published-cache.repository.d.ts +0 -53
  163. package/dist/repositories/cms-published-cache.repository.d.ts.map +0 -1
  164. package/dist/repositories/cms-published-cache.repository.js +0 -54
  165. package/dist/repositories/cms-published-cache.repository.js.map +0 -1
  166. package/dist/repositories/index.d.ts +0 -8
  167. package/dist/repositories/index.d.ts.map +0 -1
  168. package/dist/repositories/index.js +0 -9
  169. package/dist/repositories/index.js.map +0 -1
  170. package/dist/routes/labels/[id]/contract.d.ts +0 -68
  171. package/dist/routes/labels/[id]/contract.d.ts.map +0 -1
  172. package/dist/routes/labels/[id]/contract.js +0 -84
  173. package/dist/routes/labels/[id]/contract.js.map +0 -1
  174. package/dist/routes/labels/[id]/index.d.ts.map +0 -1
  175. package/dist/routes/labels/[id]/index.js +0 -96
  176. package/dist/routes/labels/[id]/index.js.map +0 -1
  177. package/dist/routes/labels/by-key/[key]/contract.d.ts +0 -24
  178. package/dist/routes/labels/by-key/[key]/contract.d.ts.map +0 -1
  179. package/dist/routes/labels/by-key/[key]/contract.js +0 -28
  180. package/dist/routes/labels/by-key/[key]/contract.js.map +0 -1
  181. package/dist/routes/labels/by-key/[key]/index.d.ts +0 -8
  182. package/dist/routes/labels/by-key/[key]/index.d.ts.map +0 -1
  183. package/dist/routes/labels/by-key/[key]/index.js +0 -32
  184. package/dist/routes/labels/by-key/[key]/index.js.map +0 -1
  185. package/dist/routes/labels/contract.d.ts +0 -59
  186. package/dist/routes/labels/contract.d.ts.map +0 -1
  187. package/dist/routes/labels/contract.js +0 -75
  188. package/dist/routes/labels/contract.js.map +0 -1
  189. package/dist/routes/labels/index.d.ts +0 -10
  190. package/dist/routes/labels/index.d.ts.map +0 -1
  191. package/dist/routes/labels/index.js +0 -73
  192. package/dist/routes/labels/index.js.map +0 -1
  193. package/dist/routes/published-cache/contract.d.ts +0 -25
  194. package/dist/routes/published-cache/contract.d.ts.map +0 -1
  195. package/dist/routes/published-cache/contract.js +0 -35
  196. package/dist/routes/published-cache/contract.js.map +0 -1
  197. package/dist/routes/published-cache/index.d.ts +0 -8
  198. package/dist/routes/published-cache/index.d.ts.map +0 -1
  199. package/dist/routes/published-cache/index.js +0 -33
  200. package/dist/routes/published-cache/index.js.map +0 -1
  201. package/dist/routes/values/[labelId]/[version]/contract.d.ts +0 -29
  202. package/dist/routes/values/[labelId]/[version]/contract.d.ts.map +0 -1
  203. package/dist/routes/values/[labelId]/[version]/contract.js +0 -33
  204. package/dist/routes/values/[labelId]/[version]/contract.js.map +0 -1
  205. package/dist/routes/values/[labelId]/[version]/index.d.ts +0 -8
  206. package/dist/routes/values/[labelId]/[version]/index.d.ts.map +0 -1
  207. package/dist/routes/values/[labelId]/[version]/index.js +0 -45
  208. package/dist/routes/values/[labelId]/[version]/index.js.map +0 -1
  209. package/dist/routes/values/[labelId]/contract.d.ts +0 -38
  210. package/dist/routes/values/[labelId]/contract.d.ts.map +0 -1
  211. package/dist/routes/values/[labelId]/contract.js +0 -59
  212. package/dist/routes/values/[labelId]/contract.js.map +0 -1
  213. package/dist/routes/values/[labelId]/index.d.ts +0 -8
  214. package/dist/routes/values/[labelId]/index.d.ts.map +0 -1
  215. package/dist/routes/values/[labelId]/index.js +0 -42
  216. package/dist/routes/values/[labelId]/index.js.map +0 -1
  217. package/dist/server.d.ts.map +0 -1
  218. package/dist/store.d.ts +0 -87
  219. package/dist/store.d.ts.map +0 -1
  220. package/dist/store.js +0 -205
  221. package/dist/store.js.map +0 -1
  222. package/dist/types.d.ts.map +0 -1
  223. package/dist/types.js +0 -7
  224. package/dist/types.js.map +0 -1
package/dist/client.d.ts CHANGED
@@ -1,138 +1,147 @@
1
+ import { SectionData, SectionAPI } from './server.js';
2
+ import * as zustand from 'zustand';
3
+ export { g as getLocale, b as getLocaleWithInfo, a as getLocales, c as getLocalesWithInfo, s as setLocale } from './actions-BpTAYuBA.js';
4
+ export { L as LOCALE_COOKIE_KEY, d as LOCALE_INFO_MAP, e as LocaleInfo, S as SupportedLocale, c as getDialCode, b as getFlag, g as getLocaleInfo, a as getSupportedLocales, i as isRTL } from './locale.constants-BMBK70YM.js';
5
+ import './index-Dh5FjWzR.js';
6
+ import './server/repositories/index.js';
7
+ import './server/entities/cms-labels.js';
8
+ import 'drizzle-orm/pg-core';
9
+ import './server/entities/cms-label-values.js';
10
+ import './server/entities/cms-draft-cache.js';
11
+ import './server/entities/cms-published-cache.js';
12
+ import './server/entities/cms-label-versions.js';
13
+ import './server/entities/cms-audit-logs.js';
14
+ import './label-sync-generator-B0EmvtWM.js';
15
+ import '@spfn/core/codegen';
16
+
1
17
  /**
2
- * @spfn/cms/client
18
+ * useSection Hook
3
19
  *
4
- * Client Components Only
5
- * 클라이언트 컴포넌트 전용 (브라우저에서 실행)
20
+ * 클라이언트 컴포넌트에서 섹션 데이터 사용
6
21
  */
7
- import type { InferContract } from '@spfn/core';
8
- import { getLabelsContract, createLabelContract } from './routes/labels/contract';
9
- import { getLabelContract, updateLabelContract, deleteLabelContract } from './routes/labels/[id]/contract';
10
- import { getPublishedCacheContract } from './routes/published-cache/contract';
11
22
  /**
12
- * CMS API Client
23
+ * 섹션 Hook (서버 API 동일한 패턴)
24
+ *
25
+ * @param section - 섹션 이름
26
+ * @param options - 옵션 (autoLoad: 자동 로드 여부)
27
+ * @returns { t, data, loading }
28
+ *
29
+ * @example
30
+ * ```tsx
31
+ * 'use client';
32
+ * import { useSection } from '@spfn/cms/client';
33
+ *
34
+ * export function ClientComponent()
35
+ * {
36
+ * const { t } = useSection('home', { autoLoad: true });
37
+ * return <h1>{t('hero.title')}</h1>;
38
+ * }
39
+ * ```
40
+ */
41
+ declare function useSection(section: string, options?: {
42
+ autoLoad?: boolean;
43
+ locale?: string;
44
+ }): {
45
+ t: (key: string, defaultValue?: any, replace?: Record<string, string | number>) => any;
46
+ data: SectionData;
47
+ loading: boolean;
48
+ };
49
+
50
+ /**
51
+ * useSections Hook
52
+ *
53
+ * 여러 섹션을 한번에 사용
54
+ */
55
+ /**
56
+ * 여러 섹션 Hook
57
+ *
58
+ * @param sectionNames - 섹션 이름 배열
59
+ * @returns { [section]: { t, data, loading }, ... }
60
+ *
61
+ * @example
62
+ * ```tsx
63
+ * 'use client';
64
+ * import { useSections } from '@spfn/cms/client';
65
+ *
66
+ * export function Component()
67
+ * {
68
+ * const sections = useSections(['home', 'layout']);
69
+ * return (
70
+ * <div>
71
+ * <h1>{sections.home.t('hero.title')}</h1>
72
+ * <p>{sections.layout.t('footer.copyright')}</p>
73
+ * </div>
74
+ * );
75
+ * }
76
+ * ```
13
77
  */
14
- export declare const cmsApi: {
78
+ declare function useSections(sectionNames: string[]): Record<string, {
79
+ t: (key: string, defaultValue?: any, replace?: Record<string, string | number>) => any;
80
+ data: SectionData;
81
+ loading: boolean;
82
+ }>;
83
+
84
+ interface CmsState {
15
85
  /**
16
- * Labels API
86
+ * 섹션별 데이터
87
+ * { 'home': { section: 'home', content: {...}, version: 1, ... }, ... }
17
88
  */
18
- readonly labels: {
19
- /**
20
- * GET /cms/labels
21
- * 라벨 목록 조회 (섹션 필터, 페이지네이션)
22
- */
23
- readonly list: (options?: {
24
- query?: InferContract<typeof getLabelsContract>["query"];
25
- }) => Promise<{
26
- limit: number;
27
- offset: number;
28
- labels: {
29
- section: string;
30
- id: number;
31
- key: string;
32
- type: string;
33
- publishedVersion: number | null;
34
- createdBy: string | null;
35
- createdAt: string;
36
- updatedAt: string;
37
- }[];
38
- total: number;
39
- }>;
40
- /**
41
- * GET /cms/labels/:id
42
- * 특정 라벨 조회
43
- */
44
- readonly getById: (options: {
45
- params: InferContract<typeof getLabelContract>["params"];
46
- }) => Promise<{
47
- section: string;
48
- id: number;
49
- key: string;
50
- type: string;
51
- publishedVersion: number | null;
52
- createdBy: string | null;
53
- createdAt: string;
54
- updatedAt: string;
55
- } | {
56
- error: string;
57
- }>;
58
- /**
59
- * POST /cms/labels
60
- * 새 라벨 생성
61
- */
62
- readonly create: (options: {
63
- body: InferContract<typeof createLabelContract>["body"];
64
- }) => Promise<{
65
- section: string;
66
- id: number;
67
- key: string;
68
- type: string;
69
- publishedVersion: number | null;
70
- createdBy: string | null;
71
- createdAt: string;
72
- updatedAt: string;
73
- } | {
74
- key?: string | undefined;
75
- error: string;
76
- }>;
77
- /**
78
- * PATCH /cms/labels/:id
79
- * 라벨 업데이트
80
- */
81
- readonly update: (options: {
82
- params: InferContract<typeof updateLabelContract>["params"];
83
- body: InferContract<typeof updateLabelContract>["body"];
84
- }) => Promise<{
85
- section: string;
86
- id: number;
87
- key: string;
88
- type: string;
89
- publishedVersion: number | null;
90
- createdBy: string | null;
91
- createdAt: string;
92
- updatedAt: string;
93
- } | {
94
- error: string;
95
- }>;
96
- /**
97
- * DELETE /cms/labels/:id
98
- * 라벨 삭제
99
- */
100
- readonly delete: (options: {
101
- params: InferContract<typeof deleteLabelContract>["params"];
102
- }) => Promise<{
103
- id: number;
104
- success: boolean;
105
- } | {
106
- error: string;
107
- }>;
108
- };
89
+ sections: Record<string, SectionData>;
109
90
  /**
110
- * Published Cache API
91
+ * 로딩 상태
111
92
  */
112
- readonly publishedCache: {
113
- /**
114
- * GET /cms/published-cache
115
- * 발행된 콘텐츠 캐시 조회
116
- */
117
- readonly get: (options: {
118
- query: InferContract<typeof getPublishedCacheContract>["query"];
119
- }) => Promise<{
120
- section: string;
121
- locale: string;
122
- content: {
123
- [x: string]: any;
124
- };
125
- version: number;
126
- publishedAt: string | null;
127
- }[] | {
128
- error: string;
129
- }>;
130
- };
131
- };
93
+ loading: Record<string, boolean>;
94
+ /**
95
+ * 섹션 데이터 설정 (서버에서 초기화용)
96
+ */
97
+ setSection: (section: string, data: SectionData) => void;
98
+ /**
99
+ * 여러 섹션 한번에 설정
100
+ */
101
+ setSections: (sections: Record<string, SectionData>) => void;
102
+ /**
103
+ * 섹션 비동기 로드
104
+ */
105
+ loadSection: (section: string, locale?: string) => Promise<void>;
106
+ /**
107
+ * 라벨 업데이트 (Draft Mode용)
108
+ */
109
+ updateLabel: (section: string, key: string, value: any) => void;
110
+ /**
111
+ * 초기화
112
+ */
113
+ reset: () => void;
114
+ }
115
+ declare const useCmsStore: zustand.UseBoundStore<zustand.StoreApi<CmsState>>;
116
+
132
117
  /**
133
- * Type exports
118
+ * CMS Store Initializer
119
+ *
120
+ * 서버 컴포넌트에서 로드한 섹션 데이터를 클라이언트 store에 초기화
121
+ */
122
+
123
+ interface InitCmsProps {
124
+ /**
125
+ * 서버에서 로드한 섹션 데이터
126
+ * { home: { t, data }, ... }
127
+ */
128
+ sections: Record<string, SectionAPI>;
129
+ }
130
+ /**
131
+ * CMS Store 초기화 컴포넌트
132
+ *
133
+ * 서버 컴포넌트에서 로드한 데이터를 클라이언트 store에 주입
134
+ * 이후 하위 클라이언트 컴포넌트에서 useSection() 사용 가능
135
+ *
136
+ * @param props - InitCmsProps
137
+ * @param props.sections - 서버에서 로드한 섹션 데이터
138
+ *
139
+ * @example
140
+ * // Server Component
141
+ * const home = await getSection('home');
142
+ * <InitCms sections={{ home }} />
143
+ * // 이후 하위 클라이언트 컴포넌트에서 useSection('home') 사용 가능
134
144
  */
135
- export type CmsApi = typeof cmsApi;
136
- export { useCmsStore, useSection, useSections } from './store';
137
- export { InitCms } from './init';
138
- //# sourceMappingURL=client.d.ts.map
145
+ declare function InitCms({ sections }: InitCmsProps): null;
146
+
147
+ export { InitCms, useCmsStore, useSection, useSections };