@spfn/cms 0.1.0-alpha.63 → 0.1.0-alpha.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -30
- package/dist/actions-CwvmPG0e.d.ts +296 -0
- package/dist/actions.d.ts +1 -143
- package/dist/actions.js +5 -5
- package/dist/actions.js.map +1 -1
- package/dist/api.d.ts +376 -0
- package/dist/api.js +364 -0
- package/dist/api.js.map +1 -0
- package/dist/client.d.ts +115 -141
- package/dist/client.js +860 -63
- package/dist/client.js.map +1 -1
- package/dist/{types.d.ts → index-Dh5FjWzR.d.ts} +32 -1
- package/dist/index.d.ts +21 -43
- package/dist/index.js +556 -1061
- package/dist/index.js.map +1 -1
- package/dist/label-sync-generator-B0EmvtWM.d.ts +32 -0
- package/dist/{contracts → lib/contracts}/labels.d.ts +13 -12
- package/dist/{contracts → lib/contracts}/labels.js +7 -7
- package/dist/lib/contracts/labels.js.map +1 -0
- package/dist/{contracts → lib/contracts}/published-cache.d.ts +3 -2
- package/dist/{contracts → lib/contracts}/published-cache.js +2 -2
- package/dist/lib/contracts/published-cache.js.map +1 -0
- package/dist/{contracts → lib/contracts}/values.d.ts +6 -4
- package/dist/{contracts → lib/contracts}/values.js +3 -3
- package/dist/lib/contracts/values.js.map +1 -0
- package/dist/{entities → server/entities}/cms-audit-logs.js +3 -3
- package/dist/server/entities/cms-audit-logs.js.map +1 -0
- package/dist/{entities → server/entities}/cms-draft-cache.js +1 -1
- package/dist/server/entities/cms-draft-cache.js.map +1 -0
- package/dist/{entities → server/entities}/cms-label-values.js +3 -3
- package/dist/server/entities/cms-label-values.js.map +1 -0
- package/dist/{entities → server/entities}/cms-label-versions.js +3 -3
- package/dist/server/entities/cms-label-versions.js.map +1 -0
- package/dist/{entities → server/entities}/cms-labels.js +1 -1
- package/dist/server/entities/cms-labels.js.map +1 -0
- package/dist/{entities → server/entities}/cms-published-cache.js +1 -1
- package/dist/server/entities/cms-published-cache.js.map +1 -0
- package/dist/{entities → server/entities}/index.js +6 -6
- package/dist/server/entities/index.js.map +1 -0
- package/dist/{generators → server/generators}/index.d.ts +1 -2
- package/dist/{generators → server/generators}/index.js +169 -75
- package/dist/server/generators/index.js.map +1 -0
- package/dist/server/labels/index.d.ts +1 -0
- package/dist/{labels → server/labels}/index.js +1 -1
- package/dist/server/labels/index.js.map +1 -0
- package/dist/{repositories → server/repositories}/index.js +11 -11
- package/dist/server/repositories/index.js.map +1 -0
- package/dist/{routes → server/routes}/labels/[id]/index.js +20 -20
- package/dist/server/routes/labels/[id]/index.js.map +1 -0
- package/dist/{routes → server/routes}/labels/by-key/[key]/index.js +20 -20
- package/dist/server/routes/labels/by-key/[key]/index.js.map +1 -0
- package/dist/{routes → server/routes}/labels/index.d.ts +2 -2
- package/dist/{routes → server/routes}/labels/index.js +21 -22
- package/dist/server/routes/labels/index.js.map +1 -0
- package/dist/{routes → server/routes}/published-cache/index.js +14 -14
- package/dist/server/routes/published-cache/index.js.map +1 -0
- package/dist/{routes → server/routes}/values/[labelId]/[version]/index.js +16 -16
- package/dist/server/routes/values/[labelId]/[version]/index.js.map +1 -0
- package/dist/{routes → server/routes}/values/[labelId]/index.js +16 -16
- package/dist/server/routes/values/[labelId]/index.js.map +1 -0
- package/dist/server.d.ts +76 -7
- package/dist/server.js +1601 -42
- package/dist/server.js.map +1 -1
- package/package.json +37 -35
- package/dist/contracts/labels.js.map +0 -1
- package/dist/contracts/published-cache.js.map +0 -1
- package/dist/contracts/values.js.map +0 -1
- package/dist/entities/cms-audit-logs.js.map +0 -1
- package/dist/entities/cms-draft-cache.js.map +0 -1
- package/dist/entities/cms-label-values.js.map +0 -1
- package/dist/entities/cms-label-versions.js.map +0 -1
- package/dist/entities/cms-labels.js.map +0 -1
- package/dist/entities/cms-published-cache.js.map +0 -1
- package/dist/entities/index.js.map +0 -1
- package/dist/generators/index.js.map +0 -1
- package/dist/label-sync-generator-lQrcVfja.d.ts +0 -36
- package/dist/labels/index.d.ts +0 -34
- package/dist/labels/index.js.map +0 -1
- package/dist/repositories/index.js.map +0 -1
- package/dist/routes/labels/[id]/index.js.map +0 -1
- package/dist/routes/labels/by-key/[key]/index.js.map +0 -1
- package/dist/routes/labels/index.js.map +0 -1
- package/dist/routes/published-cache/index.js.map +0 -1
- package/dist/routes/values/[labelId]/[version]/index.js.map +0 -1
- package/dist/routes/values/[labelId]/index.js.map +0 -1
- package/dist/store.d.ts +0 -81
- package/dist/store.js +0 -403
- package/dist/store.js.map +0 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +0 -1
- package/dist/{entities → server/entities}/cms-audit-logs.d.ts +0 -0
- package/dist/{entities → server/entities}/cms-draft-cache.d.ts +0 -0
- package/dist/{entities → server/entities}/cms-label-values.d.ts +0 -0
- package/dist/{entities → server/entities}/cms-label-versions.d.ts +0 -0
- package/dist/{entities → server/entities}/cms-labels.d.ts +0 -0
- package/dist/{entities → server/entities}/cms-published-cache.d.ts +0 -0
- package/dist/{entities → server/entities}/index.d.ts +0 -0
- package/dist/{repositories → server/repositories}/index.d.ts +7 -7
- /package/dist/{routes → server/routes}/labels/_id_/index.d.ts +0 -0
- /package/dist/{routes → server/routes}/labels/by-key/_key_/index.d.ts +0 -0
- /package/dist/{routes → server/routes}/published-cache/index.d.ts +0 -0
- /package/dist/{routes → server/routes}/values/_labelId_/_version_/index.d.ts +0 -0
- /package/dist/{routes → server/routes}/values/_labelId_/index.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// src/cms.config.ts
|
|
1
|
+
// src/server/config/cms.config.ts
|
|
2
2
|
function getEnvVar(key, defaultValue) {
|
|
3
3
|
return process.env[key] || defaultValue;
|
|
4
4
|
}
|
|
@@ -10,7 +10,7 @@ function getEnvBoolean(key, defaultValue) {
|
|
|
10
10
|
function loadConfigFromEnv() {
|
|
11
11
|
const defaultLocale = getEnvVar("SPFN_CMS_DEFAULT_LOCALE", "en");
|
|
12
12
|
const supportedLocalesStr = getEnvVar("SPFN_CMS_SUPPORTED_LOCALES", "en,ko");
|
|
13
|
-
const
|
|
13
|
+
const detectBrowserLanguage = getEnvBoolean("SPFN_CMS_DETECT_BROWSER_LANGUAGE", true);
|
|
14
14
|
const supportedLocales = supportedLocalesStr.split(",").map((locale) => locale.trim()).filter((locale) => locale.length > 0);
|
|
15
15
|
if (!supportedLocales.includes(defaultLocale)) {
|
|
16
16
|
supportedLocales.unshift(defaultLocale);
|
|
@@ -18,7 +18,7 @@ function loadConfigFromEnv() {
|
|
|
18
18
|
return {
|
|
19
19
|
defaultLocale,
|
|
20
20
|
supportedLocales,
|
|
21
|
-
detectBrowserLanguage
|
|
21
|
+
detectBrowserLanguage
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
var currentConfig = loadConfigFromEnv();
|
|
@@ -42,1075 +42,570 @@ function resetCmsConfig() {
|
|
|
42
42
|
currentConfig = loadConfigFromEnv();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
// src/
|
|
46
|
-
|
|
47
|
-
import { client } from "@spfn/core/client";
|
|
45
|
+
// src/lib/constants/index.ts
|
|
46
|
+
var DEFAULT_LABELS_DIR = "src/lib/labels";
|
|
48
47
|
|
|
49
|
-
// src/
|
|
50
|
-
import { Type } from "@sinclair/typebox";
|
|
51
|
-
var SectionData = Type.Object({
|
|
52
|
-
section: Type.String(),
|
|
53
|
-
locale: Type.String(),
|
|
54
|
-
content: Type.Record(Type.String(), Type.Any()),
|
|
55
|
-
version: Type.Number(),
|
|
56
|
-
publishedAt: Type.Union([Type.String(), Type.Null()])
|
|
57
|
-
});
|
|
58
|
-
var getPublishedCacheContract = {
|
|
59
|
-
method: "GET",
|
|
60
|
-
path: "/cms/published-cache",
|
|
61
|
-
query: Type.Object({
|
|
62
|
-
sections: Type.Union([
|
|
63
|
-
Type.String({ description: "\uB2E8\uC77C \uC139\uC158 \uC774\uB984 (\uC608: home)" }),
|
|
64
|
-
Type.Array(Type.String(), { description: '\uC5EC\uB7EC \uC139\uC158 \uC774\uB984 (\uC608: ["home", "footer"])' })
|
|
65
|
-
]),
|
|
66
|
-
locale: Type.Optional(Type.String({ default: "ko", description: "\uC5B8\uC5B4 \uCF54\uB4DC" }))
|
|
67
|
-
}),
|
|
68
|
-
response: Type.Union([
|
|
69
|
-
// 성공: 항상 배열로 반환
|
|
70
|
-
Type.Array(SectionData),
|
|
71
|
-
// 에러
|
|
72
|
-
Type.Object({
|
|
73
|
-
error: Type.String()
|
|
74
|
-
})
|
|
75
|
-
])
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
// src/helpers/locale.actions.ts
|
|
79
|
-
import { cookies, headers } from "next/headers.js";
|
|
80
|
-
|
|
81
|
-
// src/helpers/locale.constants.ts
|
|
48
|
+
// src/lib/constants/locale.constants.ts
|
|
82
49
|
var LOCALE_COOKIE_KEY = "spfn-locale";
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
//
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
//
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
//
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
},
|
|
360
|
-
//
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
//
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
//
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
//
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
},
|
|
492
|
-
//
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
//
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
import { findOne as findOne3, findMany as findMany3, deleteOne as deleteOne2, deleteMany as deleteMany2, upsert as upsertHelper } from "@spfn/core/db";
|
|
615
|
-
import { eq as eq2, and as and2, lt } from "drizzle-orm";
|
|
616
|
-
async function findByUser(section, locale, userId) {
|
|
617
|
-
return findOne3(
|
|
618
|
-
cmsDraftCache,
|
|
619
|
-
and2(
|
|
620
|
-
eq2(cmsDraftCache.section, section),
|
|
621
|
-
eq2(cmsDraftCache.locale, locale),
|
|
622
|
-
eq2(cmsDraftCache.userId, userId)
|
|
623
|
-
)
|
|
624
|
-
);
|
|
625
|
-
}
|
|
626
|
-
async function upsert2(data) {
|
|
627
|
-
return upsertHelper(cmsDraftCache, data, {
|
|
628
|
-
target: [cmsDraftCache.section, cmsDraftCache.locale, cmsDraftCache.userId],
|
|
629
|
-
set: {
|
|
630
|
-
content: data.content,
|
|
631
|
-
updatedAt: /* @__PURE__ */ new Date()
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
async function findAllByUser(userId) {
|
|
636
|
-
return findMany3(cmsDraftCache, {
|
|
637
|
-
where: eq2(cmsDraftCache.userId, userId)
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
async function deleteByUser(section, locale, userId) {
|
|
641
|
-
await deleteOne2(
|
|
642
|
-
cmsDraftCache,
|
|
643
|
-
and2(
|
|
644
|
-
eq2(cmsDraftCache.section, section),
|
|
645
|
-
eq2(cmsDraftCache.locale, locale),
|
|
646
|
-
eq2(cmsDraftCache.userId, userId)
|
|
647
|
-
)
|
|
648
|
-
);
|
|
649
|
-
}
|
|
650
|
-
async function cleanupOldDrafts(daysOld = 30) {
|
|
651
|
-
const cutoffDate = /* @__PURE__ */ new Date();
|
|
652
|
-
cutoffDate.setDate(cutoffDate.getDate() - daysOld);
|
|
653
|
-
return deleteMany2(
|
|
654
|
-
cmsDraftCache,
|
|
655
|
-
lt(cmsDraftCache.updatedAt, cutoffDate)
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
var cmsDraftCacheRepository = {
|
|
659
|
-
findByUser,
|
|
660
|
-
upsert: upsert2,
|
|
661
|
-
findAllByUser,
|
|
662
|
-
deleteByUser,
|
|
663
|
-
cleanupOldDrafts
|
|
664
|
-
};
|
|
665
|
-
|
|
666
|
-
// src/repositories/cms-published-cache.repository.ts
|
|
667
|
-
import { findOne as findOne4, findMany as findMany4, deleteOne as deleteOne3, deleteMany as deleteMany3, upsert as upsertHelper2 } from "@spfn/core/db";
|
|
668
|
-
import { eq as eq3, and as and3, sql } from "drizzle-orm";
|
|
669
|
-
async function findBySection2(section, locale = "ko") {
|
|
670
|
-
return findOne4(
|
|
671
|
-
cmsPublishedCache,
|
|
672
|
-
and3(
|
|
673
|
-
eq3(cmsPublishedCache.section, section),
|
|
674
|
-
eq3(cmsPublishedCache.locale, locale)
|
|
675
|
-
)
|
|
676
|
-
);
|
|
677
|
-
}
|
|
678
|
-
async function upsert3(data) {
|
|
679
|
-
return upsertHelper2(cmsPublishedCache, data, {
|
|
680
|
-
target: [cmsPublishedCache.section, cmsPublishedCache.locale],
|
|
681
|
-
set: {
|
|
682
|
-
content: data.content,
|
|
683
|
-
publishedAt: data.publishedAt,
|
|
684
|
-
publishedBy: data.publishedBy,
|
|
685
|
-
version: sql`${cmsPublishedCache.version} + 1`
|
|
686
|
-
// 버전 증가로 클라이언트 캐시 무효화
|
|
687
|
-
}
|
|
688
|
-
});
|
|
689
|
-
}
|
|
690
|
-
async function findAllLanguages(section) {
|
|
691
|
-
return findMany4(cmsPublishedCache, {
|
|
692
|
-
where: eq3(cmsPublishedCache.section, section)
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
async function deleteBySection(section, locale) {
|
|
696
|
-
if (locale) {
|
|
697
|
-
await deleteOne3(
|
|
698
|
-
cmsPublishedCache,
|
|
699
|
-
and3(
|
|
700
|
-
eq3(cmsPublishedCache.section, section),
|
|
701
|
-
eq3(cmsPublishedCache.locale, locale)
|
|
702
|
-
)
|
|
703
|
-
);
|
|
704
|
-
} else {
|
|
705
|
-
await deleteMany3(
|
|
706
|
-
cmsPublishedCache,
|
|
707
|
-
eq3(cmsPublishedCache.section, section)
|
|
708
|
-
);
|
|
50
|
+
var LOCALE_INFO_MAP = {
|
|
51
|
+
// 한국어
|
|
52
|
+
ko: {
|
|
53
|
+
locale: "ko",
|
|
54
|
+
countryCode: "KR",
|
|
55
|
+
flag: "🇰🇷",
|
|
56
|
+
dialCode: "+82",
|
|
57
|
+
nativeName: "\uD55C\uAD6D\uC5B4",
|
|
58
|
+
englishName: "Korean",
|
|
59
|
+
currencyCode: "KRW",
|
|
60
|
+
dateFormat: "YYYY.MM.DD"
|
|
61
|
+
},
|
|
62
|
+
// 영어 (미국)
|
|
63
|
+
en: {
|
|
64
|
+
locale: "en",
|
|
65
|
+
countryCode: "US",
|
|
66
|
+
flag: "🇺🇸",
|
|
67
|
+
dialCode: "+1",
|
|
68
|
+
nativeName: "English",
|
|
69
|
+
englishName: "English",
|
|
70
|
+
currencyCode: "USD",
|
|
71
|
+
dateFormat: "MM/DD/YYYY"
|
|
72
|
+
},
|
|
73
|
+
// 일본어
|
|
74
|
+
ja: {
|
|
75
|
+
locale: "ja",
|
|
76
|
+
countryCode: "JP",
|
|
77
|
+
flag: "🇯🇵",
|
|
78
|
+
dialCode: "+81",
|
|
79
|
+
nativeName: "\u65E5\u672C\u8A9E",
|
|
80
|
+
englishName: "Japanese",
|
|
81
|
+
currencyCode: "JPY",
|
|
82
|
+
dateFormat: "YYYY/MM/DD"
|
|
83
|
+
},
|
|
84
|
+
// 중국어 (간체)
|
|
85
|
+
zh: {
|
|
86
|
+
locale: "zh",
|
|
87
|
+
countryCode: "CN",
|
|
88
|
+
flag: "🇨🇳",
|
|
89
|
+
dialCode: "+86",
|
|
90
|
+
nativeName: "\u7B80\u4F53\u4E2D\u6587",
|
|
91
|
+
englishName: "Chinese (Simplified)",
|
|
92
|
+
currencyCode: "CNY",
|
|
93
|
+
dateFormat: "YYYY-MM-DD"
|
|
94
|
+
},
|
|
95
|
+
// 중국어 (번체, 대만)
|
|
96
|
+
"zh-TW": {
|
|
97
|
+
locale: "zh-TW",
|
|
98
|
+
countryCode: "TW",
|
|
99
|
+
flag: "🇹🇼",
|
|
100
|
+
dialCode: "+886",
|
|
101
|
+
nativeName: "\u7E41\u9AD4\u4E2D\u6587",
|
|
102
|
+
englishName: "Chinese (Traditional)",
|
|
103
|
+
currencyCode: "TWD",
|
|
104
|
+
dateFormat: "YYYY/MM/DD"
|
|
105
|
+
},
|
|
106
|
+
// 스페인어
|
|
107
|
+
es: {
|
|
108
|
+
locale: "es",
|
|
109
|
+
countryCode: "ES",
|
|
110
|
+
flag: "🇪🇸",
|
|
111
|
+
dialCode: "+34",
|
|
112
|
+
nativeName: "Espa\xF1ol",
|
|
113
|
+
englishName: "Spanish",
|
|
114
|
+
currencyCode: "EUR",
|
|
115
|
+
dateFormat: "DD/MM/YYYY"
|
|
116
|
+
},
|
|
117
|
+
// 프랑스어
|
|
118
|
+
fr: {
|
|
119
|
+
locale: "fr",
|
|
120
|
+
countryCode: "FR",
|
|
121
|
+
flag: "🇫🇷",
|
|
122
|
+
dialCode: "+33",
|
|
123
|
+
nativeName: "Fran\xE7ais",
|
|
124
|
+
englishName: "French",
|
|
125
|
+
currencyCode: "EUR",
|
|
126
|
+
dateFormat: "DD/MM/YYYY"
|
|
127
|
+
},
|
|
128
|
+
// 독일어
|
|
129
|
+
de: {
|
|
130
|
+
locale: "de",
|
|
131
|
+
countryCode: "DE",
|
|
132
|
+
flag: "🇩🇪",
|
|
133
|
+
dialCode: "+49",
|
|
134
|
+
nativeName: "Deutsch",
|
|
135
|
+
englishName: "German",
|
|
136
|
+
currencyCode: "EUR",
|
|
137
|
+
dateFormat: "DD.MM.YYYY"
|
|
138
|
+
},
|
|
139
|
+
// 이탈리아어
|
|
140
|
+
it: {
|
|
141
|
+
locale: "it",
|
|
142
|
+
countryCode: "IT",
|
|
143
|
+
flag: "🇮🇹",
|
|
144
|
+
dialCode: "+39",
|
|
145
|
+
nativeName: "Italiano",
|
|
146
|
+
englishName: "Italian",
|
|
147
|
+
currencyCode: "EUR",
|
|
148
|
+
dateFormat: "DD/MM/YYYY"
|
|
149
|
+
},
|
|
150
|
+
// 포르투갈어 (브라질)
|
|
151
|
+
pt: {
|
|
152
|
+
locale: "pt",
|
|
153
|
+
countryCode: "BR",
|
|
154
|
+
flag: "🇧🇷",
|
|
155
|
+
dialCode: "+55",
|
|
156
|
+
nativeName: "Portugu\xEAs",
|
|
157
|
+
englishName: "Portuguese",
|
|
158
|
+
currencyCode: "BRL",
|
|
159
|
+
dateFormat: "DD/MM/YYYY"
|
|
160
|
+
},
|
|
161
|
+
// 러시아어
|
|
162
|
+
ru: {
|
|
163
|
+
locale: "ru",
|
|
164
|
+
countryCode: "RU",
|
|
165
|
+
flag: "🇷🇺",
|
|
166
|
+
dialCode: "+7",
|
|
167
|
+
nativeName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
|
|
168
|
+
englishName: "Russian",
|
|
169
|
+
currencyCode: "RUB",
|
|
170
|
+
dateFormat: "DD.MM.YYYY"
|
|
171
|
+
},
|
|
172
|
+
// 아랍어
|
|
173
|
+
ar: {
|
|
174
|
+
locale: "ar",
|
|
175
|
+
countryCode: "SA",
|
|
176
|
+
flag: "🇸🇦",
|
|
177
|
+
dialCode: "+966",
|
|
178
|
+
nativeName: "\u0627\u0644\u0639\u0631\u0628\u064A\u0629",
|
|
179
|
+
englishName: "Arabic",
|
|
180
|
+
rtl: true,
|
|
181
|
+
currencyCode: "SAR",
|
|
182
|
+
dateFormat: "DD/MM/YYYY"
|
|
183
|
+
},
|
|
184
|
+
// 힌디어
|
|
185
|
+
hi: {
|
|
186
|
+
locale: "hi",
|
|
187
|
+
countryCode: "IN",
|
|
188
|
+
flag: "🇮🇳",
|
|
189
|
+
dialCode: "+91",
|
|
190
|
+
nativeName: "\u0939\u093F\u0928\u094D\u0926\u0940",
|
|
191
|
+
englishName: "Hindi",
|
|
192
|
+
currencyCode: "INR",
|
|
193
|
+
dateFormat: "DD/MM/YYYY"
|
|
194
|
+
},
|
|
195
|
+
// 태국어
|
|
196
|
+
th: {
|
|
197
|
+
locale: "th",
|
|
198
|
+
countryCode: "TH",
|
|
199
|
+
flag: "🇹🇭",
|
|
200
|
+
dialCode: "+66",
|
|
201
|
+
nativeName: "\u0E44\u0E17\u0E22",
|
|
202
|
+
englishName: "Thai",
|
|
203
|
+
currencyCode: "THB",
|
|
204
|
+
dateFormat: "DD/MM/YYYY"
|
|
205
|
+
},
|
|
206
|
+
// 베트남어
|
|
207
|
+
vi: {
|
|
208
|
+
locale: "vi",
|
|
209
|
+
countryCode: "VN",
|
|
210
|
+
flag: "🇻🇳",
|
|
211
|
+
dialCode: "+84",
|
|
212
|
+
nativeName: "Ti\u1EBFng Vi\u1EC7t",
|
|
213
|
+
englishName: "Vietnamese",
|
|
214
|
+
currencyCode: "VND",
|
|
215
|
+
dateFormat: "DD/MM/YYYY"
|
|
216
|
+
},
|
|
217
|
+
// 인도네시아어
|
|
218
|
+
id: {
|
|
219
|
+
locale: "id",
|
|
220
|
+
countryCode: "ID",
|
|
221
|
+
flag: "🇮🇩",
|
|
222
|
+
dialCode: "+62",
|
|
223
|
+
nativeName: "Bahasa Indonesia",
|
|
224
|
+
englishName: "Indonesian",
|
|
225
|
+
currencyCode: "IDR",
|
|
226
|
+
dateFormat: "DD/MM/YYYY"
|
|
227
|
+
},
|
|
228
|
+
// 터키어
|
|
229
|
+
tr: {
|
|
230
|
+
locale: "tr",
|
|
231
|
+
countryCode: "TR",
|
|
232
|
+
flag: "🇹🇷",
|
|
233
|
+
dialCode: "+90",
|
|
234
|
+
nativeName: "T\xFCrk\xE7e",
|
|
235
|
+
englishName: "Turkish",
|
|
236
|
+
currencyCode: "TRY",
|
|
237
|
+
dateFormat: "DD.MM.YYYY"
|
|
238
|
+
},
|
|
239
|
+
// 폴란드어
|
|
240
|
+
pl: {
|
|
241
|
+
locale: "pl",
|
|
242
|
+
countryCode: "PL",
|
|
243
|
+
flag: "🇵🇱",
|
|
244
|
+
dialCode: "+48",
|
|
245
|
+
nativeName: "Polski",
|
|
246
|
+
englishName: "Polish",
|
|
247
|
+
currencyCode: "PLN",
|
|
248
|
+
dateFormat: "DD.MM.YYYY"
|
|
249
|
+
},
|
|
250
|
+
// 네덜란드어
|
|
251
|
+
nl: {
|
|
252
|
+
locale: "nl",
|
|
253
|
+
countryCode: "NL",
|
|
254
|
+
flag: "🇳🇱",
|
|
255
|
+
dialCode: "+31",
|
|
256
|
+
nativeName: "Nederlands",
|
|
257
|
+
englishName: "Dutch",
|
|
258
|
+
currencyCode: "EUR",
|
|
259
|
+
dateFormat: "DD-MM-YYYY"
|
|
260
|
+
},
|
|
261
|
+
// 중국어 (홍콩)
|
|
262
|
+
"zh-HK": {
|
|
263
|
+
locale: "zh-HK",
|
|
264
|
+
countryCode: "HK",
|
|
265
|
+
flag: "🇭🇰",
|
|
266
|
+
dialCode: "+852",
|
|
267
|
+
nativeName: "\u7E41\u9AD4\u4E2D\u6587 (\u9999\u6E2F)",
|
|
268
|
+
englishName: "Chinese (Hong Kong)",
|
|
269
|
+
currencyCode: "HKD",
|
|
270
|
+
dateFormat: "YYYY/MM/DD"
|
|
271
|
+
},
|
|
272
|
+
// 말레이어
|
|
273
|
+
ms: {
|
|
274
|
+
locale: "ms",
|
|
275
|
+
countryCode: "MY",
|
|
276
|
+
flag: "🇲🇾",
|
|
277
|
+
dialCode: "+60",
|
|
278
|
+
nativeName: "Bahasa Melayu",
|
|
279
|
+
englishName: "Malay",
|
|
280
|
+
currencyCode: "MYR",
|
|
281
|
+
dateFormat: "DD/MM/YYYY"
|
|
282
|
+
},
|
|
283
|
+
// 영어 (영국)
|
|
284
|
+
"en-GB": {
|
|
285
|
+
locale: "en-GB",
|
|
286
|
+
countryCode: "GB",
|
|
287
|
+
flag: "🇬🇧",
|
|
288
|
+
dialCode: "+44",
|
|
289
|
+
nativeName: "English (UK)",
|
|
290
|
+
englishName: "English (United Kingdom)",
|
|
291
|
+
currencyCode: "GBP",
|
|
292
|
+
dateFormat: "DD/MM/YYYY"
|
|
293
|
+
},
|
|
294
|
+
// 영어 (캐나다)
|
|
295
|
+
"en-CA": {
|
|
296
|
+
locale: "en-CA",
|
|
297
|
+
countryCode: "CA",
|
|
298
|
+
flag: "🇨🇦",
|
|
299
|
+
dialCode: "+1",
|
|
300
|
+
nativeName: "English (Canada)",
|
|
301
|
+
englishName: "English (Canada)",
|
|
302
|
+
currencyCode: "CAD",
|
|
303
|
+
dateFormat: "YYYY-MM-DD"
|
|
304
|
+
},
|
|
305
|
+
// 영어 (호주)
|
|
306
|
+
"en-AU": {
|
|
307
|
+
locale: "en-AU",
|
|
308
|
+
countryCode: "AU",
|
|
309
|
+
flag: "🇦🇺",
|
|
310
|
+
dialCode: "+61",
|
|
311
|
+
nativeName: "English (Australia)",
|
|
312
|
+
englishName: "English (Australia)",
|
|
313
|
+
currencyCode: "AUD",
|
|
314
|
+
dateFormat: "DD/MM/YYYY"
|
|
315
|
+
},
|
|
316
|
+
// 영어 (뉴질랜드)
|
|
317
|
+
"en-NZ": {
|
|
318
|
+
locale: "en-NZ",
|
|
319
|
+
countryCode: "NZ",
|
|
320
|
+
flag: "🇳🇿",
|
|
321
|
+
dialCode: "+64",
|
|
322
|
+
nativeName: "English (New Zealand)",
|
|
323
|
+
englishName: "English (New Zealand)",
|
|
324
|
+
currencyCode: "NZD",
|
|
325
|
+
dateFormat: "DD/MM/YYYY"
|
|
326
|
+
},
|
|
327
|
+
// 스페인어 (멕시코)
|
|
328
|
+
"es-MX": {
|
|
329
|
+
locale: "es-MX",
|
|
330
|
+
countryCode: "MX",
|
|
331
|
+
flag: "🇲🇽",
|
|
332
|
+
dialCode: "+52",
|
|
333
|
+
nativeName: "Espa\xF1ol (M\xE9xico)",
|
|
334
|
+
englishName: "Spanish (Mexico)",
|
|
335
|
+
currencyCode: "MXN",
|
|
336
|
+
dateFormat: "DD/MM/YYYY"
|
|
337
|
+
},
|
|
338
|
+
// 스페인어 (아르헨티나)
|
|
339
|
+
"es-AR": {
|
|
340
|
+
locale: "es-AR",
|
|
341
|
+
countryCode: "AR",
|
|
342
|
+
flag: "🇦🇷",
|
|
343
|
+
dialCode: "+54",
|
|
344
|
+
nativeName: "Espa\xF1ol (Argentina)",
|
|
345
|
+
englishName: "Spanish (Argentina)",
|
|
346
|
+
currencyCode: "ARS",
|
|
347
|
+
dateFormat: "DD/MM/YYYY"
|
|
348
|
+
},
|
|
349
|
+
// 스페인어 (콜롬비아)
|
|
350
|
+
"es-CO": {
|
|
351
|
+
locale: "es-CO",
|
|
352
|
+
countryCode: "CO",
|
|
353
|
+
flag: "🇨🇴",
|
|
354
|
+
dialCode: "+57",
|
|
355
|
+
nativeName: "Espa\xF1ol (Colombia)",
|
|
356
|
+
englishName: "Spanish (Colombia)",
|
|
357
|
+
currencyCode: "COP",
|
|
358
|
+
dateFormat: "DD/MM/YYYY"
|
|
359
|
+
},
|
|
360
|
+
// 스웨덴어
|
|
361
|
+
sv: {
|
|
362
|
+
locale: "sv",
|
|
363
|
+
countryCode: "SE",
|
|
364
|
+
flag: "🇸🇪",
|
|
365
|
+
dialCode: "+46",
|
|
366
|
+
nativeName: "Svenska",
|
|
367
|
+
englishName: "Swedish",
|
|
368
|
+
currencyCode: "SEK",
|
|
369
|
+
dateFormat: "YYYY-MM-DD"
|
|
370
|
+
},
|
|
371
|
+
// 노르웨이어
|
|
372
|
+
no: {
|
|
373
|
+
locale: "no",
|
|
374
|
+
countryCode: "NO",
|
|
375
|
+
flag: "🇳🇴",
|
|
376
|
+
dialCode: "+47",
|
|
377
|
+
nativeName: "Norsk",
|
|
378
|
+
englishName: "Norwegian",
|
|
379
|
+
currencyCode: "NOK",
|
|
380
|
+
dateFormat: "DD.MM.YYYY"
|
|
381
|
+
},
|
|
382
|
+
// 덴마크어
|
|
383
|
+
da: {
|
|
384
|
+
locale: "da",
|
|
385
|
+
countryCode: "DK",
|
|
386
|
+
flag: "🇩🇰",
|
|
387
|
+
dialCode: "+45",
|
|
388
|
+
nativeName: "Dansk",
|
|
389
|
+
englishName: "Danish",
|
|
390
|
+
currencyCode: "DKK",
|
|
391
|
+
dateFormat: "DD-MM-YYYY"
|
|
392
|
+
},
|
|
393
|
+
// 핀란드어
|
|
394
|
+
fi: {
|
|
395
|
+
locale: "fi",
|
|
396
|
+
countryCode: "FI",
|
|
397
|
+
flag: "🇫🇮",
|
|
398
|
+
dialCode: "+358",
|
|
399
|
+
nativeName: "Suomi",
|
|
400
|
+
englishName: "Finnish",
|
|
401
|
+
currencyCode: "EUR",
|
|
402
|
+
dateFormat: "DD.MM.YYYY"
|
|
403
|
+
},
|
|
404
|
+
// 우크라이나어
|
|
405
|
+
uk: {
|
|
406
|
+
locale: "uk",
|
|
407
|
+
countryCode: "UA",
|
|
408
|
+
flag: "🇺🇦",
|
|
409
|
+
dialCode: "+380",
|
|
410
|
+
nativeName: "\u0423\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430",
|
|
411
|
+
englishName: "Ukrainian",
|
|
412
|
+
currencyCode: "UAH",
|
|
413
|
+
dateFormat: "DD.MM.YYYY"
|
|
414
|
+
},
|
|
415
|
+
// 체코어
|
|
416
|
+
cs: {
|
|
417
|
+
locale: "cs",
|
|
418
|
+
countryCode: "CZ",
|
|
419
|
+
flag: "🇨🇿",
|
|
420
|
+
dialCode: "+420",
|
|
421
|
+
nativeName: "\u010Ce\u0161tina",
|
|
422
|
+
englishName: "Czech",
|
|
423
|
+
currencyCode: "CZK",
|
|
424
|
+
dateFormat: "DD.MM.YYYY"
|
|
425
|
+
},
|
|
426
|
+
// 헝가리어
|
|
427
|
+
hu: {
|
|
428
|
+
locale: "hu",
|
|
429
|
+
countryCode: "HU",
|
|
430
|
+
flag: "🇭🇺",
|
|
431
|
+
dialCode: "+36",
|
|
432
|
+
nativeName: "Magyar",
|
|
433
|
+
englishName: "Hungarian",
|
|
434
|
+
currencyCode: "HUF",
|
|
435
|
+
dateFormat: "YYYY.MM.DD."
|
|
436
|
+
},
|
|
437
|
+
// 루마니아어
|
|
438
|
+
ro: {
|
|
439
|
+
locale: "ro",
|
|
440
|
+
countryCode: "RO",
|
|
441
|
+
flag: "🇷🇴",
|
|
442
|
+
dialCode: "+40",
|
|
443
|
+
nativeName: "Rom\xE2n\u0103",
|
|
444
|
+
englishName: "Romanian",
|
|
445
|
+
currencyCode: "RON",
|
|
446
|
+
dateFormat: "DD.MM.YYYY"
|
|
447
|
+
},
|
|
448
|
+
// 불가리아어
|
|
449
|
+
bg: {
|
|
450
|
+
locale: "bg",
|
|
451
|
+
countryCode: "BG",
|
|
452
|
+
flag: "🇧🇬",
|
|
453
|
+
dialCode: "+359",
|
|
454
|
+
nativeName: "\u0411\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438",
|
|
455
|
+
englishName: "Bulgarian",
|
|
456
|
+
currencyCode: "BGN",
|
|
457
|
+
dateFormat: "DD.MM.YYYY"
|
|
458
|
+
},
|
|
459
|
+
// 크로아티아어
|
|
460
|
+
hr: {
|
|
461
|
+
locale: "hr",
|
|
462
|
+
countryCode: "HR",
|
|
463
|
+
flag: "🇭🇷",
|
|
464
|
+
dialCode: "+385",
|
|
465
|
+
nativeName: "Hrvatski",
|
|
466
|
+
englishName: "Croatian",
|
|
467
|
+
currencyCode: "HRK",
|
|
468
|
+
dateFormat: "DD.MM.YYYY."
|
|
469
|
+
},
|
|
470
|
+
// 세르비아어
|
|
471
|
+
sr: {
|
|
472
|
+
locale: "sr",
|
|
473
|
+
countryCode: "RS",
|
|
474
|
+
flag: "🇷🇸",
|
|
475
|
+
dialCode: "+381",
|
|
476
|
+
nativeName: "\u0421\u0440\u043F\u0441\u043A\u0438",
|
|
477
|
+
englishName: "Serbian",
|
|
478
|
+
currencyCode: "RSD",
|
|
479
|
+
dateFormat: "DD.MM.YYYY."
|
|
480
|
+
},
|
|
481
|
+
// 슬로바키아어
|
|
482
|
+
sk: {
|
|
483
|
+
locale: "sk",
|
|
484
|
+
countryCode: "SK",
|
|
485
|
+
flag: "🇸🇰",
|
|
486
|
+
dialCode: "+421",
|
|
487
|
+
nativeName: "Sloven\u010Dina",
|
|
488
|
+
englishName: "Slovak",
|
|
489
|
+
currencyCode: "EUR",
|
|
490
|
+
dateFormat: "DD.MM.YYYY"
|
|
491
|
+
},
|
|
492
|
+
// 슬로베니아어
|
|
493
|
+
sl: {
|
|
494
|
+
locale: "sl",
|
|
495
|
+
countryCode: "SI",
|
|
496
|
+
flag: "🇸🇮",
|
|
497
|
+
dialCode: "+386",
|
|
498
|
+
nativeName: "Sloven\u0161\u010Dina",
|
|
499
|
+
englishName: "Slovenian",
|
|
500
|
+
currencyCode: "EUR",
|
|
501
|
+
dateFormat: "DD.MM.YYYY"
|
|
502
|
+
},
|
|
503
|
+
// 리투아니아어
|
|
504
|
+
lt: {
|
|
505
|
+
locale: "lt",
|
|
506
|
+
countryCode: "LT",
|
|
507
|
+
flag: "🇱🇹",
|
|
508
|
+
dialCode: "+370",
|
|
509
|
+
nativeName: "Lietuvi\u0173",
|
|
510
|
+
englishName: "Lithuanian",
|
|
511
|
+
currencyCode: "EUR",
|
|
512
|
+
dateFormat: "YYYY-MM-DD"
|
|
513
|
+
},
|
|
514
|
+
// 라트비아어
|
|
515
|
+
lv: {
|
|
516
|
+
locale: "lv",
|
|
517
|
+
countryCode: "LV",
|
|
518
|
+
flag: "🇱🇻",
|
|
519
|
+
dialCode: "+371",
|
|
520
|
+
nativeName: "Latvie\u0161u",
|
|
521
|
+
englishName: "Latvian",
|
|
522
|
+
currencyCode: "EUR",
|
|
523
|
+
dateFormat: "DD.MM.YYYY."
|
|
524
|
+
},
|
|
525
|
+
// 에스토니아어
|
|
526
|
+
et: {
|
|
527
|
+
locale: "et",
|
|
528
|
+
countryCode: "EE",
|
|
529
|
+
flag: "🇪🇪",
|
|
530
|
+
dialCode: "+372",
|
|
531
|
+
nativeName: "Eesti",
|
|
532
|
+
englishName: "Estonian",
|
|
533
|
+
currencyCode: "EUR",
|
|
534
|
+
dateFormat: "DD.MM.YYYY"
|
|
535
|
+
},
|
|
536
|
+
// 그리스어
|
|
537
|
+
el: {
|
|
538
|
+
locale: "el",
|
|
539
|
+
countryCode: "GR",
|
|
540
|
+
flag: "🇬🇷",
|
|
541
|
+
dialCode: "+30",
|
|
542
|
+
nativeName: "\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC",
|
|
543
|
+
englishName: "Greek",
|
|
544
|
+
currencyCode: "EUR",
|
|
545
|
+
dateFormat: "DD/MM/YYYY"
|
|
546
|
+
},
|
|
547
|
+
// 페르시아어
|
|
548
|
+
fa: {
|
|
549
|
+
locale: "fa",
|
|
550
|
+
countryCode: "IR",
|
|
551
|
+
flag: "🇮🇷",
|
|
552
|
+
dialCode: "+98",
|
|
553
|
+
nativeName: "\u0641\u0627\u0631\u0633\u06CC",
|
|
554
|
+
englishName: "Persian",
|
|
555
|
+
rtl: true,
|
|
556
|
+
currencyCode: "IRR",
|
|
557
|
+
dateFormat: "YYYY/MM/DD"
|
|
558
|
+
},
|
|
559
|
+
// 히브리어
|
|
560
|
+
he: {
|
|
561
|
+
locale: "he",
|
|
562
|
+
countryCode: "IL",
|
|
563
|
+
flag: "🇮🇱",
|
|
564
|
+
dialCode: "+972",
|
|
565
|
+
nativeName: "\u05E2\u05D1\u05E8\u05D9\u05EA",
|
|
566
|
+
englishName: "Hebrew",
|
|
567
|
+
rtl: true,
|
|
568
|
+
currencyCode: "ILS",
|
|
569
|
+
dateFormat: "DD/MM/YYYY"
|
|
570
|
+
},
|
|
571
|
+
// 스와힐리어
|
|
572
|
+
sw: {
|
|
573
|
+
locale: "sw",
|
|
574
|
+
countryCode: "KE",
|
|
575
|
+
flag: "🇰🇪",
|
|
576
|
+
dialCode: "+254",
|
|
577
|
+
nativeName: "Kiswahili",
|
|
578
|
+
englishName: "Swahili",
|
|
579
|
+
currencyCode: "KES",
|
|
580
|
+
dateFormat: "DD/MM/YYYY"
|
|
709
581
|
}
|
|
710
|
-
}
|
|
711
|
-
var cmsPublishedCacheRepository = {
|
|
712
|
-
findBySection: findBySection2,
|
|
713
|
-
upsert: upsert3,
|
|
714
|
-
findAllLanguages,
|
|
715
|
-
deleteBySection
|
|
716
582
|
};
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
import { existsSync, readdirSync, readFileSync, statSync } from "fs";
|
|
720
|
-
import { basename, extname, join } from "path";
|
|
721
|
-
|
|
722
|
-
// src/labels/helpers.ts
|
|
723
|
-
function flattenLabels(labels) {
|
|
724
|
-
const result = [];
|
|
725
|
-
function isLabelDefinition(obj) {
|
|
726
|
-
return "key" in obj && "defaultValue" in obj && typeof obj.key === "string" && (typeof obj.defaultValue === "string" || typeof obj.defaultValue === "object");
|
|
727
|
-
}
|
|
728
|
-
function traverse(obj) {
|
|
729
|
-
if (isLabelDefinition(obj)) {
|
|
730
|
-
result.push({
|
|
731
|
-
key: obj.key,
|
|
732
|
-
defaultValue: obj.defaultValue,
|
|
733
|
-
description: obj.description
|
|
734
|
-
});
|
|
735
|
-
} else {
|
|
736
|
-
Object.values(obj).forEach((value) => {
|
|
737
|
-
if (typeof value === "object" && value !== null) {
|
|
738
|
-
traverse(value);
|
|
739
|
-
}
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
traverse(labels);
|
|
744
|
-
return result;
|
|
745
|
-
}
|
|
746
|
-
function extractLabels(definition) {
|
|
747
|
-
return flattenLabels(definition.labels);
|
|
583
|
+
function getLocaleInfo(locale) {
|
|
584
|
+
return LOCALE_INFO_MAP[locale];
|
|
748
585
|
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
async function syncAll(sections, options = {}) {
|
|
752
|
-
const results = [];
|
|
753
|
-
for (const definition of sections) {
|
|
754
|
-
const result = await syncSection(definition, options);
|
|
755
|
-
results.push(result);
|
|
756
|
-
}
|
|
757
|
-
return results;
|
|
586
|
+
function getSupportedLocales() {
|
|
587
|
+
return Object.keys(LOCALE_INFO_MAP);
|
|
758
588
|
}
|
|
759
|
-
function
|
|
760
|
-
|
|
761
|
-
if (!existsSync(labelsDir)) {
|
|
762
|
-
console.warn(`[CMS] Labels directory not found: ${labelsDir}`);
|
|
763
|
-
console.warn(`[CMS] Expected directory structure:`);
|
|
764
|
-
console.warn(`[CMS] ${labelsDir}/`);
|
|
765
|
-
console.warn(`[CMS] \u251C\u2500\u2500 common/ # Section directory`);
|
|
766
|
-
console.warn(`[CMS] \u2502 \u251C\u2500\u2500 messages.json`);
|
|
767
|
-
console.warn(`[CMS] \u2502 \u2514\u2500\u2500 errors.json`);
|
|
768
|
-
console.warn(`[CMS] \u2514\u2500\u2500 home/ # Section directory`);
|
|
769
|
-
console.warn(`[CMS] \u2514\u2500\u2500 hero.json`);
|
|
770
|
-
return sections;
|
|
771
|
-
}
|
|
772
|
-
try {
|
|
773
|
-
const entries = readdirSync(labelsDir);
|
|
774
|
-
if (entries.length === 0) {
|
|
775
|
-
console.warn(`[CMS] Labels directory is empty: ${labelsDir}`);
|
|
776
|
-
console.warn(`[CMS] Create section directories with JSON files inside`);
|
|
777
|
-
return sections;
|
|
778
|
-
}
|
|
779
|
-
const jsonFiles = entries.filter((e) => extname(e) === ".json");
|
|
780
|
-
if (jsonFiles.length > 0) {
|
|
781
|
-
console.warn(`[CMS] Found JSON files directly in ${labelsDir}:`);
|
|
782
|
-
jsonFiles.forEach((f) => console.warn(`[CMS] - ${f} (will be ignored)`));
|
|
783
|
-
console.warn(`[CMS] JSON files should be inside section directories`);
|
|
784
|
-
console.warn(`[CMS] Example: Move ${jsonFiles[0]} to ${labelsDir}/${basename(jsonFiles[0], ".json")}/${jsonFiles[0]}`);
|
|
785
|
-
}
|
|
786
|
-
for (const entry of entries) {
|
|
787
|
-
const sectionPath = join(labelsDir, entry);
|
|
788
|
-
const stat = statSync(sectionPath);
|
|
789
|
-
if (stat.isDirectory()) {
|
|
790
|
-
const sectionName = entry;
|
|
791
|
-
const labels = loadSectionLabels(sectionPath);
|
|
792
|
-
if (Object.keys(labels).length > 0) {
|
|
793
|
-
sections.push({ section: sectionName, labels });
|
|
794
|
-
} else {
|
|
795
|
-
console.warn(`[CMS] Section directory "${sectionName}" has no valid JSON files`);
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
if (sections.length === 0) {
|
|
800
|
-
console.warn(`[CMS] No valid section directories found in ${labelsDir}`);
|
|
801
|
-
}
|
|
802
|
-
} catch (error) {
|
|
803
|
-
console.warn(`[CMS] Could not scan labels directory: ${labelsDir}`);
|
|
804
|
-
console.error(`[CMS] Error:`, error);
|
|
805
|
-
}
|
|
806
|
-
return sections;
|
|
589
|
+
function getFlag(locale) {
|
|
590
|
+
return LOCALE_INFO_MAP[locale]?.flag ?? "";
|
|
807
591
|
}
|
|
808
|
-
function
|
|
809
|
-
|
|
810
|
-
try {
|
|
811
|
-
const files = readdirSync(sectionPath);
|
|
812
|
-
for (const file of files) {
|
|
813
|
-
if (extname(file) === ".json") {
|
|
814
|
-
const filePath = join(sectionPath, file);
|
|
815
|
-
const categoryName = basename(file, ".json");
|
|
816
|
-
try {
|
|
817
|
-
const content = readFileSync(filePath, "utf-8");
|
|
818
|
-
labels[categoryName] = JSON.parse(content);
|
|
819
|
-
} catch (error) {
|
|
820
|
-
console.warn(`[CMS] Failed to parse ${filePath}`);
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
} catch (error) {
|
|
825
|
-
console.warn(`[CMS] Could not read section directory: ${sectionPath}`);
|
|
826
|
-
}
|
|
827
|
-
return labels;
|
|
592
|
+
function getDialCode(locale) {
|
|
593
|
+
return LOCALE_INFO_MAP[locale]?.dialCode ?? "";
|
|
828
594
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
dryRun = false,
|
|
832
|
-
updateExisting = false,
|
|
833
|
-
removeUnused = false,
|
|
834
|
-
verbose = false
|
|
835
|
-
} = options;
|
|
836
|
-
const { section } = definition;
|
|
837
|
-
const result = {
|
|
838
|
-
section,
|
|
839
|
-
created: 0,
|
|
840
|
-
updated: 0,
|
|
841
|
-
deleted: 0,
|
|
842
|
-
unchanged: 0,
|
|
843
|
-
errors: []
|
|
844
|
-
};
|
|
845
|
-
try {
|
|
846
|
-
const definedLabels = extractLabels(definition);
|
|
847
|
-
const definedKeys = new Set(definedLabels.map((l) => l.key));
|
|
848
|
-
const existingLabels = await cmsLabelsRepository.findBySection(section);
|
|
849
|
-
const existingMap = new Map(existingLabels.map((l) => [l.key, l]));
|
|
850
|
-
if (verbose) {
|
|
851
|
-
console.log(`
|
|
852
|
-
[${section}] Found ${definedLabels.length} labels in definition`);
|
|
853
|
-
console.log(`[${section}] Found ${existingLabels.length} labels in DB`);
|
|
854
|
-
}
|
|
855
|
-
for (const label of definedLabels) {
|
|
856
|
-
const existing = existingMap.get(label.key);
|
|
857
|
-
if (!existing) {
|
|
858
|
-
if (verbose) console.log(` [CREATE] ${label.key}`);
|
|
859
|
-
if (!dryRun) {
|
|
860
|
-
try {
|
|
861
|
-
const defaultValue = typeof label.defaultValue === "object" ? JSON.stringify(label.defaultValue) : label.defaultValue;
|
|
862
|
-
await cmsLabelsRepository.create({
|
|
863
|
-
section,
|
|
864
|
-
key: label.key,
|
|
865
|
-
type: label.type || "text",
|
|
866
|
-
// 라벨 타입 (기본값: 'text')
|
|
867
|
-
defaultValue,
|
|
868
|
-
description: label.description
|
|
869
|
-
});
|
|
870
|
-
} catch (error) {
|
|
871
|
-
result.errors.push({
|
|
872
|
-
key: label.key,
|
|
873
|
-
error: error instanceof Error ? error.message : String(error)
|
|
874
|
-
});
|
|
875
|
-
continue;
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
result.created++;
|
|
879
|
-
} else if (updateExisting) {
|
|
880
|
-
const newDefaultValue = typeof label.defaultValue === "object" ? JSON.stringify(label.defaultValue) : label.defaultValue;
|
|
881
|
-
const hasChanged = existing.defaultValue !== newDefaultValue;
|
|
882
|
-
if (hasChanged) {
|
|
883
|
-
if (verbose) {
|
|
884
|
-
console.log(` [UPDATE] ${label.key}`);
|
|
885
|
-
console.log(` Old: "${existing.defaultValue}"`);
|
|
886
|
-
console.log(` New: "${newDefaultValue}"`);
|
|
887
|
-
}
|
|
888
|
-
if (!dryRun) {
|
|
889
|
-
try {
|
|
890
|
-
await cmsLabelsRepository.updateById(existing.id, {
|
|
891
|
-
defaultValue: newDefaultValue,
|
|
892
|
-
description: label.description
|
|
893
|
-
});
|
|
894
|
-
} catch (error) {
|
|
895
|
-
result.errors.push({
|
|
896
|
-
key: label.key,
|
|
897
|
-
error: error instanceof Error ? error.message : String(error)
|
|
898
|
-
});
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
result.updated++;
|
|
903
|
-
} else {
|
|
904
|
-
result.unchanged++;
|
|
905
|
-
}
|
|
906
|
-
} else {
|
|
907
|
-
result.unchanged++;
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
if (removeUnused) {
|
|
911
|
-
for (const existing of existingLabels) {
|
|
912
|
-
if (!definedKeys.has(existing.key)) {
|
|
913
|
-
if (verbose) console.log(` [DELETE] ${existing.key}`);
|
|
914
|
-
if (!dryRun) {
|
|
915
|
-
try {
|
|
916
|
-
await cmsLabelsRepository.deleteById(existing.id);
|
|
917
|
-
} catch (error) {
|
|
918
|
-
result.errors.push({
|
|
919
|
-
key: existing.key,
|
|
920
|
-
error: error instanceof Error ? error.message : String(error)
|
|
921
|
-
});
|
|
922
|
-
continue;
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
result.deleted++;
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
}
|
|
929
|
-
if (!dryRun && (result.created > 0 || result.updated > 0 || result.deleted > 0)) {
|
|
930
|
-
if (verbose) console.log(` [CACHE] Updating published cache for section: ${section}`);
|
|
931
|
-
await updatePublishedCache(section);
|
|
932
|
-
}
|
|
933
|
-
} catch (error) {
|
|
934
|
-
result.errors.push({
|
|
935
|
-
key: "__section__",
|
|
936
|
-
error: error instanceof Error ? error.message : String(error)
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
return result;
|
|
940
|
-
}
|
|
941
|
-
async function updatePublishedCache(section) {
|
|
942
|
-
const labels = await cmsLabelsRepository.findBySection(section);
|
|
943
|
-
const localesSet = /* @__PURE__ */ new Set();
|
|
944
|
-
const labelsByLocale = {};
|
|
945
|
-
labels.forEach((label) => {
|
|
946
|
-
try {
|
|
947
|
-
const parsed = JSON.parse(label.defaultValue || "{}");
|
|
948
|
-
if (typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
949
|
-
Object.keys(parsed).forEach((locale) => localesSet.add(locale));
|
|
950
|
-
Object.entries(parsed).forEach(([locale, value]) => {
|
|
951
|
-
if (!labelsByLocale[locale]) labelsByLocale[locale] = {};
|
|
952
|
-
labelsByLocale[locale][label.key] = value;
|
|
953
|
-
});
|
|
954
|
-
} else {
|
|
955
|
-
if (!labelsByLocale.ko) labelsByLocale.ko = {};
|
|
956
|
-
labelsByLocale.ko[label.key] = label.defaultValue;
|
|
957
|
-
localesSet.add("ko");
|
|
958
|
-
}
|
|
959
|
-
} catch {
|
|
960
|
-
if (!labelsByLocale.ko) labelsByLocale.ko = {};
|
|
961
|
-
labelsByLocale.ko[label.key] = label.defaultValue;
|
|
962
|
-
localesSet.add("ko");
|
|
963
|
-
}
|
|
964
|
-
});
|
|
965
|
-
const timestamp7 = /* @__PURE__ */ new Date();
|
|
966
|
-
for (const locale of localesSet) {
|
|
967
|
-
await cmsPublishedCacheRepository.upsert({
|
|
968
|
-
section,
|
|
969
|
-
locale,
|
|
970
|
-
content: labelsByLocale[locale] || {},
|
|
971
|
-
publishedAt: timestamp7,
|
|
972
|
-
publishedBy: "system"
|
|
973
|
-
});
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
async function initLabelSync(options = {}) {
|
|
977
|
-
const isDevelopment = process.env.NODE_ENV === "development";
|
|
978
|
-
const verbose = options.verbose ?? isDevelopment;
|
|
979
|
-
const labelsDir = options.labelsDir ?? "src/cms/labels";
|
|
980
|
-
if (verbose) {
|
|
981
|
-
console.log("\n\u{1F504} Initializing label sync...\n");
|
|
982
|
-
}
|
|
983
|
-
const sections = loadLabelsFromJson(labelsDir);
|
|
984
|
-
if (sections.length === 0) {
|
|
985
|
-
if (verbose) {
|
|
986
|
-
console.log("\u26A0\uFE0F No labels found in", labelsDir);
|
|
987
|
-
console.log("");
|
|
988
|
-
}
|
|
989
|
-
return;
|
|
990
|
-
}
|
|
991
|
-
const results = await syncAll(sections, {
|
|
992
|
-
updateExisting: true,
|
|
993
|
-
// 🔄 항상 업데이트 (프로덕션 포함)
|
|
994
|
-
...options,
|
|
995
|
-
verbose
|
|
996
|
-
});
|
|
997
|
-
const totalCreated = results.reduce((sum, r) => sum + r.created, 0);
|
|
998
|
-
const totalUpdated = results.reduce((sum, r) => sum + r.updated, 0);
|
|
999
|
-
const totalUnchanged = results.reduce((sum, r) => sum + r.unchanged, 0);
|
|
1000
|
-
const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
|
|
1001
|
-
if (verbose) {
|
|
1002
|
-
console.log("\u2705 Label sync completed\n");
|
|
1003
|
-
console.log(` Sections: ${results.length}`);
|
|
1004
|
-
console.log(` Created: ${totalCreated}`);
|
|
1005
|
-
console.log(` Updated: ${totalUpdated}`);
|
|
1006
|
-
console.log(` Unchanged: ${totalUnchanged}`);
|
|
1007
|
-
if (totalErrors > 0) {
|
|
1008
|
-
console.log(` Errors: ${totalErrors}
|
|
1009
|
-
`);
|
|
1010
|
-
} else {
|
|
1011
|
-
console.log("");
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
if (totalErrors > 0) {
|
|
1015
|
-
results.forEach((result) => {
|
|
1016
|
-
result.errors.forEach((error) => {
|
|
1017
|
-
console.error(`[${result.section}] ${error.key}: ${error.error}`);
|
|
1018
|
-
});
|
|
1019
|
-
});
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
// src/generators/label-sync-generator.ts
|
|
1024
|
-
import { logger } from "@spfn/core";
|
|
1025
|
-
import { join as join2 } from "path";
|
|
1026
|
-
var syncLogger = logger.child("label-sync");
|
|
1027
|
-
var LabelSyncGenerator = class {
|
|
1028
|
-
name = "label-sync";
|
|
1029
|
-
labelsDir;
|
|
1030
|
-
constructor(config = {}) {
|
|
1031
|
-
this.labelsDir = config.labelsDir ?? "src/cms/labels";
|
|
1032
|
-
}
|
|
1033
|
-
/**
|
|
1034
|
-
* Watch patterns for label definition files
|
|
1035
|
-
*/
|
|
1036
|
-
get watchPatterns() {
|
|
1037
|
-
return [
|
|
1038
|
-
`${this.labelsDir}/**/*.json`
|
|
1039
|
-
];
|
|
1040
|
-
}
|
|
1041
|
-
async generate(options) {
|
|
1042
|
-
if (options.debug) {
|
|
1043
|
-
syncLogger.info("Starting label sync...");
|
|
1044
|
-
}
|
|
1045
|
-
try {
|
|
1046
|
-
const labelsPath = join2(options.cwd, this.labelsDir);
|
|
1047
|
-
const sections = loadLabelsFromJson(labelsPath);
|
|
1048
|
-
if (sections.length === 0) {
|
|
1049
|
-
syncLogger.warn(`No labels found in ${labelsPath}`);
|
|
1050
|
-
return;
|
|
1051
|
-
}
|
|
1052
|
-
syncLogger.info(`Found ${sections.length} sections`);
|
|
1053
|
-
const results = await syncAll(sections, {
|
|
1054
|
-
verbose: options.debug ?? false,
|
|
1055
|
-
updateExisting: true
|
|
1056
|
-
// 항상 업데이트 (프로덕션 포함)
|
|
1057
|
-
});
|
|
1058
|
-
const totalCreated = results.reduce((sum, r) => sum + r.created, 0);
|
|
1059
|
-
const totalUpdated = results.reduce((sum, r) => sum + r.updated, 0);
|
|
1060
|
-
const totalErrors = results.reduce((sum, r) => sum + r.errors.length, 0);
|
|
1061
|
-
if (options.debug || totalCreated > 0 || totalUpdated > 0) {
|
|
1062
|
-
syncLogger.info("Label sync completed", {
|
|
1063
|
-
sections: results.length,
|
|
1064
|
-
created: totalCreated,
|
|
1065
|
-
updated: totalUpdated,
|
|
1066
|
-
errors: totalErrors
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
if (totalErrors > 0) {
|
|
1070
|
-
results.forEach((result) => {
|
|
1071
|
-
result.errors.forEach((error) => {
|
|
1072
|
-
syncLogger.error(`[${result.section}] ${error.key}: ${error.error}`);
|
|
1073
|
-
});
|
|
1074
|
-
});
|
|
1075
|
-
}
|
|
1076
|
-
} catch (error) {
|
|
1077
|
-
syncLogger.error(
|
|
1078
|
-
"Label sync failed",
|
|
1079
|
-
error instanceof Error ? error : new Error(String(error))
|
|
1080
|
-
);
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
async onFileChange(filePath, event) {
|
|
1084
|
-
syncLogger.info(`Label file ${event}`, { file: filePath });
|
|
1085
|
-
await this.generate({ cwd: process.cwd(), debug: true });
|
|
1086
|
-
}
|
|
1087
|
-
};
|
|
1088
|
-
function createLabelSyncGenerator(config) {
|
|
1089
|
-
return new LabelSyncGenerator(config);
|
|
595
|
+
function isRTL(locale) {
|
|
596
|
+
return LOCALE_INFO_MAP[locale]?.rtl ?? false;
|
|
1090
597
|
}
|
|
1091
598
|
export {
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
cmsDraftCacheRepository,
|
|
1096
|
-
cmsLabelValues,
|
|
1097
|
-
cmsLabelValuesRepository,
|
|
1098
|
-
cmsLabelVersions,
|
|
1099
|
-
cmsLabels,
|
|
1100
|
-
cmsLabelsRepository,
|
|
1101
|
-
cmsPublishedCache,
|
|
1102
|
-
cmsPublishedCacheRepository,
|
|
599
|
+
DEFAULT_LABELS_DIR,
|
|
600
|
+
LOCALE_COOKIE_KEY,
|
|
601
|
+
LOCALE_INFO_MAP,
|
|
1103
602
|
configureCms,
|
|
1104
|
-
createLabelSyncGenerator,
|
|
1105
|
-
extractLabels,
|
|
1106
|
-
flattenLabels,
|
|
1107
603
|
getCmsConfig,
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
syncSection
|
|
604
|
+
getDialCode,
|
|
605
|
+
getFlag,
|
|
606
|
+
getLocaleInfo,
|
|
607
|
+
getSupportedLocales,
|
|
608
|
+
isRTL,
|
|
609
|
+
resetCmsConfig
|
|
1115
610
|
};
|
|
1116
611
|
//# sourceMappingURL=index.js.map
|