10 Commits

Author SHA1 Message Date
b67e18f2fe 1.1.4
Some checks failed
Default (tags) / security (push) Failing after 12s
Default (tags) / test (push) Failing after 11s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-12-31 19:58:18 +01:00
09c9712191 fix(documentation): Update description and keywords in package.json 2024-12-31 19:58:18 +01:00
6258dcdff1 1.1.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
2024-12-31 19:54:32 +01:00
605b050177 fix(core): Added missing license file for project completeness. 2024-12-31 19:54:32 +01:00
c97c8e711a 1.1.2
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
2024-12-31 19:49:12 +01:00
d5654a7bc7 fix(GermanBusinessData): Ensure unique ID generation for BusinessRecord 2024-12-31 19:49:12 +01:00
c91439ab6b 1.1.1
Some checks failed
Default (tags) / security (push) Failing after 15s
Default (tags) / test (push) Failing after 11s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-12-31 17:38:36 +01:00
ad0c6a4112 fix(dependencies): Update dependencies and devDependencies to newer versions. 2024-12-31 17:38:36 +01:00
dd110a198d 1.1.0
Some checks failed
Default (tags) / security (push) Failing after 15s
Default (tags) / test (push) Failing after 12s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
2024-12-31 14:43:08 +01:00
c30fc40e06 feat(core): Enhanced data handling and retrieval features, improved usage documentation 2024-12-31 14:43:08 +01:00
9 changed files with 8038 additions and 5250 deletions

View File

@ -1,5 +1,48 @@
# Changelog
## 2024-12-31 - 1.1.4 - fix(documentation)
Update description and keywords in package.json
- Corrected the package description to reflect the focus on managing, accessing, and updating open data with MongoDB integration.
- Expanded the keywords in the package metadata to include data integration and processing terms.
- Improved README.md with more extensive setup, usage, and introduction of the library's functionalities.
## 2024-12-31 - 1.1.3 - fix(core)
Added missing license file for project completeness.
- Introduced a LICENSE file to the project, ensuring clarity on software usage permissions.
## 2024-12-31 - 1.1.2 - fix(GermanBusinessData)
Ensure unique ID generation for BusinessRecord
- Added generation of a new ID for each BusinessRecord in GermanBusinessData.
- Ensures each business record has a unique identifier.
## 2024-12-31 - 1.1.1 - fix(dependencies)
Update dependencies and devDependencies to newer versions.
- @git.zone/tsbuild from ^2.1.25 to ^2.2.0
- @git.zone/tsbundle from ^2.0.5 to ^2.1.0
- @git.zone/tsrun from ^1.2.46 to ^1.3.3
- @git.zone/tstest from ^1.0.84 to ^1.0.90
- @push.rocks/tapbundle from ^5.0.15 to ^5.5.4
- @types/node from ^20.9.0 to ^22.10.2
- @push.rocks/qenv from ^6.0.4 to ^6.1.0
- @push.rocks/smartarchive from ^4.0.19 to ^4.0.39
- @push.rocks/smartdata from ^5.0.33 to ^5.2.10
- @push.rocks/smartfile from ^11.0.0 to ^11.0.23
- @push.rocks/smartpath from ^5.0.11 to ^5.0.18
- @push.rocks/smartpromise from ^4.0.3 to ^4.0.4
- @push.rocks/smartrequest from ^2.0.21 to ^2.0.23
- @push.rocks/smartstream from ^3.0.30 to ^3.2.5
## 2024-12-31 - 1.1.0 - feat(core)
Enhanced data handling and retrieval features, improved usage documentation
- Updated package description and added project keywords in package.json.
- Extended readme with detailed usage examples and class structures.
- Added getBusinessRecordByName function for dynamic business record retrieval.
## 2024-07-02 - 1.0.3 - fix(core)
No new changes detected. Preparing for patch release.

19
license Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2022 Task Venture Capital GmbH (hello@task.vc)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -5,10 +5,26 @@
"githost": "gitlab.com",
"gitscope": "fin.cx",
"gitrepo": "opendata",
"description": "open business data",
"description": "A TypeScript library for accessing, managing, and updating open business data, focused on German companies and integrating with MongoDB.",
"npmPackagename": "@fin.cx/opendata",
"license": "MIT",
"projectDomain": "fin.cx"
"projectDomain": "fin.cx",
"keywords": [
"TypeScript",
"open data",
"business data",
"German companies",
"data management",
"business registry",
"npm package",
"MongoDB",
"automation",
"data integration",
"database",
"data processing",
"data retrieval",
"data update"
]
}
},
"npmci": {

View File

@ -1,8 +1,8 @@
{
"name": "@fin.cx/opendata",
"version": "1.0.3",
"version": "1.1.4",
"private": false,
"description": "open business data",
"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",
"typings": "dist_ts/index.d.ts",
"type": "module",
@ -14,23 +14,23 @@
"buildDocs": "(tsdoc)"
},
"devDependencies": {
"@git.zone/tsbuild": "^2.1.25",
"@git.zone/tsbundle": "^2.0.5",
"@git.zone/tsrun": "^1.2.46",
"@git.zone/tstest": "^1.0.84",
"@push.rocks/tapbundle": "^5.0.15",
"@types/node": "^20.9.0"
"@git.zone/tsbuild": "^2.2.0",
"@git.zone/tsbundle": "^2.1.0",
"@git.zone/tsrun": "^1.3.3",
"@git.zone/tstest": "^1.0.90",
"@push.rocks/tapbundle": "^5.5.4",
"@types/node": "^22.10.2"
},
"dependencies": {
"@push.rocks/qenv": "^6.0.4",
"@push.rocks/smartarchive": "^4.0.19",
"@push.rocks/smartdata": "^5.0.33",
"@push.rocks/qenv": "^6.1.0",
"@push.rocks/smartarchive": "^4.0.39",
"@push.rocks/smartdata": "^5.2.10",
"@push.rocks/smartdelay": "^3.0.5",
"@push.rocks/smartfile": "^11.0.0",
"@push.rocks/smartpath": "^5.0.11",
"@push.rocks/smartpromise": "^4.0.3",
"@push.rocks/smartrequest": "^2.0.21",
"@push.rocks/smartstream": "^3.0.30"
"@push.rocks/smartfile": "^11.0.23",
"@push.rocks/smartpath": "^5.0.18",
"@push.rocks/smartpromise": "^4.0.4",
"@push.rocks/smartrequest": "^2.0.23",
"@push.rocks/smartstream": "^3.2.5"
},
"repository": {
"type": "git",
@ -54,5 +54,21 @@
"cli.js",
"npmextra.json",
"readme.md"
],
"keywords": [
"TypeScript",
"open data",
"business data",
"German companies",
"data management",
"business registry",
"npm package",
"MongoDB",
"automation",
"data integration",
"database",
"data processing",
"data retrieval",
"data update"
]
}

12869
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

235
readme.md
View File

@ -1,31 +1,218 @@
# @fin.cx/opendata
open business data
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@fin.cx/opendata)
* [gitlab.com (source)](https://gitlab.com/fin.cx/opendata)
* [github.com (source mirror)](https://github.com/fin.cx/opendata)
* [docs (typedoc)](https://fin.cx.gitlab.io/opendata/)
A TypeScript-based library for accessing and managing open business data, specifically for German companies.
## Status for master
## Install
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/fin.cx/opendata/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/fin.cx/opendata/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@fin.cx/opendata)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/fin.cx/opendata)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@fin.cx/opendata)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@fin.cx/opendata)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@fin.cx/opendata)](https://lossless.cloud)
To install the `@fin.cx/opendata` package, you can use npm or yarn as your package manager. Here's how you can do it:
Using npm:
```bash
npm install @fin.cx/opendata
```
Using yarn:
```bash
yarn add @fin.cx/opendata
```
## Usage
Use TypeScript for best in class intellisense
For further information read the linked docs at the top of this readme.
## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
The `@fin.cx/opendata` package provides a comprehensive set of functionalities for handling open business data, focusing on German business data. Let's explore the detailed capabilities of this library through extensive examples and instructions.
### Setting Up the Environment
First, make sure you've set up the necessary environment variables for MongoDB. You will need the following environment variables:
- `MONGODB_URL`: The URL for your MongoDB instance.
- `MONGODB_NAME`: The name of the database to use.
- `MONGODB_USER`: A valid username for accessing the database.
- `MONGODB_PASS`: The password associated with the MongoDB user.
These variables can be configured in a `.env` file or managed through a specific service used for secure environment variables handling.
### Importing and Initializing the Library
To start working with the library, import the necessary classes and initialize the `OpenData` class.
```typescript
import { OpenData } from '@fin.cx/opendata';
const initializeOpenData = async () => {
const openData = new OpenData();
try {
await openData.start();
console.log('OpenData instance has started successfully.');
// Example usage:
await createAndManageBusinessRecords(openData);
} catch (error) {
console.error('Error starting OpenData:', error);
} finally {
await openData.stop();
console.log('OpenData instance has stopped.');
}
};
initializeOpenData();
```
### Managing Business Records
The `BusinessRecord` class represents a company's data. Let's explore how you can create, retrieve, update, and manage these records.
#### Creating a New BusinessRecord
Creating a new business record involves instantiating the `BusinessRecord` class and setting the relevant properties.
```typescript
import { BusinessRecord } from '@fin.cx/opendata';
const createBusinessRecord = async (openData: OpenData) => {
const businessRecord = new openData.CBusinessRecord();
businessRecord.data = {
name: "Tech Innovations GmbH",
address: "Tech Park 42",
postalCode: "80333",
city: "Munich",
country: "Germany",
phone: "+49 89 123456",
email: "info@techinnovations.de",
website: "https://techinnovations.de",
businessType: "GmbH",
registrationNumber: "HRB 654321",
registrationCourt: "Munich",
legalForm: "GmbH",
managingDirectors: ["Alice Müller", "Bob Schmidt"],
foundingDate: new Date("2020-01-01").toISOString(),
capital: "100,000 EUR",
purpose: "Developing innovative tech solutions",
lastUpdate: new Date().toISOString()
};
await businessRecord.save();
console.log('BusinessRecord saved:', businessRecord);
};
```
#### Retrieving Business Records
You can retrieve existing business records by querying the database using various data fields.
```typescript
const retrieveBusinessRecords = async (openData: OpenData) => {
const records = await openData.db
.collection<BusinessRecord>('businessrecords')
.find({ city: "Munich" })
.toArray();
console.log('Found Business Records:', records);
};
```
#### Updating Existing Records
To update an existing `BusinessRecord`, you retrieve the record, modify its data, and save it again.
```typescript
const updateBusinessRecord = async (openData: OpenData, recordId: string) => {
const businessRecord = await openData.CBusinessRecord.getInstance(recordId);
if (businessRecord) {
businessRecord.data.phone = "+49 89 987654";
businessRecord.data.lastUpdate = new Date().toISOString();
await businessRecord.save();
console.log('BusinessRecord updated:', businessRecord);
} else {
console.log('BusinessRecord not found for id:', recordId);
}
};
```
#### Deleting a Business Record
You can delete a business record using its unique identifier.
```typescript
const deleteBusinessRecord = async (openData: OpenData, recordId: string) => {
const businessRecord = await openData.CBusinessRecord.getInstance(recordId);
if (businessRecord) {
await businessRecord.delete();
console.log(`BusinessRecord with id ${recordId} deleted successfully.`);
} else {
console.log('No record found for the provided id:', recordId);
}
};
```
### Updating German Business Data
The package includes functionalities to keep your business data up-to-date by downloading from official German open data repositories.
```typescript
const updateGermanBusinessData = async (openData: OpenData) => {
try {
await openData.germanBusinesses.update();
console.log('German business data has been updated successfully.');
} catch (error) {
console.error('Error updating German business data:', error);
}
};
```
This function fetches the latest open data regarding German companies, processes it, and updates your local database.
### Detailed Class Insights
#### OpenData Class
The `OpenData` class serves as the core of the library, initializing necessary components and controlling data flows:
- **db**: Represents the connection to your MongoDB database.
- **germanBusinesses**: An instance handling specific operations related to German business data updates.
```typescript
class OpenData {
db: plugins.smartdata.SmartdataDb;
germanBusinesses: GermanBusinessData;
private serviceQenv = new plugins.qenv.Qenv(paths.packageDir, paths.nogitDir);
public async start() {
// Database initialization logic
}
public async stop() {
// Cleanup logic
}
}
```
#### GermanBusinessData Class
This class deals specifically with German company data — fetching, processing, and updating local databases consistently with official German data sources.
```typescript
class GermanBusinessData {
public async start() {
await this.update();
}
public async update() {
// Logic for updating business data using import streams and parsing JSON lines.
}
}
```
### Ensuring Data Accuracy and Integrity
When working with business data, ensuring integrity and accuracy is crucial. Each record should be checked for validity before being saved or updated, minimizing inconsistencies. Moreover, robust error handling is essential in every step, from data retrieval to database operations, particularly when dealing with external data sources.
The `@fin.cx/opendata` module provides an extensive toolset for accessing and managing business data, particularly for companies based in Germany. Its functionalities include creating, updating, retrieving, and deleting business records, as well as keeping them current with the latest open data releases. This makes it an invaluable asset for developers aiming to integrate open data seamlessly into their systems, ensuring robust data management capabilities within their applications.
Happy exploring and integrating open data into your projects!
undefined

View File

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

View File

@ -2,6 +2,10 @@ import * as plugins from './plugins.js';
@plugins.smartdata.Manager()
export class BusinessRecord extends plugins.smartdata.SmartDataDbDoc<BusinessRecord, BusinessRecord> {
@plugins.smartdata.unI()
id: string;
@plugins.smartdata.svDb()
data: {
name?: string,

View File

@ -57,6 +57,7 @@ export class GermanBusinessData {
totalRecordsCounter++;
if (totalRecordsCounter % 10000 === 0) console.log(`${totalRecordsCounter} total records.`);
const businessRecord = new this.openDataRef.CBusinessRecord();
businessRecord.id = await this.openDataRef.CBusinessRecord.getNewId();
businessRecord.data.name = entry.name;
await businessRecord.save();
// console.log(`stored ${businessRecord.data.name}`);
@ -72,4 +73,13 @@ export class GermanBusinessData {
})
);
}
public async getBusinessRecordByName(nameArg: string) {
const businessRecord = await this.openDataRef.CBusinessRecord.getInstance({
data: {
name: { $regex: `${nameArg}`, $options: "i" } as any,
}
});
return businessRecord;
}
}