@heripo/model 0.1.43 → 0.1.45

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 (3) hide show
  1. package/README.ko.md +41 -71
  2. package/README.md +41 -70
  3. package/package.json +5 -5
package/README.ko.md CHANGED
@@ -35,6 +35,8 @@ ProcessedDocument (LLM 최적화 중간 모델)
35
35
 
36
36
  `@heripo/model`은 현재 PDF 파싱 및 문서 구조 추출 단계에서 사용되는 데이터 모델을 정의합니다. 향후 고고학 데이터 분석, 표준화, 시맨틱 모델링 등 다양한 분야별 모델이 추가될 예정입니다.
37
37
 
38
+ Node.js 24 이상을 대상으로 하며 ESM과 CommonJS를 모두 제공합니다. 문서 인터페이스는 `import type`으로 가져오고, 언어 유틸리티는 일반 import로 사용하세요. JSON 파싱 결과를 타입 단언하는 것만으로 런타임 검증이 되지는 않습니다.
39
+
38
40
  ## 설치
39
41
 
40
42
  ```bash
@@ -66,6 +68,8 @@ import type { DoclingDocument } from '@heripo/model';
66
68
  - `texts`, `pictures`, `tables`: 추출된 content node
67
69
  - `pages`: 페이지 metadata와 렌더링된 페이지 이미지 참조
68
70
 
71
+ `DoclingReference.$ref`와 각 노드의 `self_ref`로 원천 노드를 연결합니다. `DoclingProv.page_no`와 처리 모델의 `pdfPageNo`는 1부터 시작하지만 렌더링 파일은 `pages/page_0.png`부터 시작합니다. `Chapter.pageNo`와 `PageRange`는 인쇄된 문서의 논리 페이지 번호이므로 PDF 페이지 번호와 구분하세요. `DoclingBBox.coord_origin`을 확인한 뒤 좌표를 해석해야 합니다.
72
+
69
73
  ### ProcessedDocument
70
74
 
71
75
  LLM 분석에 최적화된 중간 데이터 모델입니다.
@@ -175,9 +179,9 @@ interface ProcessedTable {
175
179
 
176
180
  `grid`는 화면에 보이는 셀만 담은 compact list입니다. 병합 셀은
177
181
  `rowSpan`, `colSpan`으로 표현하고, span으로 덮인 shadow cell은 포함하지
178
- 않습니다. 테이블 셀에는 의도적으로 cell-level `sourceRef`가 없습니다. 셀을
179
- 원천 테이블로 추적할 때는 `table.sourceRef`와 `grid[row][col]` 위치를 함께
180
- 사용합니다.
182
+ 않습니다. 테이블 셀에는 의도적으로 cell-level `sourceRef`가 없습니다.
183
+ `table.sourceRef`로 원천 표를 찾은 뒤 셀의 span과 원본 좌표를 대조하세요.
184
+ 압축 배열의 인덱스는 원천 표의 논리적 열 번호와 다를 수 있습니다.
181
185
 
182
186
  ### ProcessedTableCell
183
187
 
@@ -202,7 +206,7 @@ interface ProcessedTableCell {
202
206
  import type { Caption } from '@heripo/model';
203
207
 
204
208
  interface Caption {
205
- num?: string; // 캡션 번호 (예: "그림 1"의 "1")
209
+ num?: string; // Caption prefix and number (e.g., "Figure 1")
206
210
  fullText: string; // 전체 캡션 텍스트
207
211
  }
208
212
  ```
@@ -250,7 +254,7 @@ interface DocumentProcessResult {
250
254
 
251
255
  ### OcrStrategy
252
256
 
253
- OCR 전략 선택 결과입니다.
257
+ OCR 전략 데이터를 표현하는 기존 타입입니다. 현재 PDF 파서는 고정 ocrmac과 후속 보정을 사용하며 이 전략을 선택하거나 반환하지 않습니다.
254
258
 
255
259
  ```typescript
256
260
  import type { OcrStrategy } from '@heripo/model';
@@ -274,6 +278,7 @@ import type {
274
278
  ComponentUsageReport,
275
279
  ModelUsageDetail,
276
280
  PhaseUsageReport,
281
+ TokenUsageMetadata,
277
282
  TokenUsageReport,
278
283
  TokenUsageSummary,
279
284
  } from '@heripo/model';
@@ -290,6 +295,7 @@ interface ComponentUsageReport {
290
295
  }
291
296
 
292
297
  interface PhaseUsageReport {
298
+ metadata?: TokenUsageMetadata[]; // Per-call context
293
299
  phase: string; // 단계 이름
294
300
  primary?: ModelUsageDetail; // 기본 모델 사용량
295
301
  fallback?: ModelUsageDetail; // 폴백 모델 사용량
@@ -312,83 +318,47 @@ interface TokenUsageSummary {
312
318
 
313
319
  ### Review Assistance 타입
314
320
 
315
- `@heripo/pdf-parser`에서 `reviewAssistance`를 활성화했을 때 생성되는 선택적
316
- page-level review assistance 결과 타입입니다.
321
+ `correction.reviewAssistanceEnabled: true`일 때(파서 기본값) 생성하는 별도 감사 리포트입니다. `ProcessedDocument` 안에 포함되지 않습니다. [전체 타입 정의](./src/types/review-assistance.ts)는 명령, 근거, 이슈, 실행 추적 및 진행 이벤트를 제공합니다.
317
322
 
318
- ```typescript
319
- import type {
320
- ReviewAssistanceDecision,
321
- ReviewAssistanceIssue,
322
- ReviewAssistanceProgressEvent,
323
- ReviewAssistanceReport,
324
- } from '@heripo/model';
325
-
326
- interface ReviewAssistanceReport {
327
- schemaName: 'HeripoReviewAssistanceReport';
328
- version: '1.0';
329
- reportId: string;
330
- source: {
331
- doclingResult: 'result.json';
332
- ocrOriginSnapshot?: 'result_ocr_origin.json';
333
- originSnapshot?: 'result_review_origin.json';
334
- };
335
- summary: {
336
- pageCount: number;
337
- pagesSucceeded: number;
338
- pagesFailed: number;
339
- autoAppliedCount: number;
340
- proposalCount: number;
341
- skippedCount: number;
342
- issueCount: number;
343
- };
344
- pages: Array<{
345
- pageNo: number;
346
- status: 'succeeded' | 'failed';
347
- decisions: ReviewAssistanceDecision[];
348
- issues: ReviewAssistanceIssue[];
349
- }>;
350
- }
323
+ 리포트의 필수 필드는 `schemaName`, `version`, `reportId`, `source`, `options`, `summary`, `pages`, `callTraces`입니다. 검증에서 거부된 결정은 `command`가 없고 `invalidOp`만 있을 수 있으므로 먼저 확인하세요.
351
324
 
352
- interface ReviewAssistanceProgressEvent {
353
- substage:
354
- | 'review-assistance:prepare'
355
- | 'review-assistance:page'
356
- | 'review-assistance:patch'
357
- | 'review-assistance:write-report';
358
- status: 'started' | 'progress' | 'completed' | 'failed';
359
- reportId: string;
360
- pageNo?: number;
361
- pageCount?: number;
325
+ ```typescript
326
+ import type { ReviewAssistanceReport } from '@heripo/model';
327
+
328
+ function summarizeReview(report: ReviewAssistanceReport) {
329
+ for (const page of report.pages) {
330
+ for (const decision of page.decisions) {
331
+ console.log(
332
+ page.pageNo,
333
+ decision.command?.op ?? decision.invalidOp,
334
+ decision.disposition,
335
+ );
336
+ }
337
+ }
338
+ console.log(report.summary, report.callTraces);
362
339
  }
363
340
  ```
364
341
 
365
342
  ### BCP-47 언어 태그 유틸리티
366
343
 
367
- BCP-47 언어 태그를 다루기 위한 유틸리티입니다.
344
+ 언어 코드는 지원 목록에 대해 검증·정규화합니다. 일반 BCP-47 문법 전체를 검증하는 함수는 아닙니다. 표시 이름 유틸리티도 런타임 export입니다.
368
345
 
369
346
  ```typescript
370
347
  import {
371
- type Bcp47LanguageTag,
372
348
  BCP47_LANGUAGE_TAGS,
373
349
  BCP47_LANGUAGE_TAG_SET,
350
+ LANGUAGE_DISPLAY_NAMES,
351
+ buildLanguageDescription,
352
+ getLanguageDisplayName,
374
353
  isValidBcp47Tag,
375
354
  normalizeToBcp47,
376
355
  } from '@heripo/model';
377
356
 
378
- // Bcp47LanguageTag - 지원되는 전체 BCP-47 언어 태그의 유니온 타입
379
- type Bcp47LanguageTag = (typeof BCP47_LANGUAGE_TAGS)[number];
380
-
381
- // BCP47_LANGUAGE_TAGS - ocrmac에서 지원하는 언어 태그 상수 배열
382
- const BCP47_LANGUAGE_TAGS: readonly Bcp47LanguageTag[];
383
-
384
- // BCP47_LANGUAGE_TAG_SET - O(1) 조회를 위한 ReadonlySet
385
- const BCP47_LANGUAGE_TAG_SET: ReadonlySet<string>;
386
-
387
- // isValidBcp47Tag - 문자열이 유효한 BCP-47 태그인지 확인
388
- function isValidBcp47Tag(tag: string): tag is Bcp47LanguageTag;
389
-
390
- // normalizeToBcp47 - 언어 문자열을 BCP-47 형식으로 정규화
391
- function normalizeToBcp47(tag: string): Bcp47LanguageTag | null;
357
+ console.log(normalizeToBcp47('ko')); // 'ko-KR'
358
+ console.log(isValidBcp47Tag('ko-KR')); // true
359
+ console.log(BCP47_LANGUAGE_TAGS.length, BCP47_LANGUAGE_TAG_SET.has('ko-KR'));
360
+ console.log(LANGUAGE_DISPLAY_NAMES.ko, getLanguageDisplayName('ko-KR'));
361
+ console.log(buildLanguageDescription(['ko-KR', 'en-US']));
392
362
  ```
393
363
 
394
364
  ## 사용법
@@ -452,11 +422,11 @@ doc.chapters.forEach((chapter) => traverseChapters(chapter));
452
422
  ### 타입 가드
453
423
 
454
424
  ```typescript
455
- import type { ProcessedImage, ProcessedTable } from '@heripo/model';
425
+ import type { Caption, ProcessedImage, ProcessedTable } from '@heripo/model';
456
426
 
457
427
  function hasCaption(
458
428
  resource: ProcessedImage | ProcessedTable,
459
- ): resource is ProcessedImage | ProcessedTable {
429
+ ): resource is (ProcessedImage | ProcessedTable) & { caption: Caption } {
460
430
  return resource.caption !== undefined;
461
431
  }
462
432
 
@@ -466,8 +436,8 @@ const resourcesWithCaptions = [...doc.images, ...doc.tables].filter(hasCaption);
466
436
 
467
437
  ## 관련 패키지
468
438
 
469
- - [@heripo/pdf-parser](../pdf-parser) - PDF 파싱 및 OCR
470
- - [@heripo/document-processor](../document-processor) - 문서 구조 분석
439
+ - [@heripo/pdf-parser](../pdf-parser/README.ko.md) - PDF 파싱 및 OCR
440
+ - [@heripo/document-processor](../document-processor/README.ko.md) - 문서 구조 분석
471
441
 
472
442
  ## 후원
473
443
 
@@ -482,7 +452,7 @@ heripo lab의 오픈소스 연구를 후원하려면 다음 경로를 이용할
482
452
 
483
453
  ## 기여하기
484
454
 
485
- 기여는 언제나 환영합니다! [기여 가이드](../../CONTRIBUTING.ko.md)를 참고하세요.
455
+ 기여는 언제나 환영합니다! [기여 가이드](../../CONTRIBUTING.md)를 참고하세요.
486
456
 
487
457
  ## 프로젝트 전체 정보
488
458
 
package/README.md CHANGED
@@ -35,6 +35,8 @@ ProcessedDocument (LLM-optimized intermediate model)
35
35
 
36
36
  `@heripo/model` defines data models currently used in the PDF parsing and document structure extraction stages. Various domain-specific models for archaeological data analysis, standardization, semantic modeling, etc. will be added in the future.
37
37
 
38
+ Targets Node.js 24+ with ESM and CommonJS entry points. Use `import type` for document interfaces and ordinary imports for language utilities. A TypeScript assertion on parsed JSON does not perform runtime validation.
39
+
38
40
  ## Installation
39
41
 
40
42
  ```bash
@@ -66,6 +68,8 @@ import type { DoclingDocument } from '@heripo/model';
66
68
  - `texts`, `pictures`, `tables`: Extracted content nodes
67
69
  - `pages`: Page metadata and rendered page image references
68
70
 
71
+ `DoclingReference.$ref` and node `self_ref` values link source nodes. `DoclingProv.page_no` and processed `pdfPageNo` are one-based, while rendered files start at `pages/page_0.png`. `Chapter.pageNo` and `PageRange` refer to logical printed page numbers, which can differ from PDF page numbers. Interpret bounding boxes using their `DoclingBBox.coord_origin`.
72
+
69
73
  ### ProcessedDocument
70
74
 
71
75
  Intermediate data model optimized for LLM analysis.
@@ -175,9 +179,9 @@ interface ProcessedTable {
175
179
 
176
180
  `grid` is a compact list of visible cells. Merged cells are represented with
177
181
  `rowSpan` and `colSpan`; shadow cells covered by a span are not included.
178
- Table cells intentionally do not have cell-level `sourceRef` values. Use
179
- `table.sourceRef` together with `grid[row][col]` when tracing a cell back to
180
- the source table.
182
+ Cells have no individual `sourceRef`. Locate the source table using
183
+ `table.sourceRef`, then compare cell spans and original coordinates. Compact
184
+ array indexes need not equal logical source column indexes.
181
185
 
182
186
  ### ProcessedTableCell
183
187
 
@@ -202,7 +206,7 @@ Image and table captions.
202
206
  import type { Caption } from '@heripo/model';
203
207
 
204
208
  interface Caption {
205
- num?: string; // Caption number (e.g., "1" in "Figure 1")
209
+ num?: string; // Caption prefix and number (e.g., "Figure 1")
206
210
  fullText: string; // Full caption text
207
211
  }
208
212
  ```
@@ -250,7 +254,8 @@ interface DocumentProcessResult {
250
254
 
251
255
  ### OcrStrategy
252
256
 
253
- OCR strategy selection result.
257
+ Retained type for OCR strategy data. The current PDF parser uses fixed ocrmac
258
+ plus post-Docling correction; it no longer returns or selects this strategy.
254
259
 
255
260
  ```typescript
256
261
  import type { OcrStrategy } from '@heripo/model';
@@ -274,6 +279,7 @@ import type {
274
279
  ComponentUsageReport,
275
280
  ModelUsageDetail,
276
281
  PhaseUsageReport,
282
+ TokenUsageMetadata,
277
283
  TokenUsageReport,
278
284
  TokenUsageSummary,
279
285
  } from '@heripo/model';
@@ -290,6 +296,7 @@ interface ComponentUsageReport {
290
296
  }
291
297
 
292
298
  interface PhaseUsageReport {
299
+ metadata?: TokenUsageMetadata[]; // Per-call context
293
300
  phase: string; // Phase name
294
301
  primary?: ModelUsageDetail; // Primary model usage
295
302
  fallback?: ModelUsageDetail; // Fallback model usage
@@ -312,83 +319,47 @@ interface TokenUsageSummary {
312
319
 
313
320
  ### Review Assistance Types
314
321
 
315
- Types for optional page-level review assistance generated by
316
- `@heripo/pdf-parser` when `reviewAssistance` is enabled.
322
+ A separate audit report is produced when `correction.reviewAssistanceEnabled` is true (the parser default). It is not embedded in `ProcessedDocument`. The [complete type definitions](./src/types/review-assistance.ts) cover commands, evidence, issues, call traces and progress events.
317
323
 
318
- ```typescript
319
- import type {
320
- ReviewAssistanceDecision,
321
- ReviewAssistanceIssue,
322
- ReviewAssistanceProgressEvent,
323
- ReviewAssistanceReport,
324
- } from '@heripo/model';
325
-
326
- interface ReviewAssistanceReport {
327
- schemaName: 'HeripoReviewAssistanceReport';
328
- version: '1.0';
329
- reportId: string;
330
- source: {
331
- doclingResult: 'result.json';
332
- ocrOriginSnapshot?: 'result_ocr_origin.json';
333
- originSnapshot?: 'result_review_origin.json';
334
- };
335
- summary: {
336
- pageCount: number;
337
- pagesSucceeded: number;
338
- pagesFailed: number;
339
- autoAppliedCount: number;
340
- proposalCount: number;
341
- skippedCount: number;
342
- issueCount: number;
343
- };
344
- pages: Array<{
345
- pageNo: number;
346
- status: 'succeeded' | 'failed';
347
- decisions: ReviewAssistanceDecision[];
348
- issues: ReviewAssistanceIssue[];
349
- }>;
350
- }
324
+ Required report fields are `schemaName`, `version`, `reportId`, `source`, `options`, `summary`, `pages` and `callTraces`. A rejected decision may have `invalidOp` and no `command`; check before accessing it.
351
325
 
352
- interface ReviewAssistanceProgressEvent {
353
- substage:
354
- | 'review-assistance:prepare'
355
- | 'review-assistance:page'
356
- | 'review-assistance:patch'
357
- | 'review-assistance:write-report';
358
- status: 'started' | 'progress' | 'completed' | 'failed';
359
- reportId: string;
360
- pageNo?: number;
361
- pageCount?: number;
326
+ ```typescript
327
+ import type { ReviewAssistanceReport } from '@heripo/model';
328
+
329
+ function summarizeReview(report: ReviewAssistanceReport) {
330
+ for (const page of report.pages) {
331
+ for (const decision of page.decisions) {
332
+ console.log(
333
+ page.pageNo,
334
+ decision.command?.op ?? decision.invalidOp,
335
+ decision.disposition,
336
+ );
337
+ }
338
+ }
339
+ console.log(report.summary, report.callTraces);
362
340
  }
363
341
  ```
364
342
 
365
343
  ### BCP-47 Language Tag Utilities
366
344
 
367
- Utilities for working with BCP-47 language tags.
345
+ Language validation and normalization use the supported tag list; these are not general BCP-47 syntax validators. Display-name helpers are also runtime exports.
368
346
 
369
347
  ```typescript
370
348
  import {
371
- type Bcp47LanguageTag,
372
349
  BCP47_LANGUAGE_TAGS,
373
350
  BCP47_LANGUAGE_TAG_SET,
351
+ LANGUAGE_DISPLAY_NAMES,
352
+ buildLanguageDescription,
353
+ getLanguageDisplayName,
374
354
  isValidBcp47Tag,
375
355
  normalizeToBcp47,
376
356
  } from '@heripo/model';
377
357
 
378
- // Bcp47LanguageTag - Union type of supported full BCP-47 language tags
379
- type Bcp47LanguageTag = (typeof BCP47_LANGUAGE_TAGS)[number];
380
-
381
- // BCP47_LANGUAGE_TAGS - Const array of supported ocrmac language tags
382
- const BCP47_LANGUAGE_TAGS: readonly Bcp47LanguageTag[];
383
-
384
- // BCP47_LANGUAGE_TAG_SET - ReadonlySet for O(1) lookup
385
- const BCP47_LANGUAGE_TAG_SET: ReadonlySet<string>;
386
-
387
- // isValidBcp47Tag - Check if a string is a valid BCP-47 tag
388
- function isValidBcp47Tag(tag: string): tag is Bcp47LanguageTag;
389
-
390
- // normalizeToBcp47 - Normalize a language string to BCP-47 format
391
- function normalizeToBcp47(tag: string): Bcp47LanguageTag | null;
358
+ console.log(normalizeToBcp47('ko')); // 'ko-KR'
359
+ console.log(isValidBcp47Tag('ko-KR')); // true
360
+ console.log(BCP47_LANGUAGE_TAGS.length, BCP47_LANGUAGE_TAG_SET.has('ko-KR'));
361
+ console.log(LANGUAGE_DISPLAY_NAMES.ko, getLanguageDisplayName('ko-KR'));
362
+ console.log(buildLanguageDescription(['ko-KR', 'en-US']));
392
363
  ```
393
364
 
394
365
  ## Usage
@@ -452,11 +423,11 @@ doc.chapters.forEach((chapter) => traverseChapters(chapter));
452
423
  ### Type Guards
453
424
 
454
425
  ```typescript
455
- import type { ProcessedImage, ProcessedTable } from '@heripo/model';
426
+ import type { Caption, ProcessedImage, ProcessedTable } from '@heripo/model';
456
427
 
457
428
  function hasCaption(
458
429
  resource: ProcessedImage | ProcessedTable,
459
- ): resource is ProcessedImage | ProcessedTable {
430
+ ): resource is (ProcessedImage | ProcessedTable) & { caption: Caption } {
460
431
  return resource.caption !== undefined;
461
432
  }
462
433
 
@@ -466,8 +437,8 @@ const resourcesWithCaptions = [...doc.images, ...doc.tables].filter(hasCaption);
466
437
 
467
438
  ## Related Packages
468
439
 
469
- - [@heripo/pdf-parser](../pdf-parser) - PDF parsing and OCR
470
- - [@heripo/document-processor](../document-processor) - Document structure analysis
440
+ - [@heripo/pdf-parser](../pdf-parser/README.md) - PDF parsing and OCR
441
+ - [@heripo/document-processor](../document-processor/README.md) - Document structure analysis
471
442
 
472
443
  ## Sponsor
473
444
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@heripo/model",
3
3
  "private": false,
4
4
  "type": "module",
5
- "version": "0.1.43",
5
+ "version": "0.1.45",
6
6
  "description": "Document models and type definitions for heripo engine",
7
7
  "main": "dist/index.cjs",
8
8
  "module": "dist/index.js",
@@ -52,12 +52,12 @@
52
52
  "access": "public"
53
53
  },
54
54
  "devDependencies": {
55
- "@vitest/coverage-v8": "^4.1.10",
56
- "tsup": "^8.5.1",
57
- "vitest": "^4.1.10",
58
55
  "@heripo/tsconfig": "0.0.0",
59
56
  "@heripo/tsup-config": "0.0.0",
60
- "@heripo/vitest-config": "0.0.0"
57
+ "@heripo/vitest-config": "0.0.0",
58
+ "@vitest/coverage-v8": "^5.0.1",
59
+ "tsup": "^8.5.1",
60
+ "vitest": "^5.0.1"
61
61
  },
62
62
  "scripts": {
63
63
  "clean": "rimraf dist",