@ctchealth/plato-sdk 0.0.18 → 0.0.19

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.
@@ -1,24 +0,0 @@
1
- /**
2
- * Validates a file against size and type constraints.
3
- *
4
- * @param file - The file to check.
5
- * @param maxFileSize - The maximum allowed file size in bytes.
6
- * @param allowedMimeTypes - An array of allowed MIME types.
7
- * @returns true if valid, or a descriptive error message if invalid.
8
- */
9
- export declare function checkFile(file: File | Blob, maxFileSize: number, allowedMimeTypes: string[]): true | string;
10
- /**
11
- * Calculates the SHA-256 hash of a file or blob.
12
- *
13
- * @param file - The file or blob to hash.
14
- * @returns A promise that resolves to the hexadecimal SHA-256 hash.
15
- */
16
- export declare function calculateHash(file: File | Blob): Promise<string>;
17
- /**
18
- * Gets the page count of a PDF file.
19
- *
20
- * @param file - The PDF file or blob to check.
21
- * @returns A promise that resolves to the number of pages in the PDF.
22
- * @throws Error if the PDF cannot be parsed.
23
- */
24
- export declare function getPdfPageCount(file: File | Blob): Promise<number>;
package/src/lib/utils.js DELETED
@@ -1,70 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkFile = checkFile;
4
- exports.calculateHash = calculateHash;
5
- exports.getPdfPageCount = getPdfPageCount;
6
- /**
7
- * Copyright (c) 2025 ctcHealth. All rights reserved.
8
- *
9
- * This file is part of the ctcHealth Plato Platform, a proprietary software system developed by ctcHealth.
10
- *
11
- * This source code and all related materials are confidential and proprietary to ctcHealth.
12
- * Unauthorized access, use, copying, modification, distribution, or disclosure is strictly prohibited
13
- * and may result in disciplinary action and civil and/or criminal penalties.
14
- *
15
- * This software is intended solely for authorized use within ctcHealth and its designated partners.
16
- *
17
- * For internal use only.
18
- */
19
- const pdf_lib_1 = require("pdf-lib");
20
- /**
21
- * Validates a file against size and type constraints.
22
- *
23
- * @param file - The file to check.
24
- * @param maxFileSize - The maximum allowed file size in bytes.
25
- * @param allowedMimeTypes - An array of allowed MIME types.
26
- * @returns true if valid, or a descriptive error message if invalid.
27
- */
28
- function checkFile(file, maxFileSize, allowedMimeTypes) {
29
- if (file.size > maxFileSize) {
30
- const uploadedSizeMB = (file.size / (1024 * 1024)).toFixed(2);
31
- const maxSizeMB = (maxFileSize / (1024 * 1024)).toFixed(2);
32
- return `File size (${uploadedSizeMB} MB) exceeds the maximum allowed size of ${maxSizeMB} MB.`;
33
- }
34
- if (!allowedMimeTypes.includes(file.type)) {
35
- return `Invalid file type: ${file.type}. Allowed types are: ${allowedMimeTypes.join(', ')}.`;
36
- }
37
- return true;
38
- }
39
- /**
40
- * Calculates the SHA-256 hash of a file or blob.
41
- *
42
- * @param file - The file or blob to hash.
43
- * @returns A promise that resolves to the hexadecimal SHA-256 hash.
44
- */
45
- async function calculateHash(file) {
46
- const arrayBuffer = await file.arrayBuffer();
47
- const hashBuffer = await crypto.subtle.digest('SHA-256', arrayBuffer);
48
- const hashArray = Array.from(new Uint8Array(hashBuffer));
49
- const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
50
- return hashHex;
51
- }
52
- /**
53
- * Gets the page count of a PDF file.
54
- *
55
- * @param file - The PDF file or blob to check.
56
- * @returns A promise that resolves to the number of pages in the PDF.
57
- * @throws Error if the PDF cannot be parsed.
58
- */
59
- async function getPdfPageCount(file) {
60
- try {
61
- const arrayBuffer = await file.arrayBuffer();
62
- const pdf = await pdf_lib_1.PDFDocument.load(arrayBuffer);
63
- return pdf.getPageCount();
64
- }
65
- catch (err) {
66
- const message = err instanceof Error ? err.message : 'Unknown error';
67
- throw new Error(`Failed to read PDF page count: ${message}`);
68
- }
69
- }
70
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../libs/plato-sdk/src/lib/utils.ts"],"names":[],"mappings":";;AAuBA,8BAgBC;AAQD,sCAMC;AASD,0CASC;AAvED;;;;;;;;;;;;GAYG;AACH,qCAAsC;AA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