Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
174086defc | |||
43c9d3b3b6 | |||
39724b61d6 | |||
d9588f8f65 | |||
6ce6153ccf | |||
ec2d4f9fbc |
20
changelog.md
20
changelog.md
@ -1,5 +1,25 @@
|
||||
# Changelog
|
||||
|
||||
## 2025-04-05 - 1.4.4 - fix(dependencies & tests)
|
||||
Update dependency versions and refine test search query
|
||||
|
||||
- Bumped versions for several dependencies in package.json, including @git.zone/tsbuild, @git.zone/tsbundle, @git.zone/tstest, @push.rocks/tapbundle, @push.rocks/smartdata, @push.rocks/smartfile, @push.rocks/smartpromise, @push.rocks/smartrequest, and @tsclass/tsclass
|
||||
- Updated test file to replace the search query 'Volkswagen' with 'LADR'
|
||||
- Re-enabled the build initial data test by removing tap.skip
|
||||
|
||||
## 2025-01-07 - 1.4.3 - fix(test)
|
||||
Corrected index value in test for fetching specific company data
|
||||
|
||||
- Updated the index from 8 to 7 for the germanParsedRegistration fetch in test
|
||||
|
||||
## 2025-01-07 - 1.4.2 - fix(core)
|
||||
Fix concurrency and download handling in HandelsRegister class and adjust test cases
|
||||
|
||||
- Improved the clickFindButton function to include an argument for results limit.
|
||||
- Enhanced the downloadFile function to rename and ensure files are correctly handled.
|
||||
- Updated searchCompany method to allow specifying a limit on the number of search results.
|
||||
- Adjusted test cases to select specific test data indices and output test files to a dedicated directory.
|
||||
|
||||
## 2025-01-04 - 1.4.1 - fix(core)
|
||||
Fix issues with JSONL data processing and improve error handling in business record validation
|
||||
|
||||
|
25
package.json
25
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fin.cx/opendata",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.4",
|
||||
"private": false,
|
||||
"description": "A TypeScript library for accessing, managing, and updating open business data, focused on German companies and integrating with MongoDB.",
|
||||
"main": "dist_ts/index.js",
|
||||
@ -14,12 +14,12 @@
|
||||
"buildDocs": "(tsdoc)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@git.zone/tsbuild": "^2.2.0",
|
||||
"@git.zone/tsbundle": "^2.1.0",
|
||||
"@git.zone/tsbuild": "^2.3.2",
|
||||
"@git.zone/tsbundle": "^2.2.5",
|
||||
"@git.zone/tsrun": "^1.3.3",
|
||||
"@git.zone/tstest": "^1.0.90",
|
||||
"@push.rocks/tapbundle": "^5.5.4",
|
||||
"@types/node": "^22.10.4"
|
||||
"@git.zone/tstest": "^1.0.96",
|
||||
"@push.rocks/tapbundle": "^5.6.2",
|
||||
"@types/node": "^22.14.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@push.rocks/lik": "^6.1.0",
|
||||
@ -27,16 +27,16 @@
|
||||
"@push.rocks/smartarchive": "^4.0.39",
|
||||
"@push.rocks/smartarray": "^1.1.0",
|
||||
"@push.rocks/smartbrowser": "^2.0.8",
|
||||
"@push.rocks/smartdata": "^5.2.10",
|
||||
"@push.rocks/smartdata": "^5.2.12",
|
||||
"@push.rocks/smartdelay": "^3.0.5",
|
||||
"@push.rocks/smartfile": "^11.0.23",
|
||||
"@push.rocks/smartfile": "^11.2.0",
|
||||
"@push.rocks/smartpath": "^5.0.18",
|
||||
"@push.rocks/smartpromise": "^4.0.4",
|
||||
"@push.rocks/smartrequest": "^2.0.23",
|
||||
"@push.rocks/smartpromise": "^4.2.3",
|
||||
"@push.rocks/smartrequest": "^2.1.0",
|
||||
"@push.rocks/smartstream": "^3.2.5",
|
||||
"@push.rocks/smartunique": "^3.0.9",
|
||||
"@push.rocks/smartxml": "^1.1.1",
|
||||
"@tsclass/tsclass": "^4.2.0"
|
||||
"@tsclass/tsclass": "^8.2.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@ -76,5 +76,6 @@
|
||||
"data processing",
|
||||
"data retrieval",
|
||||
"data update"
|
||||
]
|
||||
],
|
||||
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
|
||||
}
|
||||
|
2797
pnpm-lock.yaml
generated
2797
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
15
test/test.ts
15
test/test.ts
@ -1,6 +1,11 @@
|
||||
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
||||
|
||||
import { tapNodeTools } from '@push.rocks/tapbundle/node';
|
||||
|
||||
import * as opendata from '../ts/index.js'
|
||||
|
||||
import { BusinessRecord } from '../ts/classes.businessrecord.js';
|
||||
|
||||
let testOpenDataInstance: opendata.OpenData;
|
||||
|
||||
tap.test('first test', async () => {
|
||||
@ -17,17 +22,23 @@ tap.test('should build initial data', async () => {
|
||||
});
|
||||
|
||||
const resultsSearch = tap.test('should get the data for a company', async () => {
|
||||
const result = await testOpenDataInstance.handelsregister.searchCompany('Volkswagen');
|
||||
const result = await testOpenDataInstance.handelsregister.searchCompany('LADR', 20);
|
||||
console.log(result);
|
||||
return result;
|
||||
});
|
||||
|
||||
tap.test('should get the data for a specific company', async () => {
|
||||
const testCompany = (await resultsSearch.testResultPromise)[21]['germanParsedRegistration'];
|
||||
let testCompany: BusinessRecord['data']['germanParsedRegistration'] = (await resultsSearch.testResultPromise)[7]['germanParsedRegistration'];
|
||||
console.log(`trying to find specific company with:`);
|
||||
console.log(testCompany);
|
||||
const result = await testOpenDataInstance.handelsregister.getSpecificCompany(testCompany);
|
||||
console.log(result);
|
||||
|
||||
result.files.map(async (file) => {
|
||||
await file.writeToDir('./.nogit/testoutput');
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
tap.test('should stop the instance', async () => {
|
||||
|
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@fin.cx/opendata',
|
||||
version: '1.4.1',
|
||||
version: '1.4.4',
|
||||
description: 'A TypeScript library for accessing, managing, and updating open business data, focused on German companies and integrating with MongoDB.'
|
||||
}
|
||||
|
@ -5,6 +5,18 @@ export class BusinessRecord extends plugins.smartdata.SmartDataDbDoc<
|
||||
BusinessRecord,
|
||||
BusinessRecord
|
||||
> {
|
||||
// STATIC
|
||||
public static getByGermanParsedRegistration = async (parsedGermanRegistrationArg: BusinessRecord['data']['germanParsedRegistration']) => {
|
||||
const businessRecords = await BusinessRecord.getInstance({
|
||||
data: {
|
||||
germanParsedRegistration: parsedGermanRegistrationArg,
|
||||
}
|
||||
});
|
||||
return businessRecords;
|
||||
};
|
||||
|
||||
|
||||
// INSTANCE
|
||||
@plugins.smartdata.unI()
|
||||
id: string;
|
||||
|
||||
|
@ -113,13 +113,13 @@ export class HandelsRegister {
|
||||
return businessRecords;
|
||||
};
|
||||
|
||||
private clickFindButton = async (pageArg: plugins.smartbrowser.smartpuppeteer.puppeteer.Page) => {
|
||||
private clickFindButton = async (pageArg: plugins.smartbrowser.smartpuppeteer.puppeteer.Page, resultsLimitArg: number = 100) => {
|
||||
try {
|
||||
// Wait for the button with the text "Find" to appear
|
||||
await pageArg.waitForSelector('span.ui-button-text.ui-c', { timeout: 5000 });
|
||||
|
||||
// adjust to 100 results per page
|
||||
await pageArg.select('#form\\:ergebnisseProSeite_input', '100');
|
||||
await pageArg.select('#form\\:ergebnisseProSeite_input', `${resultsLimitArg}`);
|
||||
|
||||
// Locate and click the button using its text
|
||||
await pageArg.evaluate(() => {
|
||||
@ -183,14 +183,24 @@ export class HandelsRegister {
|
||||
}
|
||||
}, typeArg);
|
||||
|
||||
// Wait a bit for the download to complete (you might want to implement
|
||||
// a more robust file-exists check or a wait-for-download library)
|
||||
await pageArg.waitForTimeout(10000);
|
||||
|
||||
await plugins.smartfile.fs.waitForFileToBeReady(this.uniqueDowloadFolder);
|
||||
|
||||
const files = await plugins.smartfile.fs.fileTreeToObject(this.uniqueDowloadFolder, '**/*');
|
||||
await plugins.smartfile.fs.ensureEmptyDir(this.uniqueDowloadFolder);
|
||||
const file = files[0];
|
||||
|
||||
return files [0];
|
||||
// lets clear the folder for the next download
|
||||
await plugins.smartfile.fs.ensureEmptyDir(this.uniqueDowloadFolder);
|
||||
switch (typeArg) {
|
||||
case 'AD':
|
||||
await file.rename(`ad.pdf`);
|
||||
break;
|
||||
case 'SI':
|
||||
await file.rename(`si.xml`);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,7 +226,7 @@ export class HandelsRegister {
|
||||
/**
|
||||
* Search for a company by name and return basic info
|
||||
*/
|
||||
public async searchCompany(companyNameArg: string) {
|
||||
public async searchCompany(companyNameArg: string, resultsLimitArg: number = 100) {
|
||||
return this.asyncExecutionStack.getExclusiveExecutionSlot(async () => {
|
||||
const page = await this.getNewPage();
|
||||
await this.navigateToPage(page, 'Normal search');
|
||||
@ -261,7 +271,7 @@ export class HandelsRegister {
|
||||
console.error('Failed to find or click the radio button:', error);
|
||||
}
|
||||
|
||||
await this.clickFindButton(page);
|
||||
await this.clickFindButton(page, resultsLimitArg);
|
||||
|
||||
const businessRecords = await this.waitForResults(page);
|
||||
|
||||
@ -336,4 +346,13 @@ export class HandelsRegister {
|
||||
};
|
||||
}, 60000);
|
||||
}
|
||||
|
||||
/**
|
||||
* get specific company by full name
|
||||
*/
|
||||
public async getSpecificCompanyByName(companyNameArg: string) {
|
||||
const businessRecords = await this.searchCompany(companyNameArg, 1);
|
||||
const result = this.getSpecificCompany(businessRecords[0].germanParsedRegistration);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user