@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/dist/server.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { cache } from "react";
3
3
  import { client } from "@spfn/core/client";
4
4
 
5
- // src/contracts/published-cache.ts
5
+ // src/lib/contracts/published-cache.ts
6
6
  import { Type } from "@sinclair/typebox";
7
7
  var SectionData = Type.Object({
8
8
  section: Type.String(),
@@ -13,7 +13,7 @@ var SectionData = Type.Object({
13
13
  });
14
14
  var getPublishedCacheContract = {
15
15
  method: "GET",
16
- path: "/cms/published-cache",
16
+ path: "/published-cache",
17
17
  query: Type.Object({
18
18
  sections: Type.Union([
19
19
  Type.String({ description: "\uB2E8\uC77C \uC139\uC158 \uC774\uB984 (\uC608: home)" }),
@@ -31,10 +31,10 @@ var getPublishedCacheContract = {
31
31
  ])
32
32
  };
33
33
 
34
- // src/helpers/locale.actions.ts
35
- import { cookies, headers } from "next/headers.js";
34
+ // src/server/helpers/locale.actions.ts
35
+ import { cookies, headers } from "next/headers";
36
36
 
37
- // src/cms.config.ts
37
+ // src/server/config/cms.config.ts
38
38
  function getEnvVar(key, defaultValue) {
39
39
  return process.env[key] || defaultValue;
40
40
  }
@@ -62,10 +62,558 @@ function getCmsConfig() {
62
62
  return currentConfig;
63
63
  }
64
64
 
65
- // src/helpers/locale.constants.ts
65
+ // src/lib/constants/locale.constants.ts
66
66
  var LOCALE_COOKIE_KEY = "spfn-locale";
67
+ var LOCALE_INFO_MAP = {
68
+ // 한국어
69
+ ko: {
70
+ locale: "ko",
71
+ countryCode: "KR",
72
+ flag: "🇰🇷",
73
+ dialCode: "+82",
74
+ nativeName: "\uD55C\uAD6D\uC5B4",
75
+ englishName: "Korean",
76
+ currencyCode: "KRW",
77
+ dateFormat: "YYYY.MM.DD"
78
+ },
79
+ // 영어 (미국)
80
+ en: {
81
+ locale: "en",
82
+ countryCode: "US",
83
+ flag: "🇺🇸",
84
+ dialCode: "+1",
85
+ nativeName: "English",
86
+ englishName: "English",
87
+ currencyCode: "USD",
88
+ dateFormat: "MM/DD/YYYY"
89
+ },
90
+ // 일본어
91
+ ja: {
92
+ locale: "ja",
93
+ countryCode: "JP",
94
+ flag: "🇯🇵",
95
+ dialCode: "+81",
96
+ nativeName: "\u65E5\u672C\u8A9E",
97
+ englishName: "Japanese",
98
+ currencyCode: "JPY",
99
+ dateFormat: "YYYY/MM/DD"
100
+ },
101
+ // 중국어 (간체)
102
+ zh: {
103
+ locale: "zh",
104
+ countryCode: "CN",
105
+ flag: "🇨🇳",
106
+ dialCode: "+86",
107
+ nativeName: "\u7B80\u4F53\u4E2D\u6587",
108
+ englishName: "Chinese (Simplified)",
109
+ currencyCode: "CNY",
110
+ dateFormat: "YYYY-MM-DD"
111
+ },
112
+ // 중국어 (번체, 대만)
113
+ "zh-TW": {
114
+ locale: "zh-TW",
115
+ countryCode: "TW",
116
+ flag: "🇹🇼",
117
+ dialCode: "+886",
118
+ nativeName: "\u7E41\u9AD4\u4E2D\u6587",
119
+ englishName: "Chinese (Traditional)",
120
+ currencyCode: "TWD",
121
+ dateFormat: "YYYY/MM/DD"
122
+ },
123
+ // 스페인어
124
+ es: {
125
+ locale: "es",
126
+ countryCode: "ES",
127
+ flag: "🇪🇸",
128
+ dialCode: "+34",
129
+ nativeName: "Espa\xF1ol",
130
+ englishName: "Spanish",
131
+ currencyCode: "EUR",
132
+ dateFormat: "DD/MM/YYYY"
133
+ },
134
+ // 프랑스어
135
+ fr: {
136
+ locale: "fr",
137
+ countryCode: "FR",
138
+ flag: "🇫🇷",
139
+ dialCode: "+33",
140
+ nativeName: "Fran\xE7ais",
141
+ englishName: "French",
142
+ currencyCode: "EUR",
143
+ dateFormat: "DD/MM/YYYY"
144
+ },
145
+ // 독일어
146
+ de: {
147
+ locale: "de",
148
+ countryCode: "DE",
149
+ flag: "🇩🇪",
150
+ dialCode: "+49",
151
+ nativeName: "Deutsch",
152
+ englishName: "German",
153
+ currencyCode: "EUR",
154
+ dateFormat: "DD.MM.YYYY"
155
+ },
156
+ // 이탈리아어
157
+ it: {
158
+ locale: "it",
159
+ countryCode: "IT",
160
+ flag: "🇮🇹",
161
+ dialCode: "+39",
162
+ nativeName: "Italiano",
163
+ englishName: "Italian",
164
+ currencyCode: "EUR",
165
+ dateFormat: "DD/MM/YYYY"
166
+ },
167
+ // 포르투갈어 (브라질)
168
+ pt: {
169
+ locale: "pt",
170
+ countryCode: "BR",
171
+ flag: "🇧🇷",
172
+ dialCode: "+55",
173
+ nativeName: "Portugu\xEAs",
174
+ englishName: "Portuguese",
175
+ currencyCode: "BRL",
176
+ dateFormat: "DD/MM/YYYY"
177
+ },
178
+ // 러시아어
179
+ ru: {
180
+ locale: "ru",
181
+ countryCode: "RU",
182
+ flag: "🇷🇺",
183
+ dialCode: "+7",
184
+ nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
185
+ englishName: "Russian",
186
+ currencyCode: "RUB",
187
+ dateFormat: "DD.MM.YYYY"
188
+ },
189
+ // 아랍어
190
+ ar: {
191
+ locale: "ar",
192
+ countryCode: "SA",
193
+ flag: "🇸🇦",
194
+ dialCode: "+966",
195
+ nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
196
+ englishName: "Arabic",
197
+ rtl: true,
198
+ currencyCode: "SAR",
199
+ dateFormat: "DD/MM/YYYY"
200
+ },
201
+ // 힌디어
202
+ hi: {
203
+ locale: "hi",
204
+ countryCode: "IN",
205
+ flag: "🇮🇳",
206
+ dialCode: "+91",
207
+ nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940",
208
+ englishName: "Hindi",
209
+ currencyCode: "INR",
210
+ dateFormat: "DD/MM/YYYY"
211
+ },
212
+ // 태국어
213
+ th: {
214
+ locale: "th",
215
+ countryCode: "TH",
216
+ flag: "🇹🇭",
217
+ dialCode: "+66",
218
+ nativeName: "\u0E44\u0E17\u0E22",
219
+ englishName: "Thai",
220
+ currencyCode: "THB",
221
+ dateFormat: "DD/MM/YYYY"
222
+ },
223
+ // 베트남어
224
+ vi: {
225
+ locale: "vi",
226
+ countryCode: "VN",
227
+ flag: "🇻🇳",
228
+ dialCode: "+84",
229
+ nativeName: "Ti\u1EBFng Vi\u1EC7t",
230
+ englishName: "Vietnamese",
231
+ currencyCode: "VND",
232
+ dateFormat: "DD/MM/YYYY"
233
+ },
234
+ // 인도네시아어
235
+ id: {
236
+ locale: "id",
237
+ countryCode: "ID",
238
+ flag: "🇮🇩",
239
+ dialCode: "+62",
240
+ nativeName: "Bahasa Indonesia",
241
+ englishName: "Indonesian",
242
+ currencyCode: "IDR",
243
+ dateFormat: "DD/MM/YYYY"
244
+ },
245
+ // 터키어
246
+ tr: {
247
+ locale: "tr",
248
+ countryCode: "TR",
249
+ flag: "🇹🇷",
250
+ dialCode: "+90",
251
+ nativeName: "T\xFCrk\xE7e",
252
+ englishName: "Turkish",
253
+ currencyCode: "TRY",
254
+ dateFormat: "DD.MM.YYYY"
255
+ },
256
+ // 폴란드어
257
+ pl: {
258
+ locale: "pl",
259
+ countryCode: "PL",
260
+ flag: "🇵🇱",
261
+ dialCode: "+48",
262
+ nativeName: "Polski",
263
+ englishName: "Polish",
264
+ currencyCode: "PLN",
265
+ dateFormat: "DD.MM.YYYY"
266
+ },
267
+ // 네덜란드어
268
+ nl: {
269
+ locale: "nl",
270
+ countryCode: "NL",
271
+ flag: "🇳🇱",
272
+ dialCode: "+31",
273
+ nativeName: "Nederlands",
274
+ englishName: "Dutch",
275
+ currencyCode: "EUR",
276
+ dateFormat: "DD-MM-YYYY"
277
+ },
278
+ // 중국어 (홍콩)
279
+ "zh-HK": {
280
+ locale: "zh-HK",
281
+ countryCode: "HK",
282
+ flag: "🇭🇰",
283
+ dialCode: "+852",
284
+ nativeName: "\u7E41\u9AD4\u4E2D\u6587 (\u9999\u6E2F)",
285
+ englishName: "Chinese (Hong Kong)",
286
+ currencyCode: "HKD",
287
+ dateFormat: "YYYY/MM/DD"
288
+ },
289
+ // 말레이어
290
+ ms: {
291
+ locale: "ms",
292
+ countryCode: "MY",
293
+ flag: "🇲🇾",
294
+ dialCode: "+60",
295
+ nativeName: "Bahasa Melayu",
296
+ englishName: "Malay",
297
+ currencyCode: "MYR",
298
+ dateFormat: "DD/MM/YYYY"
299
+ },
300
+ // 영어 (영국)
301
+ "en-GB": {
302
+ locale: "en-GB",
303
+ countryCode: "GB",
304
+ flag: "🇬🇧",
305
+ dialCode: "+44",
306
+ nativeName: "English (UK)",
307
+ englishName: "English (United Kingdom)",
308
+ currencyCode: "GBP",
309
+ dateFormat: "DD/MM/YYYY"
310
+ },
311
+ // 영어 (캐나다)
312
+ "en-CA": {
313
+ locale: "en-CA",
314
+ countryCode: "CA",
315
+ flag: "🇨🇦",
316
+ dialCode: "+1",
317
+ nativeName: "English (Canada)",
318
+ englishName: "English (Canada)",
319
+ currencyCode: "CAD",
320
+ dateFormat: "YYYY-MM-DD"
321
+ },
322
+ // 영어 (호주)
323
+ "en-AU": {
324
+ locale: "en-AU",
325
+ countryCode: "AU",
326
+ flag: "🇦🇺",
327
+ dialCode: "+61",
328
+ nativeName: "English (Australia)",
329
+ englishName: "English (Australia)",
330
+ currencyCode: "AUD",
331
+ dateFormat: "DD/MM/YYYY"
332
+ },
333
+ // 영어 (뉴질랜드)
334
+ "en-NZ": {
335
+ locale: "en-NZ",
336
+ countryCode: "NZ",
337
+ flag: "🇳🇿",
338
+ dialCode: "+64",
339
+ nativeName: "English (New Zealand)",
340
+ englishName: "English (New Zealand)",
341
+ currencyCode: "NZD",
342
+ dateFormat: "DD/MM/YYYY"
343
+ },
344
+ // 스페인어 (멕시코)
345
+ "es-MX": {
346
+ locale: "es-MX",
347
+ countryCode: "MX",
348
+ flag: "🇲🇽",
349
+ dialCode: "+52",
350
+ nativeName: "Espa\xF1ol (M\xE9xico)",
351
+ englishName: "Spanish (Mexico)",
352
+ currencyCode: "MXN",
353
+ dateFormat: "DD/MM/YYYY"
354
+ },
355
+ // 스페인어 (아르헨티나)
356
+ "es-AR": {
357
+ locale: "es-AR",
358
+ countryCode: "AR",
359
+ flag: "🇦🇷",
360
+ dialCode: "+54",
361
+ nativeName: "Espa\xF1ol (Argentina)",
362
+ englishName: "Spanish (Argentina)",
363
+ currencyCode: "ARS",
364
+ dateFormat: "DD/MM/YYYY"
365
+ },
366
+ // 스페인어 (콜롬비아)
367
+ "es-CO": {
368
+ locale: "es-CO",
369
+ countryCode: "CO",
370
+ flag: "🇨🇴",
371
+ dialCode: "+57",
372
+ nativeName: "Espa\xF1ol (Colombia)",
373
+ englishName: "Spanish (Colombia)",
374
+ currencyCode: "COP",
375
+ dateFormat: "DD/MM/YYYY"
376
+ },
377
+ // 스웨덴어
378
+ sv: {
379
+ locale: "sv",
380
+ countryCode: "SE",
381
+ flag: "🇸🇪",
382
+ dialCode: "+46",
383
+ nativeName: "Svenska",
384
+ englishName: "Swedish",
385
+ currencyCode: "SEK",
386
+ dateFormat: "YYYY-MM-DD"
387
+ },
388
+ // 노르웨이어
389
+ no: {
390
+ locale: "no",
391
+ countryCode: "NO",
392
+ flag: "🇳🇴",
393
+ dialCode: "+47",
394
+ nativeName: "Norsk",
395
+ englishName: "Norwegian",
396
+ currencyCode: "NOK",
397
+ dateFormat: "DD.MM.YYYY"
398
+ },
399
+ // 덴마크어
400
+ da: {
401
+ locale: "da",
402
+ countryCode: "DK",
403
+ flag: "🇩🇰",
404
+ dialCode: "+45",
405
+ nativeName: "Dansk",
406
+ englishName: "Danish",
407
+ currencyCode: "DKK",
408
+ dateFormat: "DD-MM-YYYY"
409
+ },
410
+ // 핀란드어
411
+ fi: {
412
+ locale: "fi",
413
+ countryCode: "FI",
414
+ flag: "🇫🇮",
415
+ dialCode: "+358",
416
+ nativeName: "Suomi",
417
+ englishName: "Finnish",
418
+ currencyCode: "EUR",
419
+ dateFormat: "DD.MM.YYYY"
420
+ },
421
+ // 우크라이나어
422
+ uk: {
423
+ locale: "uk",
424
+ countryCode: "UA",
425
+ flag: "🇺🇦",
426
+ dialCode: "+380",
427
+ nativeName: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",
428
+ englishName: "Ukrainian",
429
+ currencyCode: "UAH",
430
+ dateFormat: "DD.MM.YYYY"
431
+ },
432
+ // 체코어
433
+ cs: {
434
+ locale: "cs",
435
+ countryCode: "CZ",
436
+ flag: "🇨🇿",
437
+ dialCode: "+420",
438
+ nativeName: "\u010Ce\u0161tina",
439
+ englishName: "Czech",
440
+ currencyCode: "CZK",
441
+ dateFormat: "DD.MM.YYYY"
442
+ },
443
+ // 헝가리어
444
+ hu: {
445
+ locale: "hu",
446
+ countryCode: "HU",
447
+ flag: "🇭🇺",
448
+ dialCode: "+36",
449
+ nativeName: "Magyar",
450
+ englishName: "Hungarian",
451
+ currencyCode: "HUF",
452
+ dateFormat: "YYYY.MM.DD."
453
+ },
454
+ // 루마니아어
455
+ ro: {
456
+ locale: "ro",
457
+ countryCode: "RO",
458
+ flag: "🇷🇴",
459
+ dialCode: "+40",
460
+ nativeName: "Rom\xE2n\u0103",
461
+ englishName: "Romanian",
462
+ currencyCode: "RON",
463
+ dateFormat: "DD.MM.YYYY"
464
+ },
465
+ // 불가리아어
466
+ bg: {
467
+ locale: "bg",
468
+ countryCode: "BG",
469
+ flag: "🇧🇬",
470
+ dialCode: "+359",
471
+ nativeName: "\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438",
472
+ englishName: "Bulgarian",
473
+ currencyCode: "BGN",
474
+ dateFormat: "DD.MM.YYYY"
475
+ },
476
+ // 크로아티아어
477
+ hr: {
478
+ locale: "hr",
479
+ countryCode: "HR",
480
+ flag: "🇭🇷",
481
+ dialCode: "+385",
482
+ nativeName: "Hrvatski",
483
+ englishName: "Croatian",
484
+ currencyCode: "HRK",
485
+ dateFormat: "DD.MM.YYYY."
486
+ },
487
+ // 세르비아어
488
+ sr: {
489
+ locale: "sr",
490
+ countryCode: "RS",
491
+ flag: "🇷🇸",
492
+ dialCode: "+381",
493
+ nativeName: "\u0421\u0440\u043F\u0441\u043A\u0438",
494
+ englishName: "Serbian",
495
+ currencyCode: "RSD",
496
+ dateFormat: "DD.MM.YYYY."
497
+ },
498
+ // 슬로바키아어
499
+ sk: {
500
+ locale: "sk",
501
+ countryCode: "SK",
502
+ flag: "🇸🇰",
503
+ dialCode: "+421",
504
+ nativeName: "Sloven\u010Dina",
505
+ englishName: "Slovak",
506
+ currencyCode: "EUR",
507
+ dateFormat: "DD.MM.YYYY"
508
+ },
509
+ // 슬로베니아어
510
+ sl: {
511
+ locale: "sl",
512
+ countryCode: "SI",
513
+ flag: "🇸🇮",
514
+ dialCode: "+386",
515
+ nativeName: "Sloven\u0161\u010Dina",
516
+ englishName: "Slovenian",
517
+ currencyCode: "EUR",
518
+ dateFormat: "DD.MM.YYYY"
519
+ },
520
+ // 리투아니아어
521
+ lt: {
522
+ locale: "lt",
523
+ countryCode: "LT",
524
+ flag: "🇱🇹",
525
+ dialCode: "+370",
526
+ nativeName: "Lietuvi\u0173",
527
+ englishName: "Lithuanian",
528
+ currencyCode: "EUR",
529
+ dateFormat: "YYYY-MM-DD"
530
+ },
531
+ // 라트비아어
532
+ lv: {
533
+ locale: "lv",
534
+ countryCode: "LV",
535
+ flag: "🇱🇻",
536
+ dialCode: "+371",
537
+ nativeName: "Latvie\u0161u",
538
+ englishName: "Latvian",
539
+ currencyCode: "EUR",
540
+ dateFormat: "DD.MM.YYYY."
541
+ },
542
+ // 에스토니아어
543
+ et: {
544
+ locale: "et",
545
+ countryCode: "EE",
546
+ flag: "🇪🇪",
547
+ dialCode: "+372",
548
+ nativeName: "Eesti",
549
+ englishName: "Estonian",
550
+ currencyCode: "EUR",
551
+ dateFormat: "DD.MM.YYYY"
552
+ },
553
+ // 그리스어
554
+ el: {
555
+ locale: "el",
556
+ countryCode: "GR",
557
+ flag: "🇬🇷",
558
+ dialCode: "+30",
559
+ nativeName: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",
560
+ englishName: "Greek",
561
+ currencyCode: "EUR",
562
+ dateFormat: "DD/MM/YYYY"
563
+ },
564
+ // 페르시아어
565
+ fa: {
566
+ locale: "fa",
567
+ countryCode: "IR",
568
+ flag: "🇮🇷",
569
+ dialCode: "+98",
570
+ nativeName: "\u0641\u0627\u0631\u0633\u06CC",
571
+ englishName: "Persian",
572
+ rtl: true,
573
+ currencyCode: "IRR",
574
+ dateFormat: "YYYY/MM/DD"
575
+ },
576
+ // 히브리어
577
+ he: {
578
+ locale: "he",
579
+ countryCode: "IL",
580
+ flag: "🇮🇱",
581
+ dialCode: "+972",
582
+ nativeName: "\u05E2\u05D1\u05E8\u05D9\u05EA",
583
+ englishName: "Hebrew",
584
+ rtl: true,
585
+ currencyCode: "ILS",
586
+ dateFormat: "DD/MM/YYYY"
587
+ },
588
+ // 스와힐리어
589
+ sw: {
590
+ locale: "sw",
591
+ countryCode: "KE",
592
+ flag: "🇰🇪",
593
+ dialCode: "+254",
594
+ nativeName: "Kiswahili",
595
+ englishName: "Swahili",
596
+ currencyCode: "KES",
597
+ dateFormat: "DD/MM/YYYY"
598
+ }
599
+ };
600
+ function getLocaleInfo(locale) {
601
+ return LOCALE_INFO_MAP[locale];
602
+ }
603
+ function getSupportedLocales() {
604
+ return Object.keys(LOCALE_INFO_MAP);
605
+ }
606
+ function getFlag(locale) {
607
+ return LOCALE_INFO_MAP[locale]?.flag ?? "";
608
+ }
609
+ function getDialCode(locale) {
610
+ return LOCALE_INFO_MAP[locale]?.dialCode ?? "";
611
+ }
612
+ function isRTL(locale) {
613
+ return LOCALE_INFO_MAP[locale]?.rtl ?? false;
614
+ }
67
615
 
68
- // src/helpers/locale.actions.ts
616
+ // src/server/helpers/locale.actions.ts
69
617
  async function detectBrowserLanguage() {
70
618
  try {
71
619
  const headersList = await headers();
@@ -104,9 +652,910 @@ async function getLocale() {
104
652
  return config.defaultLocale;
105
653
  }
106
654
 
655
+ // src/server/helpers/sync.ts
656
+ import { existsSync, readdirSync, readFileSync, statSync } from "fs";
657
+ import { basename, extname, join } from "path";
658
+
659
+ // src/server/labels/helpers.ts
660
+ function flattenLabels(labels) {
661
+ const result = [];
662
+ function isLabelDefinition(obj) {
663
+ return "key" in obj && "defaultValue" in obj && typeof obj.key === "string" && (typeof obj.defaultValue === "string" || typeof obj.defaultValue === "object");
664
+ }
665
+ function traverse(obj) {
666
+ if (isLabelDefinition(obj)) {
667
+ result.push({
668
+ key: obj.key,
669
+ defaultValue: obj.defaultValue,
670
+ description: obj.description
671
+ });
672
+ } else {
673
+ Object.values(obj).forEach((value) => {
674
+ if (typeof value === "object" && value !== null) {
675
+ traverse(value);
676
+ }
677
+ });
678
+ }
679
+ }
680
+ traverse(labels);
681
+ return result;
682
+ }
683
+ function extractLabels(definition) {
684
+ return flattenLabels(definition.labels);
685
+ }
686
+
687
+ // src/server/repositories/cms-labels.repository.ts
688
+ import { findOne, findMany as findManyHelper, create as createHelper, updateOne, deleteOne, count as countHelper } from "@spfn/core/db";
689
+ import { desc } from "drizzle-orm";
690
+
691
+ // src/server/entities/cms-labels.ts
692
+ import { index, integer, serial, text, timestamp } from "drizzle-orm/pg-core";
693
+ import { createFunctionSchema } from "@spfn/core/db";
694
+ var schema = createFunctionSchema("@spfn/cms");
695
+ var cmsLabels = schema.table("labels", {
696
+ // Primary Key
697
+ id: serial("id").primaryKey(),
698
+ // 라벨 식별자
699
+ key: text("key").notNull().unique(),
700
+ // 예: "home.hero.title", "why-futureplay.hero.subtitle"
701
+ // 구조: {section}.{component}.{property}
702
+ // 섹션 분류 (페이지 단위)
703
+ section: text("section").notNull(),
704
+ // 예: "home", "why-futureplay", "team"
705
+ // 값 타입
706
+ type: text("type").notNull(),
707
+ // "text" | "image" | "video" | "file" | "object"
708
+ // 기본값
709
+ defaultValue: text("default_value"),
710
+ // 라벨의 기본값 (sync 시 설정)
711
+ // 설명
712
+ description: text("description"),
713
+ // 라벨에 대한 설명 (optional)
714
+ // 현재 발행된 버전 번호
715
+ publishedVersion: integer("published_version"),
716
+ // null = 미발행 상태
717
+ // 1, 2, 3... = 발행된 버전 번호
718
+ // 생성자 추적
719
+ createdBy: text("created_by"),
720
+ // 타임스탬프
721
+ createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
722
+ updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
723
+ }, (table) => [
724
+ // 인덱스: 섹션별 조회 최적화
725
+ index("cms_labels_section_idx").on(table.section),
726
+ // 인덱스: key로 조회 최적화 (unique 제약으로 자동 생성되지만 명시)
727
+ index("cms_labels_key_idx").on(table.key)
728
+ ]);
729
+
730
+ // src/server/entities/cms-label-values.ts
731
+ import { serial as serial2, integer as integer2, text as text2, jsonb, timestamp as timestamp2, index as index2, unique } from "drizzle-orm/pg-core";
732
+ import { createFunctionSchema as createFunctionSchema2 } from "@spfn/core/db";
733
+ var schema2 = createFunctionSchema2("@spfn/cms");
734
+ var cmsLabelValues = schema2.table("label_values", {
735
+ // Primary Key
736
+ id: serial2("id").primaryKey(),
737
+ // Foreign Key: cms_labels
738
+ labelId: integer2("label_id").notNull().references(() => cmsLabels.id, { onDelete: "cascade" }),
739
+ // 버전 번호
740
+ version: integer2("version").notNull().default(1),
741
+ // 언어 코드
742
+ locale: text2("locale").notNull().default("ko"),
743
+ // "ko" | "en" | "ja"
744
+ // 반응형 브레이크포인트
745
+ breakpoint: text2("breakpoint"),
746
+ // null = 기본값 (모든 화면 크기)
747
+ // "sm" | "md" | "lg" | "xl" | "2xl"
748
+ // 실제 값 (JSONB)
749
+ value: jsonb("value").notNull(),
750
+ // LabelValue 타입:
751
+ // - TextValue: { type: "text", content: string }
752
+ // - ImageValue: { type: "image", url: string, alt?: string, width?: number, height?: number }
753
+ // - VideoValue: { type: "video", url: string, thumbnail?: string, duration?: number }
754
+ // - FileValue: { type: "file", url: string, filename: string, size?: number }
755
+ // - ObjectValue: { type: "object", fields: Record<string, LabelValue> }
756
+ // 생성 시각
757
+ createdAt: timestamp2("created_at", { withTimezone: true }).notNull().defaultNow()
758
+ }, (table) => [
759
+ // UNIQUE 제약: 같은 버전에서 locale + breakpoint 조합은 유일
760
+ unique("cms_label_values_locale_breakpoint_unique").on(table.labelId, table.version, table.locale, table.breakpoint),
761
+ // 인덱스: labelId + version 복합 조회 최적화
762
+ index2("cms_label_values_label_version_idx").on(table.labelId, table.version),
763
+ // 인덱스: locale 필터링 최적화
764
+ index2("cms_label_values_locale_idx").on(table.locale)
765
+ ]);
766
+
767
+ // src/server/entities/cms-label-versions.ts
768
+ import { serial as serial3, integer as integer3, text as text3, timestamp as timestamp3, index as index3, unique as unique2 } from "drizzle-orm/pg-core";
769
+ import { createFunctionSchema as createFunctionSchema3 } from "@spfn/core/db";
770
+ var schema3 = createFunctionSchema3("@spfn/cms");
771
+ var cmsLabelVersions = schema3.table("label_versions", {
772
+ // Primary Key
773
+ id: serial3("id").primaryKey(),
774
+ // Foreign Key: cms_labels
775
+ labelId: integer3("label_id").notNull().references(() => cmsLabels.id, { onDelete: "cascade" }),
776
+ // 버전 번호
777
+ version: integer3("version").notNull(),
778
+ // 버전 상태
779
+ status: text3("status").notNull(),
780
+ // "draft" | "published" | "archived"
781
+ // 발행 정보
782
+ publishedAt: timestamp3("published_at", { withTimezone: true }),
783
+ publishedBy: text3("published_by"),
784
+ // 버전 노트 (변경사항 설명)
785
+ notes: text3("notes"),
786
+ // 버전 생성자
787
+ createdBy: text3("created_by"),
788
+ // 생성 시각
789
+ createdAt: timestamp3("created_at", { withTimezone: true }).notNull().defaultNow()
790
+ }, (table) => [
791
+ // UNIQUE 제약: 각 라벨의 버전 번호는 고유
792
+ unique2("cms_label_versions_label_version_unique").on(table.labelId, table.version),
793
+ // 인덱스: labelId로 버전 목록 조회 최적화
794
+ index3("cms_label_versions_label_id_idx").on(table.labelId),
795
+ // 인덱스: status 필터링 최적화
796
+ index3("cms_label_versions_status_idx").on(table.status)
797
+ ]);
798
+
799
+ // src/server/entities/cms-draft-cache.ts
800
+ import { serial as serial4, text as text4, jsonb as jsonb2, timestamp as timestamp4, index as index4, unique as unique3 } from "drizzle-orm/pg-core";
801
+ import { createFunctionSchema as createFunctionSchema4 } from "@spfn/core/db";
802
+ var schema4 = createFunctionSchema4("@spfn/cms");
803
+ var cmsDraftCache = schema4.table("draft_cache", {
804
+ // Primary Key
805
+ id: serial4("id").primaryKey(),
806
+ // 섹션 (페이지 단위)
807
+ section: text4("section").notNull(),
808
+ // "home" | "why-futureplay" | "team" | "our-companies" | "apply"
809
+ // 언어
810
+ locale: text4("locale").notNull(),
811
+ // "ko" | "en" | "ja"
812
+ // 사용자 ID (핵심 필드!)
813
+ userId: text4("user_id").notNull(),
814
+ // 각 관리자의 독립적인 작업 공간
815
+ // Draft 콘텐츠 (JSONB)
816
+ content: jsonb2("content").notNull(),
817
+ // Record<string, LabelValue>
818
+ // {
819
+ // "home.hero.title": { type: "text", content: "수정 중..." },
820
+ // "home.hero.subtitle": { type: "text", content: "새로운 문구" },
821
+ // ...
822
+ // }
823
+ // 최종 수정 시각
824
+ updatedAt: timestamp4("updated_at", { withTimezone: true }).notNull().defaultNow()
825
+ }, (table) => [
826
+ // UNIQUE 제약: section + locale + userId 조합은 유일
827
+ unique3("cms_draft_cache_unique").on(table.section, table.locale, table.userId),
828
+ // 인덱스: section으로 조회 최적화
829
+ index4("cms_draft_cache_section_idx").on(table.section),
830
+ // 인덱스: userId로 사용자의 모든 draft 조회 최적화
831
+ index4("cms_draft_cache_user_idx").on(table.userId)
832
+ ]);
833
+
834
+ // src/server/entities/cms-published-cache.ts
835
+ import { serial as serial5, text as text5, jsonb as jsonb3, integer as integer4, timestamp as timestamp5, index as index5, unique as unique4 } from "drizzle-orm/pg-core";
836
+ import { createFunctionSchema as createFunctionSchema5 } from "@spfn/core/db";
837
+ var schema5 = createFunctionSchema5("@spfn/cms");
838
+ var cmsPublishedCache = schema5.table("published_cache", {
839
+ // Primary Key
840
+ id: serial5("id").primaryKey(),
841
+ // 섹션 (페이지 단위)
842
+ section: text5("section").notNull(),
843
+ // "home" | "why-futureplay" | "team" | "our-companies" | "apply"
844
+ // 언어
845
+ locale: text5("locale").notNull(),
846
+ // "ko" | "en" | "ja"
847
+ // 캐시된 콘텐츠 (JSONB)
848
+ content: jsonb3("content").notNull(),
849
+ // Record<string, LabelValue>
850
+ // {
851
+ // "home.hero.title": { type: "text", content: "..." },
852
+ // "home.hero.image": { type: "image", url: "...", alt: "..." },
853
+ // ...
854
+ // }
855
+ // 발행 정보
856
+ publishedAt: timestamp5("published_at", { withTimezone: true }).notNull(),
857
+ publishedBy: text5("published_by"),
858
+ // 캐시 버전 (클라이언트 캐싱용)
859
+ version: integer4("version").notNull().default(1)
860
+ }, (table) => [
861
+ // UNIQUE 제약: section + locale 조합은 유일
862
+ unique4("cms_published_cache_unique").on(table.section, table.locale),
863
+ // 인덱스: section으로 조회 최적화
864
+ index5("cms_published_cache_section_idx").on(table.section)
865
+ ]);
866
+
867
+ // src/server/entities/cms-audit-logs.ts
868
+ import { serial as serial6, integer as integer5, text as text6, jsonb as jsonb4, timestamp as timestamp6, index as index6 } from "drizzle-orm/pg-core";
869
+ import { createFunctionSchema as createFunctionSchema6 } from "@spfn/core/db";
870
+ var schema6 = createFunctionSchema6("@spfn/cms");
871
+ var cmsAuditLogs = schema6.table("audit_logs", {
872
+ // Primary Key
873
+ id: serial6("id").primaryKey(),
874
+ // Foreign Key: cms_labels (nullable - 라벨 삭제 시 로그는 유지)
875
+ labelId: integer5("label_id").references(() => cmsLabels.id, { onDelete: "set null" }),
876
+ // 작업 유형
877
+ action: text6("action").notNull(),
878
+ // "create" | "update" | "publish" | "unpublish" | "archive" | "delete" | "rollback" | "duplicate"
879
+ // 사용자 정보
880
+ userId: text6("user_id").notNull(),
881
+ userName: text6("user_name"),
882
+ // 변경 내용 (before/after)
883
+ changes: jsonb4("changes"),
884
+ // { before: {...}, after: {...} }
885
+ // 추가 메타데이터
886
+ metadata: jsonb4("metadata"),
887
+ // { version: number, ip: string, userAgent: string, ... }
888
+ // 작업 시각
889
+ createdAt: timestamp6("created_at", { withTimezone: true }).notNull().defaultNow()
890
+ }, (table) => [
891
+ // 인덱스: labelId로 이력 조회 최적화
892
+ index6("cms_audit_logs_label_id_idx").on(table.labelId),
893
+ // 인덱스: userId로 사용자 활동 조회 최적화
894
+ index6("cms_audit_logs_user_id_idx").on(table.userId),
895
+ // 인덱스: action 필터링 최적화
896
+ index6("cms_audit_logs_action_idx").on(table.action),
897
+ // 인덱스: 시간순 조회 최적화
898
+ index6("cms_audit_logs_created_at_idx").on(table.createdAt)
899
+ ]);
900
+
901
+ // src/server/repositories/cms-labels.repository.ts
902
+ async function findMany(options) {
903
+ const { section, limit = 20, offset = 0 } = options || {};
904
+ return findManyHelper(cmsLabels, {
905
+ where: section ? { section } : void 0,
906
+ orderBy: desc(cmsLabels.updatedAt),
907
+ limit,
908
+ offset
909
+ });
910
+ }
911
+ async function count(section) {
912
+ return countHelper(cmsLabels, section ? { section } : void 0);
913
+ }
914
+ async function findById(id) {
915
+ return findOne(cmsLabels, { id });
916
+ }
917
+ async function findByKey(key) {
918
+ return findOne(cmsLabels, { key });
919
+ }
920
+ async function findBySection(section) {
921
+ return findManyHelper(cmsLabels, {
922
+ where: { section },
923
+ orderBy: desc(cmsLabels.updatedAt)
924
+ });
925
+ }
926
+ async function create(data) {
927
+ return createHelper(cmsLabels, data);
928
+ }
929
+ async function updateById(id, data) {
930
+ return updateOne(cmsLabels, { id }, { ...data, updatedAt: /* @__PURE__ */ new Date() });
931
+ }
932
+ async function deleteById(id) {
933
+ return deleteOne(cmsLabels, { id });
934
+ }
935
+ var cmsLabelsRepository = {
936
+ findMany,
937
+ count,
938
+ findById,
939
+ findByKey,
940
+ findBySection,
941
+ create,
942
+ updateById,
943
+ deleteById
944
+ };
945
+
946
+ // src/server/repositories/cms-label-values.repository.ts
947
+ import { findOne as findOne2, findMany as findMany2, create as create2, updateOne as updateOne2, deleteMany } from "@spfn/core/db";
948
+ import { eq, and, isNull } from "drizzle-orm";
949
+ async function findByLabelIdAndVersion(labelId, version, options) {
950
+ const { locale, breakpoint } = options || {};
951
+ const conditions = [
952
+ eq(cmsLabelValues.labelId, labelId),
953
+ eq(cmsLabelValues.version, version)
954
+ ];
955
+ if (locale) {
956
+ conditions.push(eq(cmsLabelValues.locale, locale));
957
+ }
958
+ if (breakpoint !== void 0) {
959
+ conditions.push(
960
+ breakpoint === null ? isNull(cmsLabelValues.breakpoint) : eq(cmsLabelValues.breakpoint, breakpoint)
961
+ );
962
+ }
963
+ return findMany2(cmsLabelValues, {
964
+ where: and(...conditions)
965
+ });
966
+ }
967
+ async function upsert(data) {
968
+ const existing = await findOne2(
969
+ cmsLabelValues,
970
+ and(
971
+ eq(cmsLabelValues.labelId, data.labelId),
972
+ eq(cmsLabelValues.version, data.version ?? 1),
973
+ eq(cmsLabelValues.locale, data.locale || "ko"),
974
+ data.breakpoint ? eq(cmsLabelValues.breakpoint, data.breakpoint) : isNull(cmsLabelValues.breakpoint)
975
+ )
976
+ );
977
+ if (existing) {
978
+ const updated = await updateOne2(
979
+ cmsLabelValues,
980
+ { id: existing.id },
981
+ { value: data.value }
982
+ );
983
+ return updated;
984
+ } else {
985
+ return create2(cmsLabelValues, data);
986
+ }
987
+ }
988
+ async function upsertMany(values) {
989
+ const results = [];
990
+ for (const value of values) {
991
+ const result = await upsert(value);
992
+ results.push(result);
993
+ }
994
+ return results;
995
+ }
996
+ async function deleteByVersion(labelId, version) {
997
+ return deleteMany(
998
+ cmsLabelValues,
999
+ and(
1000
+ eq(cmsLabelValues.labelId, labelId),
1001
+ eq(cmsLabelValues.version, version)
1002
+ )
1003
+ );
1004
+ }
1005
+ var cmsLabelValuesRepository = {
1006
+ findByLabelIdAndVersion,
1007
+ upsert,
1008
+ upsertMany,
1009
+ deleteByVersion
1010
+ };
1011
+
1012
+ // src/server/repositories/cms-draft-cache.repository.ts
1013
+ import { findOne as findOne3, findMany as findMany3, deleteOne as deleteOne2, deleteMany as deleteMany2, upsert as upsertHelper } from "@spfn/core/db";
1014
+ import { eq as eq2, and as and2, lt } from "drizzle-orm";
1015
+ async function findByUser(section, locale, userId) {
1016
+ return findOne3(
1017
+ cmsDraftCache,
1018
+ and2(
1019
+ eq2(cmsDraftCache.section, section),
1020
+ eq2(cmsDraftCache.locale, locale),
1021
+ eq2(cmsDraftCache.userId, userId)
1022
+ )
1023
+ );
1024
+ }
1025
+ async function upsert2(data) {
1026
+ return upsertHelper(cmsDraftCache, data, {
1027
+ target: [cmsDraftCache.section, cmsDraftCache.locale, cmsDraftCache.userId],
1028
+ set: {
1029
+ content: data.content,
1030
+ updatedAt: /* @__PURE__ */ new Date()
1031
+ }
1032
+ });
1033
+ }
1034
+ async function findAllByUser(userId) {
1035
+ return findMany3(cmsDraftCache, {
1036
+ where: eq2(cmsDraftCache.userId, userId)
1037
+ });
1038
+ }
1039
+ async function deleteByUser(section, locale, userId) {
1040
+ await deleteOne2(
1041
+ cmsDraftCache,
1042
+ and2(
1043
+ eq2(cmsDraftCache.section, section),
1044
+ eq2(cmsDraftCache.locale, locale),
1045
+ eq2(cmsDraftCache.userId, userId)
1046
+ )
1047
+ );
1048
+ }
1049
+ async function cleanupOldDrafts(daysOld = 30) {
1050
+ const cutoffDate = /* @__PURE__ */ new Date();
1051
+ cutoffDate.setDate(cutoffDate.getDate() - daysOld);
1052
+ return deleteMany2(
1053
+ cmsDraftCache,
1054
+ lt(cmsDraftCache.updatedAt, cutoffDate)
1055
+ );
1056
+ }
1057
+ var cmsDraftCacheRepository = {
1058
+ findByUser,
1059
+ upsert: upsert2,
1060
+ findAllByUser,
1061
+ deleteByUser,
1062
+ cleanupOldDrafts
1063
+ };
1064
+
1065
+ // src/server/repositories/cms-published-cache.repository.ts
1066
+ import { findOne as findOne4, findMany as findMany4, deleteOne as deleteOne3, deleteMany as deleteMany3, upsert as upsertHelper2 } from "@spfn/core/db";
1067
+ import { eq as eq3, and as and3, sql } from "drizzle-orm";
1068
+ async function findBySection2(section, locale = "ko") {
1069
+ return findOne4(
1070
+ cmsPublishedCache,
1071
+ and3(
1072
+ eq3(cmsPublishedCache.section, section),
1073
+ eq3(cmsPublishedCache.locale, locale)
1074
+ )
1075
+ );
1076
+ }
1077
+ async function upsert3(data) {
1078
+ return upsertHelper2(cmsPublishedCache, data, {
1079
+ target: [cmsPublishedCache.section, cmsPublishedCache.locale],
1080
+ set: {
1081
+ content: data.content,
1082
+ publishedAt: data.publishedAt,
1083
+ publishedBy: data.publishedBy,
1084
+ version: sql`${cmsPublishedCache.version} + 1`
1085
+ // 버전 증가로 클라이언트 캐시 무효화
1086
+ }
1087
+ });
1088
+ }
1089
+ async function findAllLanguages(section) {
1090
+ return findMany4(cmsPublishedCache, {
1091
+ where: eq3(cmsPublishedCache.section, section)
1092
+ });
1093
+ }
1094
+ async function deleteBySection(section, locale) {
1095
+ if (locale) {
1096
+ await deleteOne3(
1097
+ cmsPublishedCache,
1098
+ and3(
1099
+ eq3(cmsPublishedCache.section, section),
1100
+ eq3(cmsPublishedCache.locale, locale)
1101
+ )
1102
+ );
1103
+ } else {
1104
+ await deleteMany3(
1105
+ cmsPublishedCache,
1106
+ eq3(cmsPublishedCache.section, section)
1107
+ );
1108
+ }
1109
+ }
1110
+ var cmsPublishedCacheRepository = {
1111
+ findBySection: findBySection2,
1112
+ upsert: upsert3,
1113
+ findAllLanguages,
1114
+ deleteBySection
1115
+ };
1116
+
1117
+ // src/server/helpers/sync.ts
1118
+ async function syncAll(sections, options = {}) {
1119
+ const results = [];
1120
+ for (const definition of sections) {
1121
+ const result = await syncSection(definition, options);
1122
+ results.push(result);
1123
+ }
1124
+ return results;
1125
+ }
1126
+ function loadLabelsFromJson(labelsDir) {
1127
+ const sections = [];
1128
+ if (!existsSync(labelsDir)) {
1129
+ console.warn(`[CMS] Labels directory not found: ${labelsDir}`);
1130
+ console.warn(`[CMS] Expected directory structure:`);
1131
+ console.warn(`[CMS] ${labelsDir}/`);
1132
+ console.warn(`[CMS] \u251C\u2500\u2500 common/ # Section directory`);
1133
+ console.warn(`[CMS] \u2502 \u251C\u2500\u2500 messages.json`);
1134
+ console.warn(`[CMS] \u2502 \u2514\u2500\u2500 errors.json`);
1135
+ console.warn(`[CMS] \u2514\u2500\u2500 home/ # Section directory`);
1136
+ console.warn(`[CMS] \u2514\u2500\u2500 hero.json`);
1137
+ return sections;
1138
+ }
1139
+ try {
1140
+ const entries = readdirSync(labelsDir);
1141
+ if (entries.length === 0) {
1142
+ console.warn(`[CMS] Labels directory is empty: ${labelsDir}`);
1143
+ console.warn(`[CMS] Create section directories with JSON files inside`);
1144
+ return sections;
1145
+ }
1146
+ const jsonFiles = entries.filter((e) => extname(e) === ".json");
1147
+ if (jsonFiles.length > 0) {
1148
+ console.warn(`[CMS] Found JSON files directly in ${labelsDir}:`);
1149
+ jsonFiles.forEach((f) => console.warn(`[CMS] - ${f} (will be ignored)`));
1150
+ console.warn(`[CMS] JSON files should be inside section directories`);
1151
+ console.warn(`[CMS] Example: Move ${jsonFiles[0]} to ${labelsDir}/${basename(jsonFiles[0], ".json")}/${jsonFiles[0]}`);
1152
+ }
1153
+ for (const entry of entries) {
1154
+ const sectionPath = join(labelsDir, entry);
1155
+ const stat = statSync(sectionPath);
1156
+ if (stat.isDirectory()) {
1157
+ const sectionName = entry;
1158
+ const labels = loadSectionLabels(sectionPath);
1159
+ if (Object.keys(labels).length > 0) {
1160
+ sections.push({ section: sectionName, labels });
1161
+ } else {
1162
+ console.warn(`[CMS] Section directory "${sectionName}" has no valid JSON files`);
1163
+ }
1164
+ }
1165
+ }
1166
+ if (sections.length === 0) {
1167
+ console.warn(`[CMS] No valid section directories found in ${labelsDir}`);
1168
+ }
1169
+ } catch (error) {
1170
+ console.warn(`[CMS] Could not scan labels directory: ${labelsDir}`);
1171
+ console.error(`[CMS] Error:`, error);
1172
+ }
1173
+ return sections;
1174
+ }
1175
+ function loadSectionLabels(sectionPath) {
1176
+ const labels = {};
1177
+ try {
1178
+ const files = readdirSync(sectionPath);
1179
+ for (const file of files) {
1180
+ if (extname(file) === ".json") {
1181
+ const filePath = join(sectionPath, file);
1182
+ const categoryName = basename(file, ".json");
1183
+ try {
1184
+ const content = readFileSync(filePath, "utf-8");
1185
+ labels[categoryName] = JSON.parse(content);
1186
+ } catch (error) {
1187
+ console.warn(`[CMS] Failed to parse ${filePath}`);
1188
+ }
1189
+ }
1190
+ }
1191
+ } catch (error) {
1192
+ console.warn(`[CMS] Could not read section directory: ${sectionPath}`);
1193
+ }
1194
+ return labels;
1195
+ }
1196
+ async function syncSection(definition, options = {}) {
1197
+ const {
1198
+ dryRun = false,
1199
+ updateExisting = false,
1200
+ removeUnused = false,
1201
+ verbose = false
1202
+ } = options;
1203
+ const { section } = definition;
1204
+ const result = {
1205
+ section,
1206
+ created: 0,
1207
+ updated: 0,
1208
+ deleted: 0,
1209
+ unchanged: 0,
1210
+ errors: []
1211
+ };
1212
+ try {
1213
+ const definedLabels = extractLabels(definition);
1214
+ const definedKeys = new Set(definedLabels.map((l) => l.key));
1215
+ const existingLabels = await cmsLabelsRepository.findBySection(section);
1216
+ const existingMap = new Map(existingLabels.map((l) => [l.key, l]));
1217
+ if (verbose) {
1218
+ console.log(`
1219
+ [${section}] Found ${definedLabels.length} labels in definition`);
1220
+ console.log(`[${section}] Found ${existingLabels.length} labels in DB`);
1221
+ }
1222
+ for (const label of definedLabels) {
1223
+ const existing = existingMap.get(label.key);
1224
+ if (!existing) {
1225
+ if (verbose) console.log(` [CREATE] ${label.key}`);
1226
+ if (!dryRun) {
1227
+ try {
1228
+ const defaultValue = typeof label.defaultValue === "object" ? JSON.stringify(label.defaultValue) : label.defaultValue;
1229
+ await cmsLabelsRepository.create({
1230
+ section,
1231
+ key: label.key,
1232
+ type: label.type || "text",
1233
+ // 라벨 타입 (기본값: 'text')
1234
+ defaultValue,
1235
+ description: label.description
1236
+ });
1237
+ } catch (error) {
1238
+ result.errors.push({
1239
+ key: label.key,
1240
+ error: error instanceof Error ? error.message : String(error)
1241
+ });
1242
+ continue;
1243
+ }
1244
+ }
1245
+ result.created++;
1246
+ } else if (updateExisting) {
1247
+ const newDefaultValue = typeof label.defaultValue === "object" ? JSON.stringify(label.defaultValue) : label.defaultValue;
1248
+ const hasChanged = existing.defaultValue !== newDefaultValue;
1249
+ if (hasChanged) {
1250
+ if (verbose) {
1251
+ console.log(` [UPDATE] ${label.key}`);
1252
+ console.log(` Old: "${existing.defaultValue}"`);
1253
+ console.log(` New: "${newDefaultValue}"`);
1254
+ }
1255
+ if (!dryRun) {
1256
+ try {
1257
+ await cmsLabelsRepository.updateById(existing.id, {
1258
+ defaultValue: newDefaultValue,
1259
+ description: label.description
1260
+ });
1261
+ } catch (error) {
1262
+ result.errors.push({
1263
+ key: label.key,
1264
+ error: error instanceof Error ? error.message : String(error)
1265
+ });
1266
+ continue;
1267
+ }
1268
+ }
1269
+ result.updated++;
1270
+ } else {
1271
+ result.unchanged++;
1272
+ }
1273
+ } else {
1274
+ result.unchanged++;
1275
+ }
1276
+ }
1277
+ if (removeUnused) {
1278
+ for (const existing of existingLabels) {
1279
+ if (!definedKeys.has(existing.key)) {
1280
+ if (verbose) console.log(` [DELETE] ${existing.key}`);
1281
+ if (!dryRun) {
1282
+ try {
1283
+ await cmsLabelsRepository.deleteById(existing.id);
1284
+ } catch (error) {
1285
+ result.errors.push({
1286
+ key: existing.key,
1287
+ error: error instanceof Error ? error.message : String(error)
1288
+ });
1289
+ continue;
1290
+ }
1291
+ }
1292
+ result.deleted++;
1293
+ }
1294
+ }
1295
+ }
1296
+ if (!dryRun && (result.created > 0 || result.updated > 0 || result.deleted > 0)) {
1297
+ if (verbose) console.log(` [CACHE] Updating published cache for section: ${section}`);
1298
+ await updatePublishedCache(section);
1299
+ }
1300
+ } catch (error) {
1301
+ result.errors.push({
1302
+ key: "__section__",
1303
+ error: error instanceof Error ? error.message : String(error)
1304
+ });
1305
+ }
1306
+ return result;
1307
+ }
1308
+ async function updatePublishedCache(section) {
1309
+ const labels = await cmsLabelsRepository.findBySection(section);
1310
+ const localesSet = /* @__PURE__ */ new Set();
1311
+ const labelsByLocale = {};
1312
+ labels.forEach((label) => {
1313
+ try {
1314
+ const parsed = JSON.parse(label.defaultValue || "{}");
1315
+ if (typeof parsed === "object" && !Array.isArray(parsed)) {
1316
+ Object.keys(parsed).forEach((locale) => localesSet.add(locale));
1317
+ Object.entries(parsed).forEach(([locale, value]) => {
1318
+ if (!labelsByLocale[locale]) labelsByLocale[locale] = {};
1319
+ labelsByLocale[locale][label.key] = value;
1320
+ });
1321
+ } else {
1322
+ if (!labelsByLocale.ko) labelsByLocale.ko = {};
1323
+ labelsByLocale.ko[label.key] = label.defaultValue;
1324
+ localesSet.add("ko");
1325
+ }
1326
+ } catch {
1327
+ if (!labelsByLocale.ko) labelsByLocale.ko = {};
1328
+ labelsByLocale.ko[label.key] = label.defaultValue;
1329
+ localesSet.add("ko");
1330
+ }
1331
+ });
1332
+ const timestamp7 = /* @__PURE__ */ new Date();
1333
+ for (const locale of localesSet) {
1334
+ await cmsPublishedCacheRepository.upsert({
1335
+ section,
1336
+ locale,
1337
+ content: labelsByLocale[locale] || {},
1338
+ publishedAt: timestamp7,
1339
+ publishedBy: "system"
1340
+ });
1341
+ }
1342
+ }
1343
+ async function initLabelSync(options = {}) {
1344
+ const isDevelopment = process.env.NODE_ENV === "development";
1345
+ const verbose = options.verbose ?? isDevelopment;
1346
+ const labelsDir = options.labelsDir ?? "src/cms/labels";
1347
+ if (verbose) {
1348
+ console.log("\n\u{1F504} Initializing label sync...\n");
1349
+ }
1350
+ const sections = loadLabelsFromJson(labelsDir);
1351
+ if (sections.length === 0) {
1352
+ if (verbose) {
1353
+ console.log("\u26A0\uFE0F No labels found in", labelsDir);
1354
+ console.log("");
1355
+ }
1356
+ return;
1357
+ }
1358
+ const results = await syncAll(sections, {
1359
+ updateExisting: true,
1360
+ // 🔄 항상 업데이트 (프로덕션 포함)
1361
+ ...options,
1362
+ verbose
1363
+ });
1364
+ const totalCreated = results.reduce((sum, r) => sum + r.created, 0);
1365
+ const totalUpdated = results.reduce((sum, r) => sum + r.updated, 0);
1366
+ const totalUnchanged = results.reduce((sum, r) => sum + r.unchanged, 0);
1367
+ const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
1368
+ if (verbose) {
1369
+ console.log("\u2705 Label sync completed\n");
1370
+ console.log(` Sections: ${results.length}`);
1371
+ console.log(` Created: ${totalCreated}`);
1372
+ console.log(` Updated: ${totalUpdated}`);
1373
+ console.log(` Unchanged: ${totalUnchanged}`);
1374
+ if (totalErrors > 0) {
1375
+ console.log(` Errors: ${totalErrors}
1376
+ `);
1377
+ } else {
1378
+ console.log("");
1379
+ }
1380
+ }
1381
+ if (totalErrors > 0) {
1382
+ results.forEach((result) => {
1383
+ result.errors.forEach((error) => {
1384
+ console.error(`[${result.section}] ${error.key}: ${error.error}`);
1385
+ });
1386
+ });
1387
+ }
1388
+ }
1389
+
1390
+ // src/server/generators/label-sync-generator.ts
1391
+ import { logger } from "@spfn/core/logger";
1392
+ import { join as join2, relative, extname as extname2 } from "path";
1393
+ import { existsSync as existsSync2, readdirSync as readdirSync2, readFileSync as readFileSync2, statSync as statSync2 } from "fs";
1394
+
1395
+ // src/lib/constants/index.ts
1396
+ var DEFAULT_LABELS_DIR = "src/lib/labels";
1397
+
1398
+ // src/server/generators/label-sync-generator.ts
1399
+ var syncLogger = logger.child("label-sync");
1400
+ function createLabelSyncGenerator(config = {}) {
1401
+ const labelsDir = config.labelsDir ?? DEFAULT_LABELS_DIR;
1402
+ const runOn = config.runOn ?? ["watch", "manual", "build"];
1403
+ return {
1404
+ name: "label-sync",
1405
+ watchPatterns: [`${labelsDir}/**/*.json`],
1406
+ runOn,
1407
+ async generate(options) {
1408
+ const labelsPath = join2(options.cwd, labelsDir);
1409
+ if (!existsSync2(labelsPath)) {
1410
+ if (options.debug) {
1411
+ syncLogger.warn(`Labels directory not found: ${labelsPath}`);
1412
+ }
1413
+ return;
1414
+ }
1415
+ try {
1416
+ const changedFile = options.trigger?.changedFile;
1417
+ if (changedFile && changedFile.event === "change") {
1418
+ const success = await attemptIncrementalSync({
1419
+ cwd: options.cwd,
1420
+ labelsPath,
1421
+ changedFilePath: changedFile.path,
1422
+ debug: options.debug
1423
+ });
1424
+ if (success) {
1425
+ if (options.debug) {
1426
+ syncLogger.info("Incremental sync successful");
1427
+ }
1428
+ return;
1429
+ }
1430
+ if (options.debug) {
1431
+ syncLogger.info("Incremental sync failed, doing full sync");
1432
+ }
1433
+ }
1434
+ if (options.debug) {
1435
+ syncLogger.info("Starting full label sync...");
1436
+ }
1437
+ const sections = loadLabelsFromJson(labelsPath);
1438
+ if (sections.length === 0) {
1439
+ syncLogger.warn(`No labels found in ${labelsPath}`);
1440
+ return;
1441
+ }
1442
+ syncLogger.info(`Found ${sections.length} sections`);
1443
+ const results = await syncAll(sections, {
1444
+ verbose: options.debug ?? false,
1445
+ updateExisting: true
1446
+ });
1447
+ const totalCreated = results.reduce((sum, r) => sum + r.created, 0);
1448
+ const totalUpdated = results.reduce((sum, r) => sum + r.updated, 0);
1449
+ const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
1450
+ if (options.debug || totalCreated > 0 || totalUpdated > 0) {
1451
+ syncLogger.info("Label sync completed", {
1452
+ sections: results.length,
1453
+ created: totalCreated,
1454
+ updated: totalUpdated,
1455
+ errors: totalErrors
1456
+ });
1457
+ }
1458
+ if (totalErrors > 0) {
1459
+ results.forEach((result) => {
1460
+ result.errors.forEach((error) => {
1461
+ syncLogger.error(`[${result.section}] ${error.key}: ${error.error}`);
1462
+ });
1463
+ });
1464
+ }
1465
+ } catch (error) {
1466
+ const err = error instanceof Error ? error : new Error(String(error));
1467
+ syncLogger.error("Label sync failed", err);
1468
+ throw err;
1469
+ }
1470
+ }
1471
+ };
1472
+ }
1473
+ async function attemptIncrementalSync(options) {
1474
+ const { cwd, labelsPath, changedFilePath, debug } = options;
1475
+ try {
1476
+ const fullPath = join2(cwd, changedFilePath);
1477
+ if (!existsSync2(fullPath)) {
1478
+ return false;
1479
+ }
1480
+ const relativePath = relative(labelsPath, fullPath);
1481
+ const parts = relativePath.split("/");
1482
+ if (parts.length < 2) {
1483
+ return false;
1484
+ }
1485
+ const sectionName = parts[0];
1486
+ if (debug) {
1487
+ syncLogger.info("Attempting incremental sync", {
1488
+ section: sectionName,
1489
+ file: changedFilePath
1490
+ });
1491
+ }
1492
+ const sectionPath = join2(labelsPath, sectionName);
1493
+ const labels = loadSectionLabels2(sectionPath);
1494
+ if (Object.keys(labels).length === 0) {
1495
+ if (debug) {
1496
+ syncLogger.warn("Section has no valid labels");
1497
+ }
1498
+ return false;
1499
+ }
1500
+ const result = await syncSection(
1501
+ { section: sectionName, labels },
1502
+ { verbose: debug, updateExisting: true }
1503
+ );
1504
+ if (debug || result.created > 0 || result.updated > 0) {
1505
+ syncLogger.info(`[${sectionName}] Incremental sync completed`, {
1506
+ created: result.created,
1507
+ updated: result.updated,
1508
+ unchanged: result.unchanged,
1509
+ errors: result.errors.length
1510
+ });
1511
+ }
1512
+ if (result.errors.length > 0) {
1513
+ result.errors.forEach((error) => {
1514
+ syncLogger.error(`[${sectionName}] ${error.key}: ${error.error}`);
1515
+ });
1516
+ }
1517
+ return true;
1518
+ } catch (error) {
1519
+ if (debug) {
1520
+ const err = error instanceof Error ? error : new Error(String(error));
1521
+ syncLogger.warn("Incremental sync failed", err);
1522
+ }
1523
+ return false;
1524
+ }
1525
+ }
1526
+ function loadSectionLabels2(sectionPath) {
1527
+ const labels = {};
1528
+ if (!existsSync2(sectionPath)) {
1529
+ return labels;
1530
+ }
1531
+ try {
1532
+ const entries = readdirSync2(sectionPath);
1533
+ for (const entry of entries) {
1534
+ const filePath = join2(sectionPath, entry);
1535
+ const stat = statSync2(filePath);
1536
+ if (stat.isFile() && extname2(entry) === ".json") {
1537
+ try {
1538
+ const content = readFileSync2(filePath, "utf-8");
1539
+ const data = JSON.parse(content);
1540
+ if (typeof data === "object" && data !== null) {
1541
+ Object.assign(labels, data);
1542
+ }
1543
+ } catch (error) {
1544
+ const err = error instanceof Error ? error : new Error(String(error));
1545
+ syncLogger.warn(`Failed to parse ${filePath}`, err);
1546
+ }
1547
+ }
1548
+ }
1549
+ } catch (error) {
1550
+ const err = error instanceof Error ? error : new Error(String(error));
1551
+ syncLogger.warn(`Failed to read section ${sectionPath}`, err);
1552
+ }
1553
+ return labels;
1554
+ }
1555
+
107
1556
  // src/server.ts
108
- function replaceVariables(text, replace) {
109
- return text.replace(/\{(\w+)}/g, (match, key) => {
1557
+ function replaceVariables(text7, replace) {
1558
+ return text7.replace(/\{(\w+)}/g, (match, key) => {
110
1559
  const value = replace[key];
111
1560
  return value !== void 0 ? String(value) : match;
112
1561
  });
@@ -269,7 +1718,31 @@ var getSections = cache(async (sections, locale) => {
269
1718
  }
270
1719
  });
271
1720
  export {
1721
+ LOCALE_COOKIE_KEY,
1722
+ LOCALE_INFO_MAP,
1723
+ cmsAuditLogs,
1724
+ cmsDraftCache,
1725
+ cmsDraftCacheRepository,
1726
+ cmsLabelValues,
1727
+ cmsLabelValuesRepository,
1728
+ cmsLabelVersions,
1729
+ cmsLabels,
1730
+ cmsLabelsRepository,
1731
+ cmsPublishedCache,
1732
+ cmsPublishedCacheRepository,
1733
+ createLabelSyncGenerator,
1734
+ extractLabels,
1735
+ flattenLabels,
1736
+ getDialCode,
1737
+ getFlag,
1738
+ getLocaleInfo,
272
1739
  getSection,
273
- getSections
1740
+ getSections,
1741
+ getSupportedLocales,
1742
+ initLabelSync,
1743
+ isRTL,
1744
+ loadLabelsFromJson,
1745
+ syncAll,
1746
+ syncSection
274
1747
  };
275
1748
  //# sourceMappingURL=server.js.map