@dssp/supervision 1.0.0-alpha.76 → 1.0.0-alpha.78

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 (62) hide show
  1. package/dist-client/pages/building-inspection/building-inspection-list.js +2 -2
  2. package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -1
  3. package/dist-client/pages/building-inspection/building-inspection-management.d.ts +9 -0
  4. package/dist-client/pages/building-inspection/building-inspection-management.js +303 -47
  5. package/dist-client/pages/building-inspection/building-inspection-management.js.map +1 -1
  6. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.d.ts +18 -0
  7. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.js +630 -0
  8. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.js.map +1 -0
  9. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.d.ts +10 -0
  10. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.js +219 -0
  11. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.js.map +1 -0
  12. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.d.ts +25 -0
  13. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.js +545 -0
  14. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.js.map +1 -0
  15. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.d.ts +39 -0
  16. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.js +675 -0
  17. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.js.map +1 -0
  18. package/dist-client/pages/building-inspection/component/inspection-event-provider.d.ts +3 -2
  19. package/dist-client/pages/building-inspection/component/inspection-event-provider.js +129 -34
  20. package/dist-client/pages/building-inspection/component/inspection-event-provider.js.map +1 -1
  21. package/dist-client/pages/checklist-template/construction-checklist-template-list.js +9 -14
  22. package/dist-client/pages/checklist-template/construction-checklist-template-list.js.map +1 -1
  23. package/dist-client/pages/project-checklist/project-checklist-management.d.ts +2 -0
  24. package/dist-client/pages/project-checklist/project-checklist-management.js +24 -2
  25. package/dist-client/pages/project-checklist/project-checklist-management.js.map +1 -1
  26. package/dist-client/tsconfig.tsbuildinfo +1 -1
  27. package/dist-server/service/building-inspection/building-inspection-mutation.js +30 -0
  28. package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -1
  29. package/dist-server/service/building-inspection/building-inspection-query.d.ts +5 -1
  30. package/dist-server/service/building-inspection/building-inspection-query.js +114 -0
  31. package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -1
  32. package/dist-server/service/building-inspection/building-inspection-type.d.ts +4 -0
  33. package/dist-server/service/building-inspection/building-inspection-type.js +15 -1
  34. package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -1
  35. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js +10 -0
  36. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js.map +1 -1
  37. package/dist-server/service/field-document/field-document-auto-file.d.ts +21 -0
  38. package/dist-server/service/field-document/field-document-auto-file.js +47 -0
  39. package/dist-server/service/field-document/field-document-auto-file.js.map +1 -0
  40. package/dist-server/service/field-document/field-document-mutation.d.ts +9 -0
  41. package/dist-server/service/field-document/field-document-mutation.js +136 -0
  42. package/dist-server/service/field-document/field-document-mutation.js.map +1 -0
  43. package/dist-server/service/field-document/field-document-query.d.ts +14 -0
  44. package/dist-server/service/field-document/field-document-query.js +120 -0
  45. package/dist-server/service/field-document/field-document-query.js.map +1 -0
  46. package/dist-server/service/field-document/field-document-summary-service.d.ts +2 -0
  47. package/dist-server/service/field-document/field-document-summary-service.js +55 -0
  48. package/dist-server/service/field-document/field-document-summary-service.js.map +1 -0
  49. package/dist-server/service/field-document/field-document-type.d.ts +23 -0
  50. package/dist-server/service/field-document/field-document-type.js +84 -0
  51. package/dist-server/service/field-document/field-document-type.js.map +1 -0
  52. package/dist-server/service/field-document/field-document.d.ts +29 -0
  53. package/dist-server/service/field-document/field-document.js +127 -0
  54. package/dist-server/service/field-document/field-document.js.map +1 -0
  55. package/dist-server/service/field-document/index.d.ts +5 -0
  56. package/dist-server/service/field-document/index.js +9 -0
  57. package/dist-server/service/field-document/index.js.map +1 -0
  58. package/dist-server/service/index.d.ts +2 -1
  59. package/dist-server/service/index.js +4 -0
  60. package/dist-server/service/index.js.map +1 -1
  61. package/dist-server/tsconfig.tsbuildinfo +1 -1
  62. package/package.json +2 -2
@@ -7,6 +7,7 @@ const building_inspection_daily_worklog_1 = require("./building-inspection-daily
7
7
  const building_inspection_daily_worklog_type_1 = require("./building-inspection-daily-worklog-type");
8
8
  const building_inspection_1 = require("../building-inspection/building-inspection");
9
9
  const building_inspection_daily_worklog_query_1 = require("./building-inspection-daily-worklog-query");
10
+ const field_document_auto_file_1 = require("../field-document/field-document-auto-file");
10
11
  let BuildingInspectionDailyWorklogMutation = class BuildingInspectionDailyWorklogMutation {
11
12
  async createBuildingInspectionDailyWorklog(patch, context) {
12
13
  const { user, domain, tx } = context.state;
@@ -21,6 +22,15 @@ let BuildingInspectionDailyWorklogMutation = class BuildingInspectionDailyWorklo
21
22
  const buildingInspection = await buildingInspectionRepo.findOne({ where: { id: buildingInspectionId } });
22
23
  await buildingInspectionRepo.save(Object.assign(Object.assign({}, buildingInspection), { worklog: result }));
23
24
  }
25
+ // 현장 문서 자동 등록 (020108 책임기술인일지)
26
+ await (0, field_document_auto_file_1.autoFileDocument)({
27
+ projectId: patch.projectId,
28
+ code: '020108',
29
+ name: `일일 업무일지 - ${patch.date}`,
30
+ sourceType: 'DAILY_WORKLOG',
31
+ sourceRefId: result.id,
32
+ context
33
+ });
24
34
  return result;
25
35
  }
26
36
  async updateBuildingInspectionDailyWorklog(patch, context) {
@@ -1 +1 @@
1
- {"version":3,"file":"building-inspection-daily-worklog-mutation.js","sourceRoot":"","sources":["../../../server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,2FAAoF;AACpF,qGAAi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g, Ctx, Directive } from 'type-graphql'\nimport { BuildingInspectionDailyWorklog } from './building-inspection-daily-worklog'\nimport { BuildingInspectionDailyWorklogPatch, BuildingInspectionDailyWorklogNew } from './building-inspection-daily-worklog-type'\nimport { BuildingInspection } from '../building-inspection/building-inspection'\nimport { generateDailyWorklogDocumentNo } from './building-inspection-daily-worklog-query'\n\n@Resolver(BuildingInspectionDailyWorklog)\nexport class BuildingInspectionDailyWorklogMutation {\n @Directive('@transaction')\n @Mutation(returns => BuildingInspectionDailyWorklog, { description: 'Create Daily Worklog by projectId+date' })\n async createBuildingInspectionDailyWorklog(\n @Arg('patch') patch: BuildingInspectionDailyWorklogNew,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionDailyWorklog> {\n const { user, domain, tx } = context.state\n const worklogRepo = tx.getRepository(BuildingInspectionDailyWorklog)\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n\n if (!patch.projectId) throw new Error('projectId 가 없습니다.')\n if (!patch.date) throw new Error('date 가 없습니다.')\n\n const result = await worklogRepo.save({\n ...patch,\n overallSupervisory: patch.overallSupervisoryId ? ({ id: patch.overallSupervisoryId } as any) : undefined,\n taskSupervisory: patch.taskSupervisoryId ? ({ id: patch.taskSupervisoryId } as any) : undefined,\n documentNo: await generateDailyWorklogDocumentNo(patch.projectId),\n domain: domain,\n creator: user,\n updater: user\n })\n\n for (const buildingInspectionId of patch.buildingInspectionIds) {\n const buildingInspection = await buildingInspectionRepo.findOne({ where: { id: buildingInspectionId } })\n await buildingInspectionRepo.save({ ...buildingInspection, worklog: result })\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspectionDailyWorklog, { description: 'Update Daily Worklog' })\n async updateBuildingInspectionDailyWorklog(\n @Arg('patch') patch: BuildingInspectionDailyWorklogPatch,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionDailyWorklog> {\n const { user, tx } = context.state\n const worklogRepo = tx.getRepository(BuildingInspectionDailyWorklog)\n\n const origin = await worklogRepo.findOne({ where: { id: patch.id } })\n const result = await worklogRepo.save({\n ...origin,\n ...patch,\n updater: user\n })\n\n return result\n }\n}\n"]}
1
+ {"version":3,"file":"building-inspection-daily-worklog-mutation.js","sourceRoot":"","sources":["../../../server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,2FAAoF;AACpF,qGAAiI;AACjI,oFAA+E;AAC/E,uGAA0F;AAC1F,yFAA6E;AAGtE,IAAM,sCAAsC,GAA5C,MAAM,sCAAsC;IAG3C,AAAN,KAAK,CAAC,oCAAoC,CAC1B,KAAwC,EAC/C,OAAwB;QAE/B,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,kEAA8B,CAAC,CAAA;QACpE,MAAM,sBAAsB,GAAG,EAAE,CAAC,aAAa,CAAC,wCAAkB,CAAC,CAAA;QAEnE,IAAI,CAAC,KAAK,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;QAEhD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,iCAChC,KAAK,KACR,kBAAkB,EAAE,KAAK,CAAC,oBAAoB,CAAC,CAAC,CAAE,EAAE,EAAE,EAAE,KAAK,CAAC,oBAAoB,EAAU,CAAC,CAAC,CAAC,SAAS,EACxG,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAE,EAAE,EAAE,EAAE,KAAK,CAAC,iBAAiB,EAAU,CAAC,CAAC,CAAC,SAAS,EAC/F,UAAU,EAAE,MAAM,IAAA,wEAA8B,EAAC,KAAK,CAAC,SAAS,CAAC,EACjE,MAAM,EAAE,MAAM,EACd,OAAO,EA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AE,WAAW,EAAE,wCAAwC,EAAE,CAAC;IAE5G,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,0EAAiC;;kGAoCvD;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,kEAA8B,EAAE,EAAE,WAAW,EAAE,sBAAsB,EAAE,CAAC;IAE1F,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,4EAAmC;;kGAczD;iDA3DU,sCAAsC;IADlD,IAAA,uBAAQ,EAAC,kEAA8B,CAAC;GAC5B,sCAAsC,CA4DlD","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { BuildingInspectionDailyWorklog } from './building-inspection-daily-worklog'\nimport { BuildingInspectionDailyWorklogPatch, BuildingInspectionDailyWorklogNew } from './building-inspection-daily-worklog-type'\nimport { BuildingInspection } from '../building-inspection/building-inspection'\nimport { generateDailyWorklogDocumentNo } from './building-inspection-daily-worklog-query'\nimport { autoFileDocument } from '../field-document/field-document-auto-file'\n\n@Resolver(BuildingInspectionDailyWorklog)\nexport class BuildingInspectionDailyWorklogMutation {\n @Directive('@transaction')\n @Mutation(returns => BuildingInspectionDailyWorklog, { description: 'Create Daily Worklog by projectId+date' })\n async createBuildingInspectionDailyWorklog(\n @Arg('patch') patch: BuildingInspectionDailyWorklogNew,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionDailyWorklog> {\n const { user, domain, tx } = context.state\n const worklogRepo = tx.getRepository(BuildingInspectionDailyWorklog)\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n\n if (!patch.projectId) throw new Error('projectId 가 없습니다.')\n if (!patch.date) throw new Error('date 가 없습니다.')\n\n const result = await worklogRepo.save({\n ...patch,\n overallSupervisory: patch.overallSupervisoryId ? ({ id: patch.overallSupervisoryId } as any) : undefined,\n taskSupervisory: patch.taskSupervisoryId ? ({ id: patch.taskSupervisoryId } as any) : undefined,\n documentNo: await generateDailyWorklogDocumentNo(patch.projectId),\n domain: domain,\n creator: user,\n updater: user\n })\n\n for (const buildingInspectionId of patch.buildingInspectionIds) {\n const buildingInspection = await buildingInspectionRepo.findOne({ where: { id: buildingInspectionId } })\n await buildingInspectionRepo.save({ ...buildingInspection, worklog: result })\n }\n\n // 현장 문서 자동 등록 (020108 책임기술인일지)\n await autoFileDocument({\n projectId: patch.projectId,\n code: '020108',\n name: `일일 업무일지 - ${patch.date}`,\n sourceType: 'DAILY_WORKLOG',\n sourceRefId: result.id,\n context\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspectionDailyWorklog, { description: 'Update Daily Worklog' })\n async updateBuildingInspectionDailyWorklog(\n @Arg('patch') patch: BuildingInspectionDailyWorklogPatch,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionDailyWorklog> {\n const { user, tx } = context.state\n const worklogRepo = tx.getRepository(BuildingInspectionDailyWorklog)\n\n const origin = await worklogRepo.findOne({ where: { id: patch.id } })\n const result = await worklogRepo.save({\n ...origin,\n ...patch,\n updater: user\n })\n\n return result\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { FieldDocument } from './field-document';
2
+ /**
3
+ * buildingLevelId → building → buildingComplex → project 체인으로 projectId를 조회
4
+ */
5
+ export declare function getProjectIdByBuildingLevelId(buildingLevelId: string, tx?: any): Promise<string | null>;
6
+ interface AutoFileParams {
7
+ projectId: string;
8
+ code: string;
9
+ name: string;
10
+ sourceType: string;
11
+ sourceRefId: string;
12
+ context: ResolverContext;
13
+ }
14
+ /**
15
+ * 기존 프로세스에서 자동으로 현장 문서 등록
16
+ * - 일일업무일지 → 020108
17
+ * - 검측요청서 → 040201
18
+ * - 체크리스트 → 040202
19
+ */
20
+ export declare function autoFileDocument(params: AutoFileParams): Promise<FieldDocument>;
21
+ export {};
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProjectIdByBuildingLevelId = getProjectIdByBuildingLevelId;
4
+ exports.autoFileDocument = autoFileDocument;
5
+ const shell_1 = require("@things-factory/shell");
6
+ const field_document_1 = require("./field-document");
7
+ const field_document_summary_service_1 = require("./field-document-summary-service");
8
+ /**
9
+ * buildingLevelId → building → buildingComplex → project 체인으로 projectId를 조회
10
+ */
11
+ async function getProjectIdByBuildingLevelId(buildingLevelId, tx) {
12
+ const repo = tx || (0, shell_1.getRepository)('projects');
13
+ const result = await (tx || (0, shell_1.getRepository)('projects'))
14
+ .createQueryBuilder('p')
15
+ .select('p.id', 'projectId')
16
+ .leftJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
17
+ .leftJoin('buildings', 'b', 'b.building_complex_id = bc.id')
18
+ .leftJoin('building_levels', 'bl', 'bl.building_id = b.id')
19
+ .where('bl.id = :buildingLevelId', { buildingLevelId })
20
+ .getRawOne();
21
+ return (result === null || result === void 0 ? void 0 : result.projectId) || null;
22
+ }
23
+ /**
24
+ * 기존 프로세스에서 자동으로 현장 문서 등록
25
+ * - 일일업무일지 → 020108
26
+ * - 검측요청서 → 040201
27
+ * - 체크리스트 → 040202
28
+ */
29
+ async function autoFileDocument(params) {
30
+ const { projectId, code, name, sourceType, sourceRefId, context } = params;
31
+ const { domain, user, tx } = context.state;
32
+ const repo = tx.getRepository(field_document_1.FieldDocument);
33
+ const result = await repo.save({
34
+ projectId,
35
+ code,
36
+ name,
37
+ sourceType,
38
+ sourceRefId,
39
+ aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.REQUEST,
40
+ domain,
41
+ creator: user,
42
+ updater: user
43
+ });
44
+ (0, field_document_summary_service_1.queueDocumentSummary)(result.id);
45
+ return result;
46
+ }
47
+ //# sourceMappingURL=field-document-auto-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-document-auto-file.js","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EAAE,2CAA0B,CAAC,OAAO;QACnD,MAAM;QACN,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,IAAI;KACd,CAAC,CAAA;IAEF,IAAA,qDAAoB,EAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAE/B,OAAO,MAAM,CAAA;AACf,CAAC","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { FieldDocument, FieldDocumentSummaryStatus } from './field-document'\nimport { queueDocumentSummary } from './field-document-summary-service'\n\n/**\n * buildingLevelId → building → buildingComplex → project 체인으로 projectId를 조회\n */\nexport async function getProjectIdByBuildingLevelId(buildingLevelId: string, tx?: any): Promise<string | null> {\n const repo = tx || getRepository('projects')\n const result = await (tx || getRepository('projects'))\n .createQueryBuilder('p')\n .select('p.id', 'projectId')\n .leftJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')\n .leftJoin('buildings', 'b', 'b.building_complex_id = bc.id')\n .leftJoin('building_levels', 'bl', 'bl.building_id = b.id')\n .where('bl.id = :buildingLevelId', { buildingLevelId })\n .getRawOne()\n\n return result?.projectId || null\n}\n\ninterface AutoFileParams {\n projectId: string\n code: string\n name: string\n sourceType: string\n sourceRefId: string\n context: ResolverContext\n}\n\n/**\n * 기존 프로세스에서 자동으로 현장 문서 등록\n * - 일일업무일지 → 020108\n * - 검측요청서 → 040201\n * - 체크리스트 → 040202\n */\nexport async function autoFileDocument(params: AutoFileParams): Promise<FieldDocument> {\n const { projectId, code, name, sourceType, sourceRefId, context } = params\n const { domain, user, tx } = context.state\n\n const repo = tx.getRepository(FieldDocument)\n\n const result = await repo.save({\n projectId,\n code,\n name,\n sourceType,\n sourceRefId,\n aiSummaryStatus: FieldDocumentSummaryStatus.REQUEST,\n domain,\n creator: user,\n updater: user\n })\n\n queueDocumentSummary(result.id)\n\n return result\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { FieldDocument } from './field-document';
2
+ import { NewFieldDocument } from './field-document-type';
3
+ export declare class FieldDocumentMutation {
4
+ createFieldDocument(patch: NewFieldDocument, context: ResolverContext): Promise<FieldDocument>;
5
+ createFieldDocuments(patches: NewFieldDocument[], context: ResolverContext): Promise<FieldDocument[]>;
6
+ moveFieldDocuments(ids: string[], targetCode: string, context: ResolverContext): Promise<boolean>;
7
+ toggleFieldDocumentFavorite(id: string, context: ResolverContext): Promise<FieldDocument>;
8
+ deleteFieldDocuments(ids: string[], context: ResolverContext): Promise<boolean>;
9
+ }
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldDocumentMutation = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const typeorm_1 = require("typeorm");
7
+ const attachment_base_1 = require("@things-factory/attachment-base");
8
+ const field_document_1 = require("./field-document");
9
+ const field_document_type_1 = require("./field-document-type");
10
+ const field_document_summary_service_1 = require("./field-document-summary-service");
11
+ let FieldDocumentMutation = class FieldDocumentMutation {
12
+ async createFieldDocument(patch, context) {
13
+ const { domain, user, tx } = context.state;
14
+ const result = await tx.getRepository(field_document_1.FieldDocument).save({
15
+ projectId: patch.projectId,
16
+ code: patch.code,
17
+ name: patch.name,
18
+ sourceType: patch.sourceType,
19
+ sourceRefId: patch.sourceRefId,
20
+ aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.REQUEST,
21
+ domain,
22
+ creator: user,
23
+ updater: user
24
+ });
25
+ if (patch.file) {
26
+ await (0, attachment_base_1.createAttachment)(null, {
27
+ attachment: {
28
+ file: patch.file,
29
+ refType: field_document_1.FieldDocument.name,
30
+ refBy: result.id
31
+ }
32
+ }, context);
33
+ }
34
+ (0, field_document_summary_service_1.queueDocumentSummary)(result.id);
35
+ return result;
36
+ }
37
+ async createFieldDocuments(patches, context) {
38
+ const { domain, user, tx } = context.state;
39
+ const repo = tx.getRepository(field_document_1.FieldDocument);
40
+ const results = [];
41
+ for (const patch of patches) {
42
+ const result = await repo.save({
43
+ projectId: patch.projectId,
44
+ code: patch.code,
45
+ name: patch.name,
46
+ sourceType: patch.sourceType,
47
+ sourceRefId: patch.sourceRefId,
48
+ aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.REQUEST,
49
+ domain,
50
+ creator: user,
51
+ updater: user
52
+ });
53
+ if (patch.file) {
54
+ await (0, attachment_base_1.createAttachment)(null, {
55
+ attachment: {
56
+ file: patch.file,
57
+ refType: field_document_1.FieldDocument.name,
58
+ refBy: result.id
59
+ }
60
+ }, context);
61
+ }
62
+ (0, field_document_summary_service_1.queueDocumentSummary)(result.id);
63
+ results.push(result);
64
+ }
65
+ return results;
66
+ }
67
+ async moveFieldDocuments(ids, targetCode, context) {
68
+ const { user, tx } = context.state;
69
+ const repo = tx.getRepository(field_document_1.FieldDocument);
70
+ await repo.update({ id: (0, typeorm_1.In)(ids) }, { code: targetCode, updater: user });
71
+ return true;
72
+ }
73
+ async toggleFieldDocumentFavorite(id, context) {
74
+ const { user, tx } = context.state;
75
+ const repo = tx.getRepository(field_document_1.FieldDocument);
76
+ const doc = await repo.findOneBy({ id });
77
+ return await repo.save(Object.assign(Object.assign({}, doc), { isFavorite: !doc.isFavorite, updater: user }));
78
+ }
79
+ async deleteFieldDocuments(ids, context) {
80
+ const { tx } = context.state;
81
+ await tx.getRepository(field_document_1.FieldDocument).softDelete({ id: (0, typeorm_1.In)(ids) });
82
+ await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
83
+ return true;
84
+ }
85
+ };
86
+ exports.FieldDocumentMutation = FieldDocumentMutation;
87
+ tslib_1.__decorate([
88
+ (0, type_graphql_1.Directive)('@transaction'),
89
+ (0, type_graphql_1.Mutation)(returns => field_document_1.FieldDocument, { description: '현장 문서 생성' }),
90
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patch')),
91
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
92
+ tslib_1.__metadata("design:type", Function),
93
+ tslib_1.__metadata("design:paramtypes", [field_document_type_1.NewFieldDocument, Object]),
94
+ tslib_1.__metadata("design:returntype", Promise)
95
+ ], FieldDocumentMutation.prototype, "createFieldDocument", null);
96
+ tslib_1.__decorate([
97
+ (0, type_graphql_1.Directive)('@transaction'),
98
+ (0, type_graphql_1.Mutation)(returns => [field_document_1.FieldDocument], { description: '현장 문서 다건 생성' }),
99
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('patches', type => [field_document_type_1.NewFieldDocument])),
100
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
101
+ tslib_1.__metadata("design:type", Function),
102
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
103
+ tslib_1.__metadata("design:returntype", Promise)
104
+ ], FieldDocumentMutation.prototype, "createFieldDocuments", null);
105
+ tslib_1.__decorate([
106
+ (0, type_graphql_1.Directive)('@transaction'),
107
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: '문서 폴더 이동' }),
108
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
109
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('targetCode')),
110
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
111
+ tslib_1.__metadata("design:type", Function),
112
+ tslib_1.__metadata("design:paramtypes", [Array, String, Object]),
113
+ tslib_1.__metadata("design:returntype", Promise)
114
+ ], FieldDocumentMutation.prototype, "moveFieldDocuments", null);
115
+ tslib_1.__decorate([
116
+ (0, type_graphql_1.Directive)('@transaction'),
117
+ (0, type_graphql_1.Mutation)(returns => field_document_1.FieldDocument, { description: '즐겨찾기 토글' }),
118
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
119
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
120
+ tslib_1.__metadata("design:type", Function),
121
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
122
+ tslib_1.__metadata("design:returntype", Promise)
123
+ ], FieldDocumentMutation.prototype, "toggleFieldDocumentFavorite", null);
124
+ tslib_1.__decorate([
125
+ (0, type_graphql_1.Directive)('@transaction'),
126
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: '현장 문서 삭제' }),
127
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
128
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
129
+ tslib_1.__metadata("design:type", Function),
130
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
131
+ tslib_1.__metadata("design:returntype", Promise)
132
+ ], FieldDocumentMutation.prototype, "deleteFieldDocuments", null);
133
+ exports.FieldDocumentMutation = FieldDocumentMutation = tslib_1.__decorate([
134
+ (0, type_graphql_1.Resolver)(field_document_1.FieldDocument)
135
+ ], FieldDocumentMutation);
136
+ //# sourceMappingURL=field-document-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-document-mutation.js","sourceRoot":"","sources":["../../../server/service/field-document/field-document-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,qDAA4E;AAC5E,+DAAwD;AACxD,qFAAuE;AAGhE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAG1B,AAAN,KAAK,CAAC,mBAAmB,CACT,KAAuB,EAC9B,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAC,IAAI,CAAC;YACxD,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,eAAe,EAAE,2CAA0B,CAAC,OAAO;YACnD,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,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,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wEAWP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;IAEvD,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iEAQP;gCAhIU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,qBAAqB,CAiIjC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { FieldDocument, FieldDocumentSummaryStatus } from './field-document'\nimport { NewFieldDocument } from './field-document-type'\nimport { queueDocumentSummary } from './field-document-summary-service'\n\n@Resolver(FieldDocument)\nexport class FieldDocumentMutation {\n @Directive('@transaction')\n @Mutation(returns => FieldDocument, { description: '현장 문서 생성' })\n async createFieldDocument(\n @Arg('patch') patch: NewFieldDocument,\n @Ctx() context: ResolverContext\n ): Promise<FieldDocument> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(FieldDocument).save({\n projectId: patch.projectId,\n code: patch.code,\n name: patch.name,\n sourceType: patch.sourceType,\n sourceRefId: patch.sourceRefId,\n aiSummaryStatus: FieldDocumentSummaryStatus.REQUEST,\n domain,\n creator: user,\n updater: user\n })\n\n if (patch.file) {\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.file,\n refType: FieldDocument.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n queueDocumentSummary(result.id)\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [FieldDocument], { description: '현장 문서 다건 생성' })\n async createFieldDocuments(\n @Arg('patches', type => [NewFieldDocument]) patches: NewFieldDocument[],\n @Ctx() context: ResolverContext\n ): Promise<FieldDocument[]> {\n const { domain, user, tx } = context.state\n const repo = tx.getRepository(FieldDocument)\n const results: FieldDocument[] = []\n\n for (const patch of patches) {\n const result = await repo.save({\n projectId: patch.projectId,\n code: patch.code,\n name: patch.name,\n sourceType: patch.sourceType,\n sourceRefId: patch.sourceRefId,\n aiSummaryStatus: FieldDocumentSummaryStatus.REQUEST,\n domain,\n creator: user,\n updater: user\n })\n\n if (patch.file) {\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.file,\n refType: FieldDocument.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n queueDocumentSummary(result.id)\n results.push(result)\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: '문서 폴더 이동' })\n async moveFieldDocuments(\n @Arg('ids', type => [String]) ids: string[],\n @Arg('targetCode') targetCode: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const repo = tx.getRepository(FieldDocument)\n\n await repo.update({ id: In(ids) }, { code: targetCode, updater: user })\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => FieldDocument, { description: '즐겨찾기 토글' })\n async toggleFieldDocumentFavorite(\n @Arg('id') id: string,\n @Ctx() context: ResolverContext\n ): Promise<FieldDocument> {\n const { user, tx } = context.state\n const repo = tx.getRepository(FieldDocument)\n const doc = await repo.findOneBy({ id })\n\n return await repo.save({\n ...doc,\n isFavorite: !doc.isFavorite,\n updater: user\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: '현장 문서 삭제' })\n async deleteFieldDocuments(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx } = context.state\n\n await tx.getRepository(FieldDocument).softDelete({ id: In(ids) })\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ import { Domain } from '@things-factory/shell';
2
+ import { User } from '@things-factory/auth-base';
3
+ import { FieldDocument } from './field-document';
4
+ import { FieldDocumentList, FieldDocumentCodeCount } from './field-document-type';
5
+ export declare class FieldDocumentQuery {
6
+ fieldDocumentsByCode(projectId: string, code: string, context: ResolverContext): Promise<FieldDocumentList>;
7
+ fieldDocumentCountsByProject(projectId: string, context: ResolverContext): Promise<FieldDocumentCodeCount[]>;
8
+ fieldDocument(id: string, context: ResolverContext): Promise<FieldDocument>;
9
+ domain(fd: FieldDocument): Promise<Domain>;
10
+ creator(fd: FieldDocument): Promise<User>;
11
+ updater(fd: FieldDocument): Promise<User>;
12
+ fullpath(fd: FieldDocument): Promise<string | null>;
13
+ fileSize(fd: FieldDocument): Promise<string | null>;
14
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldDocumentQuery = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const shell_1 = require("@things-factory/shell");
7
+ const auth_base_1 = require("@things-factory/auth-base");
8
+ const attachment_base_1 = require("@things-factory/attachment-base");
9
+ const field_document_1 = require("./field-document");
10
+ const field_document_type_1 = require("./field-document-type");
11
+ let FieldDocumentQuery = class FieldDocumentQuery {
12
+ async fieldDocumentsByCode(projectId, code, context) {
13
+ const repository = (0, shell_1.getRepository)(field_document_1.FieldDocument);
14
+ const [items, total] = await repository.findAndCount({
15
+ where: { projectId, code },
16
+ order: { isFavorite: 'DESC', createdAt: 'DESC' }
17
+ });
18
+ return { items, total };
19
+ }
20
+ async fieldDocumentCountsByProject(projectId, context) {
21
+ const result = await (0, shell_1.getRepository)(field_document_1.FieldDocument)
22
+ .createQueryBuilder('fd')
23
+ .select('fd.code', 'code')
24
+ .addSelect('COUNT(*)', 'count')
25
+ .where('fd.project_id = :projectId', { projectId })
26
+ .andWhere('fd.deleted_at IS NULL')
27
+ .groupBy('fd.code')
28
+ .getRawMany();
29
+ return result.map(r => ({ code: r.code, count: Number(r.count) }));
30
+ }
31
+ async fieldDocument(id, context) {
32
+ return await (0, shell_1.getRepository)(field_document_1.FieldDocument).findOneBy({ id });
33
+ }
34
+ async domain(fd) {
35
+ return await (0, shell_1.getRepository)(shell_1.Domain).findOneBy({ id: fd.domainId });
36
+ }
37
+ async creator(fd) {
38
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: fd.creatorId });
39
+ }
40
+ async updater(fd) {
41
+ return await (0, shell_1.getRepository)(auth_base_1.User).findOneBy({ id: fd.updaterId });
42
+ }
43
+ async fullpath(fd) {
44
+ const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
45
+ where: { refBy: fd.id, refType: field_document_1.FieldDocument.name }
46
+ });
47
+ return (attachment === null || attachment === void 0 ? void 0 : attachment.fullpath) || null;
48
+ }
49
+ async fileSize(fd) {
50
+ const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
51
+ where: { refBy: fd.id, refType: field_document_1.FieldDocument.name }
52
+ });
53
+ return (attachment === null || attachment === void 0 ? void 0 : attachment.size) || null;
54
+ }
55
+ };
56
+ exports.FieldDocumentQuery = FieldDocumentQuery;
57
+ tslib_1.__decorate([
58
+ (0, type_graphql_1.Query)(returns => field_document_type_1.FieldDocumentList, { description: '소분류 코드별 문서 목록 조회' }),
59
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
60
+ tslib_1.__param(1, (0, type_graphql_1.Arg)('code')),
61
+ tslib_1.__param(2, (0, type_graphql_1.Ctx)()),
62
+ tslib_1.__metadata("design:type", Function),
63
+ tslib_1.__metadata("design:paramtypes", [String, String, Object]),
64
+ tslib_1.__metadata("design:returntype", Promise)
65
+ ], FieldDocumentQuery.prototype, "fieldDocumentsByCode", null);
66
+ tslib_1.__decorate([
67
+ (0, type_graphql_1.Query)(returns => [field_document_type_1.FieldDocumentCodeCount], { description: '프로젝트별 분류 코드당 문서 수' }),
68
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
69
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
70
+ tslib_1.__metadata("design:type", Function),
71
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
72
+ tslib_1.__metadata("design:returntype", Promise)
73
+ ], FieldDocumentQuery.prototype, "fieldDocumentCountsByProject", null);
74
+ tslib_1.__decorate([
75
+ (0, type_graphql_1.Query)(returns => field_document_1.FieldDocument, { nullable: true, description: '단건 문서 상세 조회' }),
76
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
77
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
78
+ tslib_1.__metadata("design:type", Function),
79
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
80
+ tslib_1.__metadata("design:returntype", Promise)
81
+ ], FieldDocumentQuery.prototype, "fieldDocument", null);
82
+ tslib_1.__decorate([
83
+ (0, type_graphql_1.FieldResolver)(type => shell_1.Domain),
84
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
85
+ tslib_1.__metadata("design:type", Function),
86
+ tslib_1.__metadata("design:paramtypes", [field_document_1.FieldDocument]),
87
+ tslib_1.__metadata("design:returntype", Promise)
88
+ ], FieldDocumentQuery.prototype, "domain", null);
89
+ tslib_1.__decorate([
90
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
91
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
92
+ tslib_1.__metadata("design:type", Function),
93
+ tslib_1.__metadata("design:paramtypes", [field_document_1.FieldDocument]),
94
+ tslib_1.__metadata("design:returntype", Promise)
95
+ ], FieldDocumentQuery.prototype, "creator", null);
96
+ tslib_1.__decorate([
97
+ (0, type_graphql_1.FieldResolver)(type => auth_base_1.User),
98
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
99
+ tslib_1.__metadata("design:type", Function),
100
+ tslib_1.__metadata("design:paramtypes", [field_document_1.FieldDocument]),
101
+ tslib_1.__metadata("design:returntype", Promise)
102
+ ], FieldDocumentQuery.prototype, "updater", null);
103
+ tslib_1.__decorate([
104
+ (0, type_graphql_1.FieldResolver)(type => String, { nullable: true }),
105
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
106
+ tslib_1.__metadata("design:type", Function),
107
+ tslib_1.__metadata("design:paramtypes", [field_document_1.FieldDocument]),
108
+ tslib_1.__metadata("design:returntype", Promise)
109
+ ], FieldDocumentQuery.prototype, "fullpath", null);
110
+ tslib_1.__decorate([
111
+ (0, type_graphql_1.FieldResolver)(type => String, { nullable: true, description: '파일 크기' }),
112
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
113
+ tslib_1.__metadata("design:type", Function),
114
+ tslib_1.__metadata("design:paramtypes", [field_document_1.FieldDocument]),
115
+ tslib_1.__metadata("design:returntype", Promise)
116
+ ], FieldDocumentQuery.prototype, "fileSize", null);
117
+ exports.FieldDocumentQuery = FieldDocumentQuery = tslib_1.__decorate([
118
+ (0, type_graphql_1.Resolver)(field_document_1.FieldDocument)
119
+ ], FieldDocumentQuery);
120
+ //# sourceMappingURL=field-document-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-document-query.js","sourceRoot":"","sources":["../../../server/service/field-document/field-document-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA6E;AAC7E,iDAA6D;AAC7D,yDAAgD;AAChD,qEAA4D;AAC5D,qDAAgD;AAChD,+DAAiF;AAG1E,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAEvB,AAAN,KAAK,CAAC,oBAAoB,CACN,SAAiB,EACtB,IAAY,EAClB,OAAwB;QAE/B,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAA;QAE/C,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,UAAU,CAAC,YAAY,CAAC;YACnD,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;YAC1B,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE;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CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;sEAYP;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,8BAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,aAAa,EAAE,CAAC;IAE7E,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IACT,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;uDAGP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAK,8BAAa;;gDAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAK,8BAAa;;iDAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAK,8BAAa;;iDAEtC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAClC,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAK,8BAAa;;kDAKvC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;IACxD,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAK,8BAAa;;kDAKvC;6BAvEU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,8BAAa,CAAC;GACX,kBAAkB,CAwE9B","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Ctx } from 'type-graphql'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { FieldDocument } from './field-document'\nimport { FieldDocumentList, FieldDocumentCodeCount } from './field-document-type'\n\n@Resolver(FieldDocument)\nexport class FieldDocumentQuery {\n @Query(returns => FieldDocumentList, { description: '소분류 코드별 문서 목록 조회' })\n async fieldDocumentsByCode(\n @Arg('projectId') projectId: string,\n @Arg('code') code: string,\n @Ctx() context: ResolverContext\n ): Promise<FieldDocumentList> {\n const repository = getRepository(FieldDocument)\n\n const [items, total] = await repository.findAndCount({\n where: { projectId, code },\n order: { isFavorite: 'DESC', createdAt: 'DESC' }\n })\n\n return { items, total }\n }\n\n @Query(returns => [FieldDocumentCodeCount], { description: '프로젝트별 분류 코드당 문서 수' })\n async fieldDocumentCountsByProject(\n @Arg('projectId') projectId: string,\n @Ctx() context: ResolverContext\n ): Promise<FieldDocumentCodeCount[]> {\n const result = await getRepository(FieldDocument)\n .createQueryBuilder('fd')\n .select('fd.code', 'code')\n .addSelect('COUNT(*)', 'count')\n .where('fd.project_id = :projectId', { projectId })\n .andWhere('fd.deleted_at IS NULL')\n .groupBy('fd.code')\n .getRawMany()\n\n return result.map(r => ({ code: r.code, count: Number(r.count) }))\n }\n\n @Query(returns => FieldDocument, { nullable: true, description: '단건 문서 상세 조회' })\n async fieldDocument(\n @Arg('id') id: string,\n @Ctx() context: ResolverContext\n ): Promise<FieldDocument> {\n return await getRepository(FieldDocument).findOneBy({ id })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() fd: FieldDocument): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: fd.domainId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() fd: FieldDocument): Promise<User> {\n return await getRepository(User).findOneBy({ id: fd.creatorId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() fd: FieldDocument): Promise<User> {\n return await getRepository(User).findOneBy({ id: fd.updaterId })\n }\n\n @FieldResolver(type => String, { nullable: true })\n async fullpath(@Root() fd: FieldDocument): Promise<string | null> {\n const attachment = await getRepository(Attachment).findOne({\n where: { refBy: fd.id, refType: FieldDocument.name }\n })\n return attachment?.fullpath || null\n }\n\n @FieldResolver(type => String, { nullable: true, description: '파일 크기' })\n async fileSize(@Root() fd: FieldDocument): Promise<string | null> {\n const attachment = await getRepository(Attachment).findOne({\n where: { refBy: fd.id, refType: FieldDocument.name }\n })\n return attachment?.size || null\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ export declare function generateDocumentSummary(fieldDocumentId: string): Promise<void>;
2
+ export declare function queueDocumentSummary(fieldDocumentId: string): void;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateDocumentSummary = generateDocumentSummary;
4
+ exports.queueDocumentSummary = queueDocumentSummary;
5
+ const shell_1 = require("@things-factory/shell");
6
+ const attachment_base_1 = require("@things-factory/attachment-base");
7
+ const field_document_1 = require("./field-document");
8
+ const SUMMARY_API_BASE_URL = 'https://hatiolab-korea-uni.ettisoft.com';
9
+ const API_USERNAME = 'admin';
10
+ const API_PASSWORD = 'admin1234';
11
+ async function generateDocumentSummary(fieldDocumentId) {
12
+ var _a, _b, _c;
13
+ const repository = (0, shell_1.getRepository)(field_document_1.FieldDocument);
14
+ try {
15
+ const doc = await repository.findOneBy({ id: fieldDocumentId });
16
+ if (!doc)
17
+ return;
18
+ const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
19
+ where: { refBy: doc.id, refType: field_document_1.FieldDocument.name }
20
+ });
21
+ const url = `${SUMMARY_API_BASE_URL}/api/run/document-summary`;
22
+ const headers = {
23
+ Authorization: `Basic ${Buffer.from(`${API_USERNAME}:${API_PASSWORD}`).toString('base64')}`
24
+ };
25
+ const form = new FormData();
26
+ form.append('input', JSON.stringify({ documentName: doc.name, documentPath: (attachment === null || attachment === void 0 ? void 0 : attachment.path) || '' }));
27
+ const response = await fetch(url, {
28
+ method: 'POST',
29
+ headers,
30
+ body: form
31
+ });
32
+ const data = ((_a = (await (response === null || response === void 0 ? void 0 : response.json()))) === null || _a === void 0 ? void 0 : _a.result) || {};
33
+ if ((data === null || data === void 0 ? void 0 : data.status) === 'success') {
34
+ const summary = ((_b = data.result) === null || _b === void 0 ? void 0 : _b['요약']) || ((_c = data.result) === null || _c === void 0 ? void 0 : _c['summary']) || '';
35
+ await repository.update({ id: fieldDocumentId }, { aiSummary: summary, aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.SUCCESS });
36
+ }
37
+ else {
38
+ await repository.update({ id: fieldDocumentId }, { aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.FAIL });
39
+ }
40
+ }
41
+ catch (error) {
42
+ console.error('Document summary generation failed:', error);
43
+ await repository.update({ id: fieldDocumentId }, { aiSummaryStatus: field_document_1.FieldDocumentSummaryStatus.FAIL });
44
+ }
45
+ }
46
+ function queueDocumentSummary(fieldDocumentId) {
47
+ if (!fieldDocumentId)
48
+ return;
49
+ setTimeout(() => {
50
+ generateDocumentSummary(fieldDocumentId).catch(err => {
51
+ console.error('Background document summary update failed:', err);
52
+ });
53
+ }, 0);
54
+ }
55
+ //# sourceMappingURL=field-document-summary-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-document-summary-service.js","sourceRoot":"","sources":["../../../server/service/field-document/field-document-summary-service.ts"],"names":[],"mappings":";;AAQA,0DAwCC;AAED,oDAQC;AA1DD,iDAAqD;AACrD,qEAA4D;AAC5D,qDAA4E;AAE5E,MAAM,oBAAoB,GAAW,yCAAyC,CAAA;AAC9E,MAAM,YAAY,GAAW,OAAO,CAAA;AACpC,MAAM,YAAY,GAAW,WAAW,CAAA;AAEjC,KAAK,UAAU,uBAAuB,CAAC,eAAuB;;IACnE,MAAM,UAAU,GAAG,IAAA,qBAAa,EAAC,8BAAa,CAAC,CAAA;IAE/C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,CAAC,CAAA;QAC/D,IAAI,C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,MAAM,CACrB,EAAE,EAAE,EAAE,eAAe,EAAE,EACvB,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAAE,2CAA0B,CAAC,OAAO,EAAE,CAC5E,CAAA;QACH,CAAC;aAAM,CAAC;YACN,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE,2CAA0B,CAAC,IAAI,EAAE,CAAC,CAAA;QACxG,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAAA;QAC3D,MAAM,UAAU,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,eAAe,EAAE,2CAA0B,CAAC,IAAI,EAAE,CAAC,CAAA;IACxG,CAAC;AACH,CAAC;AAED,SAAgB,oBAAoB,CAAC,eAAuB;IAC1D,IAAI,CAAC,eAAe;QAAE,OAAM;IAE5B,UAAU,CAAC,GAAG,EAAE;QACd,uBAAuB,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YACnD,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,GAAG,CAAC,CAAA;QAClE,CAAC,CAAC,CAAA;IACJ,CAAC,EAAE,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["import { getRepository } from '@things-factory/shell'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { FieldDocument, FieldDocumentSummaryStatus } from './field-document'\n\nconst SUMMARY_API_BASE_URL: string = 'https://hatiolab-korea-uni.ettisoft.com'\nconst API_USERNAME: string = 'admin'\nconst API_PASSWORD: string = 'admin1234'\n\nexport async function generateDocumentSummary(fieldDocumentId: string): Promise<void> {\n const repository = getRepository(FieldDocument)\n\n try {\n const doc = await repository.findOneBy({ id: fieldDocumentId })\n if (!doc) return\n\n const attachment = await getRepository(Attachment).findOne({\n where: { refBy: doc.id, refType: FieldDocument.name }\n })\n\n const url = `${SUMMARY_API_BASE_URL}/api/run/document-summary`\n const headers: any = {\n Authorization: `Basic ${Buffer.from(`${API_USERNAME}:${API_PASSWORD}`).toString('base64')}`\n }\n\n const form = new FormData()\n form.append('input', JSON.stringify({ documentName: doc.name, documentPath: attachment?.path || '' }))\n\n const response = await fetch(url, {\n method: 'POST',\n headers,\n body: form\n })\n\n const data = (await response?.json())?.result || {}\n\n if (data?.status === 'success') {\n const summary = data.result?.['요약'] || data.result?.['summary'] || ''\n await repository.update(\n { id: fieldDocumentId },\n { aiSummary: summary, aiSummaryStatus: FieldDocumentSummaryStatus.SUCCESS }\n )\n } else {\n await repository.update({ id: fieldDocumentId }, { aiSummaryStatus: FieldDocumentSummaryStatus.FAIL })\n }\n } catch (error) {\n console.error('Document summary generation failed:', error)\n await repository.update({ id: fieldDocumentId }, { aiSummaryStatus: FieldDocumentSummaryStatus.FAIL })\n }\n}\n\nexport function queueDocumentSummary(fieldDocumentId: string): void {\n if (!fieldDocumentId) return\n\n setTimeout(() => {\n generateDocumentSummary(fieldDocumentId).catch(err => {\n console.error('Background document summary update failed:', err)\n })\n }, 0)\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { FileUpload } from 'graphql-upload/GraphQLUpload.js';
2
+ import { FieldDocument } from './field-document';
3
+ export declare class NewFieldDocument {
4
+ projectId: string;
5
+ code: string;
6
+ name: string;
7
+ sourceType?: string;
8
+ sourceRefId?: string;
9
+ file?: FileUpload;
10
+ }
11
+ export declare class FieldDocumentPatch {
12
+ id: string;
13
+ code?: string;
14
+ name?: string;
15
+ }
16
+ export declare class FieldDocumentList {
17
+ items: FieldDocument[];
18
+ total: number;
19
+ }
20
+ export declare class FieldDocumentCodeCount {
21
+ code: string;
22
+ count: number;
23
+ }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FieldDocumentCodeCount = exports.FieldDocumentList = exports.FieldDocumentPatch = exports.NewFieldDocument = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const type_graphql_1 = require("type-graphql");
6
+ const GraphQLUpload_js_1 = tslib_1.__importDefault(require("graphql-upload/GraphQLUpload.js"));
7
+ const field_document_1 = require("./field-document");
8
+ let NewFieldDocument = class NewFieldDocument {
9
+ };
10
+ exports.NewFieldDocument = NewFieldDocument;
11
+ tslib_1.__decorate([
12
+ (0, type_graphql_1.Field)({ nullable: false }),
13
+ tslib_1.__metadata("design:type", String)
14
+ ], NewFieldDocument.prototype, "projectId", void 0);
15
+ tslib_1.__decorate([
16
+ (0, type_graphql_1.Field)({ nullable: false }),
17
+ tslib_1.__metadata("design:type", String)
18
+ ], NewFieldDocument.prototype, "code", void 0);
19
+ tslib_1.__decorate([
20
+ (0, type_graphql_1.Field)({ nullable: false }),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], NewFieldDocument.prototype, "name", void 0);
23
+ tslib_1.__decorate([
24
+ (0, type_graphql_1.Field)({ nullable: true }),
25
+ tslib_1.__metadata("design:type", String)
26
+ ], NewFieldDocument.prototype, "sourceType", void 0);
27
+ tslib_1.__decorate([
28
+ (0, type_graphql_1.Field)({ nullable: true }),
29
+ tslib_1.__metadata("design:type", String)
30
+ ], NewFieldDocument.prototype, "sourceRefId", void 0);
31
+ tslib_1.__decorate([
32
+ (0, type_graphql_1.Field)(() => GraphQLUpload_js_1.default, { nullable: true }),
33
+ tslib_1.__metadata("design:type", Object)
34
+ ], NewFieldDocument.prototype, "file", void 0);
35
+ exports.NewFieldDocument = NewFieldDocument = tslib_1.__decorate([
36
+ (0, type_graphql_1.InputType)()
37
+ ], NewFieldDocument);
38
+ let FieldDocumentPatch = class FieldDocumentPatch {
39
+ };
40
+ exports.FieldDocumentPatch = FieldDocumentPatch;
41
+ tslib_1.__decorate([
42
+ (0, type_graphql_1.Field)(type => type_graphql_1.ID, { nullable: false }),
43
+ tslib_1.__metadata("design:type", String)
44
+ ], FieldDocumentPatch.prototype, "id", void 0);
45
+ tslib_1.__decorate([
46
+ (0, type_graphql_1.Field)({ nullable: true }),
47
+ tslib_1.__metadata("design:type", String)
48
+ ], FieldDocumentPatch.prototype, "code", void 0);
49
+ tslib_1.__decorate([
50
+ (0, type_graphql_1.Field)({ nullable: true }),
51
+ tslib_1.__metadata("design:type", String)
52
+ ], FieldDocumentPatch.prototype, "name", void 0);
53
+ exports.FieldDocumentPatch = FieldDocumentPatch = tslib_1.__decorate([
54
+ (0, type_graphql_1.InputType)()
55
+ ], FieldDocumentPatch);
56
+ let FieldDocumentList = class FieldDocumentList {
57
+ };
58
+ exports.FieldDocumentList = FieldDocumentList;
59
+ tslib_1.__decorate([
60
+ (0, type_graphql_1.Field)(type => [field_document_1.FieldDocument]),
61
+ tslib_1.__metadata("design:type", Array)
62
+ ], FieldDocumentList.prototype, "items", void 0);
63
+ tslib_1.__decorate([
64
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
65
+ tslib_1.__metadata("design:type", Number)
66
+ ], FieldDocumentList.prototype, "total", void 0);
67
+ exports.FieldDocumentList = FieldDocumentList = tslib_1.__decorate([
68
+ (0, type_graphql_1.ObjectType)()
69
+ ], FieldDocumentList);
70
+ let FieldDocumentCodeCount = class FieldDocumentCodeCount {
71
+ };
72
+ exports.FieldDocumentCodeCount = FieldDocumentCodeCount;
73
+ tslib_1.__decorate([
74
+ (0, type_graphql_1.Field)(),
75
+ tslib_1.__metadata("design:type", String)
76
+ ], FieldDocumentCodeCount.prototype, "code", void 0);
77
+ tslib_1.__decorate([
78
+ (0, type_graphql_1.Field)(type => type_graphql_1.Int),
79
+ tslib_1.__metadata("design:type", Number)
80
+ ], FieldDocumentCodeCount.prototype, "count", void 0);
81
+ exports.FieldDocumentCodeCount = FieldDocumentCodeCount = tslib_1.__decorate([
82
+ (0, type_graphql_1.ObjectType)()
83
+ ], FieldDocumentCodeCount);
84
+ //# sourceMappingURL=field-document-type.js.map