mcard-js 2.0.0 → 2.1.0

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 (103) hide show
  1. package/README.md +91 -3
  2. package/dist/model/ContentTypeInterpreter.d.ts +16 -0
  3. package/dist/model/ContentTypeInterpreter.d.ts.map +1 -0
  4. package/dist/model/ContentTypeInterpreter.js +78 -0
  5. package/dist/model/ContentTypeInterpreter.js.map +1 -0
  6. package/dist/model/GTime.d.ts +15 -0
  7. package/dist/model/GTime.d.ts.map +1 -1
  8. package/dist/model/GTime.js +44 -2
  9. package/dist/model/GTime.js.map +1 -1
  10. package/dist/model/detectors/BaseDetector.d.ts +26 -0
  11. package/dist/model/detectors/BaseDetector.d.ts.map +1 -0
  12. package/dist/model/detectors/BaseDetector.js +5 -0
  13. package/dist/model/detectors/BaseDetector.js.map +1 -0
  14. package/dist/model/detectors/BinaryDetector.d.ts +12 -0
  15. package/dist/model/detectors/BinaryDetector.d.ts.map +1 -0
  16. package/dist/model/detectors/BinaryDetector.js +82 -0
  17. package/dist/model/detectors/BinaryDetector.js.map +1 -0
  18. package/dist/model/detectors/DataFormatDetectors.d.ts +29 -0
  19. package/dist/model/detectors/DataFormatDetectors.d.ts.map +1 -0
  20. package/dist/model/detectors/DataFormatDetectors.js +223 -0
  21. package/dist/model/detectors/DataFormatDetectors.js.map +1 -0
  22. package/dist/model/detectors/LanguageDetector.d.ts +11 -0
  23. package/dist/model/detectors/LanguageDetector.d.ts.map +1 -0
  24. package/dist/model/detectors/LanguageDetector.js +148 -0
  25. package/dist/model/detectors/LanguageDetector.js.map +1 -0
  26. package/dist/model/detectors/MarkupDetectors.d.ts +22 -0
  27. package/dist/model/detectors/MarkupDetectors.d.ts.map +1 -0
  28. package/dist/model/detectors/MarkupDetectors.js +132 -0
  29. package/dist/model/detectors/MarkupDetectors.js.map +1 -0
  30. package/dist/model/detectors/OBJDetector.d.ts +8 -0
  31. package/dist/model/detectors/OBJDetector.d.ts.map +1 -0
  32. package/dist/model/detectors/OBJDetector.js +48 -0
  33. package/dist/model/detectors/OBJDetector.js.map +1 -0
  34. package/dist/model/detectors/registry.d.ts +13 -0
  35. package/dist/model/detectors/registry.d.ts.map +1 -0
  36. package/dist/model/detectors/registry.js +67 -0
  37. package/dist/model/detectors/registry.js.map +1 -0
  38. package/dist/ptr/llm/providers/OllamaEmbeddingProvider.d.ts +20 -0
  39. package/dist/ptr/llm/providers/OllamaEmbeddingProvider.d.ts.map +1 -0
  40. package/dist/ptr/llm/providers/OllamaEmbeddingProvider.js +42 -0
  41. package/dist/ptr/llm/providers/OllamaEmbeddingProvider.js.map +1 -0
  42. package/dist/ptr/node/CLMLoader.d.ts.map +1 -1
  43. package/dist/ptr/node/CLMLoader.js +8 -0
  44. package/dist/ptr/node/CLMLoader.js.map +1 -1
  45. package/dist/ptr/node/CLMRunner.d.ts.map +1 -1
  46. package/dist/ptr/node/CLMRunner.js +4 -3
  47. package/dist/ptr/node/CLMRunner.js.map +1 -1
  48. package/dist/ptr/node/Runtimes.d.ts +7 -0
  49. package/dist/ptr/node/Runtimes.d.ts.map +1 -1
  50. package/dist/ptr/node/Runtimes.js +94 -3
  51. package/dist/ptr/node/Runtimes.js.map +1 -1
  52. package/dist/rag/HandleVectorStore.d.ts +201 -0
  53. package/dist/rag/HandleVectorStore.d.ts.map +1 -0
  54. package/dist/rag/HandleVectorStore.js +527 -0
  55. package/dist/rag/HandleVectorStore.js.map +1 -0
  56. package/dist/rag/PersistentIndexer.d.ts +144 -0
  57. package/dist/rag/PersistentIndexer.d.ts.map +1 -0
  58. package/dist/rag/PersistentIndexer.js +275 -0
  59. package/dist/rag/PersistentIndexer.js.map +1 -0
  60. package/dist/rag/embeddings/VisionEmbeddingProvider.d.ts +87 -0
  61. package/dist/rag/embeddings/VisionEmbeddingProvider.d.ts.map +1 -0
  62. package/dist/rag/embeddings/VisionEmbeddingProvider.js +164 -0
  63. package/dist/rag/embeddings/VisionEmbeddingProvider.js.map +1 -0
  64. package/dist/rag/graph/community.d.ts +56 -0
  65. package/dist/rag/graph/community.d.ts.map +1 -0
  66. package/dist/rag/graph/community.js +247 -0
  67. package/dist/rag/graph/community.js.map +1 -0
  68. package/dist/rag/graph/extractor.d.ts +99 -0
  69. package/dist/rag/graph/extractor.d.ts.map +1 -0
  70. package/dist/rag/graph/extractor.js +210 -0
  71. package/dist/rag/graph/extractor.js.map +1 -0
  72. package/dist/rag/graph/store.d.ts +176 -0
  73. package/dist/rag/graph/store.d.ts.map +1 -0
  74. package/dist/rag/graph/store.js +504 -0
  75. package/dist/rag/graph/store.js.map +1 -0
  76. package/dist/rag/index.d.ts +19 -0
  77. package/dist/rag/index.d.ts.map +1 -0
  78. package/dist/rag/index.js +24 -0
  79. package/dist/rag/index.js.map +1 -0
  80. package/dist/rag/semanticVersioning.d.ts +187 -0
  81. package/dist/rag/semanticVersioning.d.ts.map +1 -0
  82. package/dist/rag/semanticVersioning.js +253 -0
  83. package/dist/rag/semanticVersioning.js.map +1 -0
  84. package/dist/storage/IndexedDBEngine.d.ts.map +1 -1
  85. package/dist/storage/IndexedDBEngine.js +9 -1
  86. package/dist/storage/IndexedDBEngine.js.map +1 -1
  87. package/dist/storage/SqliteNodeEngine.d.ts.map +1 -1
  88. package/dist/storage/SqliteNodeEngine.js +26 -4
  89. package/dist/storage/SqliteNodeEngine.js.map +1 -1
  90. package/dist/storage/SqliteWasmEngine.d.ts.map +1 -1
  91. package/dist/storage/SqliteWasmEngine.js +9 -1
  92. package/dist/storage/SqliteWasmEngine.js.map +1 -1
  93. package/dist/storage/StorageAdapter.d.ts +2 -0
  94. package/dist/storage/StorageAdapter.d.ts.map +1 -1
  95. package/dist/storage/VectorStore.d.ts +28 -5
  96. package/dist/storage/VectorStore.d.ts.map +1 -1
  97. package/dist/storage/VectorStore.js +110 -50
  98. package/dist/storage/VectorStore.js.map +1 -1
  99. package/dist/storage/schema.d.ts +123 -80
  100. package/dist/storage/schema.d.ts.map +1 -1
  101. package/dist/storage/schema.js +305 -217
  102. package/dist/storage/schema.js.map +1 -1
  103. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Full-featured TypeScript implementation of MCard content-addressable storage, supporting both browser and Node.js environments.
4
4
 
5
- [![Tests](https://img.shields.io/badge/tests-117%20passed-brightgreen)](./tests)
5
+ [![Tests](https://img.shields.io/badge/tests-155%20passed-brightgreen)](./tests)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
7
7
  [![Node.js](https://img.shields.io/badge/Node.js-18%2B-green)](https://nodejs.org/)
8
8
 
@@ -303,6 +303,33 @@ npx tsx src/ptr/node/cli.ts status
303
303
  npx tsx src/ptr/node/cli.ts list
304
304
  ```
305
305
 
306
+ ## Content Detection
307
+
308
+ The `ContentTypeInterpreter` module provides intelligent content type detection with parity to the Python implementation.
309
+
310
+ ### Features
311
+ - **Binary Signature Detection**: Identifies images (PNG, JPEG, GIF, WEBP), ZIP archives, PDFs, etc.
312
+ - **Programming Language Detection**: Identifies Python, C/C++, JavaScript, TypeScript, etc.
313
+ - **Structured Data Detection**: Validates JSON, YAML, CSV, SQL, XML.
314
+ - **Parity with Python**: Validated against the same test dataset as the core Python library.
315
+
316
+ ### Usage
317
+
318
+ ```typescript
319
+ import { ContentTypeInterpreter } from './src/model/ContentTypeInterpreter';
320
+
321
+ // Detect from string
322
+ const pythonCode = "import os\nprint('Hello')";
323
+ const result = ContentTypeInterpreter.detectContentType(pythonCode);
324
+ console.log(result.mimeType); // 'text/x-python'
325
+ console.log(result.extension); // '.py'
326
+
327
+ // Detect from binary buffer
328
+ const pngBuffer = new Uint8Array([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
329
+ const binResult = ContentTypeInterpreter.detectContentType(pngBuffer);
330
+ console.log(binResult.mimeType); // 'image/png'
331
+ ```
332
+
306
333
  ## Vector Search (sqlite-vec)
307
334
 
308
335
  The `MCardVectorStore` provides semantic search using the sqlite-vec extension:
@@ -342,8 +369,69 @@ store.close();
342
369
  - **Hybrid search**: Combined vector + FTS5 full-text search
343
370
  - **Ollama integration**: Embedding generation via local LLM
344
371
 
345
- ## Recent Bug Fixes (December 2025)
372
+ ## RAG (Retrieval-Augmented Generation)
373
+
374
+ MCard includes a complete RAG pipeline compatible with the Python implementation, powered by Ollama.
375
+
376
+ ### Components
377
+
378
+ - **PersistentIndexer**: Automates indexing of MCards into the vector store.
379
+ - **GraphExtractor**: Extracts entities and relationships from text using LLMs (e.g., `gemma3`).
380
+ - **VisionEmbeddingProvider**: Generates embeddings for images by first describing them with a vision model (e.g., `moondream`).
381
+ - **CommunityDetection**: Detects communities within the knowledge graph using Label Propagation.
382
+
383
+ ### Example: Graph Extraction
384
+
385
+ ```typescript
386
+ import { GraphExtractor } from './rag/graph/extractor';
387
+
388
+ const extractor = new GraphExtractor({
389
+ model: 'gemma3:latest',
390
+ temperature: 0.0
391
+ });
392
+
393
+ const result = await extractor.extract("MCard uses content-addressable storage.");
394
+ console.log(result.entities);
395
+ // [{ name: "MCard", type: "TECHNOLOGY", ... }]
396
+ ```
397
+
398
+ ### Example: Vision Embedding
399
+
400
+ ```typescript
401
+ import { VisionEmbeddingProvider } from './rag/embeddings/VisionEmbeddingProvider';
402
+
403
+ const provider = new VisionEmbeddingProvider();
404
+ const embedding = await provider.embedImage(base64Image);
405
+ ```
406
+
407
+ ## Integration Testing
408
+
409
+ ### Live Integration Tests
410
+
411
+ To run integration tests against a live Ollama instance:
412
+
413
+ 1. Ensure Ollama is running (`ollama serve`).
414
+ 2. Pull required models:
415
+ ```bash
416
+ ollama pull gemma3:latest
417
+ ollama pull nomic-embed-text
418
+ ollama pull moondream
419
+ ```
420
+ 3. Run the integration suite:
421
+ ```bash
422
+ npx vitest tests/rag/Integration.test.ts
423
+ ```
424
+
425
+ ## Version 2.0.1 Release Notes (December 2025)
426
+ > Compatible with Python `mcard` package v0.1.23
427
+
428
+ ### 🛠️ Polyglot Runtime Fixes
429
+ * **ESM Compatibility**: Fixed `ReferenceError: require is not defined` in `SqliteNodeEngine` by implementing `createRequire` for `better-sqlite3` imports in ES Module environments.
430
+ * **Double-Encoding Fix**: Resolved an issue where input context was being double-JSON-encoded in `LeanRuntime`, `BinaryRuntime`, and `WasmRuntime`.
431
+ * **Loader Context Injection**: Fixed `CLMRunner` to correctly pass full configuration context to `LoaderRuntime` and `CollectionLoaderRuntime` even when the runtime name differs from the operation name.
432
+ * **CLM Example Iteration**: Updated `CLMLoader` to correctly map `balanced.examples` to `parsed.examples`, enabling the JS CLI to iterate through all test cases in complex PCards like `advanced_comparison.yaml`.
346
433
 
434
+ ### Previous Fixes (2.0.0)
347
435
  ### SQLite Foreign Key Constraint Fix
348
436
 
349
437
  **Problem**: `clearSync()` was deleting tables in wrong order, causing `SQLITE_CONSTRAINT_FOREIGNKEY` errors.
@@ -358,7 +446,7 @@ clearSync(): void {
358
446
  }
359
447
  ```
360
448
 
361
- **Impact**: All 117 tests pass ✅
449
+ **Impact**: All 155 tests pass ✅
362
450
 
363
451
  ### CLMRunner Recursive Runtime Fix
364
452
 
@@ -0,0 +1,16 @@
1
+ export declare class ContentTypeInterpreter {
2
+ private static readonly MIME_TO_EXT;
3
+ /**
4
+ * Detect content type and suggest extension.
5
+ *
6
+ * @param content Content string or binary buffer
7
+ * @param fileExtension Optional file extension hint
8
+ * @returns Object containing detected mimeType and suggested extension
9
+ */
10
+ static detectContentType(content: string | Uint8Array, fileExtension?: string): {
11
+ mimeType: string;
12
+ extension: string;
13
+ };
14
+ static getExtension(mimeType: string): string;
15
+ }
16
+ //# sourceMappingURL=ContentTypeInterpreter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentTypeInterpreter.d.ts","sourceRoot":"","sources":["../../src/model/ContentTypeInterpreter.ts"],"names":[],"mappings":"AAEA,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CA8BjC;IAEF;;;;;;OAMG;IACH,MAAM,CAAC,iBAAiB,CACpB,OAAO,EAAE,MAAM,GAAG,UAAU,EAC5B,aAAa,CAAC,EAAE,MAAM,GACvB;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAyC1C,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;CAGhD"}
@@ -0,0 +1,78 @@
1
+ import { registry } from './detectors/registry';
2
+ export class ContentTypeInterpreter {
3
+ static MIME_TO_EXT = {
4
+ 'text/plain': '.txt',
5
+ 'application/json': '.json',
6
+ 'text/csv': '.csv',
7
+ 'text/x-python': '.py',
8
+ 'text/javascript': '.js',
9
+ 'text/jsx': '.jsx',
10
+ 'text/typescript': '.ts',
11
+ 'text/x-c': '.c',
12
+ 'text/x-c++': '.cpp',
13
+ 'application/xml': '.xml',
14
+ 'text/html': '.html',
15
+ 'application/x-yaml': '.yaml',
16
+ 'text/markdown': '.md',
17
+ 'text/x-sql': '.sql',
18
+ 'image/png': '.png',
19
+ 'image/jpeg': '.jpg',
20
+ 'image/gif': '.gif',
21
+ 'image/bmp': '.bmp',
22
+ 'image/x-icon': '.ico',
23
+ 'image/webp': '.webp',
24
+ 'image/svg+xml': '.svg',
25
+ 'application/pdf': '.pdf',
26
+ 'application/zip': '.zip',
27
+ 'application/gzip': '.gz',
28
+ 'application/x-rar-compressed': '.rar',
29
+ 'application/x-7z-compressed': '.7z',
30
+ 'application/x-sqlite3': '.db',
31
+ 'audio/wav': '.wav',
32
+ // Add more as needed
33
+ };
34
+ /**
35
+ * Detect content type and suggest extension.
36
+ *
37
+ * @param content Content string or binary buffer
38
+ * @param fileExtension Optional file extension hint
39
+ * @returns Object containing detected mimeType and suggested extension
40
+ */
41
+ static detectContentType(content, fileExtension) {
42
+ // Prepare sample lines for detectors
43
+ let lines = [];
44
+ let firstLine = '';
45
+ // Convert to string for line analysis (even if binary, we try loosely)
46
+ // Note: For large binary, this might be expensive/messy, but detectors handle it.
47
+ // Python implementation converts to string for lines.
48
+ let textSample = '';
49
+ if (typeof content === 'string') {
50
+ textSample = content.slice(0, 8192); // Limit sample size
51
+ }
52
+ else {
53
+ // Decode ignoring errors for text analysis on binary
54
+ textSample = new TextDecoder('utf-8', { fatal: false }).decode(content.slice(0, 8192));
55
+ }
56
+ lines = textSample.split('\n').slice(0, 20);
57
+ firstLine = lines[0] || '';
58
+ const mimeType = registry.detect(content, lines, firstLine, fileExtension);
59
+ let extension = this.getExtension(mimeType);
60
+ // If detected extension matches provided hint, prefer the hint (case insensitive)
61
+ if (fileExtension && extension) {
62
+ if (fileExtension.toLowerCase() === extension || fileExtension.toLowerCase() === `.${extension}`) {
63
+ extension = fileExtension;
64
+ }
65
+ }
66
+ if (!extension && fileExtension) {
67
+ extension = fileExtension;
68
+ }
69
+ if (!extension) {
70
+ extension = '.txt'; // Default
71
+ }
72
+ return { mimeType, extension };
73
+ }
74
+ static getExtension(mimeType) {
75
+ return this.MIME_TO_EXT[mimeType] || '';
76
+ }
77
+ }
78
+ //# sourceMappingURL=ContentTypeInterpreter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContentTypeInterpreter.js","sourceRoot":"","sources":["../../src/model/ContentTypeInterpreter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,MAAM,OAAO,sBAAsB;IACvB,MAAM,CAAU,WAAW,GAA2B;QAC1D,YAAY,EAAE,MAAM;QACpB,kBAAkB,EAAE,OAAO;QAC3B,UAAU,EAAE,MAAM;QAClB,eAAe,EAAE,KAAK;QACtB,iBAAiB,EAAE,KAAK;QACxB,UAAU,EAAE,MAAM;QAClB,iBAAiB,EAAE,KAAK;QACxB,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,MAAM;QACpB,iBAAiB,EAAE,MAAM;QACzB,WAAW,EAAE,OAAO;QACpB,oBAAoB,EAAE,OAAO;QAC7B,eAAe,EAAE,K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EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;QAE3E,IAAI,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAE5C,kFAAkF;QAClF,IAAI,aAAa,IAAI,SAAS,EAAE,CAAC;YAC7B,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,SAAS,IAAI,aAAa,CAAC,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,EAAE,CAAC;gBAC/F,SAAS,GAAG,aAAa,CAAC;YAC9B,CAAC;QACL,CAAC;QAED,IAAI,CAAC,SAAS,IAAI,aAAa,EAAE,CAAC;YAC9B,SAAS,GAAG,aAAa,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,SAAS,EAAE,CAAC;YACb,SAAS,GAAG,MAAM,CAAC,CAAC,UAAU;QAClC,CAAC;QAED,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACnC,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC5C,CAAC"}
@@ -25,5 +25,20 @@ export declare class GTime {
25
25
  * Get the region code from a GTime string
26
26
  */
27
27
  static getRegionCode(gtime: string): string;
28
+ /**
29
+ * Check if the provided hash function is valid.
30
+ * Matches Python's GTime.is_valid_hash_function()
31
+ */
32
+ static isValidHashFunction(hashFunction: string): boolean;
33
+ /**
34
+ * Check if the provided region code is valid.
35
+ * Matches Python's GTime.is_valid_region_code()
36
+ */
37
+ static isValidRegionCode(regionCode: string): boolean;
38
+ /**
39
+ * Check if the provided timestamp is in ISO format.
40
+ * Matches Python's GTime.is_iso_format()
41
+ */
42
+ static isIsoFormat(timestamp: string): boolean;
28
43
  }
29
44
  //# sourceMappingURL=GTime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GTime.d.ts","sourceRoot":"","sources":["../../src/model/GTime.ts"],"names":[],"mappings":"AAAA,qBAAa,KAAK;IACd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,MAAM,CAAC,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIrD;;;OAGG;IACH,MAAM,CAAC,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;CAkBjD"}
@@ -1,3 +1,7 @@
1
+ /**
2
+ * Valid hash algorithms supported by the system
3
+ */
4
+ const VALID_HASH_ALGORITHMS = ['md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha512'];
1
5
  export class GTime {
2
6
  static DEFAULT_ALGORITHM = 'sha256';
3
7
  /**
@@ -17,8 +21,6 @@ export class GTime {
17
21
  static parse(gtime) {
18
22
  const parts = gtime.split('|');
19
23
  if (parts.length !== 3) {
20
- // Fallback for old format (underscore) for backward compatibility if needed?
21
- // Or strict? Python is strict about 3 parts.
22
24
  throw new Error(`Invalid GTime format: ${gtime}`);
23
25
  }
24
26
  return {
@@ -45,5 +47,45 @@ export class GTime {
45
47
  static getRegionCode(gtime) {
46
48
  return this.parse(gtime).region;
47
49
  }
50
+ /**
51
+ * Check if the provided hash function is valid.
52
+ * Matches Python's GTime.is_valid_hash_function()
53
+ */
54
+ static isValidHashFunction(hashFunction) {
55
+ if (!hashFunction || typeof hashFunction !== 'string') {
56
+ return false;
57
+ }
58
+ return VALID_HASH_ALGORITHMS.includes(hashFunction.toLowerCase());
59
+ }
60
+ /**
61
+ * Check if the provided region code is valid.
62
+ * Matches Python's GTime.is_valid_region_code()
63
+ */
64
+ static isValidRegionCode(regionCode) {
65
+ return Boolean(regionCode && regionCode === regionCode.toUpperCase());
66
+ }
67
+ /**
68
+ * Check if the provided timestamp is in ISO format.
69
+ * Matches Python's GTime.is_iso_format()
70
+ */
71
+ static isIsoFormat(timestamp) {
72
+ if (!timestamp || typeof timestamp !== 'string') {
73
+ return false;
74
+ }
75
+ try {
76
+ const date = new Date(timestamp);
77
+ // Check if it's a valid date and the string contains expected ISO patterns
78
+ if (isNaN(date.getTime())) {
79
+ return false;
80
+ }
81
+ // ISO format should have 'T' separator or be a valid date string
82
+ // Accept formats like: 2024-12-04T12:00:00.000Z or 2024-12-04T12:00:00
83
+ const isoPattern = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/;
84
+ return isoPattern.test(timestamp);
85
+ }
86
+ catch {
87
+ return false;
88
+ }
89
+ }
48
90
  }
49
91
  //# sourceMappingURL=GTime.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GTime.js","sourceRoot":"","sources":["../../src/model/GTime.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,KAAK;IACN,MAAM,CAAU,iBAAiB,GAAG,QAAQ,CAAC;IAErD;;;OAGG;IACH,MAAM,CAAC,QAAQ,CAAC,gBAAwB,IAAI,CAAC,iBAAiB;QAC1D,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,EAAE,CAAC;QACzC,qCAAqC;QACrC,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC3C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,0CAA0C;QAChE,OAAO,GAAG,IAAI,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,CAAC,KAAa;QACtB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,6EAA6E;YAC7E,6CAA6C;YAC7C,MAAM,IAAI,KAAK,CAAC,yBAAyB,KAAK,EAAE,CAAC,CAAC;QACtD,CAAC;QACD,OAAO;YACH,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;YACnB,SAAS,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;SACnB,CAAC;IACN,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,gBAAgB,CAAC,KAAa;QACjC,OAAO,IAAI,CA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ACD,iEAAiE;YACjE,uEAAuE;YACvE,MAAM,UAAU,GAAG,sCAAsC,CAAC;YAC1D,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Base interface for all content type detectors.
3
+ */
4
+ export interface BaseDetector {
5
+ /**
6
+ * Friendly name of the content type this detector handles.
7
+ */
8
+ readonly contentTypeName: string;
9
+ /**
10
+ * Detect confidence level for the given content content.
11
+ *
12
+ * @param contentSample First ~2KB of content
13
+ * @param lines First ~20 lines of content
14
+ * @param firstLine The first line of content
15
+ * @param fileExtension Optional file extension hint (e.g., ".json")
16
+ * @returns Confidence score between 0.0 and 1.0
17
+ */
18
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
19
+ /**
20
+ * Get the specific MIME type for the detected content.
21
+ *
22
+ * @returns MIME type string (e.g., "application/json") or null if not detected
23
+ */
24
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
25
+ }
26
+ //# sourceMappingURL=BaseDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseDetector.d.ts","sourceRoot":"","sources":["../../../src/model/detectors/BaseDetector.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAEjC;;;;;;;;OAQG;IACH,MAAM,CACF,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,CAAC;IAEV;;;;OAIG;IACH,WAAW,CACP,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,GAAG,IAAI,CAAC;CACpB"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Base interface for all content type detectors.
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=BaseDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseDetector.js","sourceRoot":"","sources":["../../../src/model/detectors/BaseDetector.ts"],"names":[],"mappings":"AAAA;;GAEG"}
@@ -0,0 +1,12 @@
1
+ import { BaseDetector } from './BaseDetector';
2
+ export declare class BinarySignatureDetector implements BaseDetector {
3
+ readonly contentTypeName = "binary";
4
+ private static readonly SIGNATURES;
5
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
6
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
7
+ private toBytes;
8
+ private startsWith;
9
+ private detectRiffFormat;
10
+ private detectZipType;
11
+ }
12
+ //# sourceMappingURL=BinaryDetector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BinaryDetector.d.ts","sourceRoot":"","sources":["../../../src/model/detectors/BinaryDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,uBAAwB,YAAW,YAAY;IACxD,QAAQ,CAAC,eAAe,YAAY;IAGpC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAchC;IAEF,MAAM,CACF,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM;IAKT,WAAW,CACP,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,GAAG,IAAI;IAsBhB,OAAO,CAAC,OAAO;IAKf,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,aAAa;CAaxB"}
@@ -0,0 +1,82 @@
1
+ export class BinarySignatureDetector {
2
+ contentTypeName = "binary";
3
+ // Signatures map: [Signature Bytes, Mime Type]
4
+ static SIGNATURES = [
5
+ [new Uint8Array([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]), 'image/png'],
6
+ [new Uint8Array([0xFF, 0xD8, 0xFF]), 'image/jpeg'],
7
+ [new Uint8Array([0x47, 0x49, 0x46, 0x38, 0x37, 0x61]), 'image/gif'], // GIF87a
8
+ [new Uint8Array([0x47, 0x49, 0x46, 0x38, 0x39, 0x61]), 'image/gif'], // GIF89a
9
+ [new Uint8Array([0x42, 0x4D]), 'image/bmp'], // BM
10
+ [new Uint8Array([0x00, 0x00, 0x01, 0x00]), 'image/x-icon'],
11
+ [new Uint8Array([0x00, 0x00, 0x02, 0x00]), 'image/x-icon'],
12
+ [new Uint8Array([0x25, 0x50, 0x44, 0x46]), 'application/pdf'], // %PDF
13
+ [new Uint8Array([0x50, 0x4B, 0x03, 0x04]), 'application/zip'], // PK..
14
+ [new Uint8Array([0x1F, 0x8B, 0x08]), 'application/gzip'],
15
+ [new Uint8Array([0x52, 0x61, 0x72, 0x21, 0x1A, 0x07, 0x00]), 'application/x-rar-compressed'],
16
+ [new Uint8Array([0x37, 0x7A, 0xBC, 0xAF, 0x27, 0x1C]), 'application/x-7z-compressed'],
17
+ [new Uint8Array([0x53, 0x51, 0x4C, 0x69, 0x74, 0x65, 0x20, 0x66, 0x6F, 0x72, 0x6D, 0x61, 0x74, 0x20, 0x33, 0x00]), 'application/x-sqlite3'],
18
+ ];
19
+ detect(contentSample, lines, firstLine, fileExtension) {
20
+ const mime = this.getMimeType(contentSample, lines, firstLine, fileExtension);
21
+ return (mime && mime !== 'application/octet-stream') ? 0.95 : 0.0;
22
+ }
23
+ getMimeType(contentSample, lines, firstLine, fileExtension) {
24
+ const bytes = this.toBytes(contentSample);
25
+ // RIFF check
26
+ if (this.startsWith(bytes, new Uint8Array([0x52, 0x49, 0x46, 0x46]))) { // RIFF
27
+ return this.detectRiffFormat(bytes);
28
+ }
29
+ for (const [sig, mime] of BinarySignatureDetector.SIGNATURES) {
30
+ if (this.startsWith(bytes, sig)) {
31
+ if (mime === 'application/zip') {
32
+ return this.detectZipType(bytes);
33
+ }
34
+ return mime;
35
+ }
36
+ }
37
+ // Return generic binary if no specific signature but looks binary?
38
+ // Not implemented here, returning default null/octet-stream from interface logic
39
+ return 'application/octet-stream';
40
+ }
41
+ toBytes(content) {
42
+ if (content instanceof Uint8Array)
43
+ return content;
44
+ return new TextEncoder().encode(content);
45
+ }
46
+ startsWith(data, prefix) {
47
+ if (data.length < prefix.length)
48
+ return false;
49
+ for (let i = 0; i < prefix.length; i++) {
50
+ if (data[i] !== prefix[i])
51
+ return false;
52
+ }
53
+ return true;
54
+ }
55
+ detectRiffFormat(bytes) {
56
+ if (bytes.length < 12)
57
+ return 'application/octet-stream';
58
+ // Offset 8: 4 bytes
59
+ const format = new TextDecoder().decode(bytes.slice(8, 12));
60
+ if (format === 'WAVE')
61
+ return 'audio/wav';
62
+ if (format === 'WEBP')
63
+ return 'image/webp';
64
+ return 'application/octet-stream';
65
+ }
66
+ detectZipType(bytes) {
67
+ // Basic contains check for office signatures
68
+ // Converting first 2KB to string (ignoring errors) to search
69
+ // Note: TextDecoder replacement char is .
70
+ const header = new TextDecoder().decode(bytes.slice(0, 2048));
71
+ if (header.includes('[Content_Types].xml') && header.includes('_rels/.rels')) {
72
+ if (header.includes('word/'))
73
+ return 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
74
+ if (header.includes('xl/'))
75
+ return 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
76
+ if (header.includes('ppt/'))
77
+ return 'application/vnd.openxmlformats-officedocument.presentationml.presentation';
78
+ }
79
+ return 'application/zip';
80
+ }
81
+ }
82
+ //# sourceMapp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,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC5D,IAAI,MAAM,KAAK,MAAM;YAAE,OAAO,WAAW,CAAC;QAC1C,IAAI,MAAM,KAAK,MAAM;YAAE,OAAO,YAAY,CAAC;QAC3C,OAAO,0BAA0B,CAAC;IACtC,CAAC;IAEO,aAAa,CAAC,KAAiB;QACnC,6CAA6C;QAC7C,6DAA6D;QAC7D,0CAA0C;QAC1C,MAAM,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC;QAE9D,IAAI,MAAM,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAC3E,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC;gBAAE,OAAO,yEAAyE,CAAC;YAC/G,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAAE,OAAO,mEAAmE,CAAC;YACvG,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;gBAAE,OAAO,2EAA2E,CAAC;QACpH,CAAC;QACD,OAAO,iBAAiB,CAAC;IAC7B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { BaseDetector } from './BaseDetector';
2
+ export declare class SQLDetector implements BaseDetector {
3
+ readonly contentTypeName = "sql";
4
+ private static readonly KEYWORDS;
5
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
6
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
7
+ }
8
+ export declare class JSONDetector implements BaseDetector {
9
+ readonly contentTypeName = "json";
10
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
11
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
12
+ private verifyJsonStructure;
13
+ }
14
+ export declare class YAMLDetector implements BaseDetector {
15
+ readonly contentTypeName = "yaml";
16
+ private static readonly YAML_START_PATTERNS;
17
+ private static readonly KEY_VALUE_PATTERN;
18
+ private static readonly LIST_ITEM_PATTERN;
19
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
20
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
21
+ }
22
+ export declare class CSVDetector implements BaseDetector {
23
+ readonly contentTypeName = "csv";
24
+ detect(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): number;
25
+ getMimeType(contentSample: string | Uint8Array, lines: string[], firstLine: string, fileExtension?: string): string | null;
26
+ private verifyCsvStructure;
27
+ private analyzeCsvContent;
28
+ }
29
+ //# sourceMappingURL=DataFormatDetectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataFormatDetectors.d.ts","sourceRoot":"","sources":["../../../src/model/detectors/DataFormatDetectors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,qBAAa,WAAY,YAAW,YAAY;IAC5C,QAAQ,CAAC,eAAe,SAAS;IAGjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAG9B;IAEF,MAAM,CACF,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM;IA8BT,WAAW,CACP,aAAa,EAAE,MAAM,GAAG,UAAU,EAClC,KAAK,EAAE,MAAM,EAAE,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,MAAM,GACvB,MAAM,GAAG,IAAI;CAGnB;AAKD,qBAAa,YAAa,YAAW,YAAY;IAC7C,QAAQ,CAAC,eAAe,UAAU;IAElC,MAAM,CACF,aAAa,EAAE,MAAM,GA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