Skip to content

Commit

Permalink
Move core types to extra package (#254)
Browse files Browse the repository at this point in the history
* feat: introduce new packages

* refactor: update sources

* refactor: update tests

* chore: update content dependencies

* refactor: also move CoreError to @nmshd/core-types

* fix: add references to core-types and utils to transport

* refactor: undo utils extraction

* chore: undo some stuff

* refactor: update references and dependencies

* chore: formatting

* ci: add test for new package

* fix: test issues

* fix: test issues

* refactor: move CoreId generation to CoreIdHelper

* fix: compiler errors

* chore: do not use CoreSerializable anymore

---------

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
jkoenig134 and mergify[bot] committed Aug 28, 2024
1 parent 70d921d commit 15d3e6a
Show file tree
Hide file tree
Showing 403 changed files with 1,439 additions and 1,202 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,25 @@ jobs:
fail_ci_if_error: true
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

test-core-types:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: current
- run: npm ci
env:
BUILD_NUMBER: ${{ github.run_number }}
COMMIT_HASH: ${{ github.sha }}
- run: npm run build:node
- run: npm run test:ci --workspace=@nmshd/core-types
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
env:
fail_ci_if_error: true
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

test-runtime-mongodb:
runs-on: ubuntu-latest
steps:
Expand Down
88 changes: 47 additions & 41 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"license": "MIT",
"author": "j&s-soft GmbH",
"workspaces": [
"packages/core-types",
"packages/transport",
"packages/content",
"packages/consumption",
Expand Down
14 changes: 6 additions & 8 deletions packages/app-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
"test:ci": "jest -i --forceExit --coverage"
},
"jest": {
"maxWorkers": 5,
"preset": "ts-jest",
"collectCoverageFrom": [
"./src/**"
],
"coverageProvider": "v8",
"coverageReporters": [
"text-summary",
"cobertura",
"lcov"
],
"collectCoverageFrom": [
"./src/**"
],
"maxWorkers": 5,
"preset": "ts-jest",
"setupFilesAfterEnv": [
"jest-expect-message"
],
Expand All @@ -52,6 +52,7 @@
},
"dependencies": {
"@js-soft/docdb-access-loki": "^1.1.0",
"@nmshd/runtime": "*",
"lodash": "^4.17.21"
},
"devDependencies": {
Expand All @@ -60,9 +61,6 @@
"@types/lokijs": "^1.5.14",
"@types/luxon": "^3.4.2"
},
"peerDependencies": {
"@nmshd/runtime": "*"
},
"publishConfig": {
"access": "public",
"provenance": true
Expand Down
3 changes: 2 additions & 1 deletion packages/app-runtime/src/AppRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions";
import { LokiJsConnection } from "@js-soft/docdb-access-loki";
import { Result } from "@js-soft/ts-utils";
import { ConsumptionController } from "@nmshd/consumption";
import { CoreId, ICoreAddress } from "@nmshd/core-types";
import { ModuleConfiguration, Runtime, RuntimeHealth } from "@nmshd/runtime";
import { AccountController, CoreId, ICoreAddress } from "@nmshd/transport";
import { AccountController } from "@nmshd/transport";
import { AppConfig, AppConfigOverwrite, createAppConfig } from "./AppConfig";
import { AppRuntimeErrors } from "./AppRuntimeErrors";
import { AppRuntimeServices } from "./AppRuntimeServices";
Expand Down
3 changes: 2 additions & 1 deletion packages/app-runtime/src/AppStringProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ILogger, ILoggerFactory } from "@js-soft/logging-abstractions";
import { Serializable } from "@js-soft/ts-serval";
import { EventBus, Result } from "@js-soft/ts-utils";
import { ICoreAddress } from "@nmshd/core-types";
import { AnonymousServices, Base64ForIdPrefix, DeviceMapper } from "@nmshd/runtime";
import { ICoreAddress, TokenContentDeviceSharedSecret } from "@nmshd/transport";
import { TokenContentDeviceSharedSecret } from "@nmshd/transport";
import { AppRuntimeErrors } from "./AppRuntimeErrors";
import { AppRuntimeServices } from "./AppRuntimeServices";
import { IUIBridge } from "./extensibility";
Expand Down
2 changes: 1 addition & 1 deletion packages/app-runtime/src/multiAccount/AccountServices.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CoreId } from "@nmshd/core-types";
import { DeviceMapper, DeviceOnboardingInfoDTO } from "@nmshd/runtime";
import { CoreId } from "@nmshd/transport";
import { MultiAccountController } from "./MultiAccountController";
import { LocalAccountDTO } from "./data/LocalAccountDTO";
import { LocalAccountMapper } from "./data/LocalAccountMapper";
Expand Down
17 changes: 4 additions & 13 deletions packages/app-runtime/src/multiAccount/MultiAccountController.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
import { IDatabaseCollection, IDatabaseCollectionProvider } from "@js-soft/docdb-access-abstractions";
import { LokiJsConnection } from "@js-soft/docdb-access-loki";
import { ILogger } from "@js-soft/logging-abstractions";
import {
AccountController,
CoreAddress,
CoreDate,
CoreError,
CoreId,
DeviceSharedSecret,
Transport,
CoreErrors as TransportCoreErrors,
TransportLoggerFactory
} from "@nmshd/transport";
import { CoreAddress, CoreDate, CoreError, CoreId } from "@nmshd/core-types";
import { AccountController, CoreIdHelper, DeviceSharedSecret, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport";
import { AppConfig } from "../AppConfig";
import { SessionStorage } from "../SessionStorage";
import { LocalAccount } from "./data/LocalAccount";
Expand Down Expand Up @@ -155,7 +146,7 @@ export class MultiAccountController {

this._log.trace(`Onboarding device ${deviceSharedSecret.id} for identity ${deviceSharedSecret.identity.address}...`);

const id = await CoreId.generate();
const id = await CoreIdHelper.notPrefixed.generate();

const localAccount = LocalAccount.from({
id,
Expand Down Expand Up @@ -184,7 +175,7 @@ export class MultiAccountController {
}

public async createAccount(name: string): Promise<[LocalAccount, AccountController]> {
const id = await CoreId.generate();
const id = await CoreIdHelper.notPrefixed.generate();

let localAccount = LocalAccount.from({
id,
Expand Down
8 changes: 4 additions & 4 deletions packages/app-runtime/src/multiAccount/data/LocalAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { serialize, type, validate } from "@js-soft/ts-serval";
import { CoreAddress, CoreDate, CoreId, CoreSerializable, ICoreDate, ICoreSerializable } from "@nmshd/transport";
import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval";
import { CoreAddress, CoreDate, CoreId, ICoreDate } from "@nmshd/core-types";

export interface ILocalAccount extends ICoreSerializable {
export interface ILocalAccount extends ISerializable {
id: CoreId;
address?: CoreAddress;
name: string;
Expand All @@ -12,7 +12,7 @@ export interface ILocalAccount extends ICoreSerializable {
}

@type("LocalAccount")
export class LocalAccount extends CoreSerializable implements ILocalAccount {
export class LocalAccount extends Serializable implements ILocalAccount {
@validate()
@serialize()
public id: CoreId;
Expand Down
Loading

0 comments on commit 15d3e6a

Please sign in to comment.