fix(f6.9): load PDF and image converters in production runtime
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 3m16s
DH V2 CI / API · typecheck, tests, build (push) Successful in 31s
DH V2 CI / WEB · typecheck, build (push) Successful in 18s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 8s
DH V2 CI / Docker / scripts contract (push) Successful in 50s
Android CI / RC / Android · lint, tests, debug APK, release compile (push) Successful in 3m16s
DH V2 CI / API · typecheck, tests, build (push) Successful in 31s
DH V2 CI / WEB · typecheck, build (push) Successful in 18s
Production dependency audit / API · production dependencies (push) Successful in 8s
Production dependency audit / WEB · production dependencies (push) Successful in 8s
DH V2 CI / Docker / scripts contract (push) Successful in 50s
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { existsSync } from 'node:fs';
|
import { existsSync } from 'node:fs';
|
||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import PDFDocument from 'pdfkit';
|
import PDFDocument = require('pdfkit');
|
||||||
|
|
||||||
export interface ActPdfImage {
|
export interface ActPdfImage {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import sharp from 'sharp';
|
const sharp = require('sharp') as typeof import('sharp').default;
|
||||||
|
|
||||||
// PDFKit and the Word image renderer accept JPEG/PNG. The source bytes and
|
// PDFKit and the Word image renderer accept JPEG/PNG. The source bytes and
|
||||||
// their recorded SHA-256 remain untouched; WebP is only converted for display.
|
// their recorded SHA-256 remain untouched; WebP is only converted for display.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
import { createHash } from 'node:crypto';
|
import { createHash } from 'node:crypto';
|
||||||
import { readFileSync } from 'node:fs';
|
import { existsSync, readFileSync } from 'node:fs';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
import { resolve } from 'node:path';
|
import { resolve } from 'node:path';
|
||||||
import test from 'node:test';
|
import test from 'node:test';
|
||||||
import { buildInspectionActPdf } from '../../src/inspection-reports/inspection-act-pdf-builder';
|
import { buildInspectionActPdf } from '../../src/inspection-reports/inspection-act-pdf-builder';
|
||||||
@@ -70,3 +71,16 @@ test('F6.9 renders WebP field photographs in both documents without changing the
|
|||||||
assert.ok(word.buffer.includes(display));
|
assert.ok(word.buffer.includes(display));
|
||||||
assert.ok(word.buffer.includes(Buffer.from(originalSha)));
|
assert.ok(word.buffer.includes(Buffer.from(originalSha)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('F6.9 built CommonJS runtime renders signed PDF and WebP evidence', async () => {
|
||||||
|
const builtPdf = resolve(process.cwd(), 'dist/inspection-reports/inspection-act-pdf-builder.js');
|
||||||
|
const builtImage = resolve(process.cwd(), 'dist/inspection-reports/inspection-document-images.js');
|
||||||
|
if (!existsSync(builtPdf) || !existsSync(builtImage)) return;
|
||||||
|
const requireCjs = createRequire(resolve(process.cwd(), 'package.json'));
|
||||||
|
const runtimePdf = requireCjs(builtPdf) as { buildInspectionActPdf: typeof buildInspectionActPdf };
|
||||||
|
const runtimeImage = requireCjs(builtImage) as { renderableInspectionImage: typeof renderableInspectionImage };
|
||||||
|
const webp = await sharp(photo).webp().toBuffer();
|
||||||
|
const rendered = await runtimeImage.renderableInspectionImage(webp);
|
||||||
|
const pdf = await runtimePdf.buildInspectionActPdf(sealed, [{ ...evidence, buffer: rendered, sha256: digest(webp) }]);
|
||||||
|
assert.ok(pdf.buffer.subarray(0, 8).equals(Buffer.from('%PDF-1.4')));
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user