@amirdaraee/namewise 0.5.3 → 0.5.4

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 (68) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/index.js +0 -0
  3. package/package.json +2 -2
  4. package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -82
  5. package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -61
  6. package/.github/workflows/auto-release.yml +0 -81
  7. package/.github/workflows/build.yml +0 -55
  8. package/.github/workflows/publish.yml +0 -134
  9. package/.github/workflows/test.yml +0 -45
  10. package/eng.traineddata +0 -0
  11. package/src/cli/commands.ts +0 -64
  12. package/src/cli/rename.ts +0 -171
  13. package/src/index.ts +0 -54
  14. package/src/parsers/excel-parser.ts +0 -66
  15. package/src/parsers/factory.ts +0 -38
  16. package/src/parsers/pdf-parser.ts +0 -99
  17. package/src/parsers/text-parser.ts +0 -43
  18. package/src/parsers/word-parser.ts +0 -50
  19. package/src/services/ai-factory.ts +0 -39
  20. package/src/services/claude-service.ts +0 -119
  21. package/src/services/file-renamer.ts +0 -141
  22. package/src/services/lmstudio-service.ts +0 -161
  23. package/src/services/ollama-service.ts +0 -191
  24. package/src/services/openai-service.ts +0 -117
  25. package/src/types/index.ts +0 -76
  26. package/src/types/pdf-extraction.d.ts +0 -7
  27. package/src/utils/ai-prompts.ts +0 -76
  28. package/src/utils/file-templates.ts +0 -275
  29. package/src/utils/naming-conventions.ts +0 -67
  30. package/src/utils/pdf-to-image.ts +0 -137
  31. package/tests/data/console-test-1.txt +0 -1
  32. package/tests/data/console-test-2.txt +0 -1
  33. package/tests/data/console-test-long-filename-for-display-testing.txt +0 -1
  34. package/tests/data/empty-file.txt +0 -0
  35. package/tests/data/failure.txt +0 -1
  36. package/tests/data/file1.txt +0 -1
  37. package/tests/data/file2.txt +0 -1
  38. package/tests/data/much-longer-filename-to-test-clearing.txt +0 -1
  39. package/tests/data/sample-markdown.md +0 -9
  40. package/tests/data/sample-pdf.pdf +0 -0
  41. package/tests/data/sample-text.txt +0 -25
  42. package/tests/data/short.txt +0 -1
  43. package/tests/data/single-file.txt +0 -1
  44. package/tests/data/success.txt +0 -1
  45. package/tests/data/this-is-a-very-long-filename-that-should-be-truncated-for-better-display-purposes.txt +0 -1
  46. package/tests/data/very-long-filename-that-should-be-cleared-properly.txt +0 -1
  47. package/tests/data/x.txt +0 -1
  48. package/tests/integration/ai-prompting.test.ts +0 -386
  49. package/tests/integration/end-to-end.test.ts +0 -209
  50. package/tests/integration/person-name-extraction.test.ts +0 -440
  51. package/tests/integration/workflow.test.ts +0 -336
  52. package/tests/mocks/mock-ai-service.ts +0 -58
  53. package/tests/unit/cli/commands.test.ts +0 -169
  54. package/tests/unit/parsers/factory.test.ts +0 -100
  55. package/tests/unit/parsers/pdf-parser.test.ts +0 -63
  56. package/tests/unit/parsers/text-parser.test.ts +0 -85
  57. package/tests/unit/services/ai-factory.test.ts +0 -85
  58. package/tests/unit/services/claude-service.test.ts +0 -188
  59. package/tests/unit/services/file-renamer.test.ts +0 -514
  60. package/tests/unit/services/lmstudio-service.test.ts +0 -326
  61. package/tests/unit/services/ollama-service.test.ts +0 -264
  62. package/tests/unit/services/openai-service.test.ts +0 -196
  63. package/tests/unit/utils/ai-prompts.test.ts +0 -213
  64. package/tests/unit/utils/file-templates.test.ts +0 -199
  65. package/tests/unit/utils/naming-conventions.test.ts +0 -88
  66. package/tests/unit/utils/pdf-to-image.test.ts +0 -127
  67. package/tsconfig.json +0 -20
  68. package/vitest.config.ts +0 -30
@@ -1,88 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { applyNamingConvention, getNamingInstructions, NamingConvention } from '../../../src/utils/naming-conventions.js';
3
-
4
- describe('Naming Conventions', () => {
5
- describe('applyNamingConvention()', () => {
6
- const testText = 'Project Requirements Document 2024';
7
-
8
- it('should apply kebab-case convention', () => {
9
- const result = applyNamingConvention(testText, 'kebab-case');
10
- expect(result).toBe('project-requirements-document-2024');
11
- });
12
-
13
- it('should apply snake_case convention', () => {
14
- const result = applyNamingConvention(testText, 'snake_case');
15
- expect(result).toBe('project_requirements_document_2024');
16
- });
17
-
18
- it('should apply camelCase convention', () => {
19
- const result = applyNamingConvention(testText, 'camelCase');
20
- expect(result).toBe('projectRequirementsDocument2024');
21
- });
22
-
23
- it('should apply PascalCase convention', () => {
24
- const result = applyNamingConvention(testText, 'PascalCase');
25
- expect(result).toBe('ProjectRequirementsDocument2024');
26
- });
27
-
28
- it('should apply lowercase convention', () => {
29
- const result = applyNamingConvention(testText, 'lowercase');
30
- expect(result).toBe('projectrequirementsdocument2024');
31
- });
32
-
33
- it('should apply UPPERCASE convention', () => {
34
- const result = applyNamingConvention(testText, 'UPPERCASE');
35
- expect(result).toBe('PROJECTREQUIREMENTSDOCUMENT2024');
36
- });
37
-
38
- it('should handle text with special characters', () => {
39
- const textWithSpecialChars = 'User@Guide & Manual (v2.1)';
40
-
41
- expect(applyNamingConvention(textWithSpecialChars, 'kebab-case')).toBe('userguide-manual-v21');
42
- expect(applyNamingConvention(textWithSpecialChars, 'snake_case')).toBe('userguide_manual_v21');
43
- expect(applyNamingConvention(textWithSpecialChars, 'camelCase')).toBe('userguideManualV21');
44
- expect(applyNamingConvention(textWithSpecialChars, 'PascalCase')).toBe('UserguideManualV21');
45
- });
46
-
47
- it('should handle text with existing hyphens and underscores', () => {
48
- const textWithSeparators = 'my-file_name document';
49
-
50
- expect(applyNamingConvention(textWithSeparators, 'kebab-case')).toBe('my-file-name-document');
51
- expect(applyNamingConvention(textWithSeparators, 'snake_case')).toBe('my_file_name_document');
52
- expect(applyNamingConvention(textWithSeparators, 'camelCase')).toBe('myFileNameDocument');
53
- });
54
-
55
- it('should handle empty and whitespace-only strings', () => {
56
- expect(applyNamingConvention('', 'kebab-case')).toBe('');
57
- expect(applyNamingConvention(' ', 'kebab-case')).toBe('');
58
- });
59
-
60
- it('should normalize multiple spaces', () => {
61
- const textWithSpaces = 'Meeting Notes From Today';
62
- expect(applyNamingConvention(textWithSpaces, 'kebab-case')).toBe('meeting-notes-from-today');
63
- });
64
-
65
- it('should default to kebab-case for unknown convention', () => {
66
- const result = applyNamingConvention(testText, 'unknown' as NamingConvention);
67
- expect(result).toBe('project-requirements-document-2024');
68
- });
69
- });
70
-
71
- describe('getNamingInstructions()', () => {
72
- it('should return correct instructions for each convention', () => {
73
- expect(getNamingInstructions('kebab-case')).toContain('lowercase with hyphens');
74
- expect(getNamingInstructions('snake_case')).toContain('lowercase with underscores');
75
- expect(getNamingInstructions('camelCase')).toContain('camelCase format starting with lowercase');
76
- expect(getNamingInstructions('PascalCase')).toContain('PascalCase format starting with uppercase');
77
- expect(getNamingInstructions('lowercase')).toContain('single lowercase word');
78
- expect(getNamingInstructions('UPPERCASE')).toContain('single uppercase word');
79
- });
80
-
81
- it('should include examples in instructions', () => {
82
- expect(getNamingInstructions('kebab-case')).toContain('meeting-notes-2024');
83
- expect(getNamingInstructions('snake_case')).toContain('meeting_notes_2024');
84
- expect(getNamingInstructions('camelCase')).toContain('meetingNotes2024');
85
- expect(getNamingInstructions('PascalCase')).toContain('MeetingNotes2024');
86
- });
87
- });
88
- });
@@ -1,127 +0,0 @@
1
- import { describe, it, expect, beforeAll } from 'vitest';
2
- import { PDFToImageConverter } from '../../../src/utils/pdf-to-image.js';
3
- import fs from 'fs';
4
- import path from 'path';
5
-
6
- describe('PDFToImageConverter', () => {
7
- let samplePdfBuffer: Buffer;
8
- const testDataDir = path.join(process.cwd(), 'tests/data');
9
-
10
- beforeAll(async () => {
11
- // Load sample PDF for testing
12
- const pdfPath = path.join(testDataDir, 'sample-pdf.pdf');
13
- samplePdfBuffer = fs.readFileSync(pdfPath);
14
- });
15
-
16
- describe('Integration with PDF Parser', () => {
17
- it('should successfully convert scanned PDF through parser workflow', async () => {
18
- // This simulates what happens in the actual PDF parser
19
- const { PDFParser } = await import('../../../src/parsers/pdf-parser.js');
20
- const parser = new PDFParser();
21
-
22
- // Create a minimal scanned PDF scenario
23
- const pdfPath = path.join(testDataDir, 'sample-pdf.pdf');
24
-
25
- // Parse the PDF (this will trigger conversion if detected as scanned)
26
- const result = await parser.parse(pdfPath);
27
-
28
- // The parser should complete without throwing errors
29
- expect(result).toBeDefined();
30
- expect(result.content).toBeDefined();
31
- }, 15000);
32
- });
33
-
34
- describe('convertFirstPageToBase64()', () => {
35
- it('should convert PDF first page to base64 JPEG image', async () => {
36
- const result = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer);
37
-
38
- // Verify it's a base64 data URL (always JPEG for size optimization)
39
- expect(result).toMatch(/^data:image\/jpeg;base64,/);
40
-
41
- // Verify it has actual content
42
- expect(result.length).toBeGreaterThan(100);
43
-
44
- // Verify base64 encoding is valid
45
- const base64Data = result.split(',')[1];
46
- expect(() => Buffer.from(base64Data, 'base64')).not.toThrow();
47
- }, 10000); // 10 second timeout for PDF processing
48
-
49
- it('should respect format option when specified', async () => {
50
- const result = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
51
- format: 'jpeg'
52
- });
53
-
54
- // Verify it's a base64 data URL (always JPEG for size optimization)
55
- expect(result).toMatch(/^data:image\/jpeg;base64,/);
56
-
57
- // Verify it has actual content
58
- expect(result.length).toBeGreaterThan(100);
59
- }, 10000);
60
-
61
- it('should use custom scale factor', async () => {
62
- const resultScale1 = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
63
- scale: 1.0
64
- });
65
-
66
- const resultScale2 = await PDFToImageConverter.convertFirstPageToBase64(samplePdfBuffer, {
67
- scale: 2.0
68
- });
69
-
70
- // Both should be JPEG format
71
- expect(resultScale1).toMatch(/^data:image\/jpeg;base64,/);
72
- expect(resultScale2).toMatch(/^data:image\/jpeg;base64,/);
73
-
74
- // Higher scale should generally produce larger image (though compression may vary)
75
- expect(resultScale2.length).toBeGreaterThan(0);
76
- expect(resultScale1.length).toBeGreaterThan(0);
77
- }, 15000);
78
-
79
- it('should handle invalid PDF buffer', async () => {
80
- const invalidBuffer = Buffer.from('This is not a PDF');
81
-
82
- await expect(
83
- PDFToImageConverter.convertFirstPageToBase64(invalidBuffer)
84
- ).rejects.toThrow(/PDF to image conversion failed/);
85
- });
86
-
87
- it('should handle empty buffer', async () => {
88
- const emptyBuffer = Buffer.from([]);
89
-
90
- await expect(
91
- PDFToImageConverter.convertFirstPageToBase64(emptyBuffer)
92
- ).rejects.toThrow(/PDF to image conversion failed/);
93
- });
94
- });
95
-
96
- describe('isScannedPDF()', () => {
97
- it('should detect scanned PDF with very little text', () => {
98
- const scannedText = 'abc';
99
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
100
- });
101
-
102
- it('should detect scanned PDF with few words', () => {
103
- const scannedText = 'one two three four';
104
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
105
- });
106
-
107
- it('should detect scanned PDF with high non-alphabetic ratio', () => {
108
- const scannedText = '### %%% $$$ ### %%%';
109
- expect(PDFToImageConverter.isScannedPDF(scannedText)).toBe(true);
110
- });
111
-
112
- it('should not detect normal PDF as scanned', () => {
113
- const normalText = 'This is a normal document with plenty of readable text content that was generated from a text-based PDF file.';
114
- expect(PDFToImageConverter.isScannedPDF(normalText)).toBe(false);
115
- });
116
-
117
- it('should detect empty text as scanned', () => {
118
- const emptyText = '';
119
- expect(PDFToImageConverter.isScannedPDF(emptyText)).toBe(true);
120
- });
121
-
122
- it('should detect whitespace-only text as scanned', () => {
123
- const whitespaceText = ' \n \t ';
124
- expect(PDFToImageConverter.isScannedPDF(whitespaceText)).toBe(true);
125
- });
126
- });
127
- });
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true,
15
- "resolveJsonModule": true,
16
- "allowSyntheticDefaultImports": true
17
- },
18
- "include": ["src/**/*"],
19
- "exclude": ["node_modules", "dist"]
20
- }
package/vitest.config.ts DELETED
@@ -1,30 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
- import path from 'path';
3
-
4
- export default defineConfig({
5
- test: {
6
- globals: true,
7
- environment: 'node',
8
- include: ['tests/**/*.test.{ts,js}'],
9
- exclude: ['node_modules', 'dist'],
10
- coverage: {
11
- provider: 'v8',
12
- include: ['src/**/*.ts'],
13
- exclude: ['src/types/**', 'src/**/*.d.ts'],
14
- reporter: ['text', 'json', 'html'],
15
- thresholds: {
16
- global: {
17
- branches: 80,
18
- functions: 80,
19
- lines: 80,
20
- statements: 80
21
- }
22
- }
23
- }
24
- },
25
- resolve: {
26
- alias: {
27
- '@': path.resolve(__dirname, 'src')
28
- }
29
- }
30
- });