@things-factory/attachment-base 8.0.0-alpha.25 → 8.0.0-alpha.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/attachment-base",
3
- "version": "8.0.0-alpha.25",
3
+ "version": "8.0.0-alpha.27",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -29,11 +29,11 @@
29
29
  "@aws-sdk/s3-presigned-post": "^3.46.0",
30
30
  "@azure/storage-blob": "^12.18.0",
31
31
  "@koa/multer": "^3.0.0",
32
- "@things-factory/auth-base": "^8.0.0-alpha.24",
32
+ "@things-factory/auth-base": "^8.0.0-alpha.27",
33
33
  "@things-factory/env": "^8.0.0-alpha.8",
34
- "@things-factory/shell": "^8.0.0-alpha.22",
34
+ "@things-factory/shell": "^8.0.0-alpha.27",
35
35
  "mime": "^3.0.0",
36
36
  "multer": "^1.4.5-lts.1"
37
37
  },
38
- "gitHead": "126c290973df223812311e21599224f527449b34"
38
+ "gitHead": "6c55d218253341cc51e8fa7b2f9dc8a7c061aa55"
39
39
  }
package/server/index.ts CHANGED
@@ -13,3 +13,12 @@ import './routes'
13
13
 
14
14
  export * from './attachment-const'
15
15
  export * from './util'
16
+
17
+ import { normalizeNamesToNFC } from './nfc-normalize'
18
+
19
+ process.on('bootstrap-module-start' as any, async ({ app, config, client }: any) => {
20
+ /* 이 코드는 기존 첨부파일의 NFC 정규화를 강제로 실행하기 위해서 임시로 작성되었다. */
21
+ normalizeNamesToNFC()
22
+ .then(() => console.log('Normalization completed.'))
23
+ .catch(err => console.error('Error during normalization:', err))
24
+ })
@@ -0,0 +1,25 @@
1
+ import { getRepository } from '@things-factory/shell'
2
+ import { Attachment } from './service/attachment/attachment'
3
+
4
+ export async function normalizeNamesToNFC() {
5
+ const attachmentRepository = getRepository(Attachment)
6
+
7
+ // 모든 Attachment 항목을 조회
8
+ const attachments = await attachmentRepository.find()
9
+
10
+ // NFD로 저장된 name을 NFC로 변환하여 업데이트
11
+ for (const attachment of attachments) {
12
+ if (attachment.name) {
13
+ const normalizedName = attachment.name.normalize('NFC')
14
+
15
+ // name이 NFD로 저장된 경우만 업데이트
16
+ if (attachment.name !== normalizedName) {
17
+ attachment.name = normalizedName
18
+ await attachmentRepository.save(attachment)
19
+ console.log(`Updated name for attachment ID ${attachment.id}: ${normalizedName}`)
20
+ }
21
+ }
22
+ }
23
+
24
+ console.log('All names have been normalized to NFC.')
25
+ }
@@ -22,7 +22,7 @@ export class AttachmentQuery {
22
22
  params,
23
23
  domain,
24
24
  alias: 'attachment',
25
- searchables: ['id', 'name', 'description', 'tags']
25
+ searchables: ['name', 'description', 'tags']
26
26
  })
27
27
 
28
28
  const [items, total] = await queryBuilder.getManyAndCount()