8 Commits

Author SHA1 Message Date
c6964f0310 1.4.5
Some checks failed
Default (tags) / security (push) Failing after 8s
Default (tags) / test (push) Failing after 8s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-04-05 09:05:08 +00:00
9a9f203af2 fix(metadata): Update repository, bugs, and homepage URLs to code.foss.global 2025-04-05 09:05:08 +00:00
174086defc 1.4.4
Some checks failed
Default (tags) / security (push) Failing after 19s
Default (tags) / test (push) Failing after 8s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-04-05 09:02:32 +00:00
43c9d3b3b6 fix(dependencies & tests): Update dependency versions and refine test search query 2025-04-05 09:02:32 +00:00
39724b61d6 1.4.3
Some checks failed
Default (tags) / security (push) Failing after 15s
Default (tags) / test (push) Failing after 14s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-01-07 05:13:13 +01:00
d9588f8f65 fix(test): Corrected index value in test for fetching specific company data 2025-01-07 05:13:13 +01:00
6ce6153ccf 1.4.2
Some checks failed
Default (tags) / security (push) Failing after 17s
Default (tags) / test (push) Failing after 11s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2025-01-07 05:06:17 +01:00
ec2d4f9fbc fix(core): Fix concurrency and download handling in HandelsRegister class and adjust test cases 2025-01-07 05:06:16 +01:00
7 changed files with 1550 additions and 1371 deletions

View File

@ -1,5 +1,32 @@
# Changelog
## 2025-04-05 - 1.4.5 - fix(metadata)
Update repository, bugs, and homepage URLs to code.foss.global
- Repository URL updated from gitlab.com to code.foss.global
- Bugs URL updated from gitlab.com to code.foss.global
- Homepage URL updated to code.foss.global
## 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

View File

@ -1,6 +1,6 @@
{
"name": "@fin.cx/opendata",
"version": "1.4.1",
"version": "1.4.5",
"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,25 +27,25 @@
"@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",
"url": "git+https://gitlab.com/fin.cx/opendata.git"
"url": "https://code.foss.global/fin.cx/opendata.git"
},
"bugs": {
"url": "https://gitlab.com/fin.cx/opendata/issues"
"url": "https://code.foss.global/fin.cx/opendata/issues"
},
"homepage": "https://gitlab.com/fin.cx/opendata#readme",
"homepage": "https://code.foss.global/fin.cx/opendata#readme",
"browserslist": [
"last 1 chrome versions"
],
@ -76,5 +76,6 @@
"data processing",
"data retrieval",
"data update"
]
],
"packageManager": "pnpm@10.7.0+sha512.6b865ad4b62a1d9842b61d674a393903b871d9244954f652b8842c2b553c72176b278f64c463e52d40fff8aba385c235c8c9ecf5cc7de4fd78b8bb6d49633ab6"
}

2797
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -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 () => {

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@fin.cx/opendata',
version: '1.4.1',
version: '1.4.5',
description: 'A TypeScript library for accessing, managing, and updating open business data, focused on German companies and integrating with MongoDB.'
}

View File

@ -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;

View File

@ -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;
}
}