From d90cb4dabcfcbde924ae1c2e204c67fee5924346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:14:16 +0200 Subject: [PATCH 01/16] feat: introduce new packages --- package-lock.json | 27 +++ package.json | 2 + packages/core-types/.gitignore | 12 ++ packages/core-types/package.json | 63 ++++++ packages/core-types/src/CoreAddress.ts | 43 +++++ packages/core-types/src/CoreDate.ts | 170 +++++++++++++++++ packages/core-types/src/CoreError.ts | 1 + packages/core-types/src/CoreHash.ts | 69 +++++++ packages/core-types/src/CoreId.ts | 51 +++++ packages/core-types/src/CoreSerializable.ts | 30 +++ packages/core-types/src/index.ts | 5 + packages/core-types/test/Date.test.ts | 76 ++++++++ packages/core-types/test/tsconfig.json | 11 ++ packages/core-types/tsconfig.json | 10 + packages/utils/.gitignore | 12 ++ packages/utils/package.json | 57 ++++++ packages/utils/src/PasswordGenerator.ts | 180 ++++++++++++++++++ packages/utils/src/Random.ts | 157 +++++++++++++++ packages/utils/src/index.ts | 2 + packages/utils/test/PasswordGenerator.test.ts | 64 +++++++ packages/utils/test/Random.test.ts | 150 +++++++++++++++ packages/utils/test/tsconfig.json | 11 ++ packages/utils/tsconfig.json | 9 + 23 files changed, 1212 insertions(+) create mode 100644 packages/core-types/.gitignore create mode 100644 packages/core-types/package.json create mode 100644 packages/core-types/src/CoreAddress.ts create mode 100644 packages/core-types/src/CoreDate.ts create mode 100644 packages/core-types/src/CoreError.ts create mode 100644 packages/core-types/src/CoreHash.ts create mode 100644 packages/core-types/src/CoreId.ts create mode 100644 packages/core-types/src/CoreSerializable.ts create mode 100644 packages/core-types/src/index.ts create mode 100644 packages/core-types/test/Date.test.ts create mode 100644 packages/core-types/test/tsconfig.json create mode 100644 packages/core-types/tsconfig.json create mode 100644 packages/utils/.gitignore create mode 100644 packages/utils/package.json create mode 100644 packages/utils/src/PasswordGenerator.ts create mode 100644 packages/utils/src/Random.ts create mode 100644 packages/utils/src/index.ts create mode 100644 packages/utils/test/PasswordGenerator.test.ts create mode 100644 packages/utils/test/Random.test.ts create mode 100644 packages/utils/test/tsconfig.json create mode 100644 packages/utils/tsconfig.json diff --git a/package-lock.json b/package-lock.json index c3a6f6649..fc6d883b5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,8 @@ "name": "monorepo", "license": "MIT", "workspaces": [ + "packages/utils", + "packages/core-types", "packages/transport", "packages/content", "packages/consumption", @@ -1370,6 +1372,10 @@ "resolved": "packages/content", "link": true }, + "node_modules/@nmshd/core-types": { + "resolved": "packages/core-types", + "link": true + }, "node_modules/@nmshd/crypto": { "version": "2.0.6", "license": "MIT", @@ -1404,6 +1410,10 @@ "resolved": "packages/transport", "link": true }, + "node_modules/@nmshd/utils": { + "resolved": "packages/utils", + "link": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -9347,6 +9357,18 @@ "@types/luxon": "^3.4.2" } }, + "packages/core-types": { + "name": "@nmshd/core-types", + "license": "MIT", + "dependencies": { + "@js-soft/ts-serval": "2.0.10", + "@nmshd/utils": "*", + "luxon": "^3.5.0" + }, + "devDependencies": { + "@types/luxon": "^3.4.2" + } + }, "packages/runtime": { "name": "@nmshd/runtime", "license": "MIT", @@ -9423,6 +9445,11 @@ "expect": "^29.7.0", "ts-mockito": "^2.6.1" } + }, + "packages/utils": { + "name": "@nmshd/utils", + "license": "MIT", + "devDependencies": {} } } } diff --git a/package.json b/package.json index 6b7235180..83825dfc5 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,8 @@ "license": "MIT", "author": "j&s-soft GmbH", "workspaces": [ + "packages/utils", + "packages/core-types", "packages/transport", "packages/content", "packages/consumption", diff --git a/packages/core-types/.gitignore b/packages/core-types/.gitignore new file mode 100644 index 000000000..586efae9b --- /dev/null +++ b/packages/core-types/.gitignore @@ -0,0 +1,12 @@ +node_modules +tmp-browser +dist-test +lib-web +dist +docs +*.log +*.log.* +_archive +.idea +coverage +.nyc_output diff --git a/packages/core-types/package.json b/packages/core-types/package.json new file mode 100644 index 000000000..55614a78c --- /dev/null +++ b/packages/core-types/package.json @@ -0,0 +1,63 @@ +{ + "name": "@nmshd/core-types", + "description": "The enmeshed core types.", + "homepage": "https://enmeshed.eu", + "repository": { + "type": "git", + "url": "git+https://github.com/nmshd/runtime.git", + "directory": "packages/runtime" + }, + "license": "MIT", + "author": "j&s-soft GmbH", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc", + "build:ci": "tsc", + "cdep": "tsc && madge --circular dist", + "lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit", + "test": "jest -i", + "test:ci": "jest -i --coverage" + }, + "jest": { + "maxWorkers": 1, + "preset": "ts-jest", + "coverageProvider": "v8", + "coverageReporters": [ + "text-summary", + "cobertura", + "lcov" + ], + "collectCoverageFrom": [ + "./src/**" + ], + "setupFilesAfterEnv": [ + "jest-expect-message" + ], + "testEnvironment": "node", + "testTimeout": 60000, + "transform": { + "^.+\\.ts$": [ + "ts-jest", + { + "tsconfig": "test/tsconfig.json" + } + ] + } + }, + "dependencies": { + "@js-soft/ts-serval": "2.0.10", + "@nmshd/utils": "*", + "luxon": "^3.5.0" + }, + "devDependencies": { + "@types/luxon": "^3.4.2" + }, + "publishConfig": { + "access": "public", + "provenance": true + } +} diff --git a/packages/core-types/src/CoreAddress.ts b/packages/core-types/src/CoreAddress.ts new file mode 100644 index 000000000..f79320c68 --- /dev/null +++ b/packages/core-types/src/CoreAddress.ts @@ -0,0 +1,43 @@ +import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; +import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; + +export interface ICoreAddress extends ICoreSerializable { + address: string; +} + +/** + * A CoreAddress is the primariy technical identitier of an account. + */ +@type("CoreAddress") +@serializeOnly("address", "string") +export class CoreAddress extends CoreSerializable { + @validate() + @serialize() + public address: string; + + protected static override preFrom(value: any): any { + if (typeof value === "string") { + return { address: value }; + } + + return value; + } + + public static from(value: ICoreAddress | string): CoreAddress { + return this.fromAny(value); + } + + public equals(address?: CoreAddress | string): boolean { + if (address === undefined) return false; + + return this.address === address.toString(); + } + + public override toString(): string { + return this.address; + } + + public override serialize(): string { + return this.address; + } +} diff --git a/packages/core-types/src/CoreDate.ts b/packages/core-types/src/CoreDate.ts new file mode 100644 index 000000000..faae8a5b4 --- /dev/null +++ b/packages/core-types/src/CoreDate.ts @@ -0,0 +1,170 @@ +import { type } from "@js-soft/ts-serval"; +import { DateTime, DateTimeUnit, Duration, DurationLike, Interval } from "luxon"; +import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; + +export interface ICoreDate extends ICoreSerializable { + date: string; +} + +@type("CoreDate") +export class CoreDate extends CoreSerializable { + private readonly _dateTime: DateTime; + public get dateTime(): DateTime { + return this._dateTime; + } + + public get date(): string { + return this.asValidDateTime.toISODate(); + } + + public constructor(dateTime: DateTime = DateTime.utc()) { + super(); + this._dateTime = dateTime; + } + + public static utc(): CoreDate { + return new CoreDate(DateTime.utc()); + } + + public static local(): CoreDate { + return new CoreDate(DateTime.local()); + } + + public equals(another: CoreDate): boolean { + return this.dateTime.equals(another.dateTime); + } + + public add(amount: number | Duration | DurationLike): CoreDate { + return new CoreDate(this.dateTime.plus(amount)); + } + + public subtract(amount: number | Duration | DurationLike): CoreDate { + return new CoreDate(this.dateTime.minus(amount)); + } + + public startOf(unitOfTime: DateTimeUnit): CoreDate { + return new CoreDate(this.dateTime.startOf(unitOfTime)); + } + + public endOf(unitOfTime: DateTimeUnit): CoreDate { + return new CoreDate(this.dateTime.endOf(unitOfTime)); + } + + public format(format: string): string { + return this.dateTime.toFormat(format); + } + + public isWithin(rangeMinusOrBoth: number | Duration | DurationLike, rangePlus?: number | Duration | DurationLike, other?: CoreDate, granularity?: DateTimeUnit): boolean { + if (!rangePlus) rangePlus = rangeMinusOrBoth; + + if (!other) other = CoreDate.utc(); + + const start = other.subtract(rangeMinusOrBoth); + const end = other.add(rangePlus); + + if (granularity) { + return this.dateTime.startOf(granularity) > start.dateTime.startOf(granularity) && this.dateTime.startOf(granularity) < end.dateTime.startOf(granularity); + } + + return this.dateTime > start.dateTime && this.dateTime < end.dateTime; + } + + public isBefore(other: CoreDate, granularity?: DateTimeUnit): boolean { + if (granularity) return this.dateTime.startOf(granularity) < other.dateTime.startOf(granularity); + + return this.dateTime < other.dateTime; + } + + public isAfter(other: CoreDate, granularity?: DateTimeUnit): boolean { + if (granularity) return this.dateTime.startOf(granularity) > other.dateTime.startOf(granularity); + + return this.dateTime > other.dateTime; + } + + public isSame(other: CoreDate, granularity?: DateTimeUnit): boolean { + if (granularity) return this.dateTime.startOf(granularity).valueOf() === other.dateTime.startOf(granularity).valueOf(); + + return this.dateTime.valueOf() === other.dateTime.valueOf(); + } + + public isSameOrAfter(other: CoreDate, granularity?: DateTimeUnit): boolean { + if (granularity) return this.dateTime.startOf(granularity) >= other.dateTime.startOf(granularity); + + return this.dateTime >= other.dateTime; + } + + public isSameOrBefore(other: CoreDate, granularity?: DateTimeUnit): boolean { + if (granularity) return this.dateTime.startOf(granularity) <= other.dateTime.startOf(granularity); + + return this.dateTime <= other.dateTime; + } + + public isBetween(start: CoreDate, end?: CoreDate, granularity?: DateTimeUnit): boolean { + if (!end) return this.isAfter(start, granularity); + + return Interval.fromDateTimes(start.dateTime, end.dateTime).contains(this.dateTime); + } + + public isExpired(): boolean { + return this.isSameOrBefore(CoreDate.utc()); + } + + public compare(comparator: CoreDate): number { + return this.dateTime.valueOf() - comparator.dateTime.valueOf(); + } + + /** + * Creates an ISO String. + */ + public override toString(): string { + return this.asValidDateTime.toISO(); + } + + public toISOString(): string { + return this.asValidDateTime.toISO(); + } + + public override toLocaleString(): string { + return this.dateTime.toLocaleString(); + } + + public override toJSON(): string { + return this.asValidDateTime.toISO(); + } + + public override serialize(): string { + return this.asValidDateTime.toISO(); + } + + private get asValidDateTime(): DateTime { + if (!this.dateTime.isValid) throw new Error("The date is invalid."); + return this.dateTime as DateTime; + } + + protected static override preFrom(value: any): any { + if (!value) throw new Error("The provided object is undefined and cannot be deserialized."); + + if (typeof value === "object") { + if (!value.date) { + if (typeof value.toISOString !== "function") { + throw new Error("The provided object doesn't have an 'toISOString' string method."); + } + + const iso = value.toISOString(); + return DateTime.fromISO(iso, { zone: "utc" }); + } + + return DateTime.fromISO(value.date, { zone: "utc" }); + } + + if (typeof value === "number") return DateTime.fromMillis(value); + + if (typeof value === "string") return DateTime.fromISO(value, { zone: "utc" }).toUTC(); + + throw new Error("The provided object is invalid and cannot be deserialized."); + } + + public static from(value: ICoreDate | string | number): CoreDate { + return this.fromAny(value); + } +} diff --git a/packages/core-types/src/CoreError.ts b/packages/core-types/src/CoreError.ts new file mode 100644 index 000000000..5d3a650a9 --- /dev/null +++ b/packages/core-types/src/CoreError.ts @@ -0,0 +1 @@ +export class CoreError extends Error {} diff --git a/packages/core-types/src/CoreHash.ts b/packages/core-types/src/CoreHash.ts new file mode 100644 index 000000000..7a0da300f --- /dev/null +++ b/packages/core-types/src/CoreHash.ts @@ -0,0 +1,69 @@ +import { serialize, serializeOnly, validate } from "@js-soft/ts-serval"; +import { CoreBuffer, CryptoHash, CryptoHashAlgorithm, Encoding, ICoreBuffer } from "@nmshd/crypto"; +import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; + +export interface ICoreHash extends ICoreSerializable { + hash: string; +} + +/** + * Hash wraps a hash + */ +@serializeOnly("hash", "string") +export class CoreHash extends CoreSerializable { + @validate() + @serialize() + public hash: string; + + public override toString(): string { + return this.hash; + } + + /** + * Creates a new hash of the given content + * + * @param content A String object of the content which should be hashed + * @param algorithm The CryptoHashAlgorithm, defaults to SHA512 + * @returns A Promise resolving to the Hash object + */ + public static async hash(content: string, algorithm: CryptoHashAlgorithm = CryptoHashAlgorithm.SHA512): Promise { + const hash = await CryptoHash.hash(CoreBuffer.fromString(content, Encoding.Base64_UrlSafe_NoPadding), algorithm); + return CoreHash.from(hash.toBase64()); + } + + /** + * Verifies if the given content is creating the underlying hash with the + * given hash algorithm. + * + * @param content A Buffer object of the content which should be equal to the hash + * @param algorithm The CryptoHashAlgorithm, defaults to SHA512 + * @returns A Promise resolving to true if the content equals to the hash, or false otherwise + */ + public async verify(content: ICoreBuffer, algorithm: CryptoHashAlgorithm = CryptoHashAlgorithm.SHA512): Promise { + return await CryptoHash.verify(content, CoreBuffer.fromString(this.hash, Encoding.Base64_UrlSafe_NoPadding), algorithm); + } + + protected static override preFrom(value: any): any { + if (typeof value === "string") { + return { hash: value }; + } + + return value; + } + + /** + * Creates a new Hash object from a given IHash or a string + * @param value Hash, IHash or string + */ + public static from(value: ICoreHash | string): CoreHash { + return this.fromAny(value); + } + + public override serialize(): string { + return this.hash; + } + + public override toBase64(): string { + return this.hash; + } +} diff --git a/packages/core-types/src/CoreId.ts b/packages/core-types/src/CoreId.ts new file mode 100644 index 000000000..a10da0ae5 --- /dev/null +++ b/packages/core-types/src/CoreId.ts @@ -0,0 +1,51 @@ +import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; +import { Random, RandomCharacterRange } from "@nmshd/utils"; +import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; + +export interface ICoreId extends ICoreSerializable { + id: string; +} + +/** + * A CoreId is any kind of identifier we have in the system. + */ +@type("CoreId") +@serializeOnly("id", "string") +export class CoreId extends CoreSerializable implements ICoreId { + @validate() + @serialize() + public id: string; + + public override toString(): string { + return this.id; + } + + public equals(id: CoreId | string): boolean { + return this.id === id.toString(); + } + + public static async generate(prefix = ""): Promise { + if (prefix.length > 6) { + throw new Error(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`); + } + + const random = await Random.string(20 - prefix.length, RandomCharacterRange.Alphanumeric); + return this.from(prefix.toUpperCase() + random); + } + + public static from(value: ICoreId | string): CoreId { + return this.fromAny(value); + } + + protected static override preFrom(value: any): any { + if (typeof value === "string") { + return { id: value }; + } + + return value; + } + + public override serialize(): string { + return this.id; + } +} diff --git a/packages/core-types/src/CoreSerializable.ts b/packages/core-types/src/CoreSerializable.ts new file mode 100644 index 000000000..57e032f75 --- /dev/null +++ b/packages/core-types/src/CoreSerializable.ts @@ -0,0 +1,30 @@ +import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; +import { CoreBuffer } from "@nmshd/crypto"; + +export interface ICoreSerializable extends ISerializable {} + +/** + * CoreSerializable is the local pendant of the Serializable class which + * automatically validates, serializes, deserializes and validates again. + * + * With the synchronous class, the deserialize methods (from and deserialize) + * are called synchronous. Please be aware, that CoreSerializable classes should + * have no CoreSerializableAsync properties. + */ + +@type("CoreSerializable") +export class CoreSerializable extends Serializable implements ISerializable { + public toBase64(): string { + return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); + } + + public static fromBase64T(value: string): T { + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return (this as any).deserialize(serialized); + } + + public static fromBase64Unknown(value: string): Serializable { + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return Serializable.deserializeUnknown(serialized); + } +} diff --git a/packages/core-types/src/index.ts b/packages/core-types/src/index.ts new file mode 100644 index 000000000..49f818f92 --- /dev/null +++ b/packages/core-types/src/index.ts @@ -0,0 +1,5 @@ +export * from "./CoreAddress"; +export * from "./CoreDate"; +export * from "./CoreHash"; +export * from "./CoreId"; +export * from "./CoreSerializable"; diff --git a/packages/core-types/test/Date.test.ts b/packages/core-types/test/Date.test.ts new file mode 100644 index 000000000..f266f18c6 --- /dev/null +++ b/packages/core-types/test/Date.test.ts @@ -0,0 +1,76 @@ +import { CoreDate } from "../src"; + +describe("CoreDate", function () { + describe("Constructor", function () { + test("returns the current date when constructor is empty", function () { + const date = CoreDate.utc(); + expect(date).toBeDefined(); + }); + + test("sets the date property as string", function () { + const date = CoreDate.utc(); + expect(typeof date.date).toBe("string"); + }); + }); + + describe("Add()", function () { + test("returns a date in the future", function () { + const date = CoreDate.utc().add({ years: 1 }); + expect(date).toBeDefined(); + expect(date.isAfter(CoreDate.utc())).toBe(true); + }); + }); + + describe("IsWithin()", function () { + test("should return a correct value if it is within the given range (one parameter)", function () { + const date = CoreDate.utc().subtract({ days: 1, seconds: 1 }); + expect(date.isWithin({ days: 5 })).toBe(true); + expect(date.isWithin({ days: 1 })).toBe(false); + expect(date.isWithin({ days: 1, minutes: 2 })).toBe(true); + expect(date.isWithin({ days: -1 })).toBe(false); + }); + + test("should return a correct value if it is within the given range (two parameters)", function () { + const date = CoreDate.utc().subtract({ days: 1, seconds: 1 }); + expect(date.isWithin({ days: 5 }, { days: 1 })).toBe(true); + expect(date.isWithin({ days: 20 }, { days: -20 })).toBe(false); + expect(date.isWithin({ days: 1, minutes: 2 }, { days: 1 })).toBe(true); + expect(date.isWithin({ days: -1 }, { minutes: 4000 })).toBe(false); + + const date2 = CoreDate.utc().add({ days: 1, seconds: 1 }); + expect(date2.isWithin(0, { days: 2 })).toBe(true); + expect(date2.isWithin({ days: 2 }, { days: 3 })).toBe(true); + expect(date2.isWithin({ days: 1 }, { days: 3 })).toBe(true); + expect(date2.isWithin({ days: -1 }, { seconds: 4000 })).toBe(false); + }); + + test("should return a correct value if it is within the given range (three parameters)", function () { + const date = CoreDate.from("2020-01-01"); + const reference = CoreDate.from("2020-01-02"); + expect(date.isWithin({ days: 5 }, { days: 1 }, reference)).toBe(true); + expect(date.isWithin({ days: 20 }, { days: -20 }, reference)).toBe(false); + expect(date.isWithin({ days: 1, minutes: 2 }, { days: 1 }, reference)).toBe(true); + expect(date.isWithin({ hours: 25 }, { hours: 25 }, reference)).toBe(true); + expect(date.isWithin({ hours: 23 }, { hours: 25 }, reference)).toBe(false); + + const date2 = CoreDate.from("2020-01-03"); + expect(date2.isWithin(0, { days: 2 }, reference)).toBe(true); + expect(date2.isWithin({ minutes: 2 }, { days: 1 }, reference)).toBe(false); + expect(date2.isWithin({ days: 1 }, { days: 3 }, reference)).toBe(true); + expect(date2.isWithin({ hours: 25 }, { hours: 25 }, reference)).toBe(true); + expect(date2.isWithin({ hours: 23 }, { hours: 23 }, reference)).toBe(false); + }); + }); + + describe("From()", function () { + test("returns a date when provided with a date", function () { + const date = CoreDate.from(CoreDate.utc()); + expect(date).toBeDefined(); + }); + + test("returns a date when provided with a string", function () { + const date = CoreDate.from(CoreDate.utc().date); + expect(date).toBeDefined(); + }); + }); +}); diff --git a/packages/core-types/test/tsconfig.json b/packages/core-types/test/tsconfig.json new file mode 100644 index 000000000..50e8c5f15 --- /dev/null +++ b/packages/core-types/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "../", + "noEmit": true, + "composite": false + }, + "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], + "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], + "exclude": [] +} diff --git a/packages/core-types/tsconfig.json b/packages/core-types/tsconfig.json new file mode 100644 index 000000000..7ba274db4 --- /dev/null +++ b/packages/core-types/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src/**/*.ts"], + "exclude": [], + "references": [{ "path": "../utils" }] +} diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore new file mode 100644 index 000000000..586efae9b --- /dev/null +++ b/packages/utils/.gitignore @@ -0,0 +1,12 @@ +node_modules +tmp-browser +dist-test +lib-web +dist +docs +*.log +*.log.* +_archive +.idea +coverage +.nyc_output diff --git a/packages/utils/package.json b/packages/utils/package.json new file mode 100644 index 000000000..720a49a92 --- /dev/null +++ b/packages/utils/package.json @@ -0,0 +1,57 @@ +{ + "name": "@nmshd/utils", + "description": "The enmeshed utils.", + "homepage": "https://enmeshed.eu", + "repository": { + "type": "git", + "url": "git+https://github.com/nmshd/runtime.git", + "directory": "packages/utils" + }, + "license": "MIT", + "author": "j&s-soft GmbH", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc", + "build:ci": "tsc", + "cdep": "tsc && madge --circular dist", + "lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit", + "test": "jest -i", + "test:ci": "jest -i --coverage" + }, + "jest": { + "maxWorkers": 1, + "preset": "ts-jest", + "coverageProvider": "v8", + "coverageReporters": [ + "text-summary", + "cobertura", + "lcov" + ], + "collectCoverageFrom": [ + "./src/**" + ], + "setupFilesAfterEnv": [ + "jest-expect-message" + ], + "testEnvironment": "node", + "testTimeout": 60000, + "transform": { + "^.+\\.ts$": [ + "ts-jest", + { + "tsconfig": "test/tsconfig.json" + } + ] + } + }, + "dependencies": {}, + "devDependencies": {}, + "publishConfig": { + "access": "public", + "provenance": true + } +} diff --git a/packages/utils/src/PasswordGenerator.ts b/packages/utils/src/PasswordGenerator.ts new file mode 100644 index 000000000..ab631d8ba --- /dev/null +++ b/packages/utils/src/PasswordGenerator.ts @@ -0,0 +1,180 @@ +import { Random, RandomCharacterRange } from "./Random"; + +const defaultPasswordRange = RandomCharacterRange.AlphanumericEase + RandomCharacterRange.SpecialCharacters; + +export interface IPasswordGenerator {} + +export interface IPasswordGeneratorStatic { + readonly elementsGerman: string[]; + readonly unitsGerman: string[]; + new (): IPasswordGenerator; + createPassword(minLength: number, allowedCharacters?: string | string[], maxLength?: number): Promise; + createUnitPassword(): Promise; + createElementPassword(): Promise; +} + +export class PasswordGenerator implements IPasswordGenerator { + public static readonly elementsGerman: string[] = [ + "Wasserstoff", + "Helium", + "Lithium", + "Beryllium", + "Bor", + "Kohlenstoff", + "Stickstoff", + "Sauerstoff", + "Fluor", + "Neon", + "Natrium", + "Magnesium", + "Aluminium", + "Silicium", + "Phosphor", + "Schwefel", + "Chlor", + "Argon", + "Kalium", + "Calcium", + "Scandium", + "Titan", + "Vanadium", + "Chrom", + "Mangan", + "Eisen", + "Cobalt", + "Nickel", + "Kupfer", + "Zink" + ]; + + public static readonly unitsGerman: string[] = [ + "Kelvin", + "Mol", + "Candela", + "Mikrosekunden", + "Nanosekunden", + "Millisekunden", + "Sekunden", + "Minuten", + "Stunden", + "Tage", + "Wochen", + "Monate", + "Jahre", + "Seemeilen", + "Astronomische Einheiten", + "Parsecs", + "Lichtjahre", + "Millimeter", + "Zentimeter", + "Meter", + "Kilometer", + "Quadratmeter", + "Ar", + "Hektar", + "Milliliter", + "Zentiliter", + "Liter", + "Kubikmeter", + "Barrel", + "Gramm", + "Kilogramm", + "Tonnen", + "Pfund", + "Zentner", + "Knoten", + "Newton", + "Pascal", + "Bar", + "Joule", + "Kilojoule", + "Megajoule", + "Wattstunden", + "Kilowattstunden", + "Megawattstunden", + "Kalorien", + "Kilokalorien", + "Elektronenvolt", + "Watt", + "Kilowatt", + "Megawatt", + "Voltampere", + "Ampere", + "Milliampere", + "Ohm", + "Siemens", + "Coulomb", + "Amperestunde", + "Milliamperestunde", + "Farad", + "Kelvin", + "Grad Celsius", + "Lumen", + "Lux", + "Bit", + "Byte", + "Kilobyte", + "Megabyte", + "Gigabyte", + "Terabyte", + "Etabyte" + ]; + + public static async createPassword(minLength: number, maxLength = 0, allowedCharacters: string | string[] = defaultPasswordRange): Promise { + if (maxLength <= 0) { + maxLength = minLength; + } + return await Random.stringRandomLength(minLength, maxLength, allowedCharacters); + } + + /** + * Creates a "strong" password out of a scramble of the following character sets: + * + * - 1 special character out of RandomCharacterRange.SpecialCharacters + * - 1 lowercase character out of RandomCharacterRange.LowerCaseEase + * - 1 uppercase character out of RandomCharacterRange.UpperCaseEase + * - 1 number out of RandomCharacterRange.DigitEase + * - A random number of characters (between minLength and maxLength) out of PasswordRange.Default + * + */ + public static async createStrongPassword(minLength = 8, maxLength = 12): Promise { + if (minLength > maxLength) maxLength = minLength; + if (minLength < 8) { + throw new Error("Minimum password length for a strong password should be 8 characters."); + } + + const specialCharacterBucket = { + minLength: 1, + maxLength: 1, + allowedChars: RandomCharacterRange.SpecialCharacters + }; + const lowercaseBucket = { minLength: 1, maxLength: 1, allowedChars: RandomCharacterRange.LowerCaseEase }; + const uppercaseBucket = { minLength: 1, maxLength: 1, allowedChars: RandomCharacterRange.UpperCaseEase }; + const numberBucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; + const alphanumericBucket = { + minLength: minLength - 4, + maxLength: maxLength - 4, + allowedChars: defaultPasswordRange + }; + const password = await Random.stringWithBuckets([specialCharacterBucket, lowercaseBucket, uppercaseBucket, numberBucket, alphanumericBucket]); + return await Random.scramble(password); + } + + public static async createUnitPassword(): Promise { + const number1Bucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; + const number2Bucket = { minLength: 0, maxLength: 2, allowedChars: "0123456789" }; + const commaBucket = { minLength: 0, maxLength: 1, allowedChars: "," }; + const number3Bucket = { minLength: 0, maxLength: 1, allowedChars: "0123456789" }; + const number4Bucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; + const randomMetric = await Random.stringWithBuckets([number1Bucket, number2Bucket, commaBucket, number3Bucket, number4Bucket]); + const unit = await this.createPassword(1, 0, this.unitsGerman); + + return `${randomMetric} ${unit}`; + } + + public static async createElementPassword(): Promise { + const element = await this.createPassword(1, 0, this.elementsGerman); + const number = await this.createPassword(1, 0, RandomCharacterRange.Digit); + return `${element} ${number}`; + } +} diff --git a/packages/utils/src/Random.ts b/packages/utils/src/Random.ts new file mode 100644 index 000000000..7e9edaa06 --- /dev/null +++ b/packages/utils/src/Random.ts @@ -0,0 +1,157 @@ +import { CryptoRandom, ICoreBuffer } from "@nmshd/crypto"; +import { v4 as uuidv4 } from "uuid"; + +export enum RandomCharacterRange { + Digit = "0123456789", + DigitEase = "123456789", + Hex = "0123456789ABCDEF", + LowerCase = "abcdefghijklmnopqrstuvwxyz", + LowerCaseEase = "abcdefghijkmnpqrstuvwxyz", + UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", + UpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ", + Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", + Alphanumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", + // Without I, l, O, o, 0 + AlphanumericEase = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789", + AlphanumericUpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789", + GermanUmlaut = "ÄÖÜäöü", + SpecialCharacters = "!?-_.:,;#+" +} + +export interface RandomCharacterBucket { + minLength: number; + maxLength: number; + allowedChars: string | string[]; +} + +export interface IRandom {} + +export interface IRandomStatic { + new (): IRandom; + bytes(length: number): Promise; + int(length: number): Promise; + array(length: number): Promise; + uuid(): Promise; + scramble(input: string): Promise; + intBetween(min: number, max: number): Promise; + intRandomLength(minLength: number, maxLength: number): Promise; + scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise; + stringWithBuckets(buckets: RandomCharacterBucket[]): Promise; + string(length: number, allowedChars?: string | string[]): Promise; + stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise; +} + +export class Random implements IRandom { + public static async bytes(length: number): Promise { + return await CryptoRandom.bytes(length); + } + public static async int(length: number): Promise { + if (length > 21 || length <= 0) { + throw new Error("Length must be between 1 and 21."); + } + return parseInt(await this.string(length, RandomCharacterRange.Digit)); + } + public static async array(length: number): Promise { + return (await CryptoRandom.bytes(length)).toArray(); + } + + public static uuid(): string { + return uuidv4(); + } + + public static async scramble(input: string): Promise { + const out = []; + const inar = input.split(""); + const length = input.length; + for (let i = 0; i < length - 1; i++) { + const charAt = await Random.intBetween(0, length - 1 - i); + out.push(inar.splice(charAt, 1)[0]); + } + out.push(inar[0]); + return out.join(""); + } + + public static async intBetween(min: number, max: number): Promise { + if (max <= min) { + throw new Error("Max must be larger than min."); + } + const diff = max - min + 1; + const bitLength = Math.abs(Math.ceil(Math.log2(diff))); + if (bitLength > 32) { + throw new Error("The range between the numbers is too big, 32 bit is the maximum -> 4294967296"); + } + const byteLength = Math.ceil(bitLength / 8); + const bitMask = Math.pow(2, bitLength) - 1; + const randomArray = await this.bytes(byteLength); + + let value = 0; + let p = (byteLength - 1) * 8; + for (let i = 0; i < byteLength; i++) { + value += randomArray.buffer[i] * Math.pow(2, p); + p -= 8; + } + value = value & bitMask; + if (value >= diff) { + return await this.intBetween(min, max); + } + return min + value; + } + + public static async intRandomLength(minLength: number, maxLength: number): Promise { + if (maxLength > 21) { + throw new Error("Max must be below 22."); + } + return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit)); + } + + public static async scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise { + const str = await this.stringWithBuckets(buckets); + return await this.scramble(str); + } + + public static async stringWithBuckets(buckets: RandomCharacterBucket[]): Promise { + const str = []; + for (const bucket of buckets) { + str.push(await this.stringRandomLength(bucket.minLength, bucket.maxLength, bucket.allowedChars)); + } + return str.join(""); + } + + public static async string(length: number, allowedChars: string | string[] = RandomCharacterRange.Alphanumeric): Promise { + if (length <= 0) return ""; + if (allowedChars.length > 256) { + throw new Error("Input exceeds maximum length of 256."); + } + const ar = []; + const inputLength = allowedChars.length; + const random = await this.array(length + 10); + const max = 255 - (255 % inputLength); + for (let i = 0; i < length; i++) { + const nmb = random[i]; + if (nmb > max) { + // Reject random value to remove bias if we are at the + // upper (and incomplete end) of possible random values + continue; + } + ar.push(allowedChars[nmb % inputLength]); + } + let retStr = ar.join(""); + if (retStr.length < length) { + retStr += await this.string(length - retStr.length, allowedChars); + } + return retStr; + } + + public static async stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise { + if (minLength > maxLength) { + throw new Error("maxLength must be larger than minLength."); + } + + if (minLength < 0) { + throw new Error("minlength must not be less than zero."); + } + + const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength; + return await this.string(length, allowedChars); + } +} diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts new file mode 100644 index 000000000..41ee05dab --- /dev/null +++ b/packages/utils/src/index.ts @@ -0,0 +1,2 @@ +export * from "./PasswordGenerator"; +export * from "./Random"; diff --git a/packages/utils/test/PasswordGenerator.test.ts b/packages/utils/test/PasswordGenerator.test.ts new file mode 100644 index 000000000..702d88db5 --- /dev/null +++ b/packages/utils/test/PasswordGenerator.test.ts @@ -0,0 +1,64 @@ +import { PasswordGenerator } from "../src"; + +describe("PasswordGeneratorTest", function () { + describe("CreatePassword", function () { + test("should return a fixed length password", async function () { + for (let i = 1; i < 20; i++) { + const pass = await PasswordGenerator.createPassword(i); + expect(pass).toHaveLength(i); + } + }); + + test("should return a random length password within the range", async function () { + for (let i = 1; i < 20; i++) { + const pass = await PasswordGenerator.createPassword(6, 10); + + expect(pass.length).toBeGreaterThanOrEqual(6); + expect(pass.length).toBeLessThanOrEqual(10); + } + }); + }); + + describe("CreateStrongPassword", function () { + test("should return a random password with a dynamic size", async function () { + for (let i = 1; i < 20; i++) { + const password = await PasswordGenerator.createStrongPassword(); + + expect(password.length).toBeGreaterThanOrEqual(8); + expect(password.length).toBeLessThanOrEqual(12); + } + }); + + test("should return a random password with the correct given fix length", async function () { + for (let i = 1; i < 20; i++) { + const pass = await PasswordGenerator.createStrongPassword(50, 50); + expect(pass).toHaveLength(50); + } + }); + + test("should return a random password with the correct given length interval", async function () { + for (let i = 1; i < 20; i++) { + const pass = await PasswordGenerator.createStrongPassword(20, 50); + + expect(pass.length).toBeGreaterThanOrEqual(19); + expect(pass.length).toBeLessThanOrEqual(51); + } + }); + + test("should throw an error if minLength is too low", async function () { + for (let i = 1; i < 20; i++) { + await expect(PasswordGenerator.createStrongPassword(2, 20)).rejects.toThrow("Minimum password length for a strong password should be 8 characters."); + } + }); + }); + + describe("CreateUnitPassword", function () { + test("should return a random password", async function () { + for (let i = 1; i < 20; i++) { + const pass = await PasswordGenerator.createUnitPassword(); + expect(pass.length).toBeGreaterThanOrEqual(5); + expect(pass.length).toBeLessThanOrEqual(30); + } + }); + }); +}); diff --git a/packages/utils/test/Random.test.ts b/packages/utils/test/Random.test.ts new file mode 100644 index 000000000..8faa33252 --- /dev/null +++ b/packages/utils/test/Random.test.ts @@ -0,0 +1,150 @@ +import { Random, RandomCharacterRange } from "../src"; + +describe("RandomTest", function () { + describe("IntBetween", function () { + test("should return a number between the min and max", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.intBetween(0, 1); + expect(n).toBeLessThan(2); + expect(n).toBeGreaterThan(-1); + } + }); + + test("should return an even number across all possible values (0|1)", async function () { + const buckets: number[] = [0, 0]; + const iterations = 10000; + for (let i = 1; i < iterations; i++) { + const n = await Random.intBetween(0, 1); + // eslint-disable-next-line jest/no-conditional-in-test + switch (n) { + case 0: + buckets[0]++; + break; + case 1: + buckets[1]++; + break; + default: + throw new Error(`Value '${n}' is not in the range!`); + } + } + + expect(buckets[0]).toBeLessThan(iterations * 0.6); + expect(buckets[0]).toBeGreaterThan(iterations * 0.4); + expect(buckets[1]).toBeLessThan(iterations * 0.6); + expect(buckets[1]).toBeGreaterThan(iterations * 0.4); + }); + + test("should return an even number across all possible values (0 to 100)", async function () { + const buckets: number[] = []; + const iterations = 10000; + const min = 0; + const max = 100; + const diff = max - min + 1; + + for (let j = 0; j < diff; j++) { + buckets[j] = 0; + } + + for (let i = 1; i < iterations; i++) { + const n = await Random.intBetween(min, max); + buckets[n]++; + } + + for (let j = 0; j < diff; j++) { + expect(buckets[j]).toBeLessThan((iterations / diff) * 1.5); + expect(buckets[j]).toBeGreaterThan((iterations / diff) * 0.5); + } + }); + + test("should return a number between the min and max (small numbers)", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.intBetween(-20, 20); + expect(n).toBeLessThan(21); + expect(n).toBeGreaterThan(-21); + } + }); + + test("should return a number between the min and max (very high max)", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.intBetween(0, 2 ^ (32 - 1)); + expect(n).toBeLessThan(2 ^ 32); + expect(n).toBeGreaterThan(-1); + } + }); + + test("should return a number between the min and max (very low min)", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.intBetween(-2 ^ (32 + 1), 0); + expect(n).toBeLessThan(1); + expect(n).toBeGreaterThan(-2 ^ 32); + } + }); + }); + + describe("Scramble()", function () { + test("should return a string with the same length", async function () { + for (let i = 1; i < 20; i++) { + const instring = "012345"; + const n = await Random.scramble(instring); + expect(n).toHaveLength(instring.length); + } + }); + }); + + describe("String()", function () { + test("should return a string with a fixed length", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.string(1); + expect(n).toHaveLength(1); + } + + for (let i = 1; i < 20; i++) { + const n = await Random.string(10); + expect(n).toHaveLength(10); + } + + for (let i = 1; i < 20; i++) { + const n = await Random.string(100); + expect(n).toHaveLength(100); + } + }); + + test("should return a string with a fixed length and wanted characters", async function () { + for (let i = 1; i < 20; i++) { + const n = await Random.string(1, "a"); + expect(n).toHaveLength(1); + expect(n).toBe("a"); + } + + for (let i = 1; i < 20; i++) { + const n = await Random.string(10, "a"); + expect(n).toHaveLength(10); + expect(n).toBe("aaaaaaaaaa"); + } + + for (let i = 1; i < 20; i++) { + const n = await Random.string(10, "0"); + expect(n).toHaveLength(10); + expect(n).toBe("0000000000"); + } + }); + + test("should return an even number across all possible values (Alphabet)", async function () { + const buckets: any = {}; + const iterations = 10000; + const diff = RandomCharacterRange.Alphabet.length; + + for (let i = 1; i < iterations; i++) { + const n = await Random.string(1, RandomCharacterRange.Alphabet); + // eslint-disable-next-line jest/no-conditional-in-test + if (buckets[n]) buckets[n]++; + else buckets[n] = 1; + } + + for (const char in buckets) { + expect(buckets[char]).toBeLessThan((iterations / diff) * 1.5); + expect(buckets[char]).toBeGreaterThan((iterations / diff) * 0.5); + } + }); + }); +}); diff --git a/packages/utils/test/tsconfig.json b/packages/utils/test/tsconfig.json new file mode 100644 index 000000000..50e8c5f15 --- /dev/null +++ b/packages/utils/test/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "../", + "noEmit": true, + "composite": false + }, + "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], + "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], + "exclude": [] +} diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json new file mode 100644 index 000000000..0a8a33ee7 --- /dev/null +++ b/packages/utils/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist", + "rootDir": "src" + }, + "include": ["src/**/*.ts"], + "exclude": [] +} From 1a92327d4bbb05ca1c2e091256f609728b7d31ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:14:55 +0200 Subject: [PATCH 02/16] refactor: update sources --- packages/app-runtime/src/AppRuntime.ts | 3 +- .../app-runtime/src/AppStringProcessor.ts | 3 +- .../src/multiAccount/AccountServices.ts | 2 +- .../multiAccount/MultiAccountController.ts | 13 +- .../src/multiAccount/data/LocalAccount.ts | 8 +- .../consumption/ConsumptionBaseController.ts | 5 +- .../src/consumption/ConsumptionController.ts | 3 +- .../consumption/src/consumption/CoreErrors.ts | 3 +- .../AttributeListenersController.ts | 3 +- .../CreateLocalAttributeListenerParams.ts | 2 +- .../local/LocalAttributeListener.ts | 3 +- .../attributes/AttributesController.ts | 3 +- .../local/AttributeSuccessorParams.ts | 2 +- .../attributes/local/CreateAttributeParams.ts | 2 +- .../local/CreateRepositoryAttributeParams.ts | 2 +- .../CreateSharedLocalAttributeCopyParams.ts | 2 +- .../local/CreateSharedLocalAttributeParams.ts | 2 +- .../attributes/local/LocalAttribute.ts | 3 +- .../local/LocalAttributeDeletionInfo.ts | 8 +- .../local/LocalAttributeShareInfo.ts | 8 +- .../src/modules/drafts/DraftsController.ts | 3 +- .../src/modules/drafts/local/Draft.ts | 3 +- .../notifications/NotificationsController.ts | 3 +- .../AbstractNotificationItemProcessor.ts | 3 +- ...DeletedByOwnerNotificationItemProcessor.ts | 3 +- ...eDeletedByPeerNotificationItemProcessor.ts | 3 +- ...eDeletedByPeerNotificationItemProcessor.ts | 3 +- .../notifications/local/LocalNotification.ts | 3 +- .../local/LocalNotificationSource.ts | 8 +- .../DecideRequestParametersValidator.ts | 2 +- .../incoming/IncomingRequestsController.ts | 15 +- ...rerequisitesOfIncomingRequestParameters.ts | 2 +- .../CompleteIncomingRequestParameters.ts | 3 +- .../decide/InternalDecideRequestParameters.ts | 2 +- ...nualDecisionOfIncomingRequestParameters.ts | 2 +- .../AbstractRequestItemProcessor.ts | 3 +- .../GenericRequestItemProcessor.ts | 2 +- .../itemProcessors/IRequestItemProcessor.ts | 2 +- .../CreateAttributeRequestItemProcessor.ts | 2 +- ...eptDeleteAttributeRequestItemParameters.ts | 2 +- .../DeleteAttributeRequestItemProcessor.ts | 2 +- ...ptProposeAttributeRequestItemParameters.ts | 2 +- .../ProposeAttributeRequestItemProcessor.ts | 3 +- ...cceptReadAttributeRequestItemParameters.ts | 2 +- .../ReadAttributeRequestItemProcessor.ts | 3 +- .../ShareAttributeRequestItemProcessor.ts | 3 +- .../validateAttributeMatchesWithQuery.ts | 2 +- .../itemProcessors/utility/validateQuery.ts | 2 +- .../modules/requests/local/LocalRequest.ts | 10 +- .../local/LocalRequestStatusLogEntry.ts | 8 +- .../modules/requests/local/LocalResponse.ts | 12 +- .../outgoing/OutgoingRequestsController.ts | 14 +- .../CompleteOutgoingRequestParameters.ts | 3 +- ...mRelationshipTemplateResponseParameters.ts | 3 +- .../CanCreateOutgoingRequestParameters.ts | 2 +- .../CreateOutgoingRequestParameters.ts | 2 +- .../SentOutgoingRequestParameters.ts | 3 +- .../modules/settings/SettingsController.ts | 3 +- .../settings/local/CreateSettingParameter.ts | 2 +- .../src/modules/settings/local/Setting.ts | 3 +- .../src/attributes/AbstractAttribute.ts | 2 +- .../src/attributes/AbstractAttributeQuery.ts | 2 +- .../src/attributes/IdentityAttributeQuery.ts | 2 +- .../attributes/RelationshipAttributeQuery.ts | 2 +- .../ThirdPartyRelationshipAttributeQuery.ts | 2 +- .../statement/DigitalIdentityDescriptor.ts | 2 +- .../statement/StatementIssuerConditions.ts | 2 +- .../types/statement/StatementObject.ts | 2 +- .../types/statement/StatementSubject.ts | 2 +- packages/content/src/buildInformation.ts | 4 +- packages/content/src/messages/Mail.ts | 2 +- .../content/src/notifications/Notification.ts | 2 +- ...AttributeDeletedByOwnerNotificationItem.ts | 2 +- ...dAttributeDeletedByPeerNotificationItem.ts | 2 +- ...haredAttributeSucceededNotificationItem.ts | 2 +- ...pAttributeDeletedByPeerNotificationItem.ts | 2 +- packages/content/src/requests/Request.ts | 2 +- .../content/src/requests/ResponseWrapper.ts | 2 +- ...ttributeAlreadySharedAcceptResponseItem.ts | 2 +- .../AttributeSuccessionAcceptResponseItem.ts | 2 +- .../CreateAttributeAcceptResponseItem.ts | 2 +- .../DeleteAttributeAcceptResponseItem.ts | 2 +- .../DeleteAttributeRequestItem.ts | 2 +- .../ProposeAttributeAcceptResponseItem.ts | 2 +- .../ReadAttributeAcceptResponseItem.ts | 2 +- .../ShareAttributeAcceptResponseItem.ts | 2 +- .../ShareAttributeRequestItem.ts | 2 +- .../content/src/requests/response/Response.ts | 2 +- packages/runtime/src/Runtime.ts | 2 +- .../runtime/src/dataViews/DataViewExpander.ts | 3 +- .../LoadPeerTokenAnonymousByIdAndKey.ts | 3 +- .../src/useCases/common/RuntimeErrors.ts | 2 +- .../GetAttributeListener.ts | 2 +- .../ChangeDefaultRepositoryAttribute.ts | 3 +- .../CreateAndShareRelationshipAttribute.ts | 3 +- .../DeleteOwnSharedAttributeAndNotifyPeer.ts | 3 +- ...DeletePeerSharedAttributeAndNotifyOwner.ts | 3 +- .../attributes/DeleteRepositoryAttribute.ts | 3 +- ...ributesForRejectedOrRevokedRelationship.ts | 3 +- ...OwnedRelationshipAttributeAndNotifyPeer.ts | 3 +- .../consumption/attributes/GetAttribute.ts | 2 +- .../GetSharedVersionsOfAttribute.ts | 3 +- .../attributes/GetVersionsOfAttribute.ts | 2 +- ...yPeerAboutRepositoryAttributeSuccession.ts | 3 +- .../attributes/ShareRepositoryAttribute.ts | 3 +- ...cceedRelationshipAttributeAndNotifyPeer.ts | 3 +- .../attributes/SucceedRepositoryAttribute.ts | 3 +- .../consumption/drafts/DeleteDraft.ts | 3 +- .../useCases/consumption/drafts/GetDraft.ts | 2 +- .../consumption/drafts/UpdateDraft.ts | 3 +- .../notifications/GetNotification.ts | 2 +- .../notifications/ProcessNotificationById.ts | 2 +- .../notifications/ReceivedNotification.ts | 3 +- .../notifications/SentNotification.ts | 3 +- .../requests/AcceptIncomingRequest.ts | 2 +- .../requests/CanCreateOutgoingRequest.ts | 2 +- .../CheckPrerequisitesOfIncomingRequest.ts | 2 +- .../requests/CompleteIncomingRequest.ts | 3 +- .../requests/CompleteOutgoingRequest.ts | 3 +- ...RequestFromRelationshipTemplateResponse.ts | 3 +- .../requests/CreateOutgoingRequest.ts | 2 +- .../requests/DiscardOutgoingRequest.ts | 2 +- .../requests/GetIncomingRequest.ts | 2 +- .../requests/GetOutgoingRequest.ts | 2 +- .../requests/ReceivedIncomingRequest.ts | 3 +- .../requests/RejectIncomingRequest.ts | 2 +- .../RequireManualDecisionOfIncomingRequest.ts | 2 +- .../requests/SentOutgoingRequest.ts | 3 +- .../consumption/settings/CreateSetting.ts | 3 +- .../consumption/settings/DeleteSetting.ts | 3 +- .../consumption/settings/GetSetting.ts | 2 +- .../consumption/settings/UpdateSetting.ts | 3 +- .../transport/challenges/CreateChallenge.ts | 3 +- .../devices/CreateDeviceOnboardingToken.ts | 3 +- .../transport/devices/DeleteDevice.ts | 3 +- .../transport/devices/DeviceMapper.ts | 3 +- .../useCases/transport/devices/GetDevice.ts | 3 +- .../devices/GetDeviceOnboardingInfo.ts | 3 +- .../transport/devices/UpdateDevice.ts | 3 +- .../transport/files/CreateQRCodeForFile.ts | 3 +- .../transport/files/CreateTokenForFile.ts | 3 +- .../files/CreateTokenQRCodeForFile.ts | 3 +- .../useCases/transport/files/DownloadFile.ts | 3 +- .../src/useCases/transport/files/GetFile.ts | 3 +- .../useCases/transport/files/GetOrLoadFile.ts | 3 +- .../useCases/transport/files/UploadOwnFile.ts | 3 +- .../transport/messages/DownloadAttachment.ts | 3 +- .../messages/GetAttachmentMetadata.ts | 3 +- .../useCases/transport/messages/GetMessage.ts | 3 +- .../transport/messages/MarkMessageAsRead.ts | 3 +- .../transport/messages/MarkMessageAsUnread.ts | 3 +- .../transport/messages/SendMessage.ts | 3 +- .../CreateOwnRelationshipTemplate.ts | 3 +- .../CreateQRCodeForOwnRelationshipTemplate.ts | 3 +- .../CreateTokenForOwnRelationshipTemplate.ts | 3 +- ...teTokenQRCodeForOwnRelationshipTemplate.ts | 3 +- .../GetRelationshipTemplate.ts | 3 +- .../LoadPeerRelationshipTemplate.ts | 3 +- .../relationships/AcceptRelationship.ts | 3 +- .../AcceptRelationshipReactivation.ts | 3 +- .../relationships/CreateRelationship.ts | 3 +- .../relationships/DecomposeRelationship.ts | 3 +- .../GetAttributesForRelationship.ts | 3 +- .../relationships/GetRelationship.ts | 3 +- .../relationships/GetRelationshipByAddress.ts | 3 +- .../relationships/RejectRelationship.ts | 3 +- .../RejectRelationshipReactivation.ts | 3 +- .../RequestRelationshipReactivation.ts | 3 +- .../relationships/RevokeRelationship.ts | 3 +- .../RevokeRelationshipReactivation.ts | 3 +- .../relationships/TerminateRelationship.ts | 3 +- .../transport/tokens/CreateOwnToken.ts | 3 +- .../transport/tokens/GetQRCodeForToken.ts | 3 +- .../src/useCases/transport/tokens/GetToken.ts | 3 +- .../transport/tokens/LoadPeerToken.ts | 3 +- packages/transport/src/core/CoreCrypto.ts | 2 +- packages/transport/src/core/CoreIdHelper.ts | 4 +- .../transport/src/core/CoreSerializable.ts | 30 --- .../src/core/CoreSerializableAsync.ts | 30 --- .../transport/src/core/CoreSynchronizable.ts | 9 +- packages/transport/src/core/Reference.ts | 2 +- .../transport/src/core/TransportController.ts | 4 +- .../transport/src/core/backbone/AuthClient.ts | 2 +- .../src/core/backbone/Authenticator.ts | 2 +- .../src/core/backbone/ClientResult.ts | 2 +- .../transport/src/core/backbone/RESTClient.ts | 2 +- .../src/core/backbone/RequestError.ts | 2 +- packages/transport/src/core/index.ts | 2 - .../transport/src/core/types/CoreAddress.ts | 43 ----- packages/transport/src/core/types/CoreDate.ts | 171 ----------------- packages/transport/src/core/types/CoreHash.ts | 69 ------- packages/transport/src/core/types/CoreId.ts | 52 ----- packages/transport/src/core/types/index.ts | 4 - .../RelationshipDecomposedBySelfEvent.ts | 2 +- packages/transport/src/index.ts | 1 - .../src/modules/accounts/AccountController.ts | 5 +- .../modules/accounts/IdentityController.ts | 3 +- .../IdentityDeletionProcessController.ts | 3 +- .../src/modules/accounts/IdentityUtil.ts | 2 +- .../data/CachedIdentityDeletionProcess.ts | 6 +- .../src/modules/accounts/data/Identity.ts | 8 +- .../accounts/data/IdentityDeletionProcess.ts | 3 +- .../data/IdentitySecretCredentials.ts | 7 +- .../modules/certificates/CertificateIssuer.ts | 3 +- .../modules/certificates/data/Certificate.ts | 8 +- .../data/CertificateConstraint.ts | 7 +- .../certificates/data/CertificateContent.ts | 12 +- .../certificates/data/CertificateItem.ts | 7 +- .../CertificateIdentityConstraint.ts | 2 +- .../constraints/CertificateTimeConstraint.ts | 2 +- .../items/CertificatePrivateAttributeItem.ts | 6 +- .../CertificatePrivateAttributeItemSource.ts | 2 +- .../modules/challenges/ChallengeController.ts | 3 +- .../src/modules/challenges/data/Challenge.ts | 8 +- .../challenges/data/ChallengeSigned.ts | 7 +- .../src/modules/devices/DeviceController.ts | 3 +- .../modules/devices/DeviceSecretController.ts | 3 +- .../src/modules/devices/DevicesController.ts | 5 +- .../src/modules/devices/local/Device.ts | 3 +- .../devices/local/DeviceSecretCredentials.ts | 8 +- .../devices/local/SendDeviceParameters.ts | 7 +- .../transmission/DeviceSharedSecret.ts | 8 +- .../src/modules/files/FileController.ts | 3 +- .../src/modules/files/local/CachedFile.ts | 8 +- .../transport/src/modules/files/local/File.ts | 3 +- .../modules/files/local/SendFileParameters.ts | 9 +- .../files/transmission/FileMetadata.ts | 8 +- .../src/modules/messages/MessageController.ts | 3 +- .../modules/messages/local/CachedMessage.ts | 7 +- .../messages/local/CachedMessageRecipient.ts | 9 +- .../src/modules/messages/local/Message.ts | 3 +- .../messages/local/SendMessageParameters.ts | 6 +- .../transmission/MessageContentWrapper.ts | 8 +- .../messages/transmission/MessageEnvelope.ts | 8 +- .../transmission/MessageEnvelopeRecipient.ts | 9 +- .../messages/transmission/MessageSignature.ts | 8 +- .../messages/transmission/MessageSigned.ts | 7 +- .../RelationshipTemplateController.ts | 3 +- .../local/CachedRelationshipTemplate.ts | 7 +- .../local/RelationshipTemplate.ts | 2 +- .../SendRelationshipTemplateParameters.ts | 8 +- .../RelationshipTemplateContentWrapper.ts | 5 +- .../RelationshipTemplatePublicKey.ts | 2 +- .../RelationshipTemplateSigned.ts | 7 +- .../RelationshipSecretController.ts | 3 +- .../relationships/RelationshipsController.ts | 3 +- .../relationships/local/CachedRelationship.ts | 6 +- .../relationships/local/Relationship.ts | 3 +- .../local/RelationshipAuditLog.ts | 2 +- .../local/RelationshipAuditLogEntry.ts | 8 +- .../local/SendRelationshipParameters.ts | 5 +- .../RelationshipCreationContentCipher.ts | 6 +- .../RelationshipCreationContentSigned.ts | 7 +- .../RelationshipCreationContentWrapper.ts | 6 +- ...lationshipCreationResponseContentCipher.ts | 6 +- ...lationshipCreationResponseContentSigned.ts | 7 +- ...ationshipCreationResponseContentWrapper.ts | 8 +- .../src/modules/secrets/SecretController.ts | 3 +- .../secrets/data/SecretContainerCipher.ts | 2 +- .../secrets/data/SecretContainerPlain.ts | 10 +- .../sync/DatawalletModificationMapper.ts | 3 +- .../sync/DatawalletModificationsProcessor.ts | 10 +- .../src/modules/sync/SyncController.ts | 13 +- .../modules/sync/SynchronizedCollection.ts | 4 +- .../MessageReceivedExternalEventProcessor.ts | 2 +- .../sync/local/DatawalletModification.ts | 8 +- .../tokens/AnonymousTokenController.ts | 5 +- .../src/modules/tokens/TokenController.ts | 5 +- .../src/modules/tokens/local/CachedToken.ts | 6 +- .../tokens/local/SendTokenParameters.ts | 6 +- .../src/modules/tokens/local/Token.ts | 3 +- .../TokenContentDeviceSharedSecret.ts | 7 +- .../tokens/transmission/TokenContentFile.ts | 8 +- .../TokenContentRelationshipTemplate.ts | 8 +- .../transport/src/util/PasswordGenerator.ts | 181 ------------------ packages/transport/src/util/Random.ts | 158 --------------- packages/transport/src/util/index.ts | 2 - 277 files changed, 539 insertions(+), 1218 deletions(-) delete mode 100644 packages/transport/src/core/CoreSerializable.ts delete mode 100644 packages/transport/src/core/CoreSerializableAsync.ts delete mode 100644 packages/transport/src/core/types/CoreAddress.ts delete mode 100644 packages/transport/src/core/types/CoreDate.ts delete mode 100644 packages/transport/src/core/types/CoreHash.ts delete mode 100644 packages/transport/src/core/types/CoreId.ts delete mode 100644 packages/transport/src/util/PasswordGenerator.ts delete mode 100644 packages/transport/src/util/Random.ts delete mode 100644 packages/transport/src/util/index.ts diff --git a/packages/app-runtime/src/AppRuntime.ts b/packages/app-runtime/src/AppRuntime.ts index 485f59826..8538ecca9 100644 --- a/packages/app-runtime/src/AppRuntime.ts +++ b/packages/app-runtime/src/AppRuntime.ts @@ -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"; diff --git a/packages/app-runtime/src/AppStringProcessor.ts b/packages/app-runtime/src/AppStringProcessor.ts index c2916b722..7f8fabd52 100644 --- a/packages/app-runtime/src/AppStringProcessor.ts +++ b/packages/app-runtime/src/AppStringProcessor.ts @@ -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"; diff --git a/packages/app-runtime/src/multiAccount/AccountServices.ts b/packages/app-runtime/src/multiAccount/AccountServices.ts index 23ee46130..c292161ab 100644 --- a/packages/app-runtime/src/multiAccount/AccountServices.ts +++ b/packages/app-runtime/src/multiAccount/AccountServices.ts @@ -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"; diff --git a/packages/app-runtime/src/multiAccount/MultiAccountController.ts b/packages/app-runtime/src/multiAccount/MultiAccountController.ts index b70277b2c..e59cf689c 100644 --- a/packages/app-runtime/src/multiAccount/MultiAccountController.ts +++ b/packages/app-runtime/src/multiAccount/MultiAccountController.ts @@ -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, CoreId } from "@nmshd/core-types"; +import { AccountController, CoreError, DeviceSharedSecret, Transport, CoreErrors as TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; import { AppConfig } from "../AppConfig"; import { SessionStorage } from "../SessionStorage"; import { LocalAccount } from "./data/LocalAccount"; diff --git a/packages/app-runtime/src/multiAccount/data/LocalAccount.ts b/packages/app-runtime/src/multiAccount/data/LocalAccount.ts index 06c2a358a..4bcab0860 100644 --- a/packages/app-runtime/src/multiAccount/data/LocalAccount.ts +++ b/packages/app-runtime/src/multiAccount/data/LocalAccount.ts @@ -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; @@ -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; diff --git a/packages/consumption/src/consumption/ConsumptionBaseController.ts b/packages/consumption/src/consumption/ConsumptionBaseController.ts index 2faa353b5..8896e2b08 100644 --- a/packages/consumption/src/consumption/ConsumptionBaseController.ts +++ b/packages/consumption/src/consumption/ConsumptionBaseController.ts @@ -1,5 +1,6 @@ import { ILogger } from "@js-soft/logging-abstractions"; -import { CoreSerializable, TransportLoggerFactory } from "@nmshd/transport"; +import { Serializable } from "@js-soft/ts-serval"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "./ConsumptionController"; import { ConsumptionControllerName } from "./ConsumptionControllerName"; @@ -24,7 +25,7 @@ export class ConsumptionBaseController { return Promise.resolve(this); } - protected parseArray(values: Object[], type: new () => T): T[] { + protected parseArray(values: Object[], type: new () => T): T[] { return values.map((v) => (type as any).fromAny(v)); } } diff --git a/packages/consumption/src/consumption/ConsumptionController.ts b/packages/consumption/src/consumption/ConsumptionController.ts index 224bf6326..c4f03a928 100644 --- a/packages/consumption/src/consumption/ConsumptionController.ts +++ b/packages/consumption/src/consumption/ConsumptionController.ts @@ -13,7 +13,8 @@ import { ShareAttributeRequestItem, ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AttributeListenersController, AttributesController, diff --git a/packages/consumption/src/consumption/CoreErrors.ts b/packages/consumption/src/consumption/CoreErrors.ts index aa7bb8a2a..1b2be5be3 100644 --- a/packages/consumption/src/consumption/CoreErrors.ts +++ b/packages/consumption/src/consumption/CoreErrors.ts @@ -1,5 +1,6 @@ import { ApplicationError } from "@js-soft/ts-utils"; -import { CoreAddress, CoreError, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { CoreError } from "@nmshd/transport"; class Attributes { public successorIsNotAValidAttribute(error: any) { diff --git a/packages/consumption/src/modules/attributeListeners/AttributeListenersController.ts b/packages/consumption/src/modules/attributeListeners/AttributeListenersController.ts index 7ef0b4740..e4c888de6 100644 --- a/packages/consumption/src/modules/attributeListeners/AttributeListenersController.ts +++ b/packages/consumption/src/modules/attributeListeners/AttributeListenersController.ts @@ -1,5 +1,6 @@ import { EventBus } from "@js-soft/ts-utils"; -import { CoreAddress, CoreId, SynchronizedCollection } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { SynchronizedCollection } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/attributeListeners/local/CreateLocalAttributeListenerParams.ts b/packages/consumption/src/modules/attributeListeners/local/CreateLocalAttributeListenerParams.ts index 901a0903b..aa9e5ee58 100644 --- a/packages/consumption/src/modules/attributeListeners/local/CreateLocalAttributeListenerParams.ts +++ b/packages/consumption/src/modules/attributeListeners/local/CreateLocalAttributeListenerParams.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IIdentityAttributeQuery, IThirdPartyRelationshipAttributeQuery, IdentityAttributeQuery, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; export interface ICreateLocalAttributeListenerParams extends ISerializable { query: IIdentityAttributeQuery | IThirdPartyRelationshipAttributeQuery; diff --git a/packages/consumption/src/modules/attributeListeners/local/LocalAttributeListener.ts b/packages/consumption/src/modules/attributeListeners/local/LocalAttributeListener.ts index 9a0dcd666..8278edb63 100644 --- a/packages/consumption/src/modules/attributeListeners/local/LocalAttributeListener.ts +++ b/packages/consumption/src/modules/attributeListeners/local/LocalAttributeListener.ts @@ -7,7 +7,8 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryJSON } from "@nmshd/content"; -import { CoreAddress, CoreSynchronizable, ICoreAddress, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; export interface LocalAttributeListenerJSON { diff --git a/packages/consumption/src/modules/attributes/AttributesController.ts b/packages/consumption/src/modules/attributes/AttributesController.ts index 9f27964e3..abe7fd5d0 100644 --- a/packages/consumption/src/modules/attributes/AttributesController.ts +++ b/packages/consumption/src/modules/attributes/AttributesController.ts @@ -14,8 +14,9 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryOwner } from "@nmshd/content"; +import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; import * as iql from "@nmshd/iql"; -import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import _ from "lodash"; import { nameof } from "ts-simple-nameof"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; diff --git a/packages/consumption/src/modules/attributes/local/AttributeSuccessorParams.ts b/packages/consumption/src/modules/attributes/local/AttributeSuccessorParams.ts index 4426e7a1c..2b327fd5f 100644 --- a/packages/consumption/src/modules/attributes/local/AttributeSuccessorParams.ts +++ b/packages/consumption/src/modules/attributes/local/AttributeSuccessorParams.ts @@ -1,6 +1,6 @@ import { Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IdentityAttribute, RelationshipAttribute } from "@nmshd/content"; -import { CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/transport"; +import { CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; import { ILocalAttribute, LocalAttributeJSON } from "./LocalAttribute"; import { LocalAttributeShareInfo } from "./LocalAttributeShareInfo"; diff --git a/packages/consumption/src/modules/attributes/local/CreateAttributeParams.ts b/packages/consumption/src/modules/attributes/local/CreateAttributeParams.ts index 440043ada..947de0bfb 100644 --- a/packages/consumption/src/modules/attributes/local/CreateAttributeParams.ts +++ b/packages/consumption/src/modules/attributes/local/CreateAttributeParams.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IRelationshipAttribute, RelationshipAttribute } from "@nmshd/content"; -import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; export interface ICreateAttributeParams extends ISerializable { content: IRelationshipAttribute; diff --git a/packages/consumption/src/modules/attributes/local/CreateRepositoryAttributeParams.ts b/packages/consumption/src/modules/attributes/local/CreateRepositoryAttributeParams.ts index 0e081dcc4..b43f7f74e 100644 --- a/packages/consumption/src/modules/attributes/local/CreateRepositoryAttributeParams.ts +++ b/packages/consumption/src/modules/attributes/local/CreateRepositoryAttributeParams.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; import { IIdentityAttribute, IdentityAttribute, IdentityAttributeJSON, RelationshipAttribute } from "@nmshd/content"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; export interface CreateRepositoryAttributeParamsJSON { id?: string; diff --git a/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeCopyParams.ts b/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeCopyParams.ts index aecb1c229..45da5fd09 100644 --- a/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeCopyParams.ts +++ b/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeCopyParams.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; export interface CreateSharedLocalAttributeCopyParamsJSON { attributeId?: string; diff --git a/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeParams.ts b/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeParams.ts index 2f1cc5e81..89a0a3fc1 100644 --- a/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeParams.ts +++ b/packages/consumption/src/modules/attributes/local/CreateSharedLocalAttributeParams.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; import { IIdentityAttribute, IRelationshipAttribute, IdentityAttribute, IdentityAttributeJSON, RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; -import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; export interface CreateSharedLocalAttributeParamsJSON { id?: string; diff --git a/packages/consumption/src/modules/attributes/local/LocalAttribute.ts b/packages/consumption/src/modules/attributes/local/LocalAttribute.ts index de04070cd..78e3552e3 100644 --- a/packages/consumption/src/modules/attributes/local/LocalAttribute.ts +++ b/packages/consumption/src/modules/attributes/local/LocalAttribute.ts @@ -8,7 +8,8 @@ import { RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId, CoreSynchronizable, ICoreDate, ICoreId, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { ConsumptionIds } from "../../../consumption/ConsumptionIds"; import { CoreErrors } from "../../../consumption/CoreErrors"; diff --git a/packages/consumption/src/modules/attributes/local/LocalAttributeDeletionInfo.ts b/packages/consumption/src/modules/attributes/local/LocalAttributeDeletionInfo.ts index 405574332..be4a1e9c4 100644 --- a/packages/consumption/src/modules/attributes/local/LocalAttributeDeletionInfo.ts +++ b/packages/consumption/src/modules/attributes/local/LocalAttributeDeletionInfo.ts @@ -1,5 +1,5 @@ -import { serialize, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSerializable, ICoreDate } from "@nmshd/transport"; +import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; export enum LocalAttributeDeletionStatus { DeletionRequestSent = "DeletionRequestSent", @@ -15,12 +15,12 @@ export interface LocalAttributeDeletionInfoJSON { deletionDate: string; } -export interface ILocalAttributeDeletionInfo { +export interface ILocalAttributeDeletionInfo extends ISerializable { deletionStatus: LocalAttributeDeletionStatus; deletionDate: ICoreDate; } -export class LocalAttributeDeletionInfo extends CoreSerializable implements ILocalAttributeDeletionInfo { +export class LocalAttributeDeletionInfo extends Serializable implements ILocalAttributeDeletionInfo { @serialize() @validate({ customValidator: (v) => diff --git a/packages/consumption/src/modules/attributes/local/LocalAttributeShareInfo.ts b/packages/consumption/src/modules/attributes/local/LocalAttributeShareInfo.ts index ecd6d4e62..8ebc193b7 100644 --- a/packages/consumption/src/modules/attributes/local/LocalAttributeShareInfo.ts +++ b/packages/consumption/src/modules/attributes/local/LocalAttributeShareInfo.ts @@ -1,5 +1,5 @@ -import { Serializable, serialize, validate, ValidationError } from "@js-soft/ts-serval"; -import { CoreAddress, CoreId, CoreSerializable, ICoreAddress, ICoreId } from "@nmshd/transport"; +import { ISerializable, Serializable, serialize, validate, ValidationError } from "@js-soft/ts-serval"; +import { CoreAddress, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; @@ -13,7 +13,7 @@ export interface LocalAttributeShareInfoJSON { } /* Either of requestReference or noticicationReference must be set, but not both. */ -export interface ILocalAttributeShareInfo { +export interface ILocalAttributeShareInfo extends ISerializable { requestReference?: ICoreId; notificationReference?: ICoreId; @@ -21,7 +21,7 @@ export interface ILocalAttributeShareInfo { sourceAttribute?: ICoreId; } -export class LocalAttributeShareInfo extends CoreSerializable implements ILocalAttributeShareInfo { +export class LocalAttributeShareInfo extends Serializable implements ILocalAttributeShareInfo { @serialize() @validate({ nullable: true }) public requestReference?: CoreId; diff --git a/packages/consumption/src/modules/drafts/DraftsController.ts b/packages/consumption/src/modules/drafts/DraftsController.ts index bacbefaa3..187fa4e49 100644 --- a/packages/consumption/src/modules/drafts/DraftsController.ts +++ b/packages/consumption/src/modules/drafts/DraftsController.ts @@ -1,5 +1,6 @@ import { Serializable } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, SynchronizedCollection } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { SynchronizedCollection } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/drafts/local/Draft.ts b/packages/consumption/src/modules/drafts/local/Draft.ts index c51b5279a..126ae71fc 100644 --- a/packages/consumption/src/modules/drafts/local/Draft.ts +++ b/packages/consumption/src/modules/drafts/local/Draft.ts @@ -1,5 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSynchronizable, ICoreDate, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; export interface IDraft extends ICoreSynchronizable { diff --git a/packages/consumption/src/modules/notifications/NotificationsController.ts b/packages/consumption/src/modules/notifications/NotificationsController.ts index 23a8293ac..84544b746 100644 --- a/packages/consumption/src/modules/notifications/NotificationsController.ts +++ b/packages/consumption/src/modules/notifications/NotificationsController.ts @@ -1,6 +1,7 @@ import { Event, EventBus } from "@js-soft/ts-utils"; import { Notification, NotificationItem } from "@nmshd/content"; -import { CoreAddress, CoreId, Message, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { Message, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.ts index 984bf694f..98d3f8dd6 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.ts @@ -1,6 +1,7 @@ import { Event } from "@js-soft/ts-utils"; import { NotificationItem } from "@nmshd/content"; -import { AccountController, CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ValidationResult } from "../../common"; import { LocalNotification } from "../local/LocalNotification"; diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts index fa7a1da88..ab064c087 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts @@ -1,6 +1,7 @@ import { ILogger } from "@js-soft/logging-abstractions"; import { OwnSharedAttributeDeletedByOwnerNotificationItem } from "@nmshd/content"; -import { CoreDate, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus, OwnSharedAttributeDeletedByOwnerEvent } from "../../../attributes"; diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts index 4cbe4de6a..7e23fe183 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts @@ -1,6 +1,7 @@ import { ILogger } from "@js-soft/logging-abstractions"; import { PeerSharedAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { CoreDate, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { PeerSharedAttributeDeletedByPeerEvent } from "../../../attributes"; diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts index 9757ab061..1c3a37c0d 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts @@ -1,6 +1,7 @@ import { ILogger } from "@js-soft/logging-abstractions"; import { ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { CoreDate, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { ThirdPartyOwnedRelationshipAttributeDeletedByPeerEvent } from "../../../attributes"; diff --git a/packages/consumption/src/modules/notifications/local/LocalNotification.ts b/packages/consumption/src/modules/notifications/local/LocalNotification.ts index c6bf09b8c..130d97357 100644 --- a/packages/consumption/src/modules/notifications/local/LocalNotification.ts +++ b/packages/consumption/src/modules/notifications/local/LocalNotification.ts @@ -1,6 +1,7 @@ import { Serializable, serialize, type, validate, ValidationError } from "@js-soft/ts-serval"; import { INotification, Notification } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId, CoreSynchronizable, ICoreAddress, ICoreDate, ICoreId, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; import { ILocalNotificationSource, LocalNotificationSource } from "./LocalNotificationSource"; diff --git a/packages/consumption/src/modules/notifications/local/LocalNotificationSource.ts b/packages/consumption/src/modules/notifications/local/LocalNotificationSource.ts index 18f66e316..1fd6750a0 100644 --- a/packages/consumption/src/modules/notifications/local/LocalNotificationSource.ts +++ b/packages/consumption/src/modules/notifications/local/LocalNotificationSource.ts @@ -1,13 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "@nmshd/transport"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; -export interface ILocalNotificationSource extends ICoreSerializable { +export interface ILocalNotificationSource extends ISerializable { type: "Message"; reference: ICoreId; } @type("LocalNotificationSource") -export class LocalNotificationSource extends CoreSerializable implements ILocalNotificationSource { +export class LocalNotificationSource extends Serializable implements ILocalNotificationSource { @serialize() @validate() public type: "Message"; diff --git a/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts b/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts index cbbebdcd9..75f9768c9 100644 --- a/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts +++ b/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts @@ -1,5 +1,5 @@ import { RequestItem, RequestItemGroup } from "@nmshd/content"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { CoreErrors } from "../../../consumption/CoreErrors"; import { ValidationResult } from "../../common/ValidationResult"; import { LocalRequest } from "../local/LocalRequest"; diff --git a/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts b/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts index a34a5b7c8..18e3bb185 100644 --- a/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts +++ b/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts @@ -1,19 +1,8 @@ import { ServalError } from "@js-soft/ts-serval"; import { EventBus } from "@js-soft/ts-utils"; import { RequestItem, RequestItemGroup, Response, ResponseItemDerivations, ResponseItemGroup, ResponseResult } from "@nmshd/content"; -import { - CoreAddress, - CoreDate, - CoreId, - ICoreAddress, - ICoreId, - Message, - Relationship, - RelationshipStatus, - RelationshipTemplate, - SynchronizedCollection, - CoreErrors as TransportCoreErrors -} from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; +import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.ts b/packages/consumption/src/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.ts index 7eb3a912e..4655c92b1 100644 --- a/packages/consumption/src/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; export interface ICheckPrerequisitesOfIncomingRequestParameters extends ISerializable { requestId: ICoreId; diff --git a/packages/consumption/src/modules/requests/incoming/complete/CompleteIncomingRequestParameters.ts b/packages/consumption/src/modules/requests/incoming/complete/CompleteIncomingRequestParameters.ts index c71cfdc72..ff32c7925 100644 --- a/packages/consumption/src/modules/requests/incoming/complete/CompleteIncomingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/incoming/complete/CompleteIncomingRequestParameters.ts @@ -1,5 +1,6 @@ import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId, IMessage, IRelationship, Message, Relationship } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; +import { IMessage, IRelationship, Message, Relationship } from "@nmshd/transport"; export interface ICompleteIncomingRequestParameters extends ISerializable { requestId: ICoreId; diff --git a/packages/consumption/src/modules/requests/incoming/decide/InternalDecideRequestParameters.ts b/packages/consumption/src/modules/requests/incoming/decide/InternalDecideRequestParameters.ts index 6aa560809..f1278e15b 100644 --- a/packages/consumption/src/modules/requests/incoming/decide/InternalDecideRequestParameters.ts +++ b/packages/consumption/src/modules/requests/incoming/decide/InternalDecideRequestParameters.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { DecideRequestItemGroupParametersJSON } from "./DecideRequestItemGroupParameters"; import { DecideRequestItemParametersJSON } from "./DecideRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.ts b/packages/consumption/src/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.ts index e59bef8d9..4c1ec46f6 100644 --- a/packages/consumption/src/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; export interface IRequireManualDecisionOfIncomingRequestParameters extends ISerializable { requestId: ICoreId; diff --git a/packages/consumption/src/modules/requests/itemProcessors/AbstractRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/AbstractRequestItemProcessor.ts index a072b90a1..d9ce7f774 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/AbstractRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/AbstractRequestItemProcessor.ts @@ -1,6 +1,7 @@ import { Event } from "@js-soft/ts-utils"; import { AcceptResponseItem, RejectResponseItem, Request, RequestItem, ResponseItem } from "@nmshd/content"; -import { AccountController, CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ValidationResult } from "../../common/ValidationResult"; import { AcceptRequestItemParametersJSON } from "../incoming/decide/AcceptRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/GenericRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/GenericRequestItemProcessor.ts index 288e87544..272c0142f 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/GenericRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/GenericRequestItemProcessor.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { Event } from "@js-soft/ts-utils"; import { AcceptResponseItem, RejectResponseItem, Request, RequestItem, ResponseItem, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { ValidationResult } from "../../common/ValidationResult"; import { AcceptRequestItemParametersJSON } from "../incoming/decide/AcceptRequestItemParameters"; import { RejectRequestItemParametersJSON } from "../incoming/decide/RejectRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/IRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/IRequestItemProcessor.ts index a07f9ea4a..d65a1d360 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/IRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/IRequestItemProcessor.ts @@ -1,6 +1,6 @@ import { Event } from "@js-soft/ts-utils"; import { AcceptResponseItem, RejectResponseItem, Request, RequestItem, ResponseItem } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { ValidationResult } from "../../common/ValidationResult"; import { AcceptRequestItemParametersJSON } from "../incoming/decide/AcceptRequestItemParameters"; import { RejectRequestItemParametersJSON } from "../incoming/decide/RejectRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts index 87b225c8c..e7fefe558 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts @@ -1,5 +1,5 @@ import { CreateAttributeAcceptResponseItem, CreateAttributeRequestItem, IdentityAttribute, RejectResponseItem, Request, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { LocalAttribute } from "../../../attributes"; import { ValidationResult } from "../../../common/ValidationResult"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/AcceptDeleteAttributeRequestItemParameters.ts b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/AcceptDeleteAttributeRequestItemParameters.ts index c2dfbd6fe..edf32c064 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/AcceptDeleteAttributeRequestItemParameters.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/AcceptDeleteAttributeRequestItemParameters.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { AcceptRequestItemParametersJSON } from "../../incoming/decide/AcceptRequestItemParameters"; export interface AcceptDeleteAttributeRequestItemParametersJSON extends AcceptRequestItemParametersJSON { diff --git a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts index a0828896f..a3a09e5bc 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts @@ -1,5 +1,5 @@ import { AcceptResponseItem, DeleteAttributeAcceptResponseItem, DeleteAttributeRequestItem, RejectResponseItem, Request, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress, CoreDate } from "@nmshd/transport"; +import { CoreAddress, CoreDate } from "@nmshd/core-types"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../../attributes"; import { ValidationResult } from "../../../common/ValidationResult"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.ts b/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.ts index 029802bec..073d44cba 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.ts @@ -1,6 +1,6 @@ import { Serializable, serialize, type, validate, ValidationError } from "@js-soft/ts-serval"; import { IdentityAttribute, IdentityAttributeJSON, RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../../consumption/ConsumptionError"; import { AcceptRequestItemParametersJSON } from "../../incoming/decide/AcceptRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts index 1cef00582..c53ecd327 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.ts @@ -11,7 +11,8 @@ import { Request, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress, CoreId, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { AttributeSuccessorParams, LocalAttributeDeletionStatus, LocalAttributeShareInfo, PeerSharedAttributeSucceededEvent } from "../../../attributes"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.ts b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.ts index bff2f50c0..091c84d7d 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.ts @@ -1,6 +1,6 @@ import { Serializable, serialize, type, validate, ValidationError } from "@js-soft/ts-serval"; import { IdentityAttribute, IdentityAttributeJSON, RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../../consumption/ConsumptionError"; import { AcceptRequestItemParametersJSON } from "../../incoming/decide/AcceptRequestItemParameters"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts index 11b5bbbf8..633e36f07 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts @@ -13,7 +13,8 @@ import { ResponseItemResult, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { CoreAddress, CoreId, RelationshipStatus, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { RelationshipStatus, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { AttributeSuccessorParams, LocalAttributeDeletionStatus, LocalAttributeShareInfo, PeerSharedAttributeSucceededEvent } from "../../../attributes"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts index d5a5a0bd1..c0b027040 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts @@ -8,7 +8,8 @@ import { ShareAttributeAcceptResponseItem, ShareAttributeRequestItem } from "@nmshd/content"; -import { CoreAddress, RelationshipStatus } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { RelationshipStatus } from "@nmshd/transport"; import _ from "lodash"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { LocalAttributeDeletionStatus } from "../../../attributes"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts b/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts index bc8173162..3b6366ea7 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts @@ -7,7 +7,7 @@ import { RelationshipAttributeQuery, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { ValidationResult } from "../../../common/ValidationResult"; diff --git a/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts b/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts index 1c8458e15..c598eb8e8 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts @@ -1,6 +1,6 @@ import { IdentityAttributeQuery, IQLQuery, RelationshipAttributeQuery, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; +import { CoreAddress } from "@nmshd/core-types"; import { validate as iqlValidate } from "@nmshd/iql"; -import { CoreAddress } from "@nmshd/transport"; import { CoreErrors } from "../../../../consumption/CoreErrors"; import { ValidationResult } from "../../../common/ValidationResult"; diff --git a/packages/consumption/src/modules/requests/local/LocalRequest.ts b/packages/consumption/src/modules/requests/local/LocalRequest.ts index f5ce6ac36..7f713caf4 100644 --- a/packages/consumption/src/modules/requests/local/LocalRequest.ts +++ b/packages/consumption/src/modules/requests/local/LocalRequest.ts @@ -1,19 +1,21 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IRequest, Request } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId, CoreSerializable, CoreSynchronizable, ICoreAddress, ICoreDate, ICoreId, ICoreSerializable, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; + +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; import { LocalRequestStatus } from "./LocalRequestStatus"; import { ILocalRequestStatusLogEntry, LocalRequestStatusLogEntry } from "./LocalRequestStatusLogEntry"; import { ILocalResponse, LocalResponse } from "./LocalResponse"; -export interface ILocalRequestSource extends ICoreSerializable { +export interface ILocalRequestSource extends ISerializable { type: "Message" | "RelationshipTemplate"; reference: ICoreId; } @type("LocalRequestSource") -export class LocalRequestSource extends CoreSerializable implements ILocalRequestSource { +export class LocalRequestSource extends Serializable implements ILocalRequestSource { @serialize() @validate() public type: "Message" | "RelationshipTemplate"; diff --git a/packages/consumption/src/modules/requests/local/LocalRequestStatusLogEntry.ts b/packages/consumption/src/modules/requests/local/LocalRequestStatusLogEntry.ts index 4f9668011..b1d9b941e 100644 --- a/packages/consumption/src/modules/requests/local/LocalRequestStatusLogEntry.ts +++ b/packages/consumption/src/modules/requests/local/LocalRequestStatusLogEntry.ts @@ -1,8 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSerializable, ICoreDate, ICoreSerializable } from "@nmshd/transport"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { LocalRequestStatus } from "./LocalRequestStatus"; -export interface ILocalRequestStatusLogEntry extends ICoreSerializable { +export interface ILocalRequestStatusLogEntry extends ISerializable { createdAt: ICoreDate; oldStatus: LocalRequestStatus; newStatus: LocalRequestStatus; @@ -11,7 +11,7 @@ export interface ILocalRequestStatusLogEntry extends ICoreSerializable { } @type("LocalRequestStatusLogEntry") -export class LocalRequestStatusLogEntry extends CoreSerializable implements ILocalRequestStatusLogEntry { +export class LocalRequestStatusLogEntry extends Serializable implements ILocalRequestStatusLogEntry { @serialize() @validate() public createdAt: CoreDate; diff --git a/packages/consumption/src/modules/requests/local/LocalResponse.ts b/packages/consumption/src/modules/requests/local/LocalResponse.ts index 6b28933c3..4a1988947 100644 --- a/packages/consumption/src/modules/requests/local/LocalResponse.ts +++ b/packages/consumption/src/modules/requests/local/LocalResponse.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IResponse, Response } from "@nmshd/content"; -import { CoreDate, CoreId, CoreSerializable, ICoreDate, ICoreId, ICoreSerializable } from "@nmshd/transport"; +import { CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; -export interface ILocalResponseSource extends ICoreSerializable { +export interface ILocalResponseSource extends ISerializable { type: "Message" | "Relationship"; reference: ICoreId; } @type("LocalResponseSource") -export class LocalResponseSource extends CoreSerializable implements ILocalResponseSource { +export class LocalResponseSource extends Serializable implements ILocalResponseSource { @serialize() @validate() public type: "Message" | "Relationship"; @@ -22,14 +22,14 @@ export class LocalResponseSource extends CoreSerializable implements ILocalRespo } } -export interface ILocalResponse extends ICoreSerializable { +export interface ILocalResponse extends ISerializable { createdAt: ICoreDate; content: IResponse; source?: ILocalResponseSource; } @type("LocalResponse") -export class LocalResponse extends CoreSerializable implements ILocalResponse { +export class LocalResponse extends Serializable implements ILocalResponse { @serialize() @validate() public createdAt: CoreDate; diff --git a/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts b/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts index 1a4523607..8d0fe37a7 100644 --- a/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts +++ b/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts @@ -1,17 +1,7 @@ import { EventBus } from "@js-soft/ts-utils"; import { DeleteAttributeRequestItem, RelationshipTemplateContent, Request, RequestItem, RequestItemGroup, Response, ResponseItem, ResponseItemGroup } from "@nmshd/content"; -import { - CoreAddress, - CoreDate, - CoreId, - ICoreId, - Message, - Relationship, - RelationshipStatus, - RelationshipTemplate, - SynchronizedCollection, - CoreErrors as TransportCoreErrors -} from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; +import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.ts b/packages/consumption/src/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.ts index a97d8a8f2..7aa509402 100644 --- a/packages/consumption/src/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.ts @@ -1,6 +1,7 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IResponse, Response } from "@nmshd/content"; -import { CoreId, ICoreId, IMessage, Message } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; +import { IMessage, Message } from "@nmshd/transport"; export interface ICompleteOutgoingRequestParameters extends ISerializable { requestId: ICoreId; diff --git a/packages/consumption/src/modules/requests/outgoing/createAndCompleteFromRelationshipTemplateResponse/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponseParameters.ts b/packages/consumption/src/modules/requests/outgoing/createAndCompleteFromRelationshipTemplateResponse/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponseParameters.ts index aee050f58..fac9e2c78 100644 --- a/packages/consumption/src/modules/requests/outgoing/createAndCompleteFromRelationshipTemplateResponse/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponseParameters.ts +++ b/packages/consumption/src/modules/requests/outgoing/createAndCompleteFromRelationshipTemplateResponse/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponseParameters.ts @@ -1,6 +1,7 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IResponse, Response } from "@nmshd/content"; -import { CoreDate, IMessage, IRelationship, IRelationshipTemplate, Message, Relationship, RelationshipTemplate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { IMessage, IRelationship, IRelationshipTemplate, Message, Relationship, RelationshipTemplate } from "@nmshd/transport"; export interface ICreateAndCompleteOutgoingRequestFromRelationshipTemplateResponseParameters extends ISerializable { template: IRelationshipTemplate; diff --git a/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.ts b/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.ts index cec982705..8f5991926 100644 --- a/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { Request } from "@nmshd/content"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { IRequestWithoutId, RequestJSONWithoutId } from "./CreateOutgoingRequestParameters"; export interface ICanCreateOutgoingRequestParameters extends ISerializable { diff --git a/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.ts b/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.ts index 1e38b378a..55ca31e41 100644 --- a/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.ts @@ -1,6 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IRequest, Request, RequestJSON } from "@nmshd/content"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; export type IRequestWithoutId = Omit; export type RequestJSONWithoutId = Omit; diff --git a/packages/consumption/src/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.ts b/packages/consumption/src/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.ts index 7247fbd8f..a66995082 100644 --- a/packages/consumption/src/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.ts +++ b/packages/consumption/src/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.ts @@ -1,5 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId, IMessage, Message } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; +import { IMessage, Message } from "@nmshd/transport"; export interface ISentOutgoingRequestParameters extends ISerializable { requestId: ICoreId; diff --git a/packages/consumption/src/modules/settings/SettingsController.ts b/packages/consumption/src/modules/settings/SettingsController.ts index 9f3424b17..489f5a330 100644 --- a/packages/consumption/src/modules/settings/SettingsController.ts +++ b/packages/consumption/src/modules/settings/SettingsController.ts @@ -1,5 +1,6 @@ import { log } from "@js-soft/ts-utils"; -import { CoreDate, CoreId, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/settings/local/CreateSettingParameter.ts b/packages/consumption/src/modules/settings/local/CreateSettingParameter.ts index ffe6d1a72..a8c3bd891 100644 --- a/packages/consumption/src/modules/settings/local/CreateSettingParameter.ts +++ b/packages/consumption/src/modules/settings/local/CreateSettingParameter.ts @@ -1,5 +1,5 @@ import { Serializable } from "@js-soft/ts-serval"; -import { CoreDate, CoreId } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { SettingScope } from "./Setting"; export interface ICreateSettingParameters { diff --git a/packages/consumption/src/modules/settings/local/Setting.ts b/packages/consumption/src/modules/settings/local/Setting.ts index 91fe59f76..08afb868c 100644 --- a/packages/consumption/src/modules/settings/local/Setting.ts +++ b/packages/consumption/src/modules/settings/local/Setting.ts @@ -1,5 +1,6 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, CoreSynchronizable, ICoreDate, ICoreId, ICoreSynchronizable } from "@nmshd/transport"; +import { CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; +import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; export enum SettingScope { diff --git a/packages/content/src/attributes/AbstractAttribute.ts b/packages/content/src/attributes/AbstractAttribute.ts index 0d3e75804..c27de7720 100644 --- a/packages/content/src/attributes/AbstractAttribute.ts +++ b/packages/content/src/attributes/AbstractAttribute.ts @@ -1,5 +1,5 @@ import { serialize, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreSerializable, ICoreAddress, ICoreDate, ICoreSerializable } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreSerializable, ICoreAddress, ICoreDate, ICoreSerializable } from "@nmshd/core-types"; import { ContentJSON } from "../ContentJSON"; export interface AbstractAttributeJSON extends ContentJSON { diff --git a/packages/content/src/attributes/AbstractAttributeQuery.ts b/packages/content/src/attributes/AbstractAttributeQuery.ts index a4ebb947e..5658b8abf 100644 --- a/packages/content/src/attributes/AbstractAttributeQuery.ts +++ b/packages/content/src/attributes/AbstractAttributeQuery.ts @@ -1,4 +1,4 @@ -import { CoreSerializable, ICoreSerializable } from "@nmshd/transport"; +import { CoreSerializable, ICoreSerializable } from "@nmshd/core-types"; import { ContentJSON } from "../ContentJSON"; export interface AbstractAttributeQueryJSON extends ContentJSON {} diff --git a/packages/content/src/attributes/IdentityAttributeQuery.ts b/packages/content/src/attributes/IdentityAttributeQuery.ts index 3a8002966..495b17631 100644 --- a/packages/content/src/attributes/IdentityAttributeQuery.ts +++ b/packages/content/src/attributes/IdentityAttributeQuery.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, ICoreDate } from "@nmshd/transport"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { AbstractAttributeQuery, AbstractAttributeQueryJSON, IAbstractAttributeQuery } from "./AbstractAttributeQuery"; import { AttributeValues } from "./AttributeValueTypes"; diff --git a/packages/content/src/attributes/RelationshipAttributeQuery.ts b/packages/content/src/attributes/RelationshipAttributeQuery.ts index ee7c4cbb4..83c38576a 100644 --- a/packages/content/src/attributes/RelationshipAttributeQuery.ts +++ b/packages/content/src/attributes/RelationshipAttributeQuery.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/transport"; +import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { AbstractAttributeQuery, AbstractAttributeQueryJSON, IAbstractAttributeQuery } from "./AbstractAttributeQuery"; import { AttributeValues } from "./AttributeValueTypes"; import { IValueHints, ValueHints, ValueHintsJSON } from "./hints"; diff --git a/packages/content/src/attributes/ThirdPartyRelationshipAttributeQuery.ts b/packages/content/src/attributes/ThirdPartyRelationshipAttributeQuery.ts index 7b74944c4..64c61a634 100644 --- a/packages/content/src/attributes/ThirdPartyRelationshipAttributeQuery.ts +++ b/packages/content/src/attributes/ThirdPartyRelationshipAttributeQuery.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/transport"; +import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { AbstractAttributeQuery, AbstractAttributeQueryJSON, IAbstractAttributeQuery } from "./AbstractAttributeQuery"; export interface ThirdPartyRelationshipAttributeQueryJSON extends AbstractAttributeQueryJSON { "@type": "ThirdPartyRelationshipAttributeQuery"; diff --git a/packages/content/src/attributes/types/statement/DigitalIdentityDescriptor.ts b/packages/content/src/attributes/types/statement/DigitalIdentityDescriptor.ts index 65fe8eaf3..4c17e7726 100644 --- a/packages/content/src/attributes/types/statement/DigitalIdentityDescriptor.ts +++ b/packages/content/src/attributes/types/statement/DigitalIdentityDescriptor.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { RenderHints, RenderHintsEditType, RenderHintsTechnicalType, ValueHints } from "../../../attributes/hints"; import { nameof } from "ts-simple-nameof"; diff --git a/packages/content/src/attributes/types/statement/StatementIssuerConditions.ts b/packages/content/src/attributes/types/statement/StatementIssuerConditions.ts index cdd62750c..f2eb3117d 100644 --- a/packages/content/src/attributes/types/statement/StatementIssuerConditions.ts +++ b/packages/content/src/attributes/types/statement/StatementIssuerConditions.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, ICoreDate } from "@nmshd/transport"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { AbstractComplexValue, AbstractComplexValueJSON, IAbstractComplexValue } from "../../AbstractComplexValue"; import { RenderHints, RenderHintsEditType, RenderHintsTechnicalType, ValueHints } from "../../hints"; diff --git a/packages/content/src/attributes/types/statement/StatementObject.ts b/packages/content/src/attributes/types/statement/StatementObject.ts index 5394a05fb..6c84f3dab 100644 --- a/packages/content/src/attributes/types/statement/StatementObject.ts +++ b/packages/content/src/attributes/types/statement/StatementObject.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { RenderHints, RenderHintsEditType, RenderHintsTechnicalType, ValueHints } from "../../../attributes/hints"; import { AbstractIdentityDescriptor, AbstractIdentityDescriptorJSON, IAbstractIdentityDescriptor } from "./AbstractIdentityDescriptor"; diff --git a/packages/content/src/attributes/types/statement/StatementSubject.ts b/packages/content/src/attributes/types/statement/StatementSubject.ts index 6cf75e52c..ce3808c33 100644 --- a/packages/content/src/attributes/types/statement/StatementSubject.ts +++ b/packages/content/src/attributes/types/statement/StatementSubject.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { RenderHints, RenderHintsEditType, RenderHintsTechnicalType, ValueHints } from "../../../attributes/hints"; import { AbstractIdentityDescriptor, AbstractIdentityDescriptorJSON, IAbstractIdentityDescriptor } from "./AbstractIdentityDescriptor"; diff --git a/packages/content/src/buildInformation.ts b/packages/content/src/buildInformation.ts index 401c0e68e..f83c6d4d9 100644 --- a/packages/content/src/buildInformation.ts +++ b/packages/content/src/buildInformation.ts @@ -1,6 +1,5 @@ import { buildInformation as servalBuildInformation } from "@js-soft/ts-serval"; import { buildInformation as cryptoBuildInformation } from "@nmshd/crypto"; -import { buildInformation as transportBuildInformation } from "@nmshd/transport"; export const buildInformation = { version: "{{version}}", @@ -10,7 +9,6 @@ export const buildInformation = { dependencies: "{{dependencies}}", libraries: { serval: servalBuildInformation, - crypto: cryptoBuildInformation, - transport: transportBuildInformation + crypto: cryptoBuildInformation } }; diff --git a/packages/content/src/messages/Mail.ts b/packages/content/src/messages/Mail.ts index f8337432a..662771d4f 100644 --- a/packages/content/src/messages/Mail.ts +++ b/packages/content/src/messages/Mail.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, ICoreAddress } from "@nmshd/transport"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { ContentJSON } from "../ContentJSON"; export interface MailJSON extends ContentJSON { diff --git a/packages/content/src/notifications/Notification.ts b/packages/content/src/notifications/Notification.ts index e08885411..530907ba3 100644 --- a/packages/content/src/notifications/Notification.ts +++ b/packages/content/src/notifications/Notification.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { INotificationItem, NotificationItem, NotificationItemJSON } from "./NotificationItem"; export interface NotificationJSON { diff --git a/packages/content/src/notifications/items/OwnSharedAttributeDeletedByOwnerNotificationItem.ts b/packages/content/src/notifications/items/OwnSharedAttributeDeletedByOwnerNotificationItem.ts index 37541b302..39f087f89 100644 --- a/packages/content/src/notifications/items/OwnSharedAttributeDeletedByOwnerNotificationItem.ts +++ b/packages/content/src/notifications/items/OwnSharedAttributeDeletedByOwnerNotificationItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { INotificationItem, NotificationItem, NotificationItemJSON } from "../NotificationItem"; export interface OwnSharedAttributeDeletedByOwnerNotificationItemJSON extends NotificationItemJSON { diff --git a/packages/content/src/notifications/items/PeerSharedAttributeDeletedByPeerNotificationItem.ts b/packages/content/src/notifications/items/PeerSharedAttributeDeletedByPeerNotificationItem.ts index b808a02c8..a5a03625a 100644 --- a/packages/content/src/notifications/items/PeerSharedAttributeDeletedByPeerNotificationItem.ts +++ b/packages/content/src/notifications/items/PeerSharedAttributeDeletedByPeerNotificationItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { INotificationItem, NotificationItem, NotificationItemJSON } from "../NotificationItem"; export interface PeerSharedAttributeDeletedByPeerNotificationItemJSON extends NotificationItemJSON { diff --git a/packages/content/src/notifications/items/PeerSharedAttributeSucceededNotificationItem.ts b/packages/content/src/notifications/items/PeerSharedAttributeSucceededNotificationItem.ts index cef8cf0e1..6ea719f50 100644 --- a/packages/content/src/notifications/items/PeerSharedAttributeSucceededNotificationItem.ts +++ b/packages/content/src/notifications/items/PeerSharedAttributeSucceededNotificationItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { IdentityAttribute, IdentityAttributeJSON, IIdentityAttribute, IRelationshipAttribute, RelationshipAttribute, RelationshipAttributeJSON } from "../../attributes"; import { INotificationItem, NotificationItem, NotificationItemJSON } from "../NotificationItem"; diff --git a/packages/content/src/notifications/items/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem.ts b/packages/content/src/notifications/items/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem.ts index 1580ed44b..b6cb287c7 100644 --- a/packages/content/src/notifications/items/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem.ts +++ b/packages/content/src/notifications/items/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { INotificationItem, NotificationItem, NotificationItemJSON } from "../NotificationItem"; export interface ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemJSON extends NotificationItemJSON { diff --git a/packages/content/src/requests/Request.ts b/packages/content/src/requests/Request.ts index b77f3b5d7..c5895937c 100644 --- a/packages/content/src/requests/Request.ts +++ b/packages/content/src/requests/Request.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, ICoreDate } from "@nmshd/transport"; +import { CoreDate, CoreId, ICoreDate } from "@nmshd/core-types"; import { ContentJSON } from "../ContentJSON"; import { IRequestItemDerivations, RequestItemDerivations, RequestItemJSONDerivations } from "./RequestItem"; import { IRequestItemGroup, RequestItemGroup, RequestItemGroupJSON } from "./RequestItemGroup"; diff --git a/packages/content/src/requests/ResponseWrapper.ts b/packages/content/src/requests/ResponseWrapper.ts index 58edaf929..54fd29c0a 100644 --- a/packages/content/src/requests/ResponseWrapper.ts +++ b/packages/content/src/requests/ResponseWrapper.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { IResponse, Response, ResponseJSON } from "./response"; export interface ResponseWrapperJSON { diff --git a/packages/content/src/requests/items/common/AttributeAlreadySharedAcceptResponseItem.ts b/packages/content/src/requests/items/common/AttributeAlreadySharedAcceptResponseItem.ts index 5f6013fb4..bc85a5f66 100644 --- a/packages/content/src/requests/items/common/AttributeAlreadySharedAcceptResponseItem.ts +++ b/packages/content/src/requests/items/common/AttributeAlreadySharedAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; export interface AttributeAlreadySharedAcceptResponseItemJSON extends AcceptResponseItemJSON { diff --git a/packages/content/src/requests/items/common/AttributeSuccessionAcceptResponseItem.ts b/packages/content/src/requests/items/common/AttributeSuccessionAcceptResponseItem.ts index dce6ffc26..9ef44b861 100644 --- a/packages/content/src/requests/items/common/AttributeSuccessionAcceptResponseItem.ts +++ b/packages/content/src/requests/items/common/AttributeSuccessionAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { IdentityAttribute, IdentityAttributeJSON, IIdentityAttribute, IRelationshipAttribute, RelationshipAttribute, RelationshipAttributeJSON } from "../../../attributes"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; diff --git a/packages/content/src/requests/items/createAttribute/CreateAttributeAcceptResponseItem.ts b/packages/content/src/requests/items/createAttribute/CreateAttributeAcceptResponseItem.ts index 35646b286..9489b4769 100644 --- a/packages/content/src/requests/items/createAttribute/CreateAttributeAcceptResponseItem.ts +++ b/packages/content/src/requests/items/createAttribute/CreateAttributeAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; export interface CreateAttributeAcceptResponseItemJSON extends AcceptResponseItemJSON { diff --git a/packages/content/src/requests/items/deleteAttribute/DeleteAttributeAcceptResponseItem.ts b/packages/content/src/requests/items/deleteAttribute/DeleteAttributeAcceptResponseItem.ts index 237f0a04d..d27d24409 100644 --- a/packages/content/src/requests/items/deleteAttribute/DeleteAttributeAcceptResponseItem.ts +++ b/packages/content/src/requests/items/deleteAttribute/DeleteAttributeAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, ICoreDate } from "@nmshd/transport"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; export interface DeleteAttributeAcceptResponseItemJSON extends AcceptResponseItemJSON { diff --git a/packages/content/src/requests/items/deleteAttribute/DeleteAttributeRequestItem.ts b/packages/content/src/requests/items/deleteAttribute/DeleteAttributeRequestItem.ts index 701f29621..e01944811 100644 --- a/packages/content/src/requests/items/deleteAttribute/DeleteAttributeRequestItem.ts +++ b/packages/content/src/requests/items/deleteAttribute/DeleteAttributeRequestItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { RequestItemJSON } from "../.."; import { IRequestItem, RequestItem } from "../../RequestItem"; diff --git a/packages/content/src/requests/items/proposeAttribute/ProposeAttributeAcceptResponseItem.ts b/packages/content/src/requests/items/proposeAttribute/ProposeAttributeAcceptResponseItem.ts index 8ffccd90b..76738326f 100644 --- a/packages/content/src/requests/items/proposeAttribute/ProposeAttributeAcceptResponseItem.ts +++ b/packages/content/src/requests/items/proposeAttribute/ProposeAttributeAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { IdentityAttribute, IdentityAttributeJSON, IIdentityAttribute, IRelationshipAttribute, RelationshipAttribute, RelationshipAttributeJSON } from "../../../attributes"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; diff --git a/packages/content/src/requests/items/readAttribute/ReadAttributeAcceptResponseItem.ts b/packages/content/src/requests/items/readAttribute/ReadAttributeAcceptResponseItem.ts index c29b04993..61736eba1 100644 --- a/packages/content/src/requests/items/readAttribute/ReadAttributeAcceptResponseItem.ts +++ b/packages/content/src/requests/items/readAttribute/ReadAttributeAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { IdentityAttribute, IdentityAttributeJSON, IIdentityAttribute, IRelationshipAttribute, RelationshipAttribute, RelationshipAttributeJSON } from "../../../attributes"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; diff --git a/packages/content/src/requests/items/shareAttribute/ShareAttributeAcceptResponseItem.ts b/packages/content/src/requests/items/shareAttribute/ShareAttributeAcceptResponseItem.ts index 788f6e3d6..3f1d03e91 100644 --- a/packages/content/src/requests/items/shareAttribute/ShareAttributeAcceptResponseItem.ts +++ b/packages/content/src/requests/items/shareAttribute/ShareAttributeAcceptResponseItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { AcceptResponseItem, AcceptResponseItemJSON, IAcceptResponseItem } from "../../response"; export interface ShareAttributeAcceptResponseItemJSON extends AcceptResponseItemJSON { diff --git a/packages/content/src/requests/items/shareAttribute/ShareAttributeRequestItem.ts b/packages/content/src/requests/items/shareAttribute/ShareAttributeRequestItem.ts index 55a16ab22..12443380c 100644 --- a/packages/content/src/requests/items/shareAttribute/ShareAttributeRequestItem.ts +++ b/packages/content/src/requests/items/shareAttribute/ShareAttributeRequestItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { RequestItemJSON } from "../.."; import { IdentityAttribute, IdentityAttributeJSON, IIdentityAttribute, IRelationshipAttribute, RelationshipAttribute, RelationshipAttributeJSON } from "../../../attributes"; import { IRequestItem, RequestItem } from "../../RequestItem"; diff --git a/packages/content/src/requests/response/Response.ts b/packages/content/src/requests/response/Response.ts index b4608277c..b0bc1f542 100644 --- a/packages/content/src/requests/response/Response.ts +++ b/packages/content/src/requests/response/Response.ts @@ -1,5 +1,5 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, ICoreId } from "@nmshd/transport"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { ContentJSON } from "../../ContentJSON"; import { IResponseItemDerivations, ResponseItemDerivations, ResponseItemJSONDerivations } from "./ResponseItem"; import { IResponseItemGroup, ResponseItemGroup, ResponseItemGroupJSON } from "./ResponseItemGroup"; diff --git a/packages/runtime/src/Runtime.ts b/packages/runtime/src/Runtime.ts index 76eed1cb9..7ee4c97da 100644 --- a/packages/runtime/src/Runtime.ts +++ b/packages/runtime/src/Runtime.ts @@ -11,6 +11,7 @@ import { OutgoingRequestsController, SettingsController } from "@nmshd/consumption"; +import { ICoreAddress } from "@nmshd/core-types"; import { AccountController, AnonymousTokenController, @@ -20,7 +21,6 @@ import { DevicesController, FileController, IConfigOverwrite, - ICoreAddress, IdentityController, IdentityDeletionProcessController, MessageController, diff --git a/packages/runtime/src/dataViews/DataViewExpander.ts b/packages/runtime/src/dataViews/DataViewExpander.ts index b9b8f3443..726fcec18 100644 --- a/packages/runtime/src/dataViews/DataViewExpander.ts +++ b/packages/runtime/src/dataViews/DataViewExpander.ts @@ -51,7 +51,8 @@ import { ValueHintsJSON, isRequestItemDerivation } from "@nmshd/content"; -import { CoreAddress, CoreId, IdentityController } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { IdentityController } from "@nmshd/transport"; import _ from "lodash"; import { Inject } from "typescript-ioc"; import { diff --git a/packages/runtime/src/useCases/anonymous/tokens/LoadPeerTokenAnonymousByIdAndKey.ts b/packages/runtime/src/useCases/anonymous/tokens/LoadPeerTokenAnonymousByIdAndKey.ts index 1f35c5118..65e853332 100644 --- a/packages/runtime/src/useCases/anonymous/tokens/LoadPeerTokenAnonymousByIdAndKey.ts +++ b/packages/runtime/src/useCases/anonymous/tokens/LoadPeerTokenAnonymousByIdAndKey.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { AnonymousTokenController, CoreId } from "@nmshd/transport"; +import { AnonymousTokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { SchemaRepository, SchemaValidator, TokenIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/common/RuntimeErrors.ts b/packages/runtime/src/useCases/common/RuntimeErrors.ts index dd2745b4c..e51c866c6 100644 --- a/packages/runtime/src/useCases/common/RuntimeErrors.ts +++ b/packages/runtime/src/useCases/common/RuntimeErrors.ts @@ -1,6 +1,6 @@ import { ApplicationError } from "@js-soft/ts-utils"; import { LocalAttribute } from "@nmshd/consumption"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { Base64ForIdPrefix } from "./Base64ForIdPrefix"; class General { diff --git a/packages/runtime/src/useCases/consumption/attributeListeners/GetAttributeListener.ts b/packages/runtime/src/useCases/consumption/attributeListeners/GetAttributeListener.ts index 8ffa24bd8..dbbfa81b3 100644 --- a/packages/runtime/src/useCases/consumption/attributeListeners/GetAttributeListener.ts +++ b/packages/runtime/src/useCases/consumption/attributeListeners/GetAttributeListener.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { AttributeListenersController, LocalAttributeListener } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalAttributeListenerDTO } from "../../../types"; import { AttributeListenerIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/ChangeDefaultRepositoryAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/ChangeDefaultRepositoryAttribute.ts index a50001c15..4b27a2551 100644 --- a/packages/runtime/src/useCases/consumption/attributes/ChangeDefaultRepositoryAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/ChangeDefaultRepositoryAttribute.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, LocalAttribute } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AttributeIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/CreateAndShareRelationshipAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/CreateAndShareRelationshipAttribute.ts index 8883e65e0..809fde551 100644 --- a/packages/runtime/src/useCases/consumption/attributes/CreateAndShareRelationshipAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/CreateAndShareRelationshipAttribute.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { CreateOutgoingRequestParameters, OutgoingRequestsController } from "@nmshd/consumption"; import { AttributeValues, CreateAttributeRequestItem, RelationshipAttribute, RelationshipAttributeConfidentiality, Request } from "@nmshd/content"; -import { AccountController, CoreAddress, MessageController } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { AddressString, ISO8601DateTimeString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/DeleteOwnSharedAttributeAndNotifyPeer.ts b/packages/runtime/src/useCases/consumption/attributes/DeleteOwnSharedAttributeAndNotifyPeer.ts index ad6997b1d..688138f5b 100644 --- a/packages/runtime/src/useCases/consumption/attributes/DeleteOwnSharedAttributeAndNotifyPeer.ts +++ b/packages/runtime/src/useCases/consumption/attributes/DeleteOwnSharedAttributeAndNotifyPeer.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, ConsumptionIds, LocalAttribute } from "@nmshd/consumption"; import { Notification, OwnSharedAttributeDeletedByOwnerNotificationItem } from "@nmshd/content"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { AttributeIdString, NotificationIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/DeletePeerSharedAttributeAndNotifyOwner.ts b/packages/runtime/src/useCases/consumption/attributes/DeletePeerSharedAttributeAndNotifyOwner.ts index f2498be9b..98e116326 100644 --- a/packages/runtime/src/useCases/consumption/attributes/DeletePeerSharedAttributeAndNotifyOwner.ts +++ b/packages/runtime/src/useCases/consumption/attributes/DeletePeerSharedAttributeAndNotifyOwner.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, ConsumptionIds, LocalAttribute } from "@nmshd/consumption"; import { Notification, PeerSharedAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { AttributeIdString, NotificationIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/DeleteRepositoryAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/DeleteRepositoryAttribute.ts index 9cd2db75f..08744a806 100644 --- a/packages/runtime/src/useCases/consumption/attributes/DeleteRepositoryAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/DeleteRepositoryAttribute.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, LocalAttribute } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { AttributeIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/DeleteSharedAttributesForRejectedOrRevokedRelationship.ts b/packages/runtime/src/useCases/consumption/attributes/DeleteSharedAttributesForRejectedOrRevokedRelationship.ts index 4041be704..7e5cebaaa 100644 --- a/packages/runtime/src/useCases/consumption/attributes/DeleteSharedAttributesForRejectedOrRevokedRelationship.ts +++ b/packages/runtime/src/useCases/consumption/attributes/DeleteSharedAttributesForRejectedOrRevokedRelationship.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController } from "@nmshd/consumption"; -import { AccountController, CoreId, Relationship, RelationshipsController, RelationshipStatus } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController, RelationshipStatus } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/DeleteThirdPartyOwnedRelationshipAttributeAndNotifyPeer.ts b/packages/runtime/src/useCases/consumption/attributes/DeleteThirdPartyOwnedRelationshipAttributeAndNotifyPeer.ts index d34e82b3a..f406663c2 100644 --- a/packages/runtime/src/useCases/consumption/attributes/DeleteThirdPartyOwnedRelationshipAttributeAndNotifyPeer.ts +++ b/packages/runtime/src/useCases/consumption/attributes/DeleteThirdPartyOwnedRelationshipAttributeAndNotifyPeer.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, ConsumptionIds, LocalAttribute } from "@nmshd/consumption"; import { Notification, ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { AttributeIdString, NotificationIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/GetAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/GetAttribute.ts index 54ce22abc..7cd042c62 100644 --- a/packages/runtime/src/useCases/consumption/attributes/GetAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/GetAttribute.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, LocalAttribute } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AttributeIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/GetSharedVersionsOfAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/GetSharedVersionsOfAttribute.ts index 20e02b269..37ee084db 100644 --- a/packages/runtime/src/useCases/consumption/attributes/GetSharedVersionsOfAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/GetSharedVersionsOfAttribute.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, LocalAttribute } from "@nmshd/consumption"; -import { AccountController, CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AddressString, AttributeIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/GetVersionsOfAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/GetVersionsOfAttribute.ts index a39a6120c..db55b8f91 100644 --- a/packages/runtime/src/useCases/consumption/attributes/GetVersionsOfAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/GetVersionsOfAttribute.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, LocalAttribute } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AttributeIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/NotifyPeerAboutRepositoryAttributeSuccession.ts b/packages/runtime/src/useCases/consumption/attributes/NotifyPeerAboutRepositoryAttributeSuccession.ts index 20386ee25..1121dccec 100644 --- a/packages/runtime/src/useCases/consumption/attributes/NotifyPeerAboutRepositoryAttributeSuccession.ts +++ b/packages/runtime/src/useCases/consumption/attributes/NotifyPeerAboutRepositoryAttributeSuccession.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, ConsumptionIds, IAttributeSuccessorParams, LocalAttribute } from "@nmshd/consumption"; import { Notification, PeerSharedAttributeSucceededNotificationItem } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreId, MessageController } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AddressString, AttributeIdString, NotificationIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/ShareRepositoryAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/ShareRepositoryAttribute.ts index db2383600..5671da82a 100644 --- a/packages/runtime/src/useCases/consumption/attributes/ShareRepositoryAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/ShareRepositoryAttribute.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, CreateOutgoingRequestParameters, ErrorValidationResult, LocalAttribute, OutgoingRequestsController } from "@nmshd/consumption"; import { Request, ShareAttributeRequestItem } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreId, MessageController } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { AddressString, AttributeIdString, ISO8601DateTimeString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts b/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts index f4c86e554..9f3bf2baa 100644 --- a/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts +++ b/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, AttributeSuccessorParams, ConsumptionIds, CoreErrors } from "@nmshd/consumption"; import { AttributeValues, Notification, PeerSharedAttributeSucceededNotificationItem, RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { AttributeIdString, ISO8601DateTimeString, NotificationIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts index bd1710f25..7fc3dd86c 100644 --- a/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts @@ -1,7 +1,8 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController, AttributeSuccessorParamsJSON, CoreErrors } from "@nmshd/consumption"; import { AttributeValues } from "@nmshd/content"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { ISO8601DateTimeString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/drafts/DeleteDraft.ts b/packages/runtime/src/useCases/consumption/drafts/DeleteDraft.ts index 6feafd0ba..3dda0ef45 100644 --- a/packages/runtime/src/useCases/consumption/drafts/DeleteDraft.ts +++ b/packages/runtime/src/useCases/consumption/drafts/DeleteDraft.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { Draft, DraftsController } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalDraftIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/drafts/GetDraft.ts b/packages/runtime/src/useCases/consumption/drafts/GetDraft.ts index 561ece686..4634df507 100644 --- a/packages/runtime/src/useCases/consumption/drafts/GetDraft.ts +++ b/packages/runtime/src/useCases/consumption/drafts/GetDraft.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { Draft, DraftsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { DraftDTO } from "../../../types"; import { LocalDraftIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/drafts/UpdateDraft.ts b/packages/runtime/src/useCases/consumption/drafts/UpdateDraft.ts index 83273d5d7..e6bdd82bb 100644 --- a/packages/runtime/src/useCases/consumption/drafts/UpdateDraft.ts +++ b/packages/runtime/src/useCases/consumption/drafts/UpdateDraft.ts @@ -1,7 +1,8 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; import { Draft, DraftsController } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { DraftDTO } from "../../../types"; import { LocalDraftIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/notifications/GetNotification.ts b/packages/runtime/src/useCases/consumption/notifications/GetNotification.ts index f641bafbf..8a09c8539 100644 --- a/packages/runtime/src/useCases/consumption/notifications/GetNotification.ts +++ b/packages/runtime/src/useCases/consumption/notifications/GetNotification.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { NotificationsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalNotificationDTO } from "../../../types"; import { NotificationIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/notifications/ProcessNotificationById.ts b/packages/runtime/src/useCases/consumption/notifications/ProcessNotificationById.ts index 47a3013b3..497599e1c 100644 --- a/packages/runtime/src/useCases/consumption/notifications/ProcessNotificationById.ts +++ b/packages/runtime/src/useCases/consumption/notifications/ProcessNotificationById.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { NotificationsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalNotificationDTO } from "../../../types"; import { NotificationIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/notifications/ReceivedNotification.ts b/packages/runtime/src/useCases/consumption/notifications/ReceivedNotification.ts index b6f3b43d3..d88ccad96 100644 --- a/packages/runtime/src/useCases/consumption/notifications/ReceivedNotification.ts +++ b/packages/runtime/src/useCases/consumption/notifications/ReceivedNotification.ts @@ -1,7 +1,8 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { NotificationsController } from "@nmshd/consumption"; import { Notification } from "@nmshd/content"; -import { CoreId, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalNotificationDTO } from "../../../types"; import { MessageIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/notifications/SentNotification.ts b/packages/runtime/src/useCases/consumption/notifications/SentNotification.ts index 8636f6c59..08388f8d3 100644 --- a/packages/runtime/src/useCases/consumption/notifications/SentNotification.ts +++ b/packages/runtime/src/useCases/consumption/notifications/SentNotification.ts @@ -1,7 +1,8 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { NotificationsController } from "@nmshd/consumption"; import { Notification } from "@nmshd/content"; -import { CoreId, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalNotificationDTO } from "../../../types"; import { MessageIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/AcceptIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/AcceptIncomingRequest.ts index 6f73e0a06..3ac8af7fd 100644 --- a/packages/runtime/src/useCases/consumption/requests/AcceptIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/AcceptIncomingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { DecideRequestParametersJSON, IncomingRequestsController, LocalRequest } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CanCreateOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/CanCreateOutgoingRequest.ts index d73614a61..377f122d1 100644 --- a/packages/runtime/src/useCases/consumption/requests/CanCreateOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/CanCreateOutgoingRequest.ts @@ -1,7 +1,7 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; import { RequestJSON } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { RequestValidationResultDTO } from "../../../types"; import { AddressString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CheckPrerequisitesOfIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/CheckPrerequisitesOfIncomingRequest.ts index 0694b7100..0bc695f64 100644 --- a/packages/runtime/src/useCases/consumption/requests/CheckPrerequisitesOfIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/CheckPrerequisitesOfIncomingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { IncomingRequestsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RequestIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CompleteIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/CompleteIncomingRequest.ts index f0bbcc898..5e272874a 100644 --- a/packages/runtime/src/useCases/consumption/requests/CompleteIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/CompleteIncomingRequest.ts @@ -1,6 +1,7 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { IncomingRequestsController } from "@nmshd/consumption"; -import { CoreId, IMessage, IRelationship, Message, MessageController, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { IMessage, IRelationship, Message, MessageController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { MessageIdString, RelationshipIdString, RequestIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CompleteOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/CompleteOutgoingRequest.ts index bdf75b5e5..f9d4537a2 100644 --- a/packages/runtime/src/useCases/consumption/requests/CompleteOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/CompleteOutgoingRequest.ts @@ -1,7 +1,8 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { ICompleteOutgoingRequestParameters, OutgoingRequestsController } from "@nmshd/consumption"; import { Response, ResponseJSON } from "@nmshd/content"; -import { CoreId, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { MessageIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponse.ts b/packages/runtime/src/useCases/consumption/requests/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponse.ts index 355f6bb46..60a02b39f 100644 --- a/packages/runtime/src/useCases/consumption/requests/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponse.ts +++ b/packages/runtime/src/useCases/consumption/requests/CreateAndCompleteOutgoingRequestFromRelationshipTemplateResponse.ts @@ -1,7 +1,8 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; import { Response, ResponseJSON } from "@nmshd/content"; -import { CoreId, MessageController, Relationship, RelationshipsController, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { MessageController, Relationship, RelationshipsController, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { MessageIdString, RelationshipIdString, RelationshipTemplateIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/CreateOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/CreateOutgoingRequest.ts index 6f7618994..217bab1eb 100644 --- a/packages/runtime/src/useCases/consumption/requests/CreateOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/CreateOutgoingRequest.ts @@ -1,7 +1,7 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; import { RequestJSON } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { AddressString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/DiscardOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/DiscardOutgoingRequest.ts index 40073f654..f8331351e 100644 --- a/packages/runtime/src/useCases/consumption/requests/DiscardOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/DiscardOutgoingRequest.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { RequestIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/GetIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/GetIncomingRequest.ts index 976441353..d437861b1 100644 --- a/packages/runtime/src/useCases/consumption/requests/GetIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/GetIncomingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { IncomingRequestsController, LocalRequest } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RequestIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/GetOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/GetOutgoingRequest.ts index cb904f57e..04b175cc9 100644 --- a/packages/runtime/src/useCases/consumption/requests/GetOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/GetOutgoingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { LocalRequest, OutgoingRequestsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RequestIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/ReceivedIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/ReceivedIncomingRequest.ts index 47bc72a95..9931f645e 100644 --- a/packages/runtime/src/useCases/consumption/requests/ReceivedIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/ReceivedIncomingRequest.ts @@ -1,7 +1,8 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { IncomingRequestsController } from "@nmshd/consumption"; import { Request, RequestJSON } from "@nmshd/content"; -import { CoreId, Message, MessageController, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Message, MessageController, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { MessageIdString, RelationshipTemplateIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/RejectIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/RejectIncomingRequest.ts index 7575707f4..a3f5ee880 100644 --- a/packages/runtime/src/useCases/consumption/requests/RejectIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/RejectIncomingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { DecideRequestParametersJSON, IncomingRequestsController, LocalRequest } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/RequireManualDecisionOfIncomingRequest.ts b/packages/runtime/src/useCases/consumption/requests/RequireManualDecisionOfIncomingRequest.ts index 75dca3821..aa52a39d8 100644 --- a/packages/runtime/src/useCases/consumption/requests/RequireManualDecisionOfIncomingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/RequireManualDecisionOfIncomingRequest.ts @@ -1,6 +1,6 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { IncomingRequestsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { RequestIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/requests/SentOutgoingRequest.ts b/packages/runtime/src/useCases/consumption/requests/SentOutgoingRequest.ts index 950d1fe6a..b298dd8ea 100644 --- a/packages/runtime/src/useCases/consumption/requests/SentOutgoingRequest.ts +++ b/packages/runtime/src/useCases/consumption/requests/SentOutgoingRequest.ts @@ -1,6 +1,7 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { ISentOutgoingRequestParameters, OutgoingRequestsController } from "@nmshd/consumption"; -import { CoreId, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalRequestDTO } from "../../../types"; import { MessageIdString, RequestIdString, RuntimeErrors, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/settings/CreateSetting.ts b/packages/runtime/src/useCases/consumption/settings/CreateSetting.ts index efb9ba827..bb55500aa 100644 --- a/packages/runtime/src/useCases/consumption/settings/CreateSetting.ts +++ b/packages/runtime/src/useCases/consumption/settings/CreateSetting.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { SettingsController, SettingScope } from "@nmshd/consumption"; -import { AccountController, CoreDate, CoreId } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { SettingDTO } from "../../../types"; import { GenericIdString, ISO8601DateTimeString, LocalSettingIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/settings/DeleteSetting.ts b/packages/runtime/src/useCases/consumption/settings/DeleteSetting.ts index 63eca94fc..64c20157c 100644 --- a/packages/runtime/src/useCases/consumption/settings/DeleteSetting.ts +++ b/packages/runtime/src/useCases/consumption/settings/DeleteSetting.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { Setting, SettingsController } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalSettingIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/settings/GetSetting.ts b/packages/runtime/src/useCases/consumption/settings/GetSetting.ts index d0192a5b2..139d90355 100644 --- a/packages/runtime/src/useCases/consumption/settings/GetSetting.ts +++ b/packages/runtime/src/useCases/consumption/settings/GetSetting.ts @@ -1,6 +1,6 @@ import { Result } from "@js-soft/ts-utils"; import { Setting, SettingsController } from "@nmshd/consumption"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Inject } from "typescript-ioc"; import { SettingDTO } from "../../../types"; import { LocalSettingIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/consumption/settings/UpdateSetting.ts b/packages/runtime/src/useCases/consumption/settings/UpdateSetting.ts index 017d7073c..64e7cc679 100644 --- a/packages/runtime/src/useCases/consumption/settings/UpdateSetting.ts +++ b/packages/runtime/src/useCases/consumption/settings/UpdateSetting.ts @@ -1,7 +1,8 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; import { Setting, SettingsController } from "@nmshd/consumption"; -import { AccountController, CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { SettingDTO } from "../../../types"; import { LocalSettingIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/challenges/CreateChallenge.ts b/packages/runtime/src/useCases/transport/challenges/CreateChallenge.ts index e16439b09..a459ad5a5 100644 --- a/packages/runtime/src/useCases/transport/challenges/CreateChallenge.ts +++ b/packages/runtime/src/useCases/transport/challenges/CreateChallenge.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { ChallengeController, ChallengeType, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { ChallengeController, ChallengeType, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { ChallengeDTO } from "../../../types"; import { JsonSchema, RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase, ValidationFailure, ValidationResult } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/devices/CreateDeviceOnboardingToken.ts b/packages/runtime/src/useCases/transport/devices/CreateDeviceOnboardingToken.ts index fe6f021ec..4af090b43 100644 --- a/packages/runtime/src/useCases/transport/devices/CreateDeviceOnboardingToken.ts +++ b/packages/runtime/src/useCases/transport/devices/CreateDeviceOnboardingToken.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreDate, CoreId, DevicesController, TokenContentDeviceSharedSecret, TokenController } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { DevicesController, TokenContentDeviceSharedSecret, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { DeviceIdString, ISO8601DateTimeString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/devices/DeleteDevice.ts b/packages/runtime/src/useCases/transport/devices/DeleteDevice.ts index 3946de448..802bbdbc7 100644 --- a/packages/runtime/src/useCases/transport/devices/DeleteDevice.ts +++ b/packages/runtime/src/useCases/transport/devices/DeleteDevice.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Device, DevicesController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Device, DevicesController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { DeviceIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/devices/DeviceMapper.ts b/packages/runtime/src/useCases/transport/devices/DeviceMapper.ts index a0278fb04..37e5b9b35 100644 --- a/packages/runtime/src/useCases/transport/devices/DeviceMapper.ts +++ b/packages/runtime/src/useCases/transport/devices/DeviceMapper.ts @@ -1,5 +1,6 @@ +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSecretKey, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { CoreAddress, CoreDate, CoreId, Device, DeviceSharedSecret } from "@nmshd/transport"; +import { Device, DeviceSharedSecret } from "@nmshd/transport"; import { DeviceDTO, DeviceOnboardingInfoDTO } from "../../../types"; export class DeviceMapper { diff --git a/packages/runtime/src/useCases/transport/devices/GetDevice.ts b/packages/runtime/src/useCases/transport/devices/GetDevice.ts index b99b57c90..473472e8b 100644 --- a/packages/runtime/src/useCases/transport/devices/GetDevice.ts +++ b/packages/runtime/src/useCases/transport/devices/GetDevice.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, Device, DeviceController, DevicesController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Device, DeviceController, DevicesController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { DeviceDTO } from "../../../types"; import { DeviceIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/devices/GetDeviceOnboardingInfo.ts b/packages/runtime/src/useCases/transport/devices/GetDeviceOnboardingInfo.ts index ef9dbc60f..dbbdbb201 100644 --- a/packages/runtime/src/useCases/transport/devices/GetDeviceOnboardingInfo.ts +++ b/packages/runtime/src/useCases/transport/devices/GetDeviceOnboardingInfo.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, DevicesController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { DevicesController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { DeviceOnboardingInfoDTO } from "../../../types"; import { GenericIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/devices/UpdateDevice.ts b/packages/runtime/src/useCases/transport/devices/UpdateDevice.ts index f9082b7b3..b5d27a2ee 100644 --- a/packages/runtime/src/useCases/transport/devices/UpdateDevice.ts +++ b/packages/runtime/src/useCases/transport/devices/UpdateDevice.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Device, DeviceController, DevicesController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Device, DeviceController, DevicesController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { DeviceDTO } from "../../../types"; import { DeviceIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/files/CreateQRCodeForFile.ts b/packages/runtime/src/useCases/transport/files/CreateQRCodeForFile.ts index dc6a90a32..e37343af2 100644 --- a/packages/runtime/src/useCases/transport/files/CreateQRCodeForFile.ts +++ b/packages/runtime/src/useCases/transport/files/CreateQRCodeForFile.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileIdString, QRCode, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/files/CreateTokenForFile.ts b/packages/runtime/src/useCases/transport/files/CreateTokenForFile.ts index 02316753f..380129511 100644 --- a/packages/runtime/src/useCases/transport/files/CreateTokenForFile.ts +++ b/packages/runtime/src/useCases/transport/files/CreateTokenForFile.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreDate, CoreId, File, FileController, TokenContentFile, TokenController } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, File, FileController, TokenContentFile, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { FileIdString, ISO8601DateTimeString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/files/CreateTokenQRCodeForFile.ts b/packages/runtime/src/useCases/transport/files/CreateTokenQRCodeForFile.ts index 07b8b8c0b..7c0fb4b90 100644 --- a/packages/runtime/src/useCases/transport/files/CreateTokenQRCodeForFile.ts +++ b/packages/runtime/src/useCases/transport/files/CreateTokenQRCodeForFile.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreDate, CoreId, File, FileController, TokenContentFile, TokenController } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { File, FileController, TokenContentFile, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileIdString, ISO8601DateTimeString, QRCode, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/files/DownloadFile.ts b/packages/runtime/src/useCases/transport/files/DownloadFile.ts index acafeea87..b0c2f955e 100644 --- a/packages/runtime/src/useCases/transport/files/DownloadFile.ts +++ b/packages/runtime/src/useCases/transport/files/DownloadFile.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; import { FileMapper } from "./FileMapper"; diff --git a/packages/runtime/src/useCases/transport/files/GetFile.ts b/packages/runtime/src/useCases/transport/files/GetFile.ts index 07947f7e4..ca1da485f 100644 --- a/packages/runtime/src/useCases/transport/files/GetFile.ts +++ b/packages/runtime/src/useCases/transport/files/GetFile.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileDTO } from "../../../types"; import { FileIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/files/GetOrLoadFile.ts b/packages/runtime/src/useCases/transport/files/GetOrLoadFile.ts index 846315dbe..a07f0f4ea 100644 --- a/packages/runtime/src/useCases/transport/files/GetOrLoadFile.ts +++ b/packages/runtime/src/useCases/transport/files/GetOrLoadFile.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, CoreId, FileController, Token, TokenContentFile, TokenController } from "@nmshd/transport"; +import { AccountController, FileController, Token, TokenContentFile, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileDTO } from "../../../types"; import { diff --git a/packages/runtime/src/useCases/transport/files/UploadOwnFile.ts b/packages/runtime/src/useCases/transport/files/UploadOwnFile.ts index e0f661370..c01a6704f 100644 --- a/packages/runtime/src/useCases/transport/files/UploadOwnFile.ts +++ b/packages/runtime/src/useCases/transport/files/UploadOwnFile.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreDate } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; -import { AccountController, CoreDate, FileController } from "@nmshd/transport"; +import { AccountController, FileController } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { Inject } from "typescript-ioc"; import { FileDTO } from "../../../types"; diff --git a/packages/runtime/src/useCases/transport/messages/DownloadAttachment.ts b/packages/runtime/src/useCases/transport/messages/DownloadAttachment.ts index 98e370aee..0918284d2 100644 --- a/packages/runtime/src/useCases/transport/messages/DownloadAttachment.ts +++ b/packages/runtime/src/useCases/transport/messages/DownloadAttachment.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController, Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileIdString, MessageIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; import { MessageMapper } from "./MessageMapper"; diff --git a/packages/runtime/src/useCases/transport/messages/GetAttachmentMetadata.ts b/packages/runtime/src/useCases/transport/messages/GetAttachmentMetadata.ts index 4fd2b976a..8c7391c69 100644 --- a/packages/runtime/src/useCases/transport/messages/GetAttachmentMetadata.ts +++ b/packages/runtime/src/useCases/transport/messages/GetAttachmentMetadata.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController, Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { FileDTO } from "../../../types"; import { FileIdString, MessageIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/messages/GetMessage.ts b/packages/runtime/src/useCases/transport/messages/GetMessage.ts index c53e37711..33a9d9ee4 100644 --- a/packages/runtime/src/useCases/transport/messages/GetMessage.ts +++ b/packages/runtime/src/useCases/transport/messages/GetMessage.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, File, FileController, Message, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { File, FileController, Message, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { MessageWithAttachmentsDTO } from "../../../types"; import { MessageIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/messages/MarkMessageAsRead.ts b/packages/runtime/src/useCases/transport/messages/MarkMessageAsRead.ts index b68116401..d993e631f 100644 --- a/packages/runtime/src/useCases/transport/messages/MarkMessageAsRead.ts +++ b/packages/runtime/src/useCases/transport/messages/MarkMessageAsRead.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { MessageDTO } from "../../../types"; import { MessageIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/messages/MarkMessageAsUnread.ts b/packages/runtime/src/useCases/transport/messages/MarkMessageAsUnread.ts index a9454d624..2068aa5cf 100644 --- a/packages/runtime/src/useCases/transport/messages/MarkMessageAsUnread.ts +++ b/packages/runtime/src/useCases/transport/messages/MarkMessageAsUnread.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, MessageController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, MessageController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { MessageDTO } from "../../../types"; import { MessageIdString, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/messages/SendMessage.ts b/packages/runtime/src/useCases/transport/messages/SendMessage.ts index 1faca9d92..a19ff5627 100644 --- a/packages/runtime/src/useCases/transport/messages/SendMessage.ts +++ b/packages/runtime/src/useCases/transport/messages/SendMessage.ts @@ -2,7 +2,8 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; import { ArbitraryMessageContent, Mail, Notification, Request, ResponseWrapper } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreId, File, FileController, MessageController } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController, File, FileController, MessageController } from "@nmshd/transport"; import _ from "lodash"; import { Inject } from "typescript-ioc"; import { MessageDTO } from "../../../types"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateOwnRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateOwnRelationshipTemplate.ts index 84f34e449..6885500e8 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateOwnRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateOwnRelationshipTemplate.ts @@ -2,7 +2,8 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; import { OutgoingRequestsController } from "@nmshd/consumption"; import { ArbitraryRelationshipTemplateContent, RelationshipTemplateContent } from "@nmshd/content"; -import { AccountController, CoreDate, RelationshipTemplateController } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, RelationshipTemplateController } from "@nmshd/transport"; import { DateTime } from "luxon"; import { nameof } from "ts-simple-nameof"; import { Inject } from "typescript-ioc"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateQRCodeForOwnRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateQRCodeForOwnRelationshipTemplate.ts index 8344d9be3..b8bfb8ba7 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateQRCodeForOwnRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateQRCodeForOwnRelationshipTemplate.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { QRCode, RelationshipTemplateIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenForOwnRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenForOwnRelationshipTemplate.ts index 70935bc61..a01ec5989 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenForOwnRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenForOwnRelationshipTemplate.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreDate, CoreId, RelationshipTemplate, RelationshipTemplateController, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, RelationshipTemplate, RelationshipTemplateController, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { ISO8601DateTimeString, RelationshipTemplateIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenQRCodeForOwnRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenQRCodeForOwnRelationshipTemplate.ts index 7c5ac9660..329a8078d 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenQRCodeForOwnRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/CreateTokenQRCodeForOwnRelationshipTemplate.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreDate, CoreId, RelationshipTemplate, RelationshipTemplateController, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { RelationshipTemplate, RelationshipTemplateController, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { ISO8601DateTimeString, QRCode, RelationshipTemplateIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/GetRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/GetRelationshipTemplate.ts index 00f1b4b8b..62f79a45c 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/GetRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/GetRelationshipTemplate.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { RelationshipTemplate, RelationshipTemplateController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipTemplateDTO } from "../../../types"; import { RelationshipTemplateIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationshipTemplates/LoadPeerRelationshipTemplate.ts b/packages/runtime/src/useCases/transport/relationshipTemplates/LoadPeerRelationshipTemplate.ts index 3d4bab29a..5abda01e9 100644 --- a/packages/runtime/src/useCases/transport/relationshipTemplates/LoadPeerRelationshipTemplate.ts +++ b/packages/runtime/src/useCases/transport/relationshipTemplates/LoadPeerRelationshipTemplate.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, CoreId, RelationshipTemplateController, Token, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; +import { AccountController, RelationshipTemplateController, Token, TokenContentRelationshipTemplate, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipTemplateDTO } from "../../../types"; import { diff --git a/packages/runtime/src/useCases/transport/relationships/AcceptRelationship.ts b/packages/runtime/src/useCases/transport/relationships/AcceptRelationship.ts index 15cb9dea4..e5ab1ce51 100644 --- a/packages/runtime/src/useCases/transport/relationships/AcceptRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/AcceptRelationship.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/AcceptRelationshipReactivation.ts b/packages/runtime/src/useCases/transport/relationships/AcceptRelationshipReactivation.ts index f16c2cdfe..9602511f8 100644 --- a/packages/runtime/src/useCases/transport/relationships/AcceptRelationshipReactivation.ts +++ b/packages/runtime/src/useCases/transport/relationships/AcceptRelationshipReactivation.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/CreateRelationship.ts b/packages/runtime/src/useCases/transport/relationships/CreateRelationship.ts index fdf5bee8f..3b705c10a 100644 --- a/packages/runtime/src/useCases/transport/relationships/CreateRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/CreateRelationship.ts @@ -1,7 +1,8 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; import { ArbitraryRelationshipCreationContent, RelationshipCreationContent } from "@nmshd/content"; -import { AccountController, CoreId, RelationshipTemplate, RelationshipTemplateController, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, RelationshipTemplate, RelationshipTemplateController, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipTemplateIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/DecomposeRelationship.ts b/packages/runtime/src/useCases/transport/relationships/DecomposeRelationship.ts index 371586b4d..4c0188043 100644 --- a/packages/runtime/src/useCases/transport/relationships/DecomposeRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/DecomposeRelationship.ts @@ -1,6 +1,7 @@ import { ApplicationError, Result } from "@js-soft/ts-utils"; import { ConsumptionController } from "@nmshd/consumption"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/GetAttributesForRelationship.ts b/packages/runtime/src/useCases/transport/relationships/GetAttributesForRelationship.ts index 1e2a1039a..615074b2a 100644 --- a/packages/runtime/src/useCases/transport/relationships/GetAttributesForRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/GetAttributesForRelationship.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; import { AttributesController } from "@nmshd/consumption"; -import { CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { LocalAttributeDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/GetRelationship.ts b/packages/runtime/src/useCases/transport/relationships/GetRelationship.ts index dbe03e6c3..7a6b9238d 100644 --- a/packages/runtime/src/useCases/transport/relationships/GetRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/GetRelationship.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/GetRelationshipByAddress.ts b/packages/runtime/src/useCases/transport/relationships/GetRelationshipByAddress.ts index 05a0d6a7b..7c212120f 100644 --- a/packages/runtime/src/useCases/transport/relationships/GetRelationshipByAddress.ts +++ b/packages/runtime/src/useCases/transport/relationships/GetRelationshipByAddress.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreAddress, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { AddressString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/RejectRelationship.ts b/packages/runtime/src/useCases/transport/relationships/RejectRelationship.ts index 23f58e70e..f0cd3e8d1 100644 --- a/packages/runtime/src/useCases/transport/relationships/RejectRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/RejectRelationship.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/RejectRelationshipReactivation.ts b/packages/runtime/src/useCases/transport/relationships/RejectRelationshipReactivation.ts index 9d044a6f7..874e84872 100644 --- a/packages/runtime/src/useCases/transport/relationships/RejectRelationshipReactivation.ts +++ b/packages/runtime/src/useCases/transport/relationships/RejectRelationshipReactivation.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/RequestRelationshipReactivation.ts b/packages/runtime/src/useCases/transport/relationships/RequestRelationshipReactivation.ts index 021731fcd..7f7965306 100644 --- a/packages/runtime/src/useCases/transport/relationships/RequestRelationshipReactivation.ts +++ b/packages/runtime/src/useCases/transport/relationships/RequestRelationshipReactivation.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/RevokeRelationship.ts b/packages/runtime/src/useCases/transport/relationships/RevokeRelationship.ts index 115e2e0f1..6f089748f 100644 --- a/packages/runtime/src/useCases/transport/relationships/RevokeRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/RevokeRelationship.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/RevokeRelationshipReactivation.ts b/packages/runtime/src/useCases/transport/relationships/RevokeRelationshipReactivation.ts index b42e865a1..7ed6c9cf3 100644 --- a/packages/runtime/src/useCases/transport/relationships/RevokeRelationshipReactivation.ts +++ b/packages/runtime/src/useCases/transport/relationships/RevokeRelationshipReactivation.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/relationships/TerminateRelationship.ts b/packages/runtime/src/useCases/transport/relationships/TerminateRelationship.ts index e07deb71b..4120a284e 100644 --- a/packages/runtime/src/useCases/transport/relationships/TerminateRelationship.ts +++ b/packages/runtime/src/useCases/transport/relationships/TerminateRelationship.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreId, Relationship, RelationshipsController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, RelationshipsController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; import { RelationshipIdString, RuntimeErrors, SchemaRepository, SchemaValidator, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/tokens/CreateOwnToken.ts b/packages/runtime/src/useCases/transport/tokens/CreateOwnToken.ts index afc9d357f..f8a1d8609 100644 --- a/packages/runtime/src/useCases/transport/tokens/CreateOwnToken.ts +++ b/packages/runtime/src/useCases/transport/tokens/CreateOwnToken.ts @@ -1,6 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; import { Result } from "@js-soft/ts-utils"; -import { AccountController, CoreDate, TokenController } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, TokenController } from "@nmshd/transport"; import { DateTime } from "luxon"; import { nameof } from "ts-simple-nameof"; import { Inject } from "typescript-ioc"; diff --git a/packages/runtime/src/useCases/transport/tokens/GetQRCodeForToken.ts b/packages/runtime/src/useCases/transport/tokens/GetQRCodeForToken.ts index edacbdce6..ad19b2a10 100644 --- a/packages/runtime/src/useCases/transport/tokens/GetQRCodeForToken.ts +++ b/packages/runtime/src/useCases/transport/tokens/GetQRCodeForToken.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, Token, TokenController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { Token, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { QRCode, RuntimeErrors, SchemaRepository, SchemaValidator, TokenIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/tokens/GetToken.ts b/packages/runtime/src/useCases/transport/tokens/GetToken.ts index 93ac830a7..441507921 100644 --- a/packages/runtime/src/useCases/transport/tokens/GetToken.ts +++ b/packages/runtime/src/useCases/transport/tokens/GetToken.ts @@ -1,5 +1,6 @@ import { Result } from "@js-soft/ts-utils"; -import { CoreId, TokenController } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { RuntimeErrors, SchemaRepository, SchemaValidator, TokenIdString, UseCase } from "../../common"; diff --git a/packages/runtime/src/useCases/transport/tokens/LoadPeerToken.ts b/packages/runtime/src/useCases/transport/tokens/LoadPeerToken.ts index fe4925fc7..a4c79837f 100644 --- a/packages/runtime/src/useCases/transport/tokens/LoadPeerToken.ts +++ b/packages/runtime/src/useCases/transport/tokens/LoadPeerToken.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, CoreId, Token, TokenController } from "@nmshd/transport"; +import { AccountController, Token, TokenController } from "@nmshd/transport"; import { Inject } from "typescript-ioc"; import { TokenDTO } from "../../../types"; import { JsonSchema, RuntimeErrors, SchemaRepository, SchemaValidator, TokenIdString, TokenReferenceString, UseCase, ValidationFailure, ValidationResult } from "../../common"; diff --git a/packages/transport/src/core/CoreCrypto.ts b/packages/transport/src/core/CoreCrypto.ts index 9802758d5..7ed771f70 100644 --- a/packages/transport/src/core/CoreCrypto.ts +++ b/packages/transport/src/core/CoreCrypto.ts @@ -20,7 +20,7 @@ import { CryptoSignatures, Encoding } from "@nmshd/crypto"; -import { PasswordGenerator } from "../util/PasswordGenerator"; +import { PasswordGenerator } from "@nmshd/utils"; import { TransportError } from "./TransportError"; import { TransportVersion } from "./types/TransportVersion"; diff --git a/packages/transport/src/core/CoreIdHelper.ts b/packages/transport/src/core/CoreIdHelper.ts index 2860605bf..faca0d8ac 100644 --- a/packages/transport/src/core/CoreIdHelper.ts +++ b/packages/transport/src/core/CoreIdHelper.ts @@ -1,6 +1,6 @@ -import { RandomCharacterRange } from "../util/Random"; +import { CoreId } from "@nmshd/core-types"; +import { RandomCharacterRange } from "@nmshd/utils"; import { TransportError } from "./TransportError"; -import { CoreId } from "./types/CoreId"; export class CoreIdHelper { private readonly coreIdRegex: RegExp; diff --git a/packages/transport/src/core/CoreSerializable.ts b/packages/transport/src/core/CoreSerializable.ts deleted file mode 100644 index 57e032f75..000000000 --- a/packages/transport/src/core/CoreSerializable.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; -import { CoreBuffer } from "@nmshd/crypto"; - -export interface ICoreSerializable extends ISerializable {} - -/** - * CoreSerializable is the local pendant of the Serializable class which - * automatically validates, serializes, deserializes and validates again. - * - * With the synchronous class, the deserialize methods (from and deserialize) - * are called synchronous. Please be aware, that CoreSerializable classes should - * have no CoreSerializableAsync properties. - */ - -@type("CoreSerializable") -export class CoreSerializable extends Serializable implements ISerializable { - public toBase64(): string { - return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); - } - - public static fromBase64T(value: string): T { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - return (this as any).deserialize(serialized); - } - - public static fromBase64Unknown(value: string): Serializable { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - return Serializable.deserializeUnknown(serialized); - } -} diff --git a/packages/transport/src/core/CoreSerializableAsync.ts b/packages/transport/src/core/CoreSerializableAsync.ts deleted file mode 100644 index 7319aeb42..000000000 --- a/packages/transport/src/core/CoreSerializableAsync.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ISerializableAsync, SerializableAsync, type } from "@js-soft/ts-serval"; -import { CoreBuffer } from "@nmshd/crypto"; - -export interface ICoreSerializableAsync extends ISerializableAsync {} - -/** - * CoreSerializableAsync is the local pendant of the SerializableAsync class which - * automatically validates, serializes, deserializes and validates again. - * - * With the asynchronous class, the deserialize methods (from and deserialize) - * are called asynchronous (returning a Promise). You should only use CoreSerializableAsync - * classes if properties with CoreSerializableAsync types are used. - */ -@type("CoreSerializableAsync") -export class CoreSerializableAsync extends SerializableAsync implements ISerializableAsync { - public toBase64(): string { - return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); - } - - public static async fromBase64T(value: string): Promise { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - const deserializePromise = (this as any).deserialize(serialized) as Promise; - return await deserializePromise; - } - - public static async fromBase64Unknown(value: string): Promise { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - return await SerializableAsync.deserializeUnknown(serialized); - } -} diff --git a/packages/transport/src/core/CoreSynchronizable.ts b/packages/transport/src/core/CoreSynchronizable.ts index dca14a1a9..9ed59bf6e 100644 --- a/packages/transport/src/core/CoreSynchronizable.ts +++ b/packages/transport/src/core/CoreSynchronizable.ts @@ -1,12 +1,11 @@ -import { serialize, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; -import { CoreId, ICoreId } from "./types/CoreId"; +import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; -export interface ICoreSynchronizable extends ICoreSerializable { +export interface ICoreSynchronizable extends ISerializable { id: ICoreId; } -export abstract class CoreSynchronizable extends CoreSerializable implements ICoreSynchronizable { +export abstract class CoreSynchronizable extends Serializable implements ICoreSynchronizable { public readonly technicalProperties: string[] = []; public readonly userdataProperties: string[] = []; public readonly metadataProperties: string[] = []; diff --git a/packages/transport/src/core/Reference.ts b/packages/transport/src/core/Reference.ts index 6629681eb..bba57e367 100644 --- a/packages/transport/src/core/Reference.ts +++ b/packages/transport/src/core/Reference.ts @@ -1,8 +1,8 @@ import { ISerializable, Serializable, serialize, validate, ValidationError } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; import { CoreErrors } from "./CoreErrors"; import { CoreIdHelper } from "./CoreIdHelper"; -import { CoreId, ICoreId } from "./types/CoreId"; export interface IReference extends ISerializable { id: ICoreId; diff --git a/packages/transport/src/core/TransportController.ts b/packages/transport/src/core/TransportController.ts index 500d70a3a..05e549fa1 100644 --- a/packages/transport/src/core/TransportController.ts +++ b/packages/transport/src/core/TransportController.ts @@ -1,8 +1,8 @@ import { IDatabaseCollectionProvider } from "@js-soft/docdb-access-abstractions"; import { ILogger } from "@js-soft/logging-abstractions"; +import { Serializable } from "@js-soft/ts-serval"; import { EventBus } from "@js-soft/ts-utils"; import { AccountController } from "../modules/accounts/AccountController"; -import { CoreSerializable } from "./CoreSerializable"; import { IConfig, Transport } from "./Transport"; import { TransportError } from "./TransportError"; import { TransportLoggerFactory } from "./TransportLoggerFactory"; @@ -89,7 +89,7 @@ export class TransportController { return Promise.resolve(this); } - protected parseArray(values: Object[], type: new () => T): T[] { + protected parseArray(values: Object[], type: new () => T): T[] { return values.map((v) => (type as any).fromAny(v)); } diff --git a/packages/transport/src/core/backbone/AuthClient.ts b/packages/transport/src/core/backbone/AuthClient.ts index 7c3e34b55..ad6e5c257 100644 --- a/packages/transport/src/core/backbone/AuthClient.ts +++ b/packages/transport/src/core/backbone/AuthClient.ts @@ -1,6 +1,6 @@ +import { CoreDate } from "@nmshd/core-types"; import { AxiosResponse } from "axios"; import qs from "qs"; -import { CoreDate } from "../types"; import { ClientResult } from "./ClientResult"; import { PlatformParameters } from "./PlatformParameters"; import { RequestError } from "./RequestError"; diff --git a/packages/transport/src/core/backbone/Authenticator.ts b/packages/transport/src/core/backbone/Authenticator.ts index 5df6d9149..d95769e47 100644 --- a/packages/transport/src/core/backbone/Authenticator.ts +++ b/packages/transport/src/core/backbone/Authenticator.ts @@ -1,6 +1,6 @@ import { ILogger } from "@js-soft/logging-abstractions"; +import { CoreDate } from "@nmshd/core-types"; import { AccountController } from "../../modules"; -import { CoreDate } from "../types/CoreDate"; import { AuthClient } from "./AuthClient"; import { IRESTClientConfig } from "./RESTClient"; import { CredentialsBasic } from "./RESTClientAuthenticate"; diff --git a/packages/transport/src/core/backbone/ClientResult.ts b/packages/transport/src/core/backbone/ClientResult.ts index 024a7ce84..dcf191262 100644 --- a/packages/transport/src/core/backbone/ClientResult.ts +++ b/packages/transport/src/core/backbone/ClientResult.ts @@ -1,6 +1,6 @@ import { ApplicationError } from "@js-soft/ts-utils"; +import { CoreDate } from "@nmshd/core-types"; import { TransportError } from "../TransportError"; -import { CoreDate } from "../types/CoreDate"; import { PlatformParameters } from "./PlatformParameters"; export class ClientResult { diff --git a/packages/transport/src/core/backbone/RESTClient.ts b/packages/transport/src/core/backbone/RESTClient.ts index 4da2861a2..5d5ac112c 100644 --- a/packages/transport/src/core/backbone/RESTClient.ts +++ b/packages/transport/src/core/backbone/RESTClient.ts @@ -1,4 +1,5 @@ import { ILogger } from "@js-soft/logging-abstractions"; +import { CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; import formDataLib from "form-data"; @@ -6,7 +7,6 @@ import { AgentOptions } from "http"; import { AgentOptions as HTTPSAgentOptions } from "https"; import _ from "lodash"; import { TransportLoggerFactory } from "../TransportLoggerFactory"; -import { CoreId } from "../types"; import { ClientResult } from "./ClientResult"; import { IPaginationDataSource, Paginator, PaginatorPercentageCallback } from "./Paginator"; import { PlatformParameters } from "./PlatformParameters"; diff --git a/packages/transport/src/core/backbone/RequestError.ts b/packages/transport/src/core/backbone/RequestError.ts index 02b19a6a2..68dc80e3f 100644 --- a/packages/transport/src/core/backbone/RequestError.ts +++ b/packages/transport/src/core/backbone/RequestError.ts @@ -1,7 +1,7 @@ import { ApplicationError } from "@js-soft/ts-utils"; +import { CoreDate } from "@nmshd/core-types"; import { AxiosError } from "axios"; import stringify from "json-stringify-safe"; -import { CoreDate } from "../types/CoreDate"; import { PlatformError } from "./PlatformError"; import { PlatformParameters } from "./PlatformParameters"; diff --git a/packages/transport/src/core/index.ts b/packages/transport/src/core/index.ts index 649d09a3a..e7dd7b924 100644 --- a/packages/transport/src/core/index.ts +++ b/packages/transport/src/core/index.ts @@ -3,8 +3,6 @@ export * from "./CoreCrypto"; export * from "./CoreError"; export * from "./CoreErrors"; export * from "./CoreIdHelper"; -export * from "./CoreSerializable"; -export * from "./CoreSerializableAsync"; export * from "./CoreSynchronizable"; export * from "./CoreUtil"; export * from "./DbCollectionName"; diff --git a/packages/transport/src/core/types/CoreAddress.ts b/packages/transport/src/core/types/CoreAddress.ts deleted file mode 100644 index cd45e6252..000000000 --- a/packages/transport/src/core/types/CoreAddress.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../CoreSerializable"; - -export interface ICoreAddress extends ICoreSerializable { - address: string; -} - -/** - * A CoreAddress is the primariy technical identitier of an account. - */ -@type("CoreAddress") -@serializeOnly("address", "string") -export class CoreAddress extends CoreSerializable { - @validate() - @serialize() - public address: string; - - protected static override preFrom(value: any): any { - if (typeof value === "string") { - return { address: value }; - } - - return value; - } - - public static from(value: ICoreAddress | string): CoreAddress { - return this.fromAny(value); - } - - public equals(address?: CoreAddress | string): boolean { - if (address === undefined) return false; - - return this.address === address.toString(); - } - - public override toString(): string { - return this.address; - } - - public override serialize(): string { - return this.address; - } -} diff --git a/packages/transport/src/core/types/CoreDate.ts b/packages/transport/src/core/types/CoreDate.ts deleted file mode 100644 index 329aa09f4..000000000 --- a/packages/transport/src/core/types/CoreDate.ts +++ /dev/null @@ -1,171 +0,0 @@ -import { type } from "@js-soft/ts-serval"; -import { DateTime, DateTimeUnit, Duration, DurationLike, Interval } from "luxon"; -import { CoreSerializable, ICoreSerializable } from "../CoreSerializable"; -import { TransportError } from "../TransportError"; - -export interface ICoreDate extends ICoreSerializable { - date: string; -} - -@type("CoreDate") -export class CoreDate extends CoreSerializable { - private readonly _dateTime: DateTime; - public get dateTime(): DateTime { - return this._dateTime; - } - - public get date(): string { - return this.asValidDateTime.toISODate(); - } - - public constructor(dateTime: DateTime = DateTime.utc()) { - super(); - this._dateTime = dateTime; - } - - public static utc(): CoreDate { - return new CoreDate(DateTime.utc()); - } - - public static local(): CoreDate { - return new CoreDate(DateTime.local()); - } - - public equals(another: CoreDate): boolean { - return this.dateTime.equals(another.dateTime); - } - - public add(amount: number | Duration | DurationLike): CoreDate { - return new CoreDate(this.dateTime.plus(amount)); - } - - public subtract(amount: number | Duration | DurationLike): CoreDate { - return new CoreDate(this.dateTime.minus(amount)); - } - - public startOf(unitOfTime: DateTimeUnit): CoreDate { - return new CoreDate(this.dateTime.startOf(unitOfTime)); - } - - public endOf(unitOfTime: DateTimeUnit): CoreDate { - return new CoreDate(this.dateTime.endOf(unitOfTime)); - } - - public format(format: string): string { - return this.dateTime.toFormat(format); - } - - public isWithin(rangeMinusOrBoth: number | Duration | DurationLike, rangePlus?: number | Duration | DurationLike, other?: CoreDate, granularity?: DateTimeUnit): boolean { - if (!rangePlus) rangePlus = rangeMinusOrBoth; - - if (!other) other = CoreDate.utc(); - - const start = other.subtract(rangeMinusOrBoth); - const end = other.add(rangePlus); - - if (granularity) { - return this.dateTime.startOf(granularity) > start.dateTime.startOf(granularity) && this.dateTime.startOf(granularity) < end.dateTime.startOf(granularity); - } - - return this.dateTime > start.dateTime && this.dateTime < end.dateTime; - } - - public isBefore(other: CoreDate, granularity?: DateTimeUnit): boolean { - if (granularity) return this.dateTime.startOf(granularity) < other.dateTime.startOf(granularity); - - return this.dateTime < other.dateTime; - } - - public isAfter(other: CoreDate, granularity?: DateTimeUnit): boolean { - if (granularity) return this.dateTime.startOf(granularity) > other.dateTime.startOf(granularity); - - return this.dateTime > other.dateTime; - } - - public isSame(other: CoreDate, granularity?: DateTimeUnit): boolean { - if (granularity) return this.dateTime.startOf(granularity).valueOf() === other.dateTime.startOf(granularity).valueOf(); - - return this.dateTime.valueOf() === other.dateTime.valueOf(); - } - - public isSameOrAfter(other: CoreDate, granularity?: DateTimeUnit): boolean { - if (granularity) return this.dateTime.startOf(granularity) >= other.dateTime.startOf(granularity); - - return this.dateTime >= other.dateTime; - } - - public isSameOrBefore(other: CoreDate, granularity?: DateTimeUnit): boolean { - if (granularity) return this.dateTime.startOf(granularity) <= other.dateTime.startOf(granularity); - - return this.dateTime <= other.dateTime; - } - - public isBetween(start: CoreDate, end?: CoreDate, granularity?: DateTimeUnit): boolean { - if (!end) return this.isAfter(start, granularity); - - return Interval.fromDateTimes(start.dateTime, end.dateTime).contains(this.dateTime); - } - - public isExpired(): boolean { - return this.isSameOrBefore(CoreDate.utc()); - } - - public compare(comparator: CoreDate): number { - return this.dateTime.valueOf() - comparator.dateTime.valueOf(); - } - - /** - * Creates an ISO String. - */ - public override toString(): string { - return this.asValidDateTime.toISO(); - } - - public toISOString(): string { - return this.asValidDateTime.toISO(); - } - - public override toLocaleString(): string { - return this.dateTime.toLocaleString(); - } - - public override toJSON(): string { - return this.asValidDateTime.toISO(); - } - - public override serialize(): string { - return this.asValidDateTime.toISO(); - } - - private get asValidDateTime(): DateTime { - if (!this.dateTime.isValid) throw new TransportError("The date is invalid."); - return this.dateTime as DateTime; - } - - protected static override preFrom(value: any): any { - if (!value) throw new TransportError("The provided object is undefined and cannot be deserialized."); - - if (typeof value === "object") { - if (!value.date) { - if (typeof value.toISOString !== "function") { - throw new TransportError("The provided object doesn't have an 'toISOString' string method."); - } - - const iso = value.toISOString(); - return DateTime.fromISO(iso, { zone: "utc" }); - } - - return DateTime.fromISO(value.date, { zone: "utc" }); - } - - if (typeof value === "number") return DateTime.fromMillis(value); - - if (typeof value === "string") return DateTime.fromISO(value, { zone: "utc" }).toUTC(); - - throw new TransportError("The provided object is invalid and cannot be deserialized."); - } - - public static from(value: ICoreDate | string | number): CoreDate { - return this.fromAny(value); - } -} diff --git a/packages/transport/src/core/types/CoreHash.ts b/packages/transport/src/core/types/CoreHash.ts deleted file mode 100644 index 52bdf200c..000000000 --- a/packages/transport/src/core/types/CoreHash.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { serialize, serializeOnly, validate } from "@js-soft/ts-serval"; -import { CoreBuffer, CryptoHash, CryptoHashAlgorithm, Encoding, ICoreBuffer } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../CoreSerializable"; - -export interface ICoreHash extends ICoreSerializable { - hash: string; -} - -/** - * Hash wraps a hash - */ -@serializeOnly("hash", "string") -export class CoreHash extends CoreSerializable { - @validate() - @serialize() - public hash: string; - - public override toString(): string { - return this.hash; - } - - /** - * Creates a new hash of the given content - * - * @param content A String object of the content which should be hashed - * @param algorithm The CryptoHashAlgorithm, defaults to SHA512 - * @returns A Promise resolving to the Hash object - */ - public static async hash(content: string, algorithm: CryptoHashAlgorithm = CryptoHashAlgorithm.SHA512): Promise { - const hash = await CryptoHash.hash(CoreBuffer.fromString(content, Encoding.Base64_UrlSafe_NoPadding), algorithm); - return CoreHash.from(hash.toBase64()); - } - - /** - * Verifies if the given content is creating the underlying hash with the - * given hash algorithm. - * - * @param content A Buffer object of the content which should be equal to the hash - * @param algorithm The CryptoHashAlgorithm, defaults to SHA512 - * @returns A Promise resolving to true if the content equals to the hash, or false otherwise - */ - public async verify(content: ICoreBuffer, algorithm: CryptoHashAlgorithm = CryptoHashAlgorithm.SHA512): Promise { - return await CryptoHash.verify(content, CoreBuffer.fromString(this.hash, Encoding.Base64_UrlSafe_NoPadding), algorithm); - } - - protected static override preFrom(value: any): any { - if (typeof value === "string") { - return { hash: value }; - } - - return value; - } - - /** - * Creates a new Hash object from a given IHash or a string - * @param value Hash, IHash or string - */ - public static from(value: ICoreHash | string): CoreHash { - return this.fromAny(value); - } - - public override serialize(): string { - return this.hash; - } - - public override toBase64(): string { - return this.hash; - } -} diff --git a/packages/transport/src/core/types/CoreId.ts b/packages/transport/src/core/types/CoreId.ts deleted file mode 100644 index 0a721d41e..000000000 --- a/packages/transport/src/core/types/CoreId.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -import { Random, RandomCharacterRange } from "../../util/Random"; -import { CoreSerializable, ICoreSerializable } from "../CoreSerializable"; -import { TransportError } from "../TransportError"; - -export interface ICoreId extends ICoreSerializable { - id: string; -} - -/** - * A CoreId is any kind of identifier we have in the system. - */ -@type("CoreId") -@serializeOnly("id", "string") -export class CoreId extends CoreSerializable implements ICoreId { - @validate() - @serialize() - public id: string; - - public override toString(): string { - return this.id; - } - - public equals(id: CoreId | string): boolean { - return this.id === id.toString(); - } - - public static async generate(prefix = ""): Promise { - if (prefix.length > 6) { - throw new TransportError(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`); - } - - const random = await Random.string(20 - prefix.length, RandomCharacterRange.Alphanumeric); - return this.from(prefix.toUpperCase() + random); - } - - public static from(value: ICoreId | string): CoreId { - return this.fromAny(value); - } - - protected static override preFrom(value: any): any { - if (typeof value === "string") { - return { id: value }; - } - - return value; - } - - public override serialize(): string { - return this.id; - } -} diff --git a/packages/transport/src/core/types/index.ts b/packages/transport/src/core/types/index.ts index 8740f6fd0..ee096449c 100644 --- a/packages/transport/src/core/types/index.ts +++ b/packages/transport/src/core/types/index.ts @@ -1,5 +1 @@ -export * from "./CoreAddress"; -export * from "./CoreDate"; -export * from "./CoreHash"; -export * from "./CoreId"; export * from "./TransportVersion"; diff --git a/packages/transport/src/events/RelationshipDecomposedBySelfEvent.ts b/packages/transport/src/events/RelationshipDecomposedBySelfEvent.ts index 3fef9c151..09b0deb4a 100644 --- a/packages/transport/src/events/RelationshipDecomposedBySelfEvent.ts +++ b/packages/transport/src/events/RelationshipDecomposedBySelfEvent.ts @@ -1,4 +1,4 @@ -import { CoreId } from "../core"; +import { CoreId } from "@nmshd/core-types"; import { TransportDataEvent } from "./TransportDataEvent"; export interface RelationshipDecomposedBySelfEventData { diff --git a/packages/transport/src/index.ts b/packages/transport/src/index.ts index fb95430a8..2da1fed80 100644 --- a/packages/transport/src/index.ts +++ b/packages/transport/src/index.ts @@ -2,4 +2,3 @@ export * from "./buildInformation"; export * from "./core"; export * from "./events"; export * from "./modules"; -export * from "./util"; diff --git a/packages/transport/src/modules/accounts/AccountController.ts b/packages/transport/src/modules/accounts/AccountController.ts index 14b55300c..ca66da128 100644 --- a/packages/transport/src/modules/accounts/AccountController.ts +++ b/packages/transport/src/modules/accounts/AccountController.ts @@ -1,13 +1,14 @@ import { IDatabaseCollection, IDatabaseCollectionProvider, IDatabaseMap } from "@js-soft/docdb-access-abstractions"; import { ILogger } from "@js-soft/logging-abstractions"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { AbstractAuthenticator, Authenticator, ControllerName, CoreAddress, CoreDate, CoreErrors, CoreId, IConfig, Transport, TransportError } from "../../core"; +import { PasswordGenerator } from "@nmshd/utils"; +import { AbstractAuthenticator, Authenticator, ControllerName, CoreErrors, IConfig, Transport, TransportError } from "../../core"; import { CoreCrypto } from "../../core/CoreCrypto"; import { DbCollectionName } from "../../core/DbCollectionName"; import { DependencyOverrides } from "../../core/DependencyOverrides"; import { TransportLoggerFactory } from "../../core/TransportLoggerFactory"; -import { PasswordGenerator } from "../../util"; import { CertificateController } from "../certificates/CertificateController"; import { CertificateIssuer } from "../certificates/CertificateIssuer"; import { CertificateValidator } from "../certificates/CertificateValidator"; diff --git a/packages/transport/src/modules/accounts/IdentityController.ts b/packages/transport/src/modules/accounts/IdentityController.ts index 8242cda18..f15ff37fb 100644 --- a/packages/transport/src/modules/accounts/IdentityController.ts +++ b/packages/transport/src/modules/accounts/IdentityController.ts @@ -1,6 +1,7 @@ import { log } from "@js-soft/ts-utils"; +import { CoreAddress } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignature, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreAddress, CoreCrypto, CoreErrors, TransportController } from "../../core"; +import { ControllerName, CoreCrypto, CoreErrors, TransportController } from "../../core"; import { AccountController } from "../accounts/AccountController"; import { DeviceSecretType } from "../devices/DeviceSecretController"; import { Identity } from "./data/Identity"; diff --git a/packages/transport/src/modules/accounts/IdentityDeletionProcessController.ts b/packages/transport/src/modules/accounts/IdentityDeletionProcessController.ts index e2dca7ded..0b5fb273b 100644 --- a/packages/transport/src/modules/accounts/IdentityDeletionProcessController.ts +++ b/packages/transport/src/modules/accounts/IdentityDeletionProcessController.ts @@ -1,5 +1,6 @@ import { log } from "@js-soft/ts-utils"; -import { ClientResult, ControllerName, CoreId, DbCollectionName, TransportController } from "../../core"; +import { CoreId } from "@nmshd/core-types"; +import { ClientResult, ControllerName, DbCollectionName, TransportController } from "../../core"; import { IdentityDeletionProcessStatusChangedEvent } from "../../events"; import { AccountController } from "../accounts/AccountController"; import { SynchronizedCollection } from "../sync/SynchronizedCollection"; diff --git a/packages/transport/src/modules/accounts/IdentityUtil.ts b/packages/transport/src/modules/accounts/IdentityUtil.ts index f7b681281..04e17d50f 100644 --- a/packages/transport/src/modules/accounts/IdentityUtil.ts +++ b/packages/transport/src/modules/accounts/IdentityUtil.ts @@ -1,5 +1,5 @@ +import { CoreAddress } from "@nmshd/core-types"; import { CoreBuffer, CryptoHash, CryptoHashAlgorithm, Encoding, ICryptoSignaturePublicKey } from "@nmshd/crypto"; -import { CoreAddress } from "../../core"; const enmeshedAddressDIDPrefix = "did:e:"; diff --git a/packages/transport/src/modules/accounts/data/CachedIdentityDeletionProcess.ts b/packages/transport/src/modules/accounts/data/CachedIdentityDeletionProcess.ts index fed3700bc..7aad49374 100644 --- a/packages/transport/src/modules/accounts/data/CachedIdentityDeletionProcess.ts +++ b/packages/transport/src/modules/accounts/data/CachedIdentityDeletionProcess.ts @@ -1,5 +1,5 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, CoreSerializable } from "../../../core"; +import { Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { IdentityDeletionProcessStatus } from "./IdentityDeletionProcessStatus"; export interface CachedIdentityDeletionProcessJSON { @@ -31,7 +31,7 @@ export interface ICachedIdentityDeletionProcess { } @type("CachedIdentityDeletionProcess") -export class CachedIdentityDeletionProcess extends CoreSerializable implements ICachedIdentityDeletionProcess { +export class CachedIdentityDeletionProcess extends Serializable implements ICachedIdentityDeletionProcess { @validate() @serialize() public status: IdentityDeletionProcessStatus; diff --git a/packages/transport/src/modules/accounts/data/Identity.ts b/packages/transport/src/modules/accounts/data/Identity.ts index 796e67a9e..0364e80eb 100644 --- a/packages/transport/src/modules/accounts/data/Identity.ts +++ b/packages/transport/src/modules/accounts/data/Identity.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress } from "@nmshd/core-types"; import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey } from "@nmshd/crypto"; -import { CoreAddress, CoreSerializable, ICoreSerializable } from "../../../core"; -export interface IIdentity extends ICoreSerializable { +export interface IIdentity extends ISerializable { address: CoreAddress; publicKey: ICryptoSignaturePublicKey; } @type("Identity") -export class Identity extends CoreSerializable implements IIdentity { +export class Identity extends Serializable implements IIdentity { @validate() @serialize() public address: CoreAddress; diff --git a/packages/transport/src/modules/accounts/data/IdentityDeletionProcess.ts b/packages/transport/src/modules/accounts/data/IdentityDeletionProcess.ts index 62cb8d2c7..baa4a615c 100644 --- a/packages/transport/src/modules/accounts/data/IdentityDeletionProcess.ts +++ b/packages/transport/src/modules/accounts/data/IdentityDeletionProcess.ts @@ -1,6 +1,7 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreId, CoreSynchronizable } from "../../../core"; +import { CoreSynchronizable } from "../../../core"; import { CachedIdentityDeletionProcess, CachedIdentityDeletionProcessJSON } from "./CachedIdentityDeletionProcess"; export interface IdentityDeletionProcessJSON { diff --git a/packages/transport/src/modules/accounts/data/IdentitySecretCredentials.ts b/packages/transport/src/modules/accounts/data/IdentitySecretCredentials.ts index 57b569885..7f0ee3a07 100644 --- a/packages/transport/src/modules/accounts/data/IdentitySecretCredentials.ts +++ b/packages/transport/src/modules/accounts/data/IdentitySecretCredentials.ts @@ -1,15 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoSecretKey, CryptoSignaturePrivateKey, CryptoSignaturePublicKey, ICryptoSecretKey, ICryptoSignaturePrivateKey, ICryptoSignaturePublicKey } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; -export interface IIdentitySecretCredentials extends ICoreSerializable { +export interface IIdentitySecretCredentials extends ISerializable { publicKey?: ICryptoSignaturePublicKey; synchronizationKey: ICryptoSecretKey; privateKey?: ICryptoSignaturePrivateKey; } @type("IdentitySecretCredentials") -export class IdentitySecretCredentials extends CoreSerializable implements IIdentitySecretCredentials { +export class IdentitySecretCredentials extends Serializable implements IIdentitySecretCredentials { @validate({ nullable: true }) @serialize() public publicKey?: CryptoSignaturePublicKey; diff --git a/packages/transport/src/modules/certificates/CertificateIssuer.ts b/packages/transport/src/modules/certificates/CertificateIssuer.ts index 84ace9e56..60420dee3 100644 --- a/packages/transport/src/modules/certificates/CertificateIssuer.ts +++ b/packages/transport/src/modules/certificates/CertificateIssuer.ts @@ -1,6 +1,7 @@ import { IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; +import { CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { CoreBuffer, ICryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreDate, ICoreAddress, ICoreDate, TransportController } from "../../core"; +import { ControllerName, TransportController } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { AccountController } from "../accounts/AccountController"; import { Certificate } from "./data/Certificate"; diff --git a/packages/transport/src/modules/certificates/data/Certificate.ts b/packages/transport/src/modules/certificates/data/Certificate.ts index 16b3e9588..12536d7db 100644 --- a/packages/transport/src/modules/certificates/data/Certificate.ts +++ b/packages/transport/src/modules/certificates/data/Certificate.ts @@ -1,8 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CoreBuffer, CryptoSignature, CryptoSignaturePublicKey, ICryptoSignature } from "@nmshd/crypto"; -import { CoreCrypto, CoreSerializable, ICoreSerializable } from "../../../core"; +import { CoreCrypto } from "../../../core"; -export interface ICertificate extends ICoreSerializable { +export interface ICertificate extends ISerializable { content: string; signature: ICryptoSignature; } @@ -19,7 +19,7 @@ export interface ICertificate extends ICoreSerializable { * */ @type("Certificate") -export class Certificate extends CoreSerializable { +export class Certificate extends Serializable { @validate() @serialize() public content: string; diff --git a/packages/transport/src/modules/certificates/data/CertificateConstraint.ts b/packages/transport/src/modules/certificates/data/CertificateConstraint.ts index a0a9f5855..3a6d80c11 100644 --- a/packages/transport/src/modules/certificates/data/CertificateConstraint.ts +++ b/packages/transport/src/modules/certificates/data/CertificateConstraint.ts @@ -1,13 +1,12 @@ -import { type } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; -export interface ICertificateConstraint extends ICoreSerializable {} +export interface ICertificateConstraint extends ISerializable {} /** * A CertificateConstraint limits a Certificate to a specific time, region or identity. */ @type("CertificateConstraint") -export class CertificateConstraint extends CoreSerializable { +export class CertificateConstraint extends Serializable { public static from(value: ICertificateConstraint): CertificateConstraint { return this.fromAny(value); } diff --git a/packages/transport/src/modules/certificates/data/CertificateContent.ts b/packages/transport/src/modules/certificates/data/CertificateContent.ts index 0f935b80d..4748243fa 100644 --- a/packages/transport/src/modules/certificates/data/CertificateContent.ts +++ b/packages/transport/src/modules/certificates/data/CertificateContent.ts @@ -1,13 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey } from "@nmshd/crypto"; -import { CoreAddress, CoreDate, CoreSerializable, ICoreAddress, ICoreDate, ICoreSerializable } from "../../../core"; import { CertificateConstraint, ICertificateConstraint } from "./CertificateConstraint"; import { CertificateItem, ICertificateItem } from "./CertificateItem"; -export interface ICertificateContent extends ICoreSerializable { +export interface ICertificateContent extends ISerializable { issuedAt: ICoreDate; issuer: ICoreAddress; - issuerData?: ICoreSerializable; + issuerData?: ISerializable; subject: ICoreAddress; subjectPublicKey: ICryptoSignaturePublicKey; constraints: ICertificateConstraint[]; @@ -19,7 +19,7 @@ export interface ICertificateContent extends ICoreSerializable { * is done on top of the serialized content of this data structure. */ @type("CertificateContent") -export class CertificateContent extends CoreSerializable { +export class CertificateContent extends Serializable { @validate() @serialize() public issuedAt: CoreDate; @@ -30,7 +30,7 @@ export class CertificateContent extends CoreSerializable { @validate() @serialize() - public issuerData: CoreSerializable; + public issuerData: Serializable; @validate() @serialize() diff --git a/packages/transport/src/modules/certificates/data/CertificateItem.ts b/packages/transport/src/modules/certificates/data/CertificateItem.ts index 235817612..5388eb9a3 100644 --- a/packages/transport/src/modules/certificates/data/CertificateItem.ts +++ b/packages/transport/src/modules/certificates/data/CertificateItem.ts @@ -1,14 +1,13 @@ -import { type } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; -export interface ICertificateItem extends ICoreSerializable {} +export interface ICertificateItem extends ISerializable {} /** * A CertificateItem is a digitally signed hash with information about the signature date, * the signer, the signature algorithm and the version. */ @type("CertificateItem") -export class CertificateItem extends CoreSerializable { +export class CertificateItem extends Serializable { public static from(value: ICertificateItem): CertificateItem { return this.fromAny(value); } diff --git a/packages/transport/src/modules/certificates/data/constraints/CertificateIdentityConstraint.ts b/packages/transport/src/modules/certificates/data/constraints/CertificateIdentityConstraint.ts index 218d71bdc..b073a4475 100644 --- a/packages/transport/src/modules/certificates/data/constraints/CertificateIdentityConstraint.ts +++ b/packages/transport/src/modules/certificates/data/constraints/CertificateIdentityConstraint.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, ICoreAddress } from "../../../../core"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { CertificateConstraint, ICertificateConstraint } from "../CertificateConstraint"; export interface ICertificateIdentityConstraint extends ICertificateConstraint { diff --git a/packages/transport/src/modules/certificates/data/constraints/CertificateTimeConstraint.ts b/packages/transport/src/modules/certificates/data/constraints/CertificateTimeConstraint.ts index 6f669beb6..a6a8a0243 100644 --- a/packages/transport/src/modules/certificates/data/constraints/CertificateTimeConstraint.ts +++ b/packages/transport/src/modules/certificates/data/constraints/CertificateTimeConstraint.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, ICoreDate } from "../../../../core"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CertificateConstraint, ICertificateConstraint } from "../CertificateConstraint"; export interface ICertificateTimeConstraint extends ICertificateConstraint { diff --git a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts index 022751b01..7fae2dc67 100644 --- a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts +++ b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts @@ -1,8 +1,10 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreHash } from "../../../../core/types"; +import { CoreHash, ICoreHash } from "@nmshd/core-types"; import { CertificateItem, ICertificateItem } from "../CertificateItem"; -export interface ICertificatePrivateAttributeItem extends ICertificateItem {} +export interface ICertificatePrivateAttributeItem extends ICertificateItem { + hash: ICoreHash; +} /** * A CertificatePrivateAttributeItem is a hashed representation of a single attribute, diff --git a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts index aa6a01a7f..adcab3fae 100644 --- a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts +++ b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreHash } from "../../../../core/types"; +import { CoreHash } from "@nmshd/core-types"; import { CertificateItem, ICertificateItem } from "../CertificateItem"; export interface ICertificatePrivateAttributeItemSource extends ICertificateItem { diff --git a/packages/transport/src/modules/challenges/ChallengeController.ts b/packages/transport/src/modules/challenges/ChallengeController.ts index 17dd3dd80..df2389ece 100644 --- a/packages/transport/src/modules/challenges/ChallengeController.ts +++ b/packages/transport/src/modules/challenges/ChallengeController.ts @@ -1,6 +1,7 @@ import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignatureKeypair } from "@nmshd/crypto"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreId } from "../../core"; +import { CoreCrypto, CoreErrors } from "../../core"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; import { Relationship } from "../relationships/local/Relationship"; diff --git a/packages/transport/src/modules/challenges/data/Challenge.ts b/packages/transport/src/modules/challenges/data/Challenge.ts index ffc2d774a..105d246fc 100644 --- a/packages/transport/src/modules/challenges/data/Challenge.ts +++ b/packages/transport/src/modules/challenges/data/Challenge.ts @@ -1,7 +1,7 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; -export interface IChallenge extends ICoreSerializable { +export interface IChallenge extends ISerializable { id: ICoreId; expiresAt: CoreDate; createdBy?: CoreAddress; @@ -16,7 +16,7 @@ export enum ChallengeType { } @type("Challenge") -export class Challenge extends CoreSerializable implements IChallenge { +export class Challenge extends Serializable implements IChallenge { @validate() @serialize() public id: CoreId; diff --git a/packages/transport/src/modules/challenges/data/ChallengeSigned.ts b/packages/transport/src/modules/challenges/data/ChallengeSigned.ts index 65711ebc2..48f6aa6ec 100644 --- a/packages/transport/src/modules/challenges/data/ChallengeSigned.ts +++ b/packages/transport/src/modules/challenges/data/ChallengeSigned.ts @@ -1,19 +1,18 @@ -import { ISerialized, serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, ISerialized, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoSignature, ICryptoSignature } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; export interface IChallengeSignedSerialized extends ISerialized { challenge: string; signature: string; } -export interface IChallengeSigned extends ICoreSerializable { +export interface IChallengeSigned extends ISerializable { challenge: string; signature: ICryptoSignature; } @type("ChallengeSigned") -export class ChallengeSigned extends CoreSerializable implements IChallengeSigned { +export class ChallengeSigned extends Serializable implements IChallengeSigned { @validate() @serialize({ enforceString: true }) public challenge: string; diff --git a/packages/transport/src/modules/devices/DeviceController.ts b/packages/transport/src/modules/devices/DeviceController.ts index 61432e9eb..f572c484d 100644 --- a/packages/transport/src/modules/devices/DeviceController.ts +++ b/packages/transport/src/modules/devices/DeviceController.ts @@ -1,6 +1,7 @@ import { log } from "@js-soft/ts-utils"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSecretKey, CryptoSignature, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreCrypto, CoreDate, CoreErrors, CoreId, CredentialsBasic, TransportController, TransportError } from "../../core"; +import { ControllerName, CoreCrypto, CoreErrors, CredentialsBasic, TransportController, TransportError } from "../../core"; import { AccountController } from "../accounts/AccountController"; import { DeviceSecretController, DeviceSecretType } from "./DeviceSecretController"; import { Device, DeviceType } from "./local/Device"; diff --git a/packages/transport/src/modules/devices/DeviceSecretController.ts b/packages/transport/src/modules/devices/DeviceSecretController.ts index f0669fab9..d9bcc2014 100644 --- a/packages/transport/src/modules/devices/DeviceSecretController.ts +++ b/packages/transport/src/modules/devices/DeviceSecretController.ts @@ -1,8 +1,9 @@ import { IDatabaseMap } from "@js-soft/docdb-access-abstractions"; import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreDate } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoExchangeKeypair, CryptoExchangePrivateKey, CryptoSecretKey, CryptoSignatureKeypair, CryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreDate, CoreErrors } from "../../core"; +import { CoreCrypto, CoreErrors } from "../../core"; import { ControllerName, TransportController } from "../../core/TransportController"; import { TransportIds } from "../../core/TransportIds"; import { AccountController } from "../accounts/AccountController"; diff --git a/packages/transport/src/modules/devices/DevicesController.ts b/packages/transport/src/modules/devices/DevicesController.ts index 2e7b6362f..26231578e 100644 --- a/packages/transport/src/modules/devices/DevicesController.ts +++ b/packages/transport/src/modules/devices/DevicesController.ts @@ -1,7 +1,8 @@ -import { CoreDate, CoreErrors, CoreId } from "../../core"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { PasswordGenerator } from "@nmshd/utils"; +import { CoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; -import { PasswordGenerator } from "../../util"; import { AccountController } from "../accounts/AccountController"; import { ChallengeType } from "../challenges/data/Challenge"; import { SynchronizedCollection } from "../sync/SynchronizedCollection"; diff --git a/packages/transport/src/modules/devices/local/Device.ts b/packages/transport/src/modules/devices/local/Device.ts index a940d37aa..9f9788f48 100644 --- a/packages/transport/src/modules/devices/local/Device.ts +++ b/packages/transport/src/modules/devices/local/Device.ts @@ -1,9 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSignaturePublicKey, ICryptoSignaturePublicKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; import { CoreSynchronizable, ICoreSynchronizable } from "../../../core"; -import { CoreDate } from "../../../core/types/CoreDate"; -import { CoreId } from "../../../core/types/CoreId"; export enum DeviceType { "Unknown", diff --git a/packages/transport/src/modules/devices/local/DeviceSecretCredentials.ts b/packages/transport/src/modules/devices/local/DeviceSecretCredentials.ts index 3b4366315..d9bf8d9e4 100644 --- a/packages/transport/src/modules/devices/local/DeviceSecretCredentials.ts +++ b/packages/transport/src/modules/devices/local/DeviceSecretCredentials.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, CoreSerializable, ICoreId } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; -export interface IDeviceSecretCredentials { +export interface IDeviceSecretCredentials extends ISerializable { id: ICoreId; password?: string; username?: string; } @type("DeviceSecretCredentials") -export class DeviceSecretCredentials extends CoreSerializable implements IDeviceSecretCredentials { +export class DeviceSecretCredentials extends Serializable implements IDeviceSecretCredentials { @serialize() @validate() public id: CoreId; diff --git a/packages/transport/src/modules/devices/local/SendDeviceParameters.ts b/packages/transport/src/modules/devices/local/SendDeviceParameters.ts index a19f8f327..60ef20c84 100644 --- a/packages/transport/src/modules/devices/local/SendDeviceParameters.ts +++ b/packages/transport/src/modules/devices/local/SendDeviceParameters.ts @@ -1,14 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -export interface ISendDeviceParameters extends ICoreSerializable { +export interface ISendDeviceParameters extends ISerializable { name?: string; description?: string; isAdmin?: boolean; } @type("SendDeviceParameters") -export class SendDeviceParameters extends CoreSerializable implements ISendDeviceParameters { +export class SendDeviceParameters extends Serializable implements ISendDeviceParameters { @validate({ nullable: true }) @serialize() public name?: string; diff --git a/packages/transport/src/modules/devices/transmission/DeviceSharedSecret.ts b/packages/transport/src/modules/devices/transmission/DeviceSharedSecret.ts index 8685e6971..2bc29623c 100644 --- a/packages/transport/src/modules/devices/transmission/DeviceSharedSecret.ts +++ b/packages/transport/src/modules/devices/transmission/DeviceSharedSecret.ts @@ -1,9 +1,9 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; import { CryptoSecretKey, CryptoSignaturePrivateKey, ICryptoSecretKey, ICryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { CoreDate, CoreId, CoreSerializable, ICoreId } from "../../../core"; import { Identity, IIdentity } from "../../accounts/data/Identity"; -export interface IDeviceSharedSecret { +export interface IDeviceSharedSecret extends ISerializable { id: ICoreId; createdAt: CoreDate; createdByDevice: CoreId; @@ -20,7 +20,7 @@ export interface IDeviceSharedSecret { } @type("DeviceSharedSecret") -export class DeviceSharedSecret extends CoreSerializable implements IDeviceSharedSecret { +export class DeviceSharedSecret extends Serializable implements IDeviceSharedSecret { @serialize() @validate() public id: CoreId; diff --git a/packages/transport/src/modules/files/FileController.ts b/packages/transport/src/modules/files/FileController.ts index 090b9f5dc..64701028f 100644 --- a/packages/transport/src/modules/files/FileController.ts +++ b/packages/transport/src/modules/files/FileController.ts @@ -1,7 +1,8 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreHash, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoHash, CryptoHashAlgorithm, CryptoSecretKey, Encoding } from "@nmshd/crypto"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreHash, CoreId } from "../../core"; +import { CoreCrypto, CoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; diff --git a/packages/transport/src/modules/files/local/CachedFile.ts b/packages/transport/src/modules/files/local/CachedFile.ts index 66d85a7e0..7e09eb437 100644 --- a/packages/transport/src/modules/files/local/CachedFile.ts +++ b/packages/transport/src/modules/files/local/CachedFile.ts @@ -1,10 +1,10 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreHash, CoreId, ICoreAddress, ICoreDate, ICoreHash, ICoreId } from "@nmshd/core-types"; import { CryptoSecretKey, CryptoSignature, ICryptoSecretKey, ICryptoSignature } from "@nmshd/crypto"; -import { CoreAddress, CoreDate, CoreHash, CoreId, CoreSerializable, ICoreAddress, ICoreDate, ICoreHash, ICoreId, ICoreSerializable } from "../../../core"; import { BackboneGetFilesResponse } from "../backbone/BackboneGetFiles"; import { FileMetadata } from "../transmission/FileMetadata"; -export interface ICachedFile extends ICoreSerializable { +export interface ICachedFile extends ISerializable { title?: string; filename: string; filesize: number; @@ -27,7 +27,7 @@ export interface ICachedFile extends ICoreSerializable { } @type("CachedFile") -export class CachedFile extends CoreSerializable implements ICachedFile { +export class CachedFile extends Serializable implements ICachedFile { @validate({ nullable: true }) @serialize() public title?: string; diff --git a/packages/transport/src/modules/files/local/File.ts b/packages/transport/src/modules/files/local/File.ts index a8a755b6a..f28390f41 100644 --- a/packages/transport/src/modules/files/local/File.ts +++ b/packages/transport/src/modules/files/local/File.ts @@ -1,7 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreSynchronizable, ICoreDate, ICoreSynchronizable } from "../../../core"; +import { CoreSynchronizable, ICoreSynchronizable } from "../../../core"; import { FileReference } from "../transmission/FileReference"; import { CachedFile, ICachedFile } from "./CachedFile"; diff --git a/packages/transport/src/modules/files/local/SendFileParameters.ts b/packages/transport/src/modules/files/local/SendFileParameters.ts index c0988b3c6..37e1a8f80 100644 --- a/packages/transport/src/modules/files/local/SendFileParameters.ts +++ b/packages/transport/src/modules/files/local/SendFileParameters.ts @@ -1,9 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CoreBuffer, ICoreBuffer } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; -import { CoreDate, ICoreDate } from "../../../core/types/CoreDate"; -export interface ISendFileParameters extends ICoreSerializable { +export interface ISendFileParameters extends ISerializable { title: string; description: string; filename: string; @@ -14,7 +13,7 @@ export interface ISendFileParameters extends ICoreSerializable { } @type("SendFileParameters") -export class SendFileParameters extends CoreSerializable implements ISendFileParameters { +export class SendFileParameters extends Serializable implements ISendFileParameters { @validate() @serialize() public title: string; diff --git a/packages/transport/src/modules/files/transmission/FileMetadata.ts b/packages/transport/src/modules/files/transmission/FileMetadata.ts index d29a6284e..cb315fcfa 100644 --- a/packages/transport/src/modules/files/transmission/FileMetadata.ts +++ b/packages/transport/src/modules/files/transmission/FileMetadata.ts @@ -1,8 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreHash, ICoreDate, ICoreHash } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; -import { CoreDate, CoreHash, CoreSerializable, ICoreDate, ICoreHash, ICoreSerializable } from "../../../core"; -export interface IFileMetadata extends ICoreSerializable { +export interface IFileMetadata extends ISerializable { title?: string; description?: string; filename: string; @@ -16,7 +16,7 @@ export interface IFileMetadata extends ICoreSerializable { } @type("FileMetadata") -export class FileMetadata extends CoreSerializable implements IFileMetadata { +export class FileMetadata extends Serializable implements IFileMetadata { @validate({ nullable: true }) @serialize() public title?: string; diff --git a/packages/transport/src/modules/messages/MessageController.ts b/packages/transport/src/modules/messages/MessageController.ts index afed3bb42..fe62f2e48 100644 --- a/packages/transport/src/modules/messages/MessageController.ts +++ b/packages/transport/src/modules/messages/MessageController.ts @@ -1,8 +1,9 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreId, ICoreAddress, ICoreId, TransportError } from "../../core"; +import { CoreCrypto, CoreErrors, TransportError } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { MessageSentEvent, MessageWasReadAtChangedEvent } from "../../events"; diff --git a/packages/transport/src/modules/messages/local/CachedMessage.ts b/packages/transport/src/modules/messages/local/CachedMessage.ts index 5c2408a4b..562038377 100644 --- a/packages/transport/src/modules/messages/local/CachedMessage.ts +++ b/packages/transport/src/modules/messages/local/CachedMessage.ts @@ -1,10 +1,9 @@ /* eslint-disable @typescript-eslint/no-inferrable-types */ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreId, CoreSerializable, ICoreAddress, ICoreId, ICoreSerializable } from "../../../core"; -import { CoreDate, ICoreDate } from "../../../core/types/CoreDate"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CachedMessageRecipient, ICachedMessageRecipient } from "./CachedMessageRecipient"; -export interface ICachedMessage extends ICoreSerializable { +export interface ICachedMessage extends ISerializable { createdBy: ICoreAddress; createdByDevice: ICoreId; @@ -19,7 +18,7 @@ export interface ICachedMessage extends ICoreSerializable { } @type("CachedMessage") -export class CachedMessage extends CoreSerializable implements ICachedMessage { +export class CachedMessage extends Serializable implements ICachedMessage { @validate() @serialize() public createdBy: CoreAddress; diff --git a/packages/transport/src/modules/messages/local/CachedMessageRecipient.ts b/packages/transport/src/modules/messages/local/CachedMessageRecipient.ts index 3acb4f09e..26fb30ddc 100644 --- a/packages/transport/src/modules/messages/local/CachedMessageRecipient.ts +++ b/packages/transport/src/modules/messages/local/CachedMessageRecipient.ts @@ -1,9 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CryptoCipher, ICryptoCipher } from "@nmshd/crypto"; -import { CoreDate, CoreId, CoreSerializable, ICoreDate, ICoreId, ICoreSerializable } from "../../../core"; -import { CoreAddress, ICoreAddress } from "../../../core/types/CoreAddress"; -export interface ICachedMessageRecipient extends ICoreSerializable { +export interface ICachedMessageRecipient extends ISerializable { address: ICoreAddress; encryptedKey: ICryptoCipher; receivedAt?: ICoreDate; @@ -12,7 +11,7 @@ export interface ICachedMessageRecipient extends ICoreSerializable { } @type("CachedMessageRecipient") -export class CachedMessageRecipient extends CoreSerializable implements ICachedMessageRecipient { +export class CachedMessageRecipient extends Serializable implements ICachedMessageRecipient { @validate() @serialize() public address: CoreAddress; diff --git a/packages/transport/src/modules/messages/local/Message.ts b/packages/transport/src/modules/messages/local/Message.ts index 797129f7b..eec3cb939 100644 --- a/packages/transport/src/modules/messages/local/Message.ts +++ b/packages/transport/src/modules/messages/local/Message.ts @@ -1,7 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreSynchronizable, ICoreDate, ICoreSynchronizable } from "../../../core"; +import { CoreSynchronizable, ICoreSynchronizable } from "../../../core"; import { CachedMessage, ICachedMessage } from "./CachedMessage"; export interface IMessage extends ICoreSynchronizable { diff --git a/packages/transport/src/modules/messages/local/SendMessageParameters.ts b/packages/transport/src/modules/messages/local/SendMessageParameters.ts index c726f87d1..6f93b4abc 100644 --- a/packages/transport/src/modules/messages/local/SendMessageParameters.ts +++ b/packages/transport/src/modules/messages/local/SendMessageParameters.ts @@ -1,15 +1,15 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreSerializable, ICoreAddress, ICoreSerializable } from "../../../core"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { File, IFile } from "../../files/local/File"; -export interface ISendMessageParameters extends ICoreSerializable { +export interface ISendMessageParameters extends ISerializable { recipients: ICoreAddress[]; content: ISerializable; attachments?: IFile[]; } @type("SendMessageParameters") -export class SendMessageParameters extends CoreSerializable implements ISendMessageParameters { +export class SendMessageParameters extends Serializable implements ISendMessageParameters { @validate() @serialize({ type: CoreAddress }) public recipients: CoreAddress[]; diff --git a/packages/transport/src/modules/messages/transmission/MessageContentWrapper.ts b/packages/transport/src/modules/messages/transmission/MessageContentWrapper.ts index 0b80afbf3..2b10909d2 100644 --- a/packages/transport/src/modules/messages/transmission/MessageContentWrapper.ts +++ b/packages/transport/src/modules/messages/transmission/MessageContentWrapper.ts @@ -1,10 +1,8 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; -import { CoreAddress, ICoreAddress } from "../../../core/types/CoreAddress"; -import { CoreDate, ICoreDate } from "../../../core/types/CoreDate"; +import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { FileReference, IFileReference } from "../../files/transmission/FileReference"; -export interface IMessageContentWrapper extends ICoreSerializable { +export interface IMessageContentWrapper extends ISerializable { attachments?: IFileReference[]; content: ISerializable; createdAt?: ICoreDate; @@ -22,7 +20,7 @@ export interface IMessageContentWrapper extends ICoreSerializable { * ignored (as the whole message could have been forwarded by bad party to a wrong recipient). */ @type("MessageContentWrapper") -export class MessageContentWrapper extends CoreSerializable implements IMessageContentWrapper { +export class MessageContentWrapper extends Serializable implements IMessageContentWrapper { @validate() @serialize({ type: FileReference }) public attachments: FileReference[] = []; diff --git a/packages/transport/src/modules/messages/transmission/MessageEnvelope.ts b/packages/transport/src/modules/messages/transmission/MessageEnvelope.ts index 3ef831dae..6c0991cd0 100644 --- a/packages/transport/src/modules/messages/transmission/MessageEnvelope.ts +++ b/packages/transport/src/modules/messages/transmission/MessageEnvelope.ts @@ -1,9 +1,9 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CryptoCipher, ICryptoCipher } from "@nmshd/crypto"; -import { CoreAddress, CoreDate, CoreId, CoreSerializable, ICoreAddress, ICoreDate, ICoreId, ICoreSerializable } from "../../../core"; import { IMessageEnvelopeRecipient, MessageEnvelopeRecipient } from "./MessageEnvelopeRecipient"; -export interface IMessageEnvelope extends ICoreSerializable { +export interface IMessageEnvelope extends ISerializable { id: ICoreId; createdAt: ICoreDate; @@ -17,7 +17,7 @@ export interface IMessageEnvelope extends ICoreSerializable { } @type("MessageEnvelope") -export class MessageEnvelope extends CoreSerializable implements IMessageEnvelope { +export class MessageEnvelope extends Serializable implements IMessageEnvelope { @validate() @serialize() public id: CoreId; diff --git a/packages/transport/src/modules/messages/transmission/MessageEnvelopeRecipient.ts b/packages/transport/src/modules/messages/transmission/MessageEnvelopeRecipient.ts index c575b491a..753b0130b 100644 --- a/packages/transport/src/modules/messages/transmission/MessageEnvelopeRecipient.ts +++ b/packages/transport/src/modules/messages/transmission/MessageEnvelopeRecipient.ts @@ -1,9 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CryptoCipher, ICryptoCipher } from "@nmshd/crypto"; -import { CoreDate, CoreId, CoreSerializable, ICoreDate, ICoreId, ICoreSerializable } from "../../../core"; -import { CoreAddress, ICoreAddress } from "../../../core/types/CoreAddress"; -export interface IMessageEnvelopeRecipient extends ICoreSerializable { +export interface IMessageEnvelopeRecipient extends ISerializable { address: ICoreAddress; encryptedKey: ICryptoCipher; receivedAt?: ICoreDate; @@ -11,7 +10,7 @@ export interface IMessageEnvelopeRecipient extends ICoreSerializable { } @type("MessageEnvelopeRecipient") -export class MessageEnvelopeRecipient extends CoreSerializable implements IMessageEnvelopeRecipient { +export class MessageEnvelopeRecipient extends Serializable implements IMessageEnvelopeRecipient { @validate() @serialize() public address: CoreAddress; diff --git a/packages/transport/src/modules/messages/transmission/MessageSignature.ts b/packages/transport/src/modules/messages/transmission/MessageSignature.ts index aca900067..8c2d7e939 100644 --- a/packages/transport/src/modules/messages/transmission/MessageSignature.ts +++ b/packages/transport/src/modules/messages/transmission/MessageSignature.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; import { CryptoSignature, ICryptoSignature } from "@nmshd/crypto"; -import { CoreAddress, CoreSerializable, ICoreAddress, ICoreSerializable } from "../../../core"; -export interface IMessageSignature extends ICoreSerializable { +export interface IMessageSignature extends ISerializable { recipient: ICoreAddress; signature: ICryptoSignature; } @type("MessageSignature") -export class MessageSignature extends CoreSerializable implements IMessageSignature { +export class MessageSignature extends Serializable implements IMessageSignature { @validate() @serialize() public recipient: CoreAddress; diff --git a/packages/transport/src/modules/messages/transmission/MessageSigned.ts b/packages/transport/src/modules/messages/transmission/MessageSigned.ts index de1d11747..5bf214796 100644 --- a/packages/transport/src/modules/messages/transmission/MessageSigned.ts +++ b/packages/transport/src/modules/messages/transmission/MessageSigned.ts @@ -1,8 +1,7 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { IMessageSignature, MessageSignature } from "./MessageSignature"; -export interface IMessageSigned extends ICoreSerializable { +export interface IMessageSigned extends ISerializable { signatures: IMessageSignature[]; message: string; } @@ -11,7 +10,7 @@ export interface IMessageSigned extends ICoreSerializable { * MessageSigned encapsulates the actual message with the senders digital signature. */ @type("MessageSigned") -export class MessageSigned extends CoreSerializable { +export class MessageSigned extends Serializable { @validate() @serialize({ type: MessageSignature }) public signatures: MessageSignature[]; diff --git a/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts b/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts index f5d36e5b8..6cdba186c 100644 --- a/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts +++ b/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts @@ -1,7 +1,8 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreId } from "../../core"; +import { CoreCrypto, CoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { PeerRelationshipTemplateLoadedEvent } from "../../events"; diff --git a/packages/transport/src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts b/packages/transport/src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts index dd7090062..1117e01d5 100644 --- a/packages/transport/src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts +++ b/packages/transport/src/modules/relationshipTemplates/local/CachedRelationshipTemplate.ts @@ -1,11 +1,10 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { ICryptoExchangePublicKey } from "@nmshd/crypto"; -import { CoreAddress, CoreDate, CoreSerializable, ICoreAddress, ICoreDate, ICoreSerializable } from "../../../core"; -import { CoreId, ICoreId } from "../../../core/types/CoreId"; import { IIdentity, Identity } from "../../accounts/data/Identity"; import { RelationshipTemplatePublicKey } from "../transmission/RelationshipTemplatePublicKey"; -export interface ICachedRelationshipTemplate extends ICoreSerializable { +export interface ICachedRelationshipTemplate extends ISerializable { identity: IIdentity; createdBy: ICoreAddress; createdByDevice: ICoreId; @@ -17,7 +16,7 @@ export interface ICachedRelationshipTemplate extends ICoreSerializable { } @type("CachedRelationshipTemplate") -export class CachedRelationshipTemplate extends CoreSerializable implements ICachedRelationshipTemplate { +export class CachedRelationshipTemplate extends Serializable implements ICachedRelationshipTemplate { @validate() @serialize() public identity: Identity; diff --git a/packages/transport/src/modules/relationshipTemplates/local/RelationshipTemplate.ts b/packages/transport/src/modules/relationshipTemplates/local/RelationshipTemplate.ts index 9fd7c8471..a504ea609 100644 --- a/packages/transport/src/modules/relationshipTemplates/local/RelationshipTemplate.ts +++ b/packages/transport/src/modules/relationshipTemplates/local/RelationshipTemplate.ts @@ -1,8 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; import { CoreSynchronizable, ICoreSynchronizable } from "../../../core"; -import { CoreDate, ICoreDate } from "../../../core/types/CoreDate"; import { RelationshipTemplateReference } from "../transmission/RelationshipTemplateReference"; import { CachedRelationshipTemplate, ICachedRelationshipTemplate } from "./CachedRelationshipTemplate"; diff --git a/packages/transport/src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts b/packages/transport/src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts index ad112bd04..05f7f5a3e 100644 --- a/packages/transport/src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts +++ b/packages/transport/src/modules/relationshipTemplates/local/SendRelationshipTemplateParameters.ts @@ -1,15 +1,15 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSerializable, ICoreSerializable } from "../../../core"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { validateMaxNumberOfAllocations } from "./CachedRelationshipTemplate"; -export interface ISendRelationshipTemplateParameters extends ICoreSerializable { +export interface ISendRelationshipTemplateParameters extends ISerializable { content: ISerializable; - expiresAt: CoreDate; + expiresAt: ICoreDate; maxNumberOfAllocations?: number; } @type("SendRelationshipTemplateParameters") -export class SendRelationshipTemplateParameters extends CoreSerializable implements ISendRelationshipTemplateParameters { +export class SendRelationshipTemplateParameters extends Serializable implements ISendRelationshipTemplateParameters { @validate() @serialize() public content: Serializable; diff --git a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.ts b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.ts index d47b195c4..75774b820 100644 --- a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.ts +++ b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateContentWrapper.ts @@ -1,16 +1,15 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; import { IIdentity, Identity } from "../../accounts/data/Identity"; import { IRelationshipTemplatePublicKey, RelationshipTemplatePublicKey } from "./RelationshipTemplatePublicKey"; -export interface IRelationshipTemplateContentWrapper extends ICoreSerializable { +export interface IRelationshipTemplateContentWrapper extends ISerializable { identity: IIdentity; templateKey: IRelationshipTemplatePublicKey; content: ISerializable; } @type("RelationshipTemplateContentWrapper") -export class RelationshipTemplateContentWrapper extends CoreSerializable implements IRelationshipTemplateContentWrapper { +export class RelationshipTemplateContentWrapper extends Serializable implements IRelationshipTemplateContentWrapper { @validate() @serialize() public identity: Identity; diff --git a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.ts b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.ts index 0674d5b90..70f66ba1a 100644 --- a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.ts +++ b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplatePublicKey.ts @@ -1,6 +1,6 @@ import { ISerialized, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoExchangePublicKey, ICryptoExchangePublicKey, ICryptoExchangePublicKeySerialized } from "@nmshd/crypto"; -import { CoreId, ICoreId } from "../../../core"; export interface IRelationshipTemplatePublicKey extends ICryptoExchangePublicKey { id: ICoreId; diff --git a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.ts b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.ts index 29acc5df4..abff718d4 100644 --- a/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.ts +++ b/packages/transport/src/modules/relationshipTemplates/transmission/RelationshipTemplateSigned.ts @@ -1,14 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoSignature, ICryptoSignature } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; -export interface IRelationshipTemplateSigned extends ICoreSerializable { +export interface IRelationshipTemplateSigned extends ISerializable { serializedTemplate: string; deviceSignature: ICryptoSignature; } @type("RelationshipTemplateSigned") -export class RelationshipTemplateSigned extends CoreSerializable implements IRelationshipTemplateSigned { +export class RelationshipTemplateSigned extends Serializable implements IRelationshipTemplateSigned { @validate() @serialize() public serializedTemplate: string; diff --git a/packages/transport/src/modules/relationships/RelationshipSecretController.ts b/packages/transport/src/modules/relationships/RelationshipSecretController.ts index 094940416..74733d492 100644 --- a/packages/transport/src/modules/relationships/RelationshipSecretController.ts +++ b/packages/transport/src/modules/relationships/RelationshipSecretController.ts @@ -1,5 +1,6 @@ import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, @@ -12,7 +13,7 @@ import { CryptoSignature, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreCrypto, CoreId } from "../../core"; +import { ControllerName, CoreCrypto } from "../../core"; import { CoreErrors } from "../../core/CoreErrors"; import { CoreUtil } from "../../core/CoreUtil"; import { TransportIds } from "../../core/TransportIds"; diff --git a/packages/transport/src/modules/relationships/RelationshipsController.ts b/packages/transport/src/modules/relationships/RelationshipsController.ts index b937cb495..222c2c842 100644 --- a/packages/transport/src/modules/relationships/RelationshipsController.ts +++ b/packages/transport/src/modules/relationships/RelationshipsController.ts @@ -1,8 +1,9 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignature } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { ControllerName, CoreAddress, CoreCrypto, CoreDate, CoreId, TransportController, TransportError } from "../../core"; +import { ControllerName, CoreCrypto, TransportController, TransportError } from "../../core"; import { CoreErrors } from "../../core/CoreErrors"; import { CoreUtil } from "../../core/CoreUtil"; import { DbCollectionName } from "../../core/DbCollectionName"; diff --git a/packages/transport/src/modules/relationships/local/CachedRelationship.ts b/packages/transport/src/modules/relationships/local/CachedRelationship.ts index f277b1b45..26b81a5ca 100644 --- a/packages/transport/src/modules/relationships/local/CachedRelationship.ts +++ b/packages/transport/src/modules/relationships/local/CachedRelationship.ts @@ -1,9 +1,9 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSerializable, ICoreDate, ICoreSerializable } from "../../../core"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { IRelationshipTemplate, RelationshipTemplate } from "../../relationshipTemplates/local/RelationshipTemplate"; import { IRelationshipAuditLogEntry, RelationshipAuditLogEntry } from "./RelationshipAuditLogEntry"; -export interface ICachedRelationship extends ICoreSerializable { +export interface ICachedRelationship extends ISerializable { template: IRelationshipTemplate; creationContent: ISerializable; @@ -13,7 +13,7 @@ export interface ICachedRelationship extends ICoreSerializable { } @type("CachedRelationship") -export class CachedRelationship extends CoreSerializable implements ICachedRelationship { +export class CachedRelationship extends Serializable implements ICachedRelationship { @validate() @serialize() public template: RelationshipTemplate; diff --git a/packages/transport/src/modules/relationships/local/Relationship.ts b/packages/transport/src/modules/relationships/local/Relationship.ts index 2cb95082d..f67619575 100644 --- a/packages/transport/src/modules/relationships/local/Relationship.ts +++ b/packages/transport/src/modules/relationships/local/Relationship.ts @@ -1,6 +1,7 @@ import { ISerializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreId, CoreSynchronizable, ICoreId, ICoreSynchronizable, TransportError } from "../../../core"; +import { CoreSynchronizable, ICoreSynchronizable, TransportError } from "../../../core"; import { Identity, IIdentity } from "../../accounts/data/Identity"; import { IRelationshipTemplate } from "../../relationshipTemplates/local/RelationshipTemplate"; import { BackboneGetRelationshipResponse } from "../backbone/BackboneGetRelationships"; diff --git a/packages/transport/src/modules/relationships/local/RelationshipAuditLog.ts b/packages/transport/src/modules/relationships/local/RelationshipAuditLog.ts index 5923d31eb..ebb35ce8b 100644 --- a/packages/transport/src/modules/relationships/local/RelationshipAuditLog.ts +++ b/packages/transport/src/modules/relationships/local/RelationshipAuditLog.ts @@ -1,5 +1,5 @@ +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import _ from "lodash"; -import { CoreAddress, CoreDate, CoreId } from "../../../core"; import { BackboneRelationshipAuditLog as BackboneAuditLog } from "../transmission/RelationshipAuditLog"; import { RelationshipAuditLogEntry } from "./RelationshipAuditLogEntry"; diff --git a/packages/transport/src/modules/relationships/local/RelationshipAuditLogEntry.ts b/packages/transport/src/modules/relationships/local/RelationshipAuditLogEntry.ts index 114fa1fc3..36ac7f6b2 100644 --- a/packages/transport/src/modules/relationships/local/RelationshipAuditLogEntry.ts +++ b/packages/transport/src/modules/relationships/local/RelationshipAuditLogEntry.ts @@ -1,9 +1,9 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreId, CoreSerializable, ICoreAddress, ICoreDate, ICoreId } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { RelationshipAuditLogEntryReason } from "../transmission/RelationshipAuditLog"; import { RelationshipStatus } from "../transmission/RelationshipStatus"; -export interface IRelationshipAuditLogEntry { +export interface IRelationshipAuditLogEntry extends ISerializable { createdAt: ICoreDate; createdBy: ICoreAddress; createdByDevice: ICoreId; @@ -13,7 +13,7 @@ export interface IRelationshipAuditLogEntry { } @type("RelationshipAuditLogEntry") -export class RelationshipAuditLogEntry extends CoreSerializable implements IRelationshipAuditLogEntry { +export class RelationshipAuditLogEntry extends Serializable implements IRelationshipAuditLogEntry { @validate() @serialize() public createdAt: CoreDate; diff --git a/packages/transport/src/modules/relationships/local/SendRelationshipParameters.ts b/packages/transport/src/modules/relationships/local/SendRelationshipParameters.ts index 7ac9af12c..ad1085ba6 100644 --- a/packages/transport/src/modules/relationships/local/SendRelationshipParameters.ts +++ b/packages/transport/src/modules/relationships/local/SendRelationshipParameters.ts @@ -1,14 +1,13 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; import { IRelationshipTemplate, RelationshipTemplate } from "../../relationshipTemplates/local/RelationshipTemplate"; -export interface ISendRelationshipParameters extends ICoreSerializable { +export interface ISendRelationshipParameters extends ISerializable { creationContent: ISerializable; template: IRelationshipTemplate; } @type("SendRelationshipParameters") -export class SendRelationshipParameters extends CoreSerializable implements ISendRelationshipParameters { +export class SendRelationshipParameters extends Serializable implements ISendRelationshipParameters { @validate() @serialize() public creationContent: Serializable; diff --git a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts index 7d7c32d42..887cb0eb9 100644 --- a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts @@ -1,8 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreSerializable } from "@nmshd/core-types"; import { CryptoCipher, CryptoRelationshipPublicRequest, ICryptoCipher, ICryptoRelationshipPublicRequest } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationContentCipher extends ICoreSerializable { +export interface IRelationshipCreationContentCipher extends ISerializable { cipher: ICryptoCipher; publicCreationContentCrypto: ICryptoRelationshipPublicRequest; } diff --git a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentSigned.ts b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentSigned.ts index 8a8407f1c..747ec41df 100644 --- a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentSigned.ts +++ b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentSigned.ts @@ -1,15 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoSignature, ICryptoSignature } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationContentSigned extends ICoreSerializable { +export interface IRelationshipCreationContentSigned extends ISerializable { serializedCreationContent: string; deviceSignature: ICryptoSignature; relationshipSignature: ICryptoSignature; } @type("RelationshipCreationContentSigned") -export class RelationshipCreationContentSigned extends CoreSerializable implements IRelationshipCreationContentSigned { +export class RelationshipCreationContentSigned extends Serializable implements IRelationshipCreationContentSigned { @validate() @serialize() public serializedCreationContent: string; diff --git a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.ts b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.ts index 0250057f5..8d02425e5 100644 --- a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.ts +++ b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentWrapper.ts @@ -1,15 +1,15 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "../../../../core"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { Identity, IIdentity } from "../../../accounts/data/Identity"; -export interface IRelationshipCreationContentWrapper extends ICoreSerializable { +export interface IRelationshipCreationContentWrapper extends ISerializable { identity: IIdentity; content: ISerializable; templateId: ICoreId; } @type("RelationshipCreationContentWrapper") -export class RelationshipCreationContentWrapper extends CoreSerializable implements IRelationshipCreationContentWrapper { +export class RelationshipCreationContentWrapper extends Serializable implements IRelationshipCreationContentWrapper { @validate() @serialize() public identity: Identity; diff --git a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts index b7b6c5b4a..4c2ea8dc8 100644 --- a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts @@ -1,8 +1,8 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreSerializable } from "@nmshd/core-types"; import { CryptoCipher, CryptoRelationshipPublicResponse, ICryptoCipher, ICryptoRelationshipPublicResponse } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationResponseContentCipher extends ICoreSerializable { +export interface IRelationshipCreationResponseContentCipher extends ISerializable { cipher: ICryptoCipher; publicCreationResponseContentCrypto: ICryptoRelationshipPublicResponse; } diff --git a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.ts b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.ts index 75721bcad..39a28f42f 100644 --- a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.ts +++ b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentSigned.ts @@ -1,15 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoSignature, ICryptoSignature } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationResponseContentSigned extends ICoreSerializable { +export interface IRelationshipCreationResponseContentSigned extends ISerializable { serializedCreationResponseContent: string; deviceSignature: ICryptoSignature; relationshipSignature: ICryptoSignature; } @type("RelationshipCreationResponseContentSigned") -export class RelationshipCreationResponseContentSigned extends CoreSerializable implements IRelationshipCreationResponseContentSigned { +export class RelationshipCreationResponseContentSigned extends Serializable implements IRelationshipCreationResponseContentSigned { @validate() @serialize() public serializedCreationResponseContent: string; diff --git a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.ts b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.ts index f137a2eba..46fe30cfa 100644 --- a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.ts +++ b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentWrapper.ts @@ -1,12 +1,12 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "../../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; -export interface IRelationshipCreationResponseContentWrapper extends ICoreSerializable { +export interface IRelationshipCreationResponseContentWrapper extends ISerializable { relationshipId: ICoreId; } @type("RelationshipCreationResponseContentWrapper") -export class RelationshipCreationResponseContentWrapper extends CoreSerializable implements IRelationshipCreationResponseContentWrapper { +export class RelationshipCreationResponseContentWrapper extends Serializable implements IRelationshipCreationResponseContentWrapper { @validate() @serialize() public relationshipId: CoreId; diff --git a/packages/transport/src/modules/secrets/SecretController.ts b/packages/transport/src/modules/secrets/SecretController.ts index 0ca315c98..5c066ea91 100644 --- a/packages/transport/src/modules/secrets/SecretController.ts +++ b/packages/transport/src/modules/secrets/SecretController.ts @@ -1,5 +1,6 @@ import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoExchangeKeypair, @@ -11,7 +12,7 @@ import { CryptoSignatureKeypair, CryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreDate, CoreErrors, CoreId, TransportIds } from "../../core"; +import { CoreCrypto, CoreErrors, TransportIds } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; diff --git a/packages/transport/src/modules/secrets/data/SecretContainerCipher.ts b/packages/transport/src/modules/secrets/data/SecretContainerCipher.ts index c04b2fea7..a8774bd95 100644 --- a/packages/transport/src/modules/secrets/data/SecretContainerCipher.ts +++ b/packages/transport/src/modules/secrets/data/SecretContainerCipher.ts @@ -1,8 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoCipher, ICryptoCipher } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; import { CoreSynchronizable, ICoreSynchronizable } from "../../../core/CoreSynchronizable"; -import { CoreDate, ICoreDate } from "../../../core/types/CoreDate"; export interface ISecretContainerCipher extends ICoreSynchronizable { name: string; diff --git a/packages/transport/src/modules/secrets/data/SecretContainerPlain.ts b/packages/transport/src/modules/secrets/data/SecretContainerPlain.ts index 4acfd6961..c95d52852 100644 --- a/packages/transport/src/modules/secrets/data/SecretContainerPlain.ts +++ b/packages/transport/src/modules/secrets/data/SecretContainerPlain.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/no-inferrable-types */ -import { Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, CoreSerializable, ICoreDate, ICoreId, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; -export interface ISecretContainerPlain extends ICoreSerializable { +export interface ISecretContainerPlain extends ISerializable { id: ICoreId; name: string; description?: string; @@ -11,11 +11,11 @@ export interface ISecretContainerPlain extends ICoreSerializable { validFrom: ICoreDate; validTo?: ICoreDate; active: boolean; - secret: ICoreSerializable; + secret: ISerializable; } @type("SecretContainerPlain") -export class SecretContainerPlain extends CoreSerializable implements ISecretContainerPlain { +export class SecretContainerPlain extends Serializable implements ISecretContainerPlain { @serialize() @validate() public id: CoreId; diff --git a/packages/transport/src/modules/sync/DatawalletModificationMapper.ts b/packages/transport/src/modules/sync/DatawalletModificationMapper.ts index e03c2acf7..025b7e7f9 100644 --- a/packages/transport/src/modules/sync/DatawalletModificationMapper.ts +++ b/packages/transport/src/modules/sync/DatawalletModificationMapper.ts @@ -1,4 +1,5 @@ -import { CoreId, TransportError, TransportIds } from "../../core"; +import { CoreId } from "@nmshd/core-types"; +import { TransportError, TransportIds } from "../../core"; import { BackboneDatawalletModification } from "./backbone/BackboneDatawalletModification"; import { CreateDatawalletModificationsRequestItem } from "./backbone/CreateDatawalletModifications"; import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType } from "./local/DatawalletModification"; diff --git a/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts b/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts index cb46b9a80..46d7aef1a 100644 --- a/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts +++ b/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts @@ -1,8 +1,10 @@ import { IDatabaseCollectionProvider } from "@js-soft/docdb-access-abstractions"; import { ILogger } from "@js-soft/logging-abstractions"; +import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreId } from "@nmshd/core-types"; import _ from "lodash"; -import { CoreErrors, CoreId, CoreSerializable, TransportError, TransportIds } from "../../core"; +import { CoreErrors, TransportError, TransportIds } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ICacheable } from "../../core/ICacheable"; import { CachedIdentityDeletionProcess } from "../accounts/data/CachedIdentityDeletionProcess"; @@ -84,11 +86,11 @@ export class DatawalletModificationsProcessor { mergedPayload = { ...mergedPayload, ...create.payload }; } - const newObject = CoreSerializable.fromUnknown(mergedPayload); + const newObject = Serializable.fromUnknown(mergedPayload); const oldDoc = await targetCollection.read(objectIdentifier); if (oldDoc) { - const oldObject = CoreSerializable.fromUnknown(oldDoc); + const oldObject = Serializable.fromUnknown(oldDoc); const updatedObject = { ...oldObject.toJSON(), ...newObject.toJSON() }; await targetCollection.update(oldDoc, updatedObject); } else { @@ -128,7 +130,7 @@ export class DatawalletModificationsProcessor { throw new TransportError("Document to update was not found."); } - const oldObject = CoreSerializable.fromUnknown(oldDoc); + const oldObject = Serializable.fromUnknown(oldDoc); const newObject = { ...oldObject.toJSON(), ...updateModification.payload }; await targetCollection.update(oldDoc, newObject); diff --git a/packages/transport/src/modules/sync/SyncController.ts b/packages/transport/src/modules/sync/SyncController.ts index ea966443e..742f101e9 100644 --- a/packages/transport/src/modules/sync/SyncController.ts +++ b/packages/transport/src/modules/sync/SyncController.ts @@ -1,6 +1,7 @@ import { IDatabaseCollection, IDatabaseMap } from "@js-soft/docdb-access-abstractions"; import { log } from "@js-soft/ts-utils"; -import { ControllerName, CoreDate, CoreError, CoreErrors, CoreId, RequestError, TransportController, TransportError, TransportLoggerFactory } from "../../core"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { ControllerName, CoreError, CoreErrors, RequestError, TransportController, TransportError, TransportLoggerFactory } from "../../core"; import { DependencyOverrides } from "../../core/DependencyOverrides"; import { AccountController } from "../accounts/AccountController"; import { ChangedItems } from "./ChangedItems"; @@ -405,17 +406,9 @@ export class SyncController extends TransportController { } catch (e: any) { this.log.error("There was an error while trying to apply an external event: ", e); - let errorCode; - if (e.code) { - errorCode = e.code; - } else if (e.message) { - errorCode = e.message; - } else { - errorCode = JSON.stringify(e); - } results.push({ externalEventId: externalEvent.id, - errorCode: errorCode + errorCode: e instanceof CoreError ? e.code : "error.transport.unknown" }); } } diff --git a/packages/transport/src/modules/sync/SynchronizedCollection.ts b/packages/transport/src/modules/sync/SynchronizedCollection.ts index 4e5de0d4f..a63479887 100644 --- a/packages/transport/src/modules/sync/SynchronizedCollection.ts +++ b/packages/transport/src/modules/sync/SynchronizedCollection.ts @@ -1,8 +1,8 @@ import { DatabaseType, IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; +import { Serializable } from "@js-soft/ts-serval"; import jsonpatch from "fast-json-patch"; import _ from "lodash"; import { nameof } from "ts-simple-nameof"; -import { CoreSerializable } from "../../core/CoreSerializable"; import { CoreSynchronizable, ICoreSynchronizable } from "../../core/CoreSynchronizable"; import { ICacheable } from "../../core/ICacheable"; import { TransportIds } from "../../core/TransportIds"; @@ -83,7 +83,7 @@ export class SynchronizedCollection implements IDatabaseCollection { } public async update(oldDoc: any, newObject: CoreSynchronizable): Promise { - const oldObject = CoreSerializable.fromUnknown(oldDoc); + const oldObject = Serializable.fromUnknown(oldDoc); const newObjectJson = newObject.toJSON(); diff --git a/packages/transport/src/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.ts b/packages/transport/src/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.ts index 6f97ab91a..7e6a2cefb 100644 --- a/packages/transport/src/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.ts +++ b/packages/transport/src/modules/sync/externalEventProcessors/MessageReceivedExternalEventProcessor.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId } from "../../../core"; +import { CoreId } from "@nmshd/core-types"; import { MessageReceivedEvent } from "../../../events"; import { Message } from "../../messages/local/Message"; import { ExternalEvent } from "../data/ExternalEvent"; diff --git a/packages/transport/src/modules/sync/local/DatawalletModification.ts b/packages/transport/src/modules/sync/local/DatawalletModification.ts index 6cba51611..9d7dd9e7a 100644 --- a/packages/transport/src/modules/sync/local/DatawalletModification.ts +++ b/packages/transport/src/modules/sync/local/DatawalletModification.ts @@ -1,7 +1,7 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId, CoreSerializable, ICoreId } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; -export interface IDatawalletModification { +export interface IDatawalletModification extends ISerializable { localId: ICoreId; objectIdentifier: ICoreId; payloadCategory?: DatawalletModificationCategory; @@ -25,7 +25,7 @@ export enum DatawalletModificationCategory { } @type("DatawalletModification") -export class DatawalletModification extends CoreSerializable implements IDatawalletModification { +export class DatawalletModification extends Serializable implements IDatawalletModification { @validate() @serialize() public localId: CoreId; diff --git a/packages/transport/src/modules/tokens/AnonymousTokenController.ts b/packages/transport/src/modules/tokens/AnonymousTokenController.ts index 88ccff3ce..cefd20369 100644 --- a/packages/transport/src/modules/tokens/AnonymousTokenController.ts +++ b/packages/transport/src/modules/tokens/AnonymousTokenController.ts @@ -1,6 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreId, CoreSerializable, IConfig } from "../../core"; +import { CoreCrypto, CoreErrors, IConfig } from "../../core"; import { AnonymousTokenClient } from "./backbone/AnonymousTokenClient"; import { CachedToken } from "./local/CachedToken"; import { Token } from "./local/Token"; @@ -26,7 +27,7 @@ export class AnonymousTokenController { const cipher = CryptoCipher.fromBase64(response.content); const plaintextTokenBuffer = await CoreCrypto.decrypt(cipher, secretKey); - const plaintextTokenContent = CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); + const plaintextTokenContent = Serializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); if (!(plaintextTokenContent instanceof Serializable)) { throw CoreErrors.tokens.invalidTokenContent(id.toString()); diff --git a/packages/transport/src/modules/tokens/TokenController.ts b/packages/transport/src/modules/tokens/TokenController.ts index 84b19d0f1..234240cf3 100644 --- a/packages/transport/src/modules/tokens/TokenController.ts +++ b/packages/transport/src/modules/tokens/TokenController.ts @@ -1,7 +1,8 @@ import { ISerializable, Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreAddress, CoreCrypto, CoreDate, CoreErrors, CoreId, CoreSerializable, TransportError } from "../../core"; +import { CoreCrypto, CoreErrors, TransportError } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; @@ -164,7 +165,7 @@ export class TokenController extends TransportController { private async decryptToken(response: BackboneGetTokensResponse, secretKey: CryptoSecretKey) { const cipher = CryptoCipher.fromBase64(response.content); const plaintextTokenBuffer = await CoreCrypto.decrypt(cipher, secretKey); - const plaintextTokenContent = CoreSerializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); + const plaintextTokenContent = Serializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); if (!(plaintextTokenContent instanceof Serializable)) { throw CoreErrors.tokens.invalidTokenContent(response.id); diff --git a/packages/transport/src/modules/tokens/local/CachedToken.ts b/packages/transport/src/modules/tokens/local/CachedToken.ts index 90bf415f2..c44489f53 100644 --- a/packages/transport/src/modules/tokens/local/CachedToken.ts +++ b/packages/transport/src/modules/tokens/local/CachedToken.ts @@ -1,7 +1,7 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreId, CoreSerializable, ICoreAddress, ICoreDate, ICoreId, ICoreSerializable } from "../../../core"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; -export interface ICachedToken extends ICoreSerializable { +export interface ICachedToken extends ISerializable { createdBy: ICoreAddress; createdAt: ICoreDate; expiresAt: ICoreDate; @@ -10,7 +10,7 @@ export interface ICachedToken extends ICoreSerializable { } @type("CachedToken") -export class CachedToken extends CoreSerializable implements ICachedToken { +export class CachedToken extends Serializable implements ICachedToken { @validate() @serialize() public createdBy: CoreAddress; diff --git a/packages/transport/src/modules/tokens/local/SendTokenParameters.ts b/packages/transport/src/modules/tokens/local/SendTokenParameters.ts index 46221b80f..822f2f202 100644 --- a/packages/transport/src/modules/tokens/local/SendTokenParameters.ts +++ b/packages/transport/src/modules/tokens/local/SendTokenParameters.ts @@ -1,14 +1,14 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreSerializable, ICoreDate, ICoreSerializable } from "../../../core"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; -export interface ISendTokenParameters extends ICoreSerializable { +export interface ISendTokenParameters extends ISerializable { content: ISerializable; expiresAt: ICoreDate; ephemeral: boolean; } @type("SendTokenParameters") -export class SendTokenParameters extends CoreSerializable implements ISendTokenParameters { +export class SendTokenParameters extends Serializable implements ISendTokenParameters { @validate() @serialize() public content: Serializable; diff --git a/packages/transport/src/modules/tokens/local/Token.ts b/packages/transport/src/modules/tokens/local/Token.ts index 56e13887b..3ad820708 100644 --- a/packages/transport/src/modules/tokens/local/Token.ts +++ b/packages/transport/src/modules/tokens/local/Token.ts @@ -1,7 +1,8 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreSynchronizable, ICoreDate, ICoreSynchronizable } from "../../../core"; +import { CoreSynchronizable, ICoreSynchronizable } from "../../../core"; import { TokenReference } from "../transmission/TokenReference"; import { CachedToken, ICachedToken } from "./CachedToken"; diff --git a/packages/transport/src/modules/tokens/transmission/TokenContentDeviceSharedSecret.ts b/packages/transport/src/modules/tokens/transmission/TokenContentDeviceSharedSecret.ts index 0aeef2e7a..d12db4d1c 100644 --- a/packages/transport/src/modules/tokens/transmission/TokenContentDeviceSharedSecret.ts +++ b/packages/transport/src/modules/tokens/transmission/TokenContentDeviceSharedSecret.ts @@ -1,13 +1,12 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; import { DeviceSharedSecret } from "../../devices/transmission/DeviceSharedSecret"; -export interface ITokenContentDeviceSharedSecret extends ICoreSerializable { +export interface ITokenContentDeviceSharedSecret extends ISerializable { sharedSecret: DeviceSharedSecret; } @type("TokenContentDeviceSharedSecret") -export class TokenContentDeviceSharedSecret extends CoreSerializable implements ITokenContentDeviceSharedSecret { +export class TokenContentDeviceSharedSecret extends Serializable implements ITokenContentDeviceSharedSecret { @validate() @serialize() public sharedSecret: DeviceSharedSecret; diff --git a/packages/transport/src/modules/tokens/transmission/TokenContentFile.ts b/packages/transport/src/modules/tokens/transmission/TokenContentFile.ts index 8f1353134..4cc51467d 100644 --- a/packages/transport/src/modules/tokens/transmission/TokenContentFile.ts +++ b/packages/transport/src/modules/tokens/transmission/TokenContentFile.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; -import { CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "../../../core"; -export interface ITokenContentFile extends ICoreSerializable { +export interface ITokenContentFile extends ISerializable { fileId: ICoreId; secretKey: ICryptoSecretKey; } @type("TokenContentFile") -export class TokenContentFile extends CoreSerializable implements ITokenContentFile { +export class TokenContentFile extends Serializable implements ITokenContentFile { @validate() @serialize() public fileId: CoreId; diff --git a/packages/transport/src/modules/tokens/transmission/TokenContentRelationshipTemplate.ts b/packages/transport/src/modules/tokens/transmission/TokenContentRelationshipTemplate.ts index e24ead027..1b05d93d0 100644 --- a/packages/transport/src/modules/tokens/transmission/TokenContentRelationshipTemplate.ts +++ b/packages/transport/src/modules/tokens/transmission/TokenContentRelationshipTemplate.ts @@ -1,14 +1,14 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreId, ICoreId } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; -import { CoreId, CoreSerializable, ICoreId, ICoreSerializable } from "../../../core"; -export interface ITokenContentRelationshipTemplate extends ICoreSerializable { +export interface ITokenContentRelationshipTemplate extends ISerializable { templateId: ICoreId; secretKey: ICryptoSecretKey; } @type("TokenContentRelationshipTemplate") -export class TokenContentRelationshipTemplate extends CoreSerializable implements ITokenContentRelationshipTemplate { +export class TokenContentRelationshipTemplate extends Serializable implements ITokenContentRelationshipTemplate { @validate() @serialize() public templateId: CoreId; diff --git a/packages/transport/src/util/PasswordGenerator.ts b/packages/transport/src/util/PasswordGenerator.ts deleted file mode 100644 index 47ad5436a..000000000 --- a/packages/transport/src/util/PasswordGenerator.ts +++ /dev/null @@ -1,181 +0,0 @@ -import { TransportError } from "../core/TransportError"; -import { Random, RandomCharacterRange } from "./Random"; - -const defaultPasswordRange = RandomCharacterRange.AlphanumericEase + RandomCharacterRange.SpecialCharacters; - -export interface IPasswordGenerator {} - -export interface IPasswordGeneratorStatic { - readonly elementsGerman: string[]; - readonly unitsGerman: string[]; - new (): IPasswordGenerator; - createPassword(minLength: number, allowedCharacters?: string | string[], maxLength?: number): Promise; - createUnitPassword(): Promise; - createElementPassword(): Promise; -} - -export class PasswordGenerator implements IPasswordGenerator { - public static readonly elementsGerman: string[] = [ - "Wasserstoff", - "Helium", - "Lithium", - "Beryllium", - "Bor", - "Kohlenstoff", - "Stickstoff", - "Sauerstoff", - "Fluor", - "Neon", - "Natrium", - "Magnesium", - "Aluminium", - "Silicium", - "Phosphor", - "Schwefel", - "Chlor", - "Argon", - "Kalium", - "Calcium", - "Scandium", - "Titan", - "Vanadium", - "Chrom", - "Mangan", - "Eisen", - "Cobalt", - "Nickel", - "Kupfer", - "Zink" - ]; - - public static readonly unitsGerman: string[] = [ - "Kelvin", - "Mol", - "Candela", - "Mikrosekunden", - "Nanosekunden", - "Millisekunden", - "Sekunden", - "Minuten", - "Stunden", - "Tage", - "Wochen", - "Monate", - "Jahre", - "Seemeilen", - "Astronomische Einheiten", - "Parsecs", - "Lichtjahre", - "Millimeter", - "Zentimeter", - "Meter", - "Kilometer", - "Quadratmeter", - "Ar", - "Hektar", - "Milliliter", - "Zentiliter", - "Liter", - "Kubikmeter", - "Barrel", - "Gramm", - "Kilogramm", - "Tonnen", - "Pfund", - "Zentner", - "Knoten", - "Newton", - "Pascal", - "Bar", - "Joule", - "Kilojoule", - "Megajoule", - "Wattstunden", - "Kilowattstunden", - "Megawattstunden", - "Kalorien", - "Kilokalorien", - "Elektronenvolt", - "Watt", - "Kilowatt", - "Megawatt", - "Voltampere", - "Ampere", - "Milliampere", - "Ohm", - "Siemens", - "Coulomb", - "Amperestunde", - "Milliamperestunde", - "Farad", - "Kelvin", - "Grad Celsius", - "Lumen", - "Lux", - "Bit", - "Byte", - "Kilobyte", - "Megabyte", - "Gigabyte", - "Terabyte", - "Etabyte" - ]; - - public static async createPassword(minLength: number, maxLength = 0, allowedCharacters: string | string[] = defaultPasswordRange): Promise { - if (maxLength <= 0) { - maxLength = minLength; - } - return await Random.stringRandomLength(minLength, maxLength, allowedCharacters); - } - - /** - * Creates a "strong" password out of a scramble of the following character sets: - * - * - 1 special character out of RandomCharacterRange.SpecialCharacters - * - 1 lowercase character out of RandomCharacterRange.LowerCaseEase - * - 1 uppercase character out of RandomCharacterRange.UpperCaseEase - * - 1 number out of RandomCharacterRange.DigitEase - * - A random number of characters (between minLength and maxLength) out of PasswordRange.Default - * - */ - public static async createStrongPassword(minLength = 8, maxLength = 12): Promise { - if (minLength > maxLength) maxLength = minLength; - if (minLength < 8) { - throw new TransportError("Minimum password length for a strong password should be 8 characters."); - } - - const specialCharacterBucket = { - minLength: 1, - maxLength: 1, - allowedChars: RandomCharacterRange.SpecialCharacters - }; - const lowercaseBucket = { minLength: 1, maxLength: 1, allowedChars: RandomCharacterRange.LowerCaseEase }; - const uppercaseBucket = { minLength: 1, maxLength: 1, allowedChars: RandomCharacterRange.UpperCaseEase }; - const numberBucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; - const alphanumericBucket = { - minLength: minLength - 4, - maxLength: maxLength - 4, - allowedChars: defaultPasswordRange - }; - const password = await Random.stringWithBuckets([specialCharacterBucket, lowercaseBucket, uppercaseBucket, numberBucket, alphanumericBucket]); - return await Random.scramble(password); - } - - public static async createUnitPassword(): Promise { - const number1Bucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; - const number2Bucket = { minLength: 0, maxLength: 2, allowedChars: "0123456789" }; - const commaBucket = { minLength: 0, maxLength: 1, allowedChars: "," }; - const number3Bucket = { minLength: 0, maxLength: 1, allowedChars: "0123456789" }; - const number4Bucket = { minLength: 1, maxLength: 1, allowedChars: "123456789" }; - const randomMetric = await Random.stringWithBuckets([number1Bucket, number2Bucket, commaBucket, number3Bucket, number4Bucket]); - const unit = await this.createPassword(1, 0, this.unitsGerman); - - return `${randomMetric} ${unit}`; - } - - public static async createElementPassword(): Promise { - const element = await this.createPassword(1, 0, this.elementsGerman); - const number = await this.createPassword(1, 0, RandomCharacterRange.Digit); - return `${element} ${number}`; - } -} diff --git a/packages/transport/src/util/Random.ts b/packages/transport/src/util/Random.ts deleted file mode 100644 index 9290ac270..000000000 --- a/packages/transport/src/util/Random.ts +++ /dev/null @@ -1,158 +0,0 @@ -import { CryptoRandom, ICoreBuffer } from "@nmshd/crypto"; -import { v4 as uuidv4 } from "uuid"; -import { TransportError } from "../core/TransportError"; - -export enum RandomCharacterRange { - Digit = "0123456789", - DigitEase = "123456789", - Hex = "0123456789ABCDEF", - LowerCase = "abcdefghijklmnopqrstuvwxyz", - LowerCaseEase = "abcdefghijkmnpqrstuvwxyz", - UpperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - UpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ", - Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - Alphanumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", - // Without I, l, O, o, 0 - AlphanumericEase = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz123456789", - AlphanumericUpperCaseEase = "ABCDEFGHJKLMNPQRSTUVWXYZ0123456789", - GermanUmlaut = "ÄÖÜäöü", - SpecialCharacters = "!?-_.:,;#+" -} - -export interface RandomCharacterBucket { - minLength: number; - maxLength: number; - allowedChars: string | string[]; -} - -export interface IRandom {} - -export interface IRandomStatic { - new (): IRandom; - bytes(length: number): Promise; - int(length: number): Promise; - array(length: number): Promise; - uuid(): Promise; - scramble(input: string): Promise; - intBetween(min: number, max: number): Promise; - intRandomLength(minLength: number, maxLength: number): Promise; - scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise; - stringWithBuckets(buckets: RandomCharacterBucket[]): Promise; - string(length: number, allowedChars?: string | string[]): Promise; - stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise; -} - -export class Random implements IRandom { - public static async bytes(length: number): Promise { - return await CryptoRandom.bytes(length); - } - public static async int(length: number): Promise { - if (length > 21 || length <= 0) { - throw new TransportError("Length must be between 1 and 21."); - } - return parseInt(await this.string(length, RandomCharacterRange.Digit)); - } - public static async array(length: number): Promise { - return (await CryptoRandom.bytes(length)).toArray(); - } - - public static uuid(): string { - return uuidv4(); - } - - public static async scramble(input: string): Promise { - const out = []; - const inar = input.split(""); - const length = input.length; - for (let i = 0; i < length - 1; i++) { - const charAt = await Random.intBetween(0, length - 1 - i); - out.push(inar.splice(charAt, 1)[0]); - } - out.push(inar[0]); - return out.join(""); - } - - public static async intBetween(min: number, max: number): Promise { - if (max <= min) { - throw new TransportError("Max must be larger than min."); - } - const diff = max - min + 1; - const bitLength = Math.abs(Math.ceil(Math.log2(diff))); - if (bitLength > 32) { - throw new TransportError("The range between the numbers is too big, 32 bit is the maximum -> 4294967296"); - } - const byteLength = Math.ceil(bitLength / 8); - const bitMask = Math.pow(2, bitLength) - 1; - const randomArray = await this.bytes(byteLength); - - let value = 0; - let p = (byteLength - 1) * 8; - for (let i = 0; i < byteLength; i++) { - value += randomArray.buffer[i] * Math.pow(2, p); - p -= 8; - } - value = value & bitMask; - if (value >= diff) { - return await this.intBetween(min, max); - } - return min + value; - } - - public static async intRandomLength(minLength: number, maxLength: number): Promise { - if (maxLength > 21) { - throw new TransportError("Max must be below 22."); - } - return parseInt(await this.stringRandomLength(minLength, maxLength, RandomCharacterRange.Digit)); - } - - public static async scrambleWithBuckets(buckets: RandomCharacterBucket[]): Promise { - const str = await this.stringWithBuckets(buckets); - return await this.scramble(str); - } - - public static async stringWithBuckets(buckets: RandomCharacterBucket[]): Promise { - const str = []; - for (const bucket of buckets) { - str.push(await this.stringRandomLength(bucket.minLength, bucket.maxLength, bucket.allowedChars)); - } - return str.join(""); - } - - public static async string(length: number, allowedChars: string | string[] = RandomCharacterRange.Alphanumeric): Promise { - if (length <= 0) return ""; - if (allowedChars.length > 256) { - throw new TransportError("Input exceeds maximum length of 256."); - } - const ar = []; - const inputLength = allowedChars.length; - const random = await this.array(length + 10); - const max = 255 - (255 % inputLength); - for (let i = 0; i < length; i++) { - const nmb = random[i]; - if (nmb > max) { - // Reject random value to remove bias if we are at the - // upper (and incomplete end) of possible random values - continue; - } - ar.push(allowedChars[nmb % inputLength]); - } - let retStr = ar.join(""); - if (retStr.length < length) { - retStr += await this.string(length - retStr.length, allowedChars); - } - return retStr; - } - - public static async stringRandomLength(minLength: number, maxLength: number, allowedChars?: string | string[]): Promise { - if (minLength > maxLength) { - throw new TransportError("maxLength must be larger than minLength."); - } - - if (minLength < 0) { - throw new TransportError("minlength must not be less than zero."); - } - - const length = maxLength > minLength ? await this.intBetween(minLength, maxLength) : maxLength; - return await this.string(length, allowedChars); - } -} diff --git a/packages/transport/src/util/index.ts b/packages/transport/src/util/index.ts deleted file mode 100644 index 41ee05dab..000000000 --- a/packages/transport/src/util/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./PasswordGenerator"; -export * from "./Random"; From 6b3eeaa1ac58f19f0dca0b0811c65c05e3c7bc0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:15:22 +0200 Subject: [PATCH 03/16] refactor: update tests --- packages/app-runtime/test/lib/TestUtil.ts | 3 +- packages/consumption/test/core/TestUtil.ts | 4 +- .../AttributeListenersController.test.ts | 3 +- .../attributes/AttributesController.test.ts | 3 +- .../LocalAttributeDeletionInfo.test.ts | 3 +- .../notifications/NotificationEnd2End.test.ts | 3 +- .../NotificationsController.test.ts | 3 +- ...edByOwnerNotificationItemProcessor.test.ts | 3 +- ...tedByPeerNotificationItemProcessor.test.ts | 3 +- ...tedByPeerNotificationItemProcessor.test.ts | 3 +- ...SucceededNotificationItemProcessor.test.ts | 3 +- .../local/LocalNotification.test.ts | 2 +- .../DecideRequestParametersValidator.test.ts | 2 +- .../GenericRequestItemProcessor.test.ts | 3 +- .../IncomingRequestsController.test.ts | 3 +- .../OutgoingRequestsController.test.ts | 3 +- .../modules/requests/RequestEnd2End.test.ts | 3 +- .../RequestItemProcessorRegistry.test.ts | 3 +- .../requests/RequestsIntegrationTest.ts | 15 +- .../itemProcessors/createAttribute/Context.ts | 3 +- ...reateAttributeRequestItemProcessor.test.ts | 3 +- .../createAttribute/TestIdentity.ts | 2 +- ...eleteAttributeRequestItemProcessor.test.ts | 3 +- ...oposeAttributeRequestItemProcessor.test.ts | 3 +- .../ReadAttributeRequestItemProcessor.test.ts | 3 +- ...ributeListenerRequestItemProcessor.test.ts | 3 +- ...ShareAttributeRequestItemProcessor.test.ts | 3 +- .../validateAttributeMatchesWithQuery.test.ts | 3 +- .../requests/local/LocalRequest.test.ts | 2 +- .../requests/testHelpers/TestObjectFactory.ts | 5 +- .../test/attributes/IdentityAttribute.test.ts | 2 +- .../attributes/RelationshipAttribute.test.ts | 2 +- .../test/notifications/Notification.test.ts | 2 +- .../content/test/requests/Request.test.ts | 2 +- .../content/test/requests/Response.test.ts | 2 +- .../test/requests/ResponseWrapper.test.ts | 2 +- .../items/ProposeAttributeRequestItem.test.ts | 2 +- .../test/consumption/attributes.test.ts | 2 +- .../test/consumption/notifications.test.ts | 3 +- .../runtime/test/consumption/requests.test.ts | 2 +- .../runtime/test/consumption/settings.test.ts | 3 +- .../DraftIdentityAttributeDVO.test.ts | 2 +- .../runtime/test/dataViews/MessageDVO.test.ts | 2 +- .../test/dataViews/RelationshipDVO.test.ts | 2 +- .../dataViews/RelationshipTemplateDVO.test.ts | 2 +- .../DeleteAttributeRequestItemDVO.test.ts | 2 +- .../ProposeAttributeRequestItemDVO.test.ts | 2 +- .../ReadAttributeRequestItemDVO.test.ts | 2 +- .../ShareAttributeRequestItemDVO.test.ts | 2 +- packages/runtime/test/lib/TestRuntime.ts | 3 +- packages/runtime/test/lib/testUtils.ts | 3 +- .../test/misc/DatabaseSchemaUpgrader.test.ts | 3 +- .../modules/AttributeListenerModule.test.ts | 3 +- .../test/modules/DeciderModule.test.ts | 2 +- .../test/modules/RequestModule.test.ts | 2 +- .../runtime/test/transport/account.test.ts | 2 +- packages/runtime/test/transport/files.test.ts | 2 +- .../transport/identityDeletionProcess.test.ts | 3 +- .../runtime/test/transport/messages.test.ts | 2 +- .../runtime/test/transport/tokens.test.ts | 2 +- .../test/core/backbone/Authentication.test.ts | 3 +- .../transport/test/end2end/End2End.test.ts | 3 +- .../transport/test/modules/TimeSync.test.ts | 3 +- .../IdentityDeletionProcessController.test.ts | 4 +- .../certificates/CertificateIssuer.test.ts | 3 +- .../modules/challenges/Challenges.test.ts | 3 +- .../modules/devices/DeviceOnboarding.test.ts | 5 +- .../test/modules/files/FileController.test.ts | 3 +- .../test/modules/files/FileReference.test.ts | 3 +- .../modules/messages/MessageContent.test.ts | 3 +- .../messages/MessageController.test.ts | 3 +- .../RelationshipTemplateController.test.ts | 3 +- .../RelationshipTemplateReference.test.ts | 3 +- .../RelationshipsController.test.ts | 3 +- .../relationships/TerminateDecompose.test.ts | 3 +- .../relationships/decomposition.test.ts | 3 +- .../modules/sync/SyncController.error.test.ts | 2 +- .../modules/sync/SyncController.files.test.ts | 2 +- .../sync/SyncController.relationships.test.ts | 3 +- .../test/modules/sync/SyncController.test.ts | 3 +- .../sync/SyncController.tokens.test.ts | 2 +- .../sync/SynchronizedCollection.test.ts | 3 +- .../test/modules/tokens/TokenContent.test.ts | 12 +- .../modules/tokens/TokenController.test.ts | 3 +- .../modules/tokens/TokenReference.test.ts | 3 +- .../performance/PerformanceTemplates.test.ts | 3 +- .../ACacheableSynchronizedCollectionItem.ts | 7 +- .../ASynchronizedCollectionItem.ts | 6 +- .../test/testHelpers/AdminApiClient.ts | 3 +- .../test/testHelpers/FakeSyncClient.ts | 3 +- .../transport/test/testHelpers/TestUtil.ts | 4 +- packages/transport/test/tsconfig.json | 2 +- packages/transport/test/utils/Date.test.ts | 76 --------- .../test/utils/PasswordGenerator.test.ts | 65 -------- packages/transport/test/utils/Random.test.ts | 150 ------------------ 95 files changed, 151 insertions(+), 420 deletions(-) delete mode 100644 packages/transport/test/utils/Date.test.ts delete mode 100644 packages/transport/test/utils/PasswordGenerator.test.ts delete mode 100644 packages/transport/test/utils/Random.test.ts diff --git a/packages/app-runtime/test/lib/TestUtil.ts b/packages/app-runtime/test/lib/TestUtil.ts index 14161b4f1..46447d19f 100644 --- a/packages/app-runtime/test/lib/TestUtil.ts +++ b/packages/app-runtime/test/lib/TestUtil.ts @@ -3,6 +3,7 @@ import { ILoggerFactory } from "@js-soft/logging-abstractions"; import { SimpleLoggerFactory } from "@js-soft/simple-logger"; import { Result, sleep, SubscriptionTarget } from "@js-soft/ts-utils"; import { ArbitraryMessageContent, ArbitraryRelationshipCreationContent, ArbitraryRelationshipTemplateContent } from "@nmshd/content"; +import { CoreDate } from "@nmshd/core-types"; import { FileDTO, MessageContentDerivation, @@ -13,7 +14,7 @@ import { RelationshipTemplateDTO, SyncEverythingResponse } from "@nmshd/runtime"; -import { CoreDate, IConfigOverwrite, TransportLoggerFactory } from "@nmshd/transport"; +import { IConfigOverwrite, TransportLoggerFactory } from "@nmshd/transport"; import { LogLevel } from "typescript-logging"; import { AppConfig, AppRuntime, LocalAccountDTO, LocalAccountSession, createAppConfig as runtime_createAppConfig } from "../../src"; import { NativeBootstrapperMock } from "../mocks/NativeBootstrapperMock"; diff --git a/packages/consumption/test/core/TestUtil.ts b/packages/consumption/test/core/TestUtil.ts index 20a93a6dd..9a56ebd29 100644 --- a/packages/consumption/test/core/TestUtil.ts +++ b/packages/consumption/test/core/TestUtil.ts @@ -7,13 +7,11 @@ import { NodeLoggerFactory } from "@js-soft/node-logger"; import { SimpleLoggerFactory } from "@js-soft/simple-logger"; import { ISerializable, Serializable } from "@js-soft/ts-serval"; import { EventBus, EventEmitter2EventBus, sleep } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; import { AccountController, ChangedItems, - CoreAddress, - CoreDate, - CoreId, File, IConfigOverwrite, ISendFileParameters, diff --git a/packages/consumption/test/modules/attributeListeners/AttributeListenersController.test.ts b/packages/consumption/test/modules/attributeListeners/AttributeListenersController.test.ts index 130438872..9a736e053 100644 --- a/packages/consumption/test/modules/attributeListeners/AttributeListenersController.test.ts +++ b/packages/consumption/test/modules/attributeListeners/AttributeListenersController.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { AccountController, CoreAddress, Transport } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AttributeListenerCreatedEvent, ConsumptionController } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; import { MockEventBus } from "../MockEventBus"; diff --git a/packages/consumption/test/modules/attributes/AttributesController.test.ts b/packages/consumption/test/modules/attributes/AttributesController.test.ts index 08eb9cebf..237ef0034 100644 --- a/packages/consumption/test/modules/attributes/AttributesController.test.ts +++ b/packages/consumption/test/modules/attributes/AttributesController.test.ts @@ -18,7 +18,8 @@ import { ThirdPartyRelationshipAttributeQueryOwner, ZipCode } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AttributeCreatedEvent, AttributeDeletedEvent, diff --git a/packages/consumption/test/modules/attributes/LocalAttributeDeletionInfo.test.ts b/packages/consumption/test/modules/attributes/LocalAttributeDeletionInfo.test.ts index 10203f95a..f097364c6 100644 --- a/packages/consumption/test/modules/attributes/LocalAttributeDeletionInfo.test.ts +++ b/packages/consumption/test/modules/attributes/LocalAttributeDeletionInfo.test.ts @@ -1,7 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { ValidationError } from "@js-soft/ts-serval"; import { EMailAddress, IdentityAttribute, ProprietaryEMailAddress, RelationshipAttribute, RelationshipAttributeConfidentiality } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, LocalAttribute, LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; diff --git a/packages/consumption/test/modules/notifications/NotificationEnd2End.test.ts b/packages/consumption/test/modules/notifications/NotificationEnd2End.test.ts index 060dbf1ff..df9004383 100644 --- a/packages/consumption/test/modules/notifications/NotificationEnd2End.test.ts +++ b/packages/consumption/test/modules/notifications/NotificationEnd2End.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { Notification } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Message, SynchronizedCollection, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Message, SynchronizedCollection, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, LocalNotification, LocalNotificationSource, LocalNotificationStatus } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; import { TestNotificationItem, TestNotificationItemProcessor } from "./testHelpers/TestNotificationItem"; diff --git a/packages/consumption/test/modules/notifications/NotificationsController.test.ts b/packages/consumption/test/modules/notifications/NotificationsController.test.ts index c98d1aa23..fe1a623cf 100644 --- a/packages/consumption/test/modules/notifications/NotificationsController.test.ts +++ b/packages/consumption/test/modules/notifications/NotificationsController.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { Notification } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, SynchronizedCollection, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, SynchronizedCollection, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, LocalNotification, LocalNotificationSource, LocalNotificationStatus } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; import { TestNotificationItem, TestNotificationItemProcessor } from "./testHelpers/TestNotificationItem"; diff --git a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.test.ts b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.test.ts index 366d4f00f..1dd3fad6a 100644 --- a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.test.ts +++ b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IdentityAttribute, Notification, OwnSharedAttributeDeletedByOwnerNotificationItem, RelationshipAttribute, RelationshipAttributeConfidentiality } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, LocalAttributeDeletionStatus, diff --git a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.test.ts b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.test.ts index e49f41bc3..76b0f64f7 100644 --- a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.test.ts +++ b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IdentityAttribute, Notification, PeerSharedAttributeDeletedByPeerNotificationItem, RelationshipAttribute, RelationshipAttributeConfidentiality } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, IAttributeSuccessorParams, diff --git a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.test.ts b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.test.ts index cb29182c7..757b2eb4b 100644 --- a/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.test.ts +++ b/packages/consumption/test/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { Notification, RelationshipAttribute, RelationshipAttributeConfidentiality, ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, LocalAttributeDeletionStatus, diff --git a/packages/consumption/test/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.test.ts b/packages/consumption/test/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.test.ts index 2ae8e67c8..6f3606c67 100644 --- a/packages/consumption/test/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.test.ts +++ b/packages/consumption/test/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IdentityAttribute, Notification, PeerSharedAttributeSucceededNotificationItem, RelationshipAttribute, RelationshipAttributeConfidentiality } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, LocalNotification, diff --git a/packages/consumption/test/modules/notifications/local/LocalNotification.test.ts b/packages/consumption/test/modules/notifications/local/LocalNotification.test.ts index 1afae3dd7..1904f8e87 100644 --- a/packages/consumption/test/modules/notifications/local/LocalNotification.test.ts +++ b/packages/consumption/test/modules/notifications/local/LocalNotification.test.ts @@ -1,5 +1,5 @@ import { Notification } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { LocalNotification, LocalNotificationSource, LocalNotificationStatus } from "../../../../src"; import { TestNotificationItem } from "../testHelpers/TestNotificationItem"; diff --git a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts index be794a482..b1935407d 100644 --- a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts +++ b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts @@ -1,5 +1,5 @@ import { Request, RequestItemGroup } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { DecideRequestItemGroupParametersJSON, DecideRequestItemParametersJSON, diff --git a/packages/consumption/test/modules/requests/GenericRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/GenericRequestItemProcessor.test.ts index 68d526534..2f633828e 100644 --- a/packages/consumption/test/modules/requests/GenericRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/GenericRequestItemProcessor.test.ts @@ -1,5 +1,6 @@ import { AcceptResponseItem, RejectResponseItem, ResponseItemResult } from "@nmshd/content"; -import { AccountController, CoreAddress, IdentityController } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController, IdentityController } from "@nmshd/transport"; import { ConsumptionController, GenericRequestItemProcessor } from "../../../src"; import { TestRequestItem } from "./testHelpers/TestRequestItem"; diff --git a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts index e220d8b38..b1cb0ecba 100644 --- a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts +++ b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IRequest, IRequestItemGroup, Request, RequestItemGroup, ResponseItem, ResponseItemGroup, ResponseItemResult } from "@nmshd/content"; -import { CoreDate, CoreId, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionIds, DecideRequestItemGroupParametersJSON, diff --git a/packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts b/packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts index 8804727c8..b80819b00 100644 --- a/packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts +++ b/packages/consumption/test/modules/requests/OutgoingRequestsController.test.ts @@ -11,7 +11,8 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionIds, ErrorValidationResult, diff --git a/packages/consumption/test/modules/requests/RequestEnd2End.test.ts b/packages/consumption/test/modules/requests/RequestEnd2End.test.ts index 1f2b3ca72..9f7036446 100644 --- a/packages/consumption/test/modules/requests/RequestEnd2End.test.ts +++ b/packages/consumption/test/modules/requests/RequestEnd2End.test.ts @@ -1,7 +1,8 @@ /* eslint-disable jest/expect-expect */ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { AcceptResponseItem, RelationshipCreationContent, RelationshipTemplateContent, Request, Response, ResponseWrapper } from "@nmshd/content"; -import { AccountController, CoreDate, Message, Relationship, RelationshipTemplate, Transport } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, Message, Relationship, RelationshipTemplate, Transport } from "@nmshd/transport"; import { ConsumptionController, LocalRequest, LocalRequestStatus } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; import { TestRequestItem } from "./testHelpers/TestRequestItem"; diff --git a/packages/consumption/test/modules/requests/RequestItemProcessorRegistry.test.ts b/packages/consumption/test/modules/requests/RequestItemProcessorRegistry.test.ts index bc05de3da..caf87fa9f 100644 --- a/packages/consumption/test/modules/requests/RequestItemProcessorRegistry.test.ts +++ b/packages/consumption/test/modules/requests/RequestItemProcessorRegistry.test.ts @@ -1,5 +1,6 @@ import { AcceptResponseItem, IRequestItem, RejectResponseItem, RequestItem } from "@nmshd/content"; -import { AccountController, CoreAddress, IdentityController } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { AccountController, IdentityController } from "@nmshd/transport"; import { ConsumptionController, GenericRequestItemProcessor, RequestItemProcessorRegistry } from "../../../src"; import { TestUtil } from "../../core/TestUtil"; import { TestRequestItem } from "./testHelpers/TestRequestItem"; diff --git a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts index 58bd4332e..8fbf85c74 100644 --- a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts +++ b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts @@ -14,19 +14,8 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { - CoreAddress, - CoreId, - IConfigOverwrite, - ICoreId, - IMessage, - IRelationshipTemplate, - Message, - Relationship, - RelationshipTemplate, - SynchronizedCollection, - Transport -} from "@nmshd/transport"; +import { CoreAddress, CoreId, ICoreId } from "@nmshd/core-types"; +import { IConfigOverwrite, IMessage, IRelationshipTemplate, Message, Relationship, RelationshipTemplate, SynchronizedCollection, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts index 081ef22fa..56a03e241 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/Context.ts @@ -1,6 +1,7 @@ /* eslint-disable jest/no-standalone-expect */ import { CreateAttributeAcceptResponseItem, CreateAttributeRequestItem, ResponseItemResult } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, CreateAttributeRequestItemProcessor, LocalAttribute, ValidationResult } from "../../../../../src"; import { TestUtil } from "../../../../core/TestUtil"; import { TestObjectFactory } from "../../testHelpers/TestObjectFactory"; diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts index b4e00b8dd..5b77126b8 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { CoreAddress, Transport } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { Transport } from "@nmshd/transport"; import { TestUtil } from "../../../../core/TestUtil"; import { TestObjectFactory } from "../../testHelpers/TestObjectFactory"; import { Context, GivenSteps, ThenSteps, WhenSteps } from "./Context"; diff --git a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts index dadb5427b..5c73f9fc4 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/createAttribute/TestIdentity.ts @@ -1,4 +1,4 @@ -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; export class TestIdentity { public static readonly SENDER = CoreAddress.from("{{Sender}}"); diff --git a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts index 399ed50c7..d1c982aaf 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts @@ -10,7 +10,8 @@ import { Request, ResponseItemResult } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AcceptDeleteAttributeRequestItemParametersJSON, ConsumptionController, diff --git a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts index 45be8a624..eeb752c07 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts @@ -14,7 +14,8 @@ import { Request, ResponseItemResult } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AcceptProposeAttributeRequestItemParametersWithExistingAttributeJSON, AcceptProposeAttributeRequestItemParametersWithNewAttributeJSON, diff --git a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts index aa4c2efbf..98d73c6a1 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts @@ -16,7 +16,8 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryOwner } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AcceptReadAttributeRequestItemParametersWithExistingAttributeJSON, AcceptReadAttributeRequestItemParametersWithNewAttributeJSON, diff --git a/packages/consumption/test/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.test.ts index 5d1931937..e8be0e344 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/registerAttributeListener/RegisterAttributeListenerRequestItemProcessor.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { RegisterAttributeListenerRequestItem, Request, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, LocalRequest, LocalRequestStatus, RegisterAttributeListenerRequestItemProcessor } from "../../../../../src"; import { TestUtil } from "../../../../core/TestUtil"; diff --git a/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts index b76e1bb55..f55dca576 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.test.ts @@ -13,7 +13,8 @@ import { ShareAttributeRequestItem, Surname } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, diff --git a/packages/consumption/test/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.test.ts b/packages/consumption/test/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.test.ts index d00eaaebf..7060ec975 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.test.ts @@ -11,7 +11,8 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryOwner } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { AcceptReadAttributeRequestItemParametersWithExistingAttributeJSON, AcceptReadAttributeRequestItemParametersWithNewAttributeJSON, diff --git a/packages/consumption/test/modules/requests/local/LocalRequest.test.ts b/packages/consumption/test/modules/requests/local/LocalRequest.test.ts index 87f62dca2..866efa96a 100644 --- a/packages/consumption/test/modules/requests/local/LocalRequest.test.ts +++ b/packages/consumption/test/modules/requests/local/LocalRequest.test.ts @@ -1,5 +1,5 @@ import { ResponseItem } from "@nmshd/content"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { LocalRequest, LocalRequestStatus, LocalRequestStatusLogEntry, LocalResponse } from "../../../../src"; import { TestObjectFactory } from "../testHelpers/TestObjectFactory"; import { TestRequestItem } from "../testHelpers/TestRequestItem"; diff --git a/packages/consumption/test/modules/requests/testHelpers/TestObjectFactory.ts b/packages/consumption/test/modules/requests/testHelpers/TestObjectFactory.ts index 98ce3b9ea..547f95f06 100644 --- a/packages/consumption/test/modules/requests/testHelpers/TestObjectFactory.ts +++ b/packages/consumption/test/modules/requests/testHelpers/TestObjectFactory.ts @@ -17,13 +17,10 @@ import { ResponseJSON, ResponseResult } from "@nmshd/content"; +import { CoreAddress, CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoEncryptionAlgorithm, CryptoExchangeAlgorithm, CryptoSecretKey, CryptoSignatureAlgorithm, CryptoSignaturePublicKey } from "@nmshd/crypto"; import { CachedRelationship, - CoreAddress, - CoreDate, - CoreId, - ICoreId, Identity, IMessage, IRelationship, diff --git a/packages/content/test/attributes/IdentityAttribute.test.ts b/packages/content/test/attributes/IdentityAttribute.test.ts index 132316205..420c13734 100644 --- a/packages/content/test/attributes/IdentityAttribute.test.ts +++ b/packages/content/test/attributes/IdentityAttribute.test.ts @@ -1,4 +1,4 @@ -import { CoreAddress, CoreDate } from "@nmshd/transport"; +import { CoreAddress, CoreDate } from "@nmshd/core-types"; import { Affiliation, AffiliationOrganization, diff --git a/packages/content/test/attributes/RelationshipAttribute.test.ts b/packages/content/test/attributes/RelationshipAttribute.test.ts index 8d9fd824f..572c9d57f 100644 --- a/packages/content/test/attributes/RelationshipAttribute.test.ts +++ b/packages/content/test/attributes/RelationshipAttribute.test.ts @@ -1,4 +1,4 @@ -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { ProprietaryURL, RelationshipAttribute, RelationshipAttributeConfidentiality } from "../../src"; describe("RelationshipAttribute", function () { diff --git a/packages/content/test/notifications/Notification.test.ts b/packages/content/test/notifications/Notification.test.ts index a0b896142..50b9e3208 100644 --- a/packages/content/test/notifications/Notification.test.ts +++ b/packages/content/test/notifications/Notification.test.ts @@ -1,5 +1,5 @@ import { Serializable } from "@js-soft/ts-serval"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { IdentityAttribute, Notification, PeerSharedAttributeSucceededNotificationItem, Surname } from "../../src"; describe("Notification", function () { diff --git a/packages/content/test/requests/Request.test.ts b/packages/content/test/requests/Request.test.ts index 1934d5798..07b34f267 100644 --- a/packages/content/test/requests/Request.test.ts +++ b/packages/content/test/requests/Request.test.ts @@ -1,5 +1,5 @@ import { Serializable, type } from "@js-soft/ts-serval"; -import { CoreDate, CoreId } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { IRequest, IRequestItem, IRequestItemGroup, Request, RequestItem, RequestItemGroup, RequestItemGroupJSON, RequestItemJSON, RequestJSON } from "../../src"; import { expectThrowsAsync } from "../testUtils"; diff --git a/packages/content/test/requests/Response.test.ts b/packages/content/test/requests/Response.test.ts index 76176d750..5579bb4cd 100644 --- a/packages/content/test/requests/Response.test.ts +++ b/packages/content/test/requests/Response.test.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { AcceptResponseItem, AcceptResponseItemJSON, diff --git a/packages/content/test/requests/ResponseWrapper.test.ts b/packages/content/test/requests/ResponseWrapper.test.ts index e4a70be3b..21a529b7d 100644 --- a/packages/content/test/requests/ResponseWrapper.test.ts +++ b/packages/content/test/requests/ResponseWrapper.test.ts @@ -1,4 +1,4 @@ -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { Response, ResponseItemJSON, ResponseItemResult, ResponseJSON, ResponseResult, ResponseWrapper } from "../../src"; describe("ResponseWrapper", function () { diff --git a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts index 44b7a784a..1b2d16a06 100644 --- a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts +++ b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts @@ -1,7 +1,7 @@ import { ValidationError } from "@js-soft/ts-serval"; import { TestObjectFactory } from "@nmshd/consumption/test/modules/requests/testHelpers/TestObjectFactory"; import { IdentityAttributeQuery, IQLQuery, ProposeAttributeRequestItem, RelationshipAttributeConfidentiality, RelationshipAttributeQuery } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; describe("creation of ProposeAttributeRequestItem", () => { diff --git a/packages/runtime/test/consumption/attributes.test.ts b/packages/runtime/test/consumption/attributes.test.ts index 4a0157a09..9f6325244 100644 --- a/packages/runtime/test/consumption/attributes.test.ts +++ b/packages/runtime/test/consumption/attributes.test.ts @@ -11,7 +11,7 @@ import { ThirdPartyRelationshipAttributeQueryOwner, ZipCodeJSON } from "@nmshd/content"; -import { CoreDate, CoreId } from "@nmshd/transport"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { AttributeCreatedEvent, ChangeDefaultRepositoryAttributeUseCase, diff --git a/packages/runtime/test/consumption/notifications.test.ts b/packages/runtime/test/consumption/notifications.test.ts index 6efec9c4b..079a040f2 100644 --- a/packages/runtime/test/consumption/notifications.test.ts +++ b/packages/runtime/test/consumption/notifications.test.ts @@ -1,6 +1,7 @@ import { ConsumptionIds } from "@nmshd/consumption"; import { Notification } from "@nmshd/content"; -import { CoreId, CoreIdHelper } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { CoreIdHelper } from "@nmshd/transport"; import { ConsumptionServices, LocalNotificationStatus, RuntimeErrors, TransportServices } from "../../src"; import { establishRelationship, diff --git a/packages/runtime/test/consumption/requests.test.ts b/packages/runtime/test/consumption/requests.test.ts index 029447b00..580468ad5 100644 --- a/packages/runtime/test/consumption/requests.test.ts +++ b/packages/runtime/test/consumption/requests.test.ts @@ -1,7 +1,7 @@ import { EventBus } from "@js-soft/ts-utils"; import { TestRequestItemJSON } from "@nmshd/consumption/test/modules/requests/testHelpers/TestRequestItem"; import { RelationshipCreationContentJSON, RelationshipTemplateContentJSON } from "@nmshd/content"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { ConsumptionServices, CreateOutgoingRequestRequest, diff --git a/packages/runtime/test/consumption/settings.test.ts b/packages/runtime/test/consumption/settings.test.ts index b2a44a912..921e00e0e 100644 --- a/packages/runtime/test/consumption/settings.test.ts +++ b/packages/runtime/test/consumption/settings.test.ts @@ -1,5 +1,6 @@ import { ConsumptionIds } from "@nmshd/consumption"; -import { CoreDate, TransportIds } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; +import { TransportIds } from "@nmshd/transport"; import { ConsumptionServices, GetSettingsQuery } from "../../src"; import { QueryParamConditions, RuntimeServiceProvider } from "../lib"; diff --git a/packages/runtime/test/dataViews/DraftIdentityAttributeDVO.test.ts b/packages/runtime/test/dataViews/DraftIdentityAttributeDVO.test.ts index cce041093..089b8bb12 100644 --- a/packages/runtime/test/dataViews/DraftIdentityAttributeDVO.test.ts +++ b/packages/runtime/test/dataViews/DraftIdentityAttributeDVO.test.ts @@ -11,7 +11,7 @@ import { PersonName, Sex } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { DataViewExpander, TransportServices } from "../../src"; import { RuntimeServiceProvider } from "../lib"; diff --git a/packages/runtime/test/dataViews/MessageDVO.test.ts b/packages/runtime/test/dataViews/MessageDVO.test.ts index e9ce67a8f..3e255db6f 100644 --- a/packages/runtime/test/dataViews/MessageDVO.test.ts +++ b/packages/runtime/test/dataViews/MessageDVO.test.ts @@ -10,7 +10,7 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { DataViewExpander, MailDVO, SendMessageRequest, TransportServices } from "../../src"; import { establishRelationshipWithContents, getRelationship, RuntimeServiceProvider, syncUntilHasMessage, uploadFile } from "../lib"; diff --git a/packages/runtime/test/dataViews/RelationshipDVO.test.ts b/packages/runtime/test/dataViews/RelationshipDVO.test.ts index 19cdc26f8..e360b36f2 100644 --- a/packages/runtime/test/dataViews/RelationshipDVO.test.ts +++ b/packages/runtime/test/dataViews/RelationshipDVO.test.ts @@ -8,7 +8,7 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { DataViewExpander, TransportServices } from "../../src"; import { establishRelationshipWithContents, RuntimeServiceProvider } from "../lib"; diff --git a/packages/runtime/test/dataViews/RelationshipTemplateDVO.test.ts b/packages/runtime/test/dataViews/RelationshipTemplateDVO.test.ts index 64509ae09..e7e62ebbd 100644 --- a/packages/runtime/test/dataViews/RelationshipTemplateDVO.test.ts +++ b/packages/runtime/test/dataViews/RelationshipTemplateDVO.test.ts @@ -13,7 +13,7 @@ import { RequestItemGroupJSON, Surname } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { IncomingRequestStatusChangedEvent, LocalRequestStatus, diff --git a/packages/runtime/test/dataViews/requestItems/DeleteAttributeRequestItemDVO.test.ts b/packages/runtime/test/dataViews/requestItems/DeleteAttributeRequestItemDVO.test.ts index 06135479b..01f567738 100644 --- a/packages/runtime/test/dataViews/requestItems/DeleteAttributeRequestItemDVO.test.ts +++ b/packages/runtime/test/dataViews/requestItems/DeleteAttributeRequestItemDVO.test.ts @@ -1,6 +1,6 @@ import { DecideRequestItemParametersJSON } from "@nmshd/consumption"; import { AbstractStringJSON, DeleteAttributeRequestItemJSON } from "@nmshd/content"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { AcceptResponseItemDVO, ConsumptionServices, diff --git a/packages/runtime/test/dataViews/requestItems/ProposeAttributeRequestItemDVO.test.ts b/packages/runtime/test/dataViews/requestItems/ProposeAttributeRequestItemDVO.test.ts index 759883770..069b959d6 100644 --- a/packages/runtime/test/dataViews/requestItems/ProposeAttributeRequestItemDVO.test.ts +++ b/packages/runtime/test/dataViews/requestItems/ProposeAttributeRequestItemDVO.test.ts @@ -14,7 +14,7 @@ import { Surname, SurnameJSON } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/transport"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { AttributeAlreadySharedAcceptResponseItemDVO, AttributeSuccessionAcceptResponseItemDVO, diff --git a/packages/runtime/test/dataViews/requestItems/ReadAttributeRequestItemDVO.test.ts b/packages/runtime/test/dataViews/requestItems/ReadAttributeRequestItemDVO.test.ts index a073a3619..ce1daa16d 100644 --- a/packages/runtime/test/dataViews/requestItems/ReadAttributeRequestItemDVO.test.ts +++ b/packages/runtime/test/dataViews/requestItems/ReadAttributeRequestItemDVO.test.ts @@ -4,7 +4,7 @@ import { DecideRequestItemParametersJSON } from "@nmshd/consumption"; import { GivenNameJSON, IdentityAttributeQuery, IQLQuery, ReadAttributeRequestItem, SurnameJSON } from "@nmshd/content"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { AttributeAlreadySharedAcceptResponseItemDVO, AttributeSuccessionAcceptResponseItemDVO, diff --git a/packages/runtime/test/dataViews/requestItems/ShareAttributeRequestItemDVO.test.ts b/packages/runtime/test/dataViews/requestItems/ShareAttributeRequestItemDVO.test.ts index 7dc7fbf8b..12c3de249 100644 --- a/packages/runtime/test/dataViews/requestItems/ShareAttributeRequestItemDVO.test.ts +++ b/packages/runtime/test/dataViews/requestItems/ShareAttributeRequestItemDVO.test.ts @@ -1,6 +1,6 @@ import { DecideRequestItemParametersJSON } from "@nmshd/consumption"; import { AbstractStringJSON, DisplayNameJSON, ShareAttributeRequestItemJSON } from "@nmshd/content"; -import { CoreId } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; import { AcceptResponseItemDVO, ConsumptionServices, diff --git a/packages/runtime/test/lib/TestRuntime.ts b/packages/runtime/test/lib/TestRuntime.ts index 787741d36..184671486 100644 --- a/packages/runtime/test/lib/TestRuntime.ts +++ b/packages/runtime/test/lib/TestRuntime.ts @@ -3,7 +3,8 @@ import { LokiJsConnection } from "@js-soft/docdb-access-loki"; import { MongoDbConnection } from "@js-soft/docdb-access-mongo"; import { NodeLoggerFactory } from "@js-soft/node-logger"; import { ConsumptionConfig, ConsumptionController, GenericRequestItemProcessor } from "@nmshd/consumption"; -import { AccountController, ICoreAddress } from "@nmshd/transport"; +import { ICoreAddress } from "@nmshd/core-types"; +import { AccountController } from "@nmshd/transport"; import { ConsumptionServices, DataViewExpander, ModuleConfiguration, Runtime, RuntimeConfig, RuntimeHealth, RuntimeServices, TransportServices } from "../../src"; import { MockEventBus } from "./MockEventBus"; import { TestNotificationItem, TestNotificationItemProcessor } from "./TestNotificationItem"; diff --git a/packages/runtime/test/lib/testUtils.ts b/packages/runtime/test/lib/testUtils.ts index 6e7b3be96..383479dc8 100644 --- a/packages/runtime/test/lib/testUtils.ts +++ b/packages/runtime/test/lib/testUtils.ts @@ -20,8 +20,9 @@ import { ResponseWrapperJSON, ShareAttributeAcceptResponseItemJSON } from "@nmshd/content"; +import { CoreAddress, CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; -import { CoreAddress, CoreId, IdentityUtil } from "@nmshd/transport"; +import { IdentityUtil } from "@nmshd/transport"; import fs from "fs"; import { DateTime } from "luxon"; import { diff --git a/packages/runtime/test/misc/DatabaseSchemaUpgrader.test.ts b/packages/runtime/test/misc/DatabaseSchemaUpgrader.test.ts index ef7d1d4e5..90f261a1b 100644 --- a/packages/runtime/test/misc/DatabaseSchemaUpgrader.test.ts +++ b/packages/runtime/test/misc/DatabaseSchemaUpgrader.test.ts @@ -5,7 +5,8 @@ import { NodeLoggerFactory } from "@js-soft/node-logger"; import { EventEmitter2EventBus } from "@js-soft/ts-utils"; import { ConsumptionController, LocalAttribute, LocalRequest } from "@nmshd/consumption"; import { DisplayName, IdentityAttribute } from "@nmshd/content"; -import { AccountController, CoreAddress, CoreDate, CoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "@nmshd/transport"; import { LocalRequestStatus } from "../../src"; import { DatabaseSchemaUpgrader, UPGRADE_LOGIC } from "../../src/DatabaseSchemaUpgrader"; import { RuntimeServiceProvider, TestRequestItem } from "../lib"; diff --git a/packages/runtime/test/modules/AttributeListenerModule.test.ts b/packages/runtime/test/modules/AttributeListenerModule.test.ts index 07496fdd9..63c60ed5d 100644 --- a/packages/runtime/test/modules/AttributeListenerModule.test.ts +++ b/packages/runtime/test/modules/AttributeListenerModule.test.ts @@ -1,5 +1,6 @@ import { IdentityAttributeJSON, RelationshipAttribute, RelationshipAttributeConfidentiality, RelationshipAttributeJSON, ShareAttributeRequestItemJSON } from "@nmshd/content"; -import { CoreAddress, RelationshipStatus } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; +import { RelationshipStatus } from "@nmshd/transport"; import { AttributeListenerCreatedEvent, OutgoingRequestCreatedEvent } from "../../src"; import { ensureActiveRelationship, diff --git a/packages/runtime/test/modules/DeciderModule.test.ts b/packages/runtime/test/modules/DeciderModule.test.ts index fac1f86b2..987819b48 100644 --- a/packages/runtime/test/modules/DeciderModule.test.ts +++ b/packages/runtime/test/modules/DeciderModule.test.ts @@ -1,5 +1,5 @@ import { RelationshipTemplateContent, Request } from "@nmshd/content"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { ConsumptionServices, IncomingRequestStatusChangedEvent, diff --git a/packages/runtime/test/modules/RequestModule.test.ts b/packages/runtime/test/modules/RequestModule.test.ts index be28dfef0..168b2d04a 100644 --- a/packages/runtime/test/modules/RequestModule.test.ts +++ b/packages/runtime/test/modules/RequestModule.test.ts @@ -11,7 +11,7 @@ import { ResponseResult, ResponseWrapperJSON } from "@nmshd/content"; -import { CoreAddress } from "@nmshd/transport"; +import { CoreAddress } from "@nmshd/core-types"; import { CreateOutgoingRequestRequest, IncomingRequestReceivedEvent, diff --git a/packages/runtime/test/transport/account.test.ts b/packages/runtime/test/transport/account.test.ts index 49fe99aff..9697b9a4d 100644 --- a/packages/runtime/test/transport/account.test.ts +++ b/packages/runtime/test/transport/account.test.ts @@ -1,4 +1,4 @@ -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { DateTime } from "luxon"; import { DeviceDTO, DeviceOnboardingInfoDTO, TransportServices } from "../../src"; import { emptyRelationshipTemplateContent, RuntimeServiceProvider, uploadFile } from "../lib"; diff --git a/packages/runtime/test/transport/files.test.ts b/packages/runtime/test/transport/files.test.ts index c306600b1..bf7e40f4a 100644 --- a/packages/runtime/test/transport/files.test.ts +++ b/packages/runtime/test/transport/files.test.ts @@ -1,4 +1,4 @@ -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import fs from "fs"; import { DateTime } from "luxon"; import { FileDTO, GetFilesQuery, OwnerRestriction, TransportServices } from "../../src"; diff --git a/packages/runtime/test/transport/identityDeletionProcess.test.ts b/packages/runtime/test/transport/identityDeletionProcess.test.ts index 446bdf1b1..0c575877f 100644 --- a/packages/runtime/test/transport/identityDeletionProcess.test.ts +++ b/packages/runtime/test/transport/identityDeletionProcess.test.ts @@ -1,4 +1,5 @@ -import { CoreId, IdentityDeletionProcessStatus } from "@nmshd/transport"; +import { CoreId } from "@nmshd/core-types"; +import { IdentityDeletionProcessStatus } from "@nmshd/transport"; import { ApproveIdentityDeletionProcessUseCase, CancelIdentityDeletionProcessUseCase, diff --git a/packages/runtime/test/transport/messages.test.ts b/packages/runtime/test/transport/messages.test.ts index 17a77d5b8..3f1d4cd77 100644 --- a/packages/runtime/test/transport/messages.test.ts +++ b/packages/runtime/test/transport/messages.test.ts @@ -1,5 +1,5 @@ import { ConsentRequestItemJSON } from "@nmshd/content"; -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { GetMessagesQuery, MessageReceivedEvent, MessageSentEvent, MessageWasReadAtChangedEvent } from "../../src"; import { QueryParamConditions, diff --git a/packages/runtime/test/transport/tokens.test.ts b/packages/runtime/test/transport/tokens.test.ts index bd27322aa..a02bd87e0 100644 --- a/packages/runtime/test/transport/tokens.test.ts +++ b/packages/runtime/test/transport/tokens.test.ts @@ -1,4 +1,4 @@ -import { CoreDate } from "@nmshd/transport"; +import { CoreDate } from "@nmshd/core-types"; import { GetTokensQuery, OwnerRestriction, TransportServices } from "../../src"; import { exchangeToken, QueryParamConditions, RuntimeServiceProvider, uploadOwnToken } from "../lib"; diff --git a/packages/transport/test/core/backbone/Authentication.test.ts b/packages/transport/test/core/backbone/Authentication.test.ts index 5a2d55df1..d3e020e33 100644 --- a/packages/transport/test/core/backbone/Authentication.test.ts +++ b/packages/transport/test/core/backbone/Authentication.test.ts @@ -1,7 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { ILogger } from "@js-soft/logging-abstractions"; +import { CoreDate } from "@nmshd/core-types"; import { mock } from "ts-mockito"; -import { AccountController, CoreDate, Transport, TransportController } from "../../../src"; +import { AccountController, Transport, TransportController } from "../../../src"; import { RequestInterceptor } from "../../testHelpers/RequestInterceptor"; import { TestUtil } from "../../testHelpers/TestUtil"; diff --git a/packages/transport/test/end2end/End2End.test.ts b/packages/transport/test/end2end/End2End.test.ts index 31c153ab5..e0f61efd1 100644 --- a/packages/transport/test/end2end/End2End.test.ts +++ b/packages/transport/test/end2end/End2End.test.ts @@ -1,7 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; -import { AccountController, CoreDate, CoreId, FileReference, RelationshipAuditLogEntryReason, RelationshipStatus, TokenContentRelationshipTemplate, Transport } from "../../src"; +import { AccountController, FileReference, RelationshipAuditLogEntryReason, RelationshipStatus, TokenContentRelationshipTemplate, Transport } from "../../src"; import { TestUtil } from "../testHelpers/TestUtil"; describe("AccountTest", function () { diff --git a/packages/transport/test/modules/TimeSync.test.ts b/packages/transport/test/modules/TimeSync.test.ts index 2b46b7fba..16411811a 100644 --- a/packages/transport/test/modules/TimeSync.test.ts +++ b/packages/transport/test/modules/TimeSync.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreDate, Transport } from "../../src"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, Transport } from "../../src"; import { TestUtil } from "../testHelpers/TestUtil"; describe("TimeSyncTest", function () { diff --git a/packages/transport/test/modules/account/IdentityDeletionProcessController.test.ts b/packages/transport/test/modules/account/IdentityDeletionProcessController.test.ts index de99e803a..060b341e3 100644 --- a/packages/transport/test/modules/account/IdentityDeletionProcessController.test.ts +++ b/packages/transport/test/modules/account/IdentityDeletionProcessController.test.ts @@ -64,7 +64,7 @@ describe("IdentityDeletionProcessController", function () { await account.identityDeletionProcess.cancelIdentityDeletionProcess(cancelledIdentityDeletionProcess.id.toString()); const activeIdentityDeletionProcess = await account.identityDeletionProcess.initiateIdentityDeletionProcess(); const result = await account.identityDeletionProcess.getIdentityDeletionProcessByStatus(IdentityDeletionProcessStatus.Approved); - expect(activeIdentityDeletionProcess.toBase64()).toBe(result!.toBase64()); + expect(activeIdentityDeletionProcess.toJSON()).toStrictEqual(result!.toJSON()); }); test("should get an IdentityDeletionProcess after it got updated by the Backbone", async function () { @@ -121,7 +121,7 @@ describe("IdentityDeletionProcessController", function () { await account.identityDeletionProcess.cancelIdentityDeletionProcess(cancelledIdentityDeletionProcess.id.toString()); const waitingForApprovalIdentityDeletionProcess = await AdminApiClient.startIdentityDeletionProcessFromBackboneAdminApi(account); const result = await account.identityDeletionProcess.getIdentityDeletionProcessByStatus(IdentityDeletionProcessStatus.WaitingForApproval); - expect(waitingForApprovalIdentityDeletionProcess.toBase64()).toBe(result!.toBase64()); + expect(waitingForApprovalIdentityDeletionProcess.toJSON()).toStrictEqual(result!.toJSON()); expect(waitingForApprovalIdentityDeletionProcess.cache!.status).toBe(IdentityDeletionProcessStatus.WaitingForApproval); }); diff --git a/packages/transport/test/modules/certificates/CertificateIssuer.test.ts b/packages/transport/test/modules/certificates/CertificateIssuer.test.ts index 422fd8d89..c53236474 100644 --- a/packages/transport/test/modules/certificates/CertificateIssuer.test.ts +++ b/packages/transport/test/modules/certificates/CertificateIssuer.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, Certificate, CertificatePublicAttributeItem, CertificateTimeConstraint, CoreDate, ICertificateContent, Transport } from "../../../src"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, Certificate, CertificatePublicAttributeItem, CertificateTimeConstraint, ICertificateContent, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("CertificateIssuer", function () { diff --git a/packages/transport/test/modules/challenges/Challenges.test.ts b/packages/transport/test/modules/challenges/Challenges.test.ts index 44ad045cf..0c3ab70dd 100644 --- a/packages/transport/test/modules/challenges/Challenges.test.ts +++ b/packages/transport/test/modules/challenges/Challenges.test.ts @@ -1,7 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { Serializable } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSignature } from "@nmshd/crypto"; -import { AccountController, Challenge, ChallengeSigned, ChallengeType, CoreAddress, CoreDate, CoreId, Transport } from "../../../src"; +import { AccountController, Challenge, ChallengeSigned, ChallengeType, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("ChallengeTest", function () { diff --git a/packages/transport/test/modules/devices/DeviceOnboarding.test.ts b/packages/transport/test/modules/devices/DeviceOnboarding.test.ts index 4f3ecdcd3..27e9a2332 100644 --- a/packages/transport/test/modules/devices/DeviceOnboarding.test.ts +++ b/packages/transport/test/modules/devices/DeviceOnboarding.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSecretKey, CryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { AccountController, CoreDate, CoreId, Device, DeviceSecretCredentials, DeviceSecretType, DeviceSharedSecret } from "../../../src"; +import { AccountController, Device, DeviceSecretCredentials, DeviceSecretType, DeviceSharedSecret } from "../../../src"; import { AppDeviceTest } from "../../testHelpers/AppDeviceTest"; import { DeviceTestParameters } from "../../testHelpers/DeviceTestParameters"; import { TestUtil } from "../../testHelpers/TestUtil"; @@ -102,7 +103,7 @@ describe("Device Onboarding", function () { }); test("should own the same identity", function () { - expect(device1Account.identity.identity.toBase64()).toBe(device2Account.identity.identity.toBase64()); + expect(device1Account.identity.identity.toJSON()).toStrictEqual(device2Account.identity.identity.toJSON()); }); test("should be able to sign for the existing identity", async function () { diff --git a/packages/transport/test/modules/files/FileController.test.ts b/packages/transport/test/modules/files/FileController.test.ts index 7c501456c..ab47eb89e 100644 --- a/packages/transport/test/modules/files/FileController.test.ts +++ b/packages/transport/test/modules/files/FileController.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; -import { AccountController, CoreDate, CoreId, File, Transport } from "../../../src"; +import { AccountController, File, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("FileController", function () { diff --git a/packages/transport/test/modules/files/FileReference.test.ts b/packages/transport/test/modules/files/FileReference.test.ts index c682bedf7..e41a411af 100644 --- a/packages/transport/test/modules/files/FileReference.test.ts +++ b/packages/transport/test/modules/files/FileReference.test.ts @@ -1,6 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; +import { CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { BackboneIds, CoreId, FileReference } from "../../../src"; +import { BackboneIds, FileReference } from "../../../src"; describe("FileReference", function () { test("should serialize and deserialize correctly (verbose)", async function () { diff --git a/packages/transport/test/modules/messages/MessageContent.test.ts b/packages/transport/test/modules/messages/MessageContent.test.ts index 4ac8219f3..21c0c70a9 100644 --- a/packages/transport/test/modules/messages/MessageContent.test.ts +++ b/packages/transport/test/modules/messages/MessageContent.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { ISerializable, JSONWrapper, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { AccountController, CoreAddress, ICoreAddress, Transport } from "../../../src"; +import { CoreAddress, ICoreAddress } from "@nmshd/core-types"; +import { AccountController, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("MessageContent", function () { diff --git a/packages/transport/test/modules/messages/MessageController.test.ts b/packages/transport/test/modules/messages/MessageController.test.ts index c0d1ad9bb..0ed4e2112 100644 --- a/packages/transport/test/modules/messages/MessageController.test.ts +++ b/packages/transport/test/modules/messages/MessageController.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreDate, CoreId, Message, Relationship, Transport } from "../../../src"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Message, Relationship, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("MessageController", function () { diff --git a/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateController.test.ts b/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateController.test.ts index 3aec40aa7..f6255fc50 100644 --- a/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateController.test.ts +++ b/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateController.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreDate, CoreId, RelationshipTemplate, Transport } from "../../../src"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, RelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("RelationshipTemplateController", function () { diff --git a/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateReference.test.ts b/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateReference.test.ts index 67ec048eb..993aa0763 100644 --- a/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateReference.test.ts +++ b/packages/transport/test/modules/relationshipTemplates/RelationshipTemplateReference.test.ts @@ -1,6 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; +import { CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { BackboneIds, CoreId, RelationshipTemplateReference } from "../../../src"; +import { BackboneIds, RelationshipTemplateReference } from "../../../src"; describe("RelationshipTemplateReference", function () { test("should serialize and deserialize correctly (verbose)", async function () { diff --git a/packages/transport/test/modules/relationships/RelationshipsController.test.ts b/packages/transport/test/modules/relationships/RelationshipsController.test.ts index a309993f8..689b0a1d0 100644 --- a/packages/transport/test/modules/relationships/RelationshipsController.test.ts +++ b/packages/transport/test/modules/relationships/RelationshipsController.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CachedRelationship, CoreDate, CoreId, Identity, Relationship, RelationshipStatus, RelationshipTemplate, Transport } from "../../../src"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, CachedRelationship, Identity, Relationship, RelationshipStatus, RelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("RelationshipsController", function () { diff --git a/packages/transport/test/modules/relationships/TerminateDecompose.test.ts b/packages/transport/test/modules/relationships/TerminateDecompose.test.ts index de8c31298..e256d5b63 100644 --- a/packages/transport/test/modules/relationships/TerminateDecompose.test.ts +++ b/packages/transport/test/modules/relationships/TerminateDecompose.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreId, RelationshipChangedEvent, Transport } from "../../../src"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, RelationshipChangedEvent, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("Terminate and Decompose simultaneously", function () { diff --git a/packages/transport/test/modules/relationships/decomposition.test.ts b/packages/transport/test/modules/relationships/decomposition.test.ts index 985aaabd0..d39ea5acb 100644 --- a/packages/transport/test/modules/relationships/decomposition.test.ts +++ b/packages/transport/test/modules/relationships/decomposition.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { Serializable } from "@js-soft/ts-serval"; -import { AccountController, CoreDate, CoreId, Relationship, Transport } from "../../../src"; +import { CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, Relationship, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("Data cleanup after relationship decomposition", function () { diff --git a/packages/transport/test/modules/sync/SyncController.error.test.ts b/packages/transport/test/modules/sync/SyncController.error.test.ts index 75232279a..de9fea63f 100644 --- a/packages/transport/test/modules/sync/SyncController.error.test.ts +++ b/packages/transport/test/modules/sync/SyncController.error.test.ts @@ -1,5 +1,5 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { CoreDate } from "../../../src"; +import { CoreDate } from "@nmshd/core-types"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("SyncController.error", function () { diff --git a/packages/transport/test/modules/sync/SyncController.files.test.ts b/packages/transport/test/modules/sync/SyncController.files.test.ts index aa7e27f96..93a0f99ae 100644 --- a/packages/transport/test/modules/sync/SyncController.files.test.ts +++ b/packages/transport/test/modules/sync/SyncController.files.test.ts @@ -1,6 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; +import { CoreDate } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; -import { CoreDate } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("FileSync", function () { diff --git a/packages/transport/test/modules/sync/SyncController.relationships.test.ts b/packages/transport/test/modules/sync/SyncController.relationships.test.ts index ba0abee2c..bda4e5d40 100644 --- a/packages/transport/test/modules/sync/SyncController.relationships.test.ts +++ b/packages/transport/test/modules/sync/SyncController.relationships.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { CoreDate, RelationshipStatus } from "../../../src"; +import { CoreDate } from "@nmshd/core-types"; +import { RelationshipStatus } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("RelationshipSync", function () { diff --git a/packages/transport/test/modules/sync/SyncController.test.ts b/packages/transport/test/modules/sync/SyncController.test.ts index b99a5d3e7..30b82a620 100644 --- a/packages/transport/test/modules/sync/SyncController.test.ts +++ b/packages/transport/test/modules/sync/SyncController.test.ts @@ -1,6 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { sleep } from "@js-soft/ts-utils"; -import { AccountController, CoreDate, Transport } from "../../../src"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, Transport } from "../../../src"; import { FakeSyncClient } from "../../testHelpers/FakeSyncClient"; import { TestUtil } from "../../testHelpers/TestUtil"; diff --git a/packages/transport/test/modules/sync/SyncController.tokens.test.ts b/packages/transport/test/modules/sync/SyncController.tokens.test.ts index dad085ee0..4983feb3b 100644 --- a/packages/transport/test/modules/sync/SyncController.tokens.test.ts +++ b/packages/transport/test/modules/sync/SyncController.tokens.test.ts @@ -1,5 +1,5 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { CoreDate } from "../../../src"; +import { CoreDate } from "@nmshd/core-types"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenSync", function () { diff --git a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts index 28b7f8b95..d6e29bf80 100644 --- a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts +++ b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts @@ -1,6 +1,7 @@ import { IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { instance, mock, verify } from "ts-mockito"; -import { CoreDate, CoreId, DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, SynchronizedCollection } from "../../../src"; +import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, SynchronizedCollection } from "../../../src"; import { ACacheableSynchronizedCollectionItem, CachedACacheableSynchronizedCollectionItem } from "../../testHelpers/ACacheableSynchronizedCollectionItem"; import { ASynchronizedCollectionItem } from "../../testHelpers/ASynchronizedCollectionItem"; import { FakeDatabaseCollection } from "../../testHelpers/FakeDatabaseCollection"; diff --git a/packages/transport/test/modules/tokens/TokenContent.test.ts b/packages/transport/test/modules/tokens/TokenContent.test.ts index 822c7bbe3..99e965f9e 100644 --- a/packages/transport/test/modules/tokens/TokenContent.test.ts +++ b/packages/transport/test/modules/tokens/TokenContent.test.ts @@ -1,16 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { - AccountController, - CoreDate, - CoreId, - DeviceSharedSecret, - TokenContentDeviceSharedSecret, - TokenContentFile, - TokenContentRelationshipTemplate, - Transport -} from "../../../src"; +import { AccountController, DeviceSharedSecret, TokenContentDeviceSharedSecret, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenContent", function () { diff --git a/packages/transport/test/modules/tokens/TokenController.test.ts b/packages/transport/test/modules/tokens/TokenController.test.ts index 78ea382c1..be91e667e 100644 --- a/packages/transport/test/modules/tokens/TokenController.test.ts +++ b/packages/transport/test/modules/tokens/TokenController.test.ts @@ -1,7 +1,8 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, CoreDate, CoreId, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; +import { AccountController, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenController", function () { diff --git a/packages/transport/test/modules/tokens/TokenReference.test.ts b/packages/transport/test/modules/tokens/TokenReference.test.ts index cb6a39eda..ff5d4dd87 100644 --- a/packages/transport/test/modules/tokens/TokenReference.test.ts +++ b/packages/transport/test/modules/tokens/TokenReference.test.ts @@ -1,6 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; +import { CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { BackboneIds, CoreId, TokenReference } from "../../../src"; +import { BackboneIds, TokenReference } from "../../../src"; describe("TokenReference", function () { test("should serialize and deserialize correctly (verbose)", async function () { diff --git a/packages/transport/test/performance/PerformanceTemplates.test.ts b/packages/transport/test/performance/PerformanceTemplates.test.ts index 0c4e35250..74d90567b 100644 --- a/packages/transport/test/performance/PerformanceTemplates.test.ts +++ b/packages/transport/test/performance/PerformanceTemplates.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreDate, RelationshipTemplate, Transport } from "../../src"; +import { CoreDate } from "@nmshd/core-types"; +import { AccountController, RelationshipTemplate, Transport } from "../../src"; import { TestUtil } from "../testHelpers/TestUtil"; async function createTemplate(from: AccountController) { diff --git a/packages/transport/test/testHelpers/ACacheableSynchronizedCollectionItem.ts b/packages/transport/test/testHelpers/ACacheableSynchronizedCollectionItem.ts index 004135332..f39c3ccf9 100644 --- a/packages/transport/test/testHelpers/ACacheableSynchronizedCollectionItem.ts +++ b/packages/transport/test/testHelpers/ACacheableSynchronizedCollectionItem.ts @@ -1,14 +1,13 @@ import { Serializable, serialize, validate } from "@js-soft/ts-serval"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; -import { CoreDate, CoreId, CoreSynchronizable, ICoreDate, ICoreSerializable } from "../../src"; +import { CoreSynchronizable, ICoreSynchronizable } from "../../src"; export interface ICachedACacheableSynchronizedCollectionItem { someCacheProperty: string; } -export interface IACacheableSynchronizedCollectionItem extends ICoreSerializable { - id: CoreId; - +export interface IACacheableSynchronizedCollectionItem extends ICoreSynchronizable { someTechnicalProperty?: string; cache?: ICachedACacheableSynchronizedCollectionItem; diff --git a/packages/transport/test/testHelpers/ASynchronizedCollectionItem.ts b/packages/transport/test/testHelpers/ASynchronizedCollectionItem.ts index b6b96827f..790db33b5 100644 --- a/packages/transport/test/testHelpers/ASynchronizedCollectionItem.ts +++ b/packages/transport/test/testHelpers/ASynchronizedCollectionItem.ts @@ -1,10 +1,8 @@ import { serialize, validate } from "@js-soft/ts-serval"; import { nameof } from "ts-simple-nameof"; -import { CoreId, CoreSynchronizable, ICoreSerializable } from "../../src"; - -interface IASynchronizedCollectionItem extends ICoreSerializable { - id: CoreId; +import { CoreSynchronizable, ICoreSynchronizable } from "../../src"; +interface IASynchronizedCollectionItem extends ICoreSynchronizable { someTechnicalStringProperty?: string; someTechnicalNumberProperty?: number; someTechnicalBooleanProperty?: boolean; diff --git a/packages/transport/test/testHelpers/AdminApiClient.ts b/packages/transport/test/testHelpers/AdminApiClient.ts index 7639b477a..e013f85ef 100644 --- a/packages/transport/test/testHelpers/AdminApiClient.ts +++ b/packages/transport/test/testHelpers/AdminApiClient.ts @@ -1,5 +1,6 @@ +import { CoreId } from "@nmshd/core-types"; import axios, { Axios } from "axios"; -import { AccountController, CoreId, IdentityDeletionProcess, IdentityDeletionProcessStatus } from "../../src"; +import { AccountController, IdentityDeletionProcess, IdentityDeletionProcessStatus } from "../../src"; import { TestUtil } from "./TestUtil"; export class AdminApiClient { diff --git a/packages/transport/test/testHelpers/FakeSyncClient.ts b/packages/transport/test/testHelpers/FakeSyncClient.ts index ed2d5a882..cb830bb09 100644 --- a/packages/transport/test/testHelpers/FakeSyncClient.ts +++ b/packages/transport/test/testHelpers/FakeSyncClient.ts @@ -1,9 +1,8 @@ +import { CoreDate, CoreId } from "@nmshd/core-types"; import { BackboneDatawalletModification, BackboneExternalEvent, ClientResult, - CoreDate, - CoreId, CreateDatawalletModificationsRequest, CreateDatawalletModificationsResponse, FinalizeDatawalletVersionUpgradeRequest, diff --git a/packages/transport/test/testHelpers/TestUtil.ts b/packages/transport/test/testHelpers/TestUtil.ts index 686591405..a92f83254 100644 --- a/packages/transport/test/testHelpers/TestUtil.ts +++ b/packages/transport/test/testHelpers/TestUtil.ts @@ -7,15 +7,13 @@ import { NodeLoggerFactory } from "@js-soft/node-logger"; import { SimpleLoggerFactory } from "@js-soft/simple-logger"; import { ISerializable, Serializable } from "@js-soft/ts-serval"; import { EventEmitter2EventBus, sleep } from "@js-soft/ts-utils"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; import { DurationLike } from "luxon"; import { LogLevel } from "typescript-logging"; import { AccountController, ChangedItems, - CoreAddress, - CoreDate, - CoreId, DependencyOverrides, DeviceSharedSecret, File, diff --git a/packages/transport/test/tsconfig.json b/packages/transport/test/tsconfig.json index db9a0d1ee..50e8c5f15 100644 --- a/packages/transport/test/tsconfig.json +++ b/packages/transport/test/tsconfig.json @@ -6,6 +6,6 @@ "composite": false }, "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], - "include": ["**/*.ts", "../src/**/*.ts"], + "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], "exclude": [] } diff --git a/packages/transport/test/utils/Date.test.ts b/packages/transport/test/utils/Date.test.ts deleted file mode 100644 index 6135c663f..000000000 --- a/packages/transport/test/utils/Date.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { CoreDate } from "../../src"; - -describe("CoreDate", function () { - describe("Constructor", function () { - test("returns the current date when constructor is empty", function () { - const date = CoreDate.utc(); - expect(date).toBeDefined(); - }); - - test("sets the date property as string", function () { - const date = CoreDate.utc(); - expect(typeof date.date).toBe("string"); - }); - }); - - describe("Add()", function () { - test("returns a date in the future", function () { - const date = CoreDate.utc().add({ years: 1 }); - expect(date).toBeDefined(); - expect(date.isAfter(CoreDate.utc())).toBe(true); - }); - }); - - describe("IsWithin()", function () { - test("should return a correct value if it is within the given range (one parameter)", function () { - const date = CoreDate.utc().subtract({ days: 1, seconds: 1 }); - expect(date.isWithin({ days: 5 })).toBe(true); - expect(date.isWithin({ days: 1 })).toBe(false); - expect(date.isWithin({ days: 1, minutes: 2 })).toBe(true); - expect(date.isWithin({ days: -1 })).toBe(false); - }); - - test("should return a correct value if it is within the given range (two parameters)", function () { - const date = CoreDate.utc().subtract({ days: 1, seconds: 1 }); - expect(date.isWithin({ days: 5 }, { days: 1 })).toBe(true); - expect(date.isWithin({ days: 20 }, { days: -20 })).toBe(false); - expect(date.isWithin({ days: 1, minutes: 2 }, { days: 1 })).toBe(true); - expect(date.isWithin({ days: -1 }, { minutes: 4000 })).toBe(false); - - const date2 = CoreDate.utc().add({ days: 1, seconds: 1 }); - expect(date2.isWithin(0, { days: 2 })).toBe(true); - expect(date2.isWithin({ days: 2 }, { days: 3 })).toBe(true); - expect(date2.isWithin({ days: 1 }, { days: 3 })).toBe(true); - expect(date2.isWithin({ days: -1 }, { seconds: 4000 })).toBe(false); - }); - - test("should return a correct value if it is within the given range (three parameters)", function () { - const date = CoreDate.from("2020-01-01"); - const reference = CoreDate.from("2020-01-02"); - expect(date.isWithin({ days: 5 }, { days: 1 }, reference)).toBe(true); - expect(date.isWithin({ days: 20 }, { days: -20 }, reference)).toBe(false); - expect(date.isWithin({ days: 1, minutes: 2 }, { days: 1 }, reference)).toBe(true); - expect(date.isWithin({ hours: 25 }, { hours: 25 }, reference)).toBe(true); - expect(date.isWithin({ hours: 23 }, { hours: 25 }, reference)).toBe(false); - - const date2 = CoreDate.from("2020-01-03"); - expect(date2.isWithin(0, { days: 2 }, reference)).toBe(true); - expect(date2.isWithin({ minutes: 2 }, { days: 1 }, reference)).toBe(false); - expect(date2.isWithin({ days: 1 }, { days: 3 }, reference)).toBe(true); - expect(date2.isWithin({ hours: 25 }, { hours: 25 }, reference)).toBe(true); - expect(date2.isWithin({ hours: 23 }, { hours: 23 }, reference)).toBe(false); - }); - }); - - describe("From()", function () { - test("returns a date when provided with a date", function () { - const date = CoreDate.from(CoreDate.utc()); - expect(date).toBeDefined(); - }); - - test("returns a date when provided with a string", function () { - const date = CoreDate.from(CoreDate.utc().date); - expect(date).toBeDefined(); - }); - }); -}); diff --git a/packages/transport/test/utils/PasswordGenerator.test.ts b/packages/transport/test/utils/PasswordGenerator.test.ts deleted file mode 100644 index 604917049..000000000 --- a/packages/transport/test/utils/PasswordGenerator.test.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { PasswordGenerator } from "../../src"; -import { TestUtil } from "../testHelpers/TestUtil"; - -describe("PasswordGeneratorTest", function () { - describe("CreatePassword", function () { - test("should return a fixed length password", async function () { - for (let i = 1; i < 20; i++) { - const pass = await PasswordGenerator.createPassword(i); - expect(pass).toHaveLength(i); - } - }); - - test("should return a random length password within the range", async function () { - for (let i = 1; i < 20; i++) { - const pass = await PasswordGenerator.createPassword(6, 10); - - expect(pass.length).toBeGreaterThanOrEqual(6); - expect(pass.length).toBeLessThanOrEqual(10); - } - }); - }); - - describe("CreateStrongPassword", function () { - test("should return a random password with a dynamic size", async function () { - for (let i = 1; i < 20; i++) { - const password = await PasswordGenerator.createStrongPassword(); - - expect(password.length).toBeGreaterThanOrEqual(8); - expect(password.length).toBeLessThanOrEqual(12); - } - }); - - test("should return a random password with the correct given fix length", async function () { - for (let i = 1; i < 20; i++) { - const pass = await PasswordGenerator.createStrongPassword(50, 50); - expect(pass).toHaveLength(50); - } - }); - - test("should return a random password with the correct given length interval", async function () { - for (let i = 1; i < 20; i++) { - const pass = await PasswordGenerator.createStrongPassword(20, 50); - - expect(pass.length).toBeGreaterThanOrEqual(19); - expect(pass.length).toBeLessThanOrEqual(51); - } - }); - - test("should throw an error if minLength is too low", async function () { - for (let i = 1; i < 20; i++) { - await TestUtil.expectThrowsAsync(PasswordGenerator.createStrongPassword(2, 20), "Minimum password length for a strong password should be 8 characters."); - } - }); - }); - - describe("CreateUnitPassword", function () { - test("should return a random password", async function () { - for (let i = 1; i < 20; i++) { - const pass = await PasswordGenerator.createUnitPassword(); - expect(pass.length).toBeGreaterThanOrEqual(5); - expect(pass.length).toBeLessThanOrEqual(30); - } - }); - }); -}); diff --git a/packages/transport/test/utils/Random.test.ts b/packages/transport/test/utils/Random.test.ts deleted file mode 100644 index 164bcd0d5..000000000 --- a/packages/transport/test/utils/Random.test.ts +++ /dev/null @@ -1,150 +0,0 @@ -import { Random, RandomCharacterRange } from "../../src"; - -describe("RandomTest", function () { - describe("IntBetween", function () { - test("should return a number between the min and max", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.intBetween(0, 1); - expect(n).toBeLessThan(2); - expect(n).toBeGreaterThan(-1); - } - }); - - test("should return an even number across all possible values (0|1)", async function () { - const buckets: number[] = [0, 0]; - const iterations = 10000; - for (let i = 1; i < iterations; i++) { - const n = await Random.intBetween(0, 1); - // eslint-disable-next-line jest/no-conditional-in-test - switch (n) { - case 0: - buckets[0]++; - break; - case 1: - buckets[1]++; - break; - default: - throw new Error(`Value '${n}' is not in the range!`); - } - } - - expect(buckets[0]).toBeLessThan(iterations * 0.6); - expect(buckets[0]).toBeGreaterThan(iterations * 0.4); - expect(buckets[1]).toBeLessThan(iterations * 0.6); - expect(buckets[1]).toBeGreaterThan(iterations * 0.4); - }); - - test("should return an even number across all possible values (0 to 100)", async function () { - const buckets: number[] = []; - const iterations = 10000; - const min = 0; - const max = 100; - const diff = max - min + 1; - - for (let j = 0; j < diff; j++) { - buckets[j] = 0; - } - - for (let i = 1; i < iterations; i++) { - const n = await Random.intBetween(min, max); - buckets[n]++; - } - - for (let j = 0; j < diff; j++) { - expect(buckets[j]).toBeLessThan((iterations / diff) * 1.5); - expect(buckets[j]).toBeGreaterThan((iterations / diff) * 0.5); - } - }); - - test("should return a number between the min and max (small numbers)", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.intBetween(-20, 20); - expect(n).toBeLessThan(21); - expect(n).toBeGreaterThan(-21); - } - }); - - test("should return a number between the min and max (very high max)", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.intBetween(0, 2 ^ (32 - 1)); - expect(n).toBeLessThan(2 ^ 32); - expect(n).toBeGreaterThan(-1); - } - }); - - test("should return a number between the min and max (very low min)", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.intBetween(-2 ^ (32 + 1), 0); - expect(n).toBeLessThan(1); - expect(n).toBeGreaterThan(-2 ^ 32); - } - }); - }); - - describe("Scramble()", function () { - test("should return a string with the same length", async function () { - for (let i = 1; i < 20; i++) { - const instring = "012345"; - const n = await Random.scramble(instring); - expect(n).toHaveLength(instring.length); - } - }); - }); - - describe("String()", function () { - test("should return a string with a fixed length", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.string(1); - expect(n).toHaveLength(1); - } - - for (let i = 1; i < 20; i++) { - const n = await Random.string(10); - expect(n).toHaveLength(10); - } - - for (let i = 1; i < 20; i++) { - const n = await Random.string(100); - expect(n).toHaveLength(100); - } - }); - - test("should return a string with a fixed length and wanted characters", async function () { - for (let i = 1; i < 20; i++) { - const n = await Random.string(1, "a"); - expect(n).toHaveLength(1); - expect(n).toBe("a"); - } - - for (let i = 1; i < 20; i++) { - const n = await Random.string(10, "a"); - expect(n).toHaveLength(10); - expect(n).toBe("aaaaaaaaaa"); - } - - for (let i = 1; i < 20; i++) { - const n = await Random.string(10, "0"); - expect(n).toHaveLength(10); - expect(n).toBe("0000000000"); - } - }); - - test("should return an even number across all possible values (Alphabet)", async function () { - const buckets: any = {}; - const iterations = 10000; - const diff = RandomCharacterRange.Alphabet.length; - - for (let i = 1; i < iterations; i++) { - const n = await Random.string(1, RandomCharacterRange.Alphabet); - // eslint-disable-next-line jest/no-conditional-in-test - if (buckets[n]) buckets[n]++; - else buckets[n] = 1; - } - - for (const char in buckets) { - expect(buckets[char]).toBeLessThan((iterations / diff) * 1.5); - expect(buckets[char]).toBeGreaterThan((iterations / diff) * 0.5); - } - }); - }); -}); From c02aaadf287043014bdd72d2a4cddc6796be370d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:16:57 +0200 Subject: [PATCH 04/16] chore: update content dependencies --- packages/content/package.json | 1 + packages/content/tsconfig.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/content/package.json b/packages/content/package.json index d28bd81e1..38999133f 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -53,6 +53,7 @@ "dependencies": { "@js-soft/logging-abstractions": "^1.0.1", "@nmshd/iql": "^1.0.2", + "@nmshd/core-types": "*", "ts-simple-nameof": "^1.3.1" }, "devDependencies": { diff --git a/packages/content/tsconfig.json b/packages/content/tsconfig.json index de32fcfd9..27e162755 100644 --- a/packages/content/tsconfig.json +++ b/packages/content/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src/**/*.ts"], "exclude": [], - "references": [{ "path": "../transport" }] + "references": [{ "path": "../core-types" }] } From 32ba2d7f89e8fd9ff890d2828f7dc7ed53948fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:26:58 +0200 Subject: [PATCH 05/16] refactor: also move CoreError to @nmshd/core-types --- .../multiAccount/MultiAccountController.ts | 4 +- ...CoreErrors.ts => ConsumptionCoreErrors.ts} | 5 +- packages/consumption/src/index.ts | 2 +- .../attributes/AttributesController.ts | 114 +++++++++--------- .../attributes/local/LocalAttribute.ts | 10 +- .../notifications/NotificationsController.ts | 2 +- ...DeletedByOwnerNotificationItemProcessor.ts | 6 +- ...eDeletedByPeerNotificationItemProcessor.ts | 6 +- ...eDeletedByPeerNotificationItemProcessor.ts | 6 +- ...ibuteSucceededNotificationItemProcessor.ts | 4 +- .../DecideRequestParametersValidator.ts | 16 +-- .../incoming/IncomingRequestsController.ts | 10 +- .../CreateAttributeRequestItemProcessor.ts | 14 ++- .../DeleteAttributeRequestItemProcessor.ts | 17 +-- .../freeText/FreeTextRequestItemProcessor.ts | 4 +- .../ProposeAttributeRequestItemProcessor.ts | 16 +-- .../ReadAttributeRequestItemProcessor.ts | 26 ++-- .../ShareAttributeRequestItemProcessor.ts | 32 +++-- .../validateAttributeMatchesWithQuery.ts | 54 +++++---- .../itemProcessors/utility/validateQuery.ts | 8 +- .../outgoing/OutgoingRequestsController.ts | 8 +- .../modules/settings/SettingsController.ts | 2 +- packages/core-types/src/CoreError.ts | 75 +++++++++++- packages/core-types/src/index.ts | 1 + .../runtime/src/useCases/common/UseCase.ts | 3 +- ...cceedRelationshipAttributeAndNotifyPeer.ts | 6 +- .../attributes/SucceedRepositoryAttribute.ts | 4 +- .../transport/challenges/ValidateChallenge.ts | 3 +- packages/transport/src/core/CoreError.ts | 74 ------------ packages/transport/src/core/Reference.ts | 6 +- packages/transport/src/core/Transport.ts | 8 +- .../{CoreErrors.ts => TransportCoreErrors.ts} | 4 +- packages/transport/src/core/index.ts | 3 +- .../src/modules/accounts/AccountController.ts | 6 +- .../modules/accounts/IdentityController.ts | 4 +- .../modules/challenges/ChallengeController.ts | 8 +- .../src/modules/devices/DeviceController.ts | 10 +- .../modules/devices/DeviceSecretController.ts | 14 +-- .../src/modules/devices/DevicesController.ts | 12 +- .../src/modules/files/FileController.ts | 16 +-- .../src/modules/messages/MessageController.ts | 28 ++--- .../RelationshipTemplateController.ts | 8 +- .../RelationshipSecretController.ts | 28 ++--- .../relationships/RelationshipsController.ts | 50 ++++---- .../src/modules/secrets/SecretController.ts | 4 +- .../sync/DatawalletModificationsProcessor.ts | 4 +- .../src/modules/sync/SyncController.ts | 18 +-- .../tokens/AnonymousTokenController.ts | 4 +- .../src/modules/tokens/TokenController.ts | 8 +- 49 files changed, 401 insertions(+), 374 deletions(-) rename packages/consumption/src/consumption/{CoreErrors.ts => ConsumptionCoreErrors.ts} (99%) delete mode 100644 packages/transport/src/core/CoreError.ts rename packages/transport/src/core/{CoreErrors.ts => TransportCoreErrors.ts} (99%) diff --git a/packages/app-runtime/src/multiAccount/MultiAccountController.ts b/packages/app-runtime/src/multiAccount/MultiAccountController.ts index e59cf689c..f926eac15 100644 --- a/packages/app-runtime/src/multiAccount/MultiAccountController.ts +++ b/packages/app-runtime/src/multiAccount/MultiAccountController.ts @@ -1,8 +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 { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { AccountController, CoreError, DeviceSharedSecret, Transport, CoreErrors as TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreError, CoreId } from "@nmshd/core-types"; +import { AccountController, DeviceSharedSecret, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; import { AppConfig } from "../AppConfig"; import { SessionStorage } from "../SessionStorage"; import { LocalAccount } from "./data/LocalAccount"; diff --git a/packages/consumption/src/consumption/CoreErrors.ts b/packages/consumption/src/consumption/ConsumptionCoreErrors.ts similarity index 99% rename from packages/consumption/src/consumption/CoreErrors.ts rename to packages/consumption/src/consumption/ConsumptionCoreErrors.ts index 1b2be5be3..2a6a2910a 100644 --- a/packages/consumption/src/consumption/CoreErrors.ts +++ b/packages/consumption/src/consumption/ConsumptionCoreErrors.ts @@ -1,6 +1,5 @@ import { ApplicationError } from "@js-soft/ts-utils"; -import { CoreAddress, CoreId } from "@nmshd/core-types"; -import { CoreError } from "@nmshd/transport"; +import { CoreAddress, CoreError, CoreId } from "@nmshd/core-types"; class Attributes { public successorIsNotAValidAttribute(error: any) { @@ -338,7 +337,7 @@ class Requests { public readonly decideValidation = new Requests._decideValidation(); } -export class CoreErrors { +export class ConsumptionCoreErrors { public static attributes = new Attributes(); public static requests = new Requests(); } diff --git a/packages/consumption/src/index.ts b/packages/consumption/src/index.ts index d96d918ce..980217b79 100644 --- a/packages/consumption/src/index.ts +++ b/packages/consumption/src/index.ts @@ -3,7 +3,7 @@ export * from "./consumption/ConsumptionBaseController"; export * from "./consumption/ConsumptionConfig"; export * from "./consumption/ConsumptionController"; export * from "./consumption/ConsumptionControllerName"; +export * from "./consumption/ConsumptionCoreErrors"; export * from "./consumption/ConsumptionError"; export * from "./consumption/ConsumptionIds"; -export * from "./consumption/CoreErrors"; export * from "./modules"; diff --git a/packages/consumption/src/modules/attributes/AttributesController.ts b/packages/consumption/src/modules/attributes/AttributesController.ts index abe7fd5d0..610f85bf0 100644 --- a/packages/consumption/src/modules/attributes/AttributesController.ts +++ b/packages/consumption/src/modules/attributes/AttributesController.ts @@ -16,15 +16,15 @@ import { } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; import * as iql from "@nmshd/iql"; -import { SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport"; import _ from "lodash"; import { nameof } from "ts-simple-nameof"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; +import { ConsumptionCoreErrors } from "../../consumption/ConsumptionCoreErrors"; import { ConsumptionError } from "../../consumption/ConsumptionError"; import { ConsumptionIds } from "../../consumption/ConsumptionIds"; -import { CoreErrors } from "../../consumption/CoreErrors"; import { ValidationResult } from "../common"; import { AttributeCreatedEvent, @@ -237,7 +237,7 @@ export class AttributesController extends ConsumptionBaseController { public async createRepositoryAttribute(params: ICreateRepositoryAttributeParams): Promise { if (params.content.owner.toString() !== this.identity.address.toString()) { - throw CoreErrors.attributes.wrongOwnerOfRepositoryAttribute(); + throw ConsumptionCoreErrors.attributes.wrongOwnerOfRepositoryAttribute(); } const parsedParams = CreateRepositoryAttributeParams.from(params); @@ -284,10 +284,10 @@ export class AttributesController extends ConsumptionBaseController { } public async setAsDefaultRepositoryAttribute(newDefaultAttribute: LocalAttribute, skipOverwrite?: boolean): Promise { - if (!this.setDefaultRepositoryAttributes) throw CoreErrors.attributes.setDefaultRepositoryAttributesIsDisabled(); + if (!this.setDefaultRepositoryAttributes) throw ConsumptionCoreErrors.attributes.setDefaultRepositoryAttributesIsDisabled(); if (!newDefaultAttribute.isRepositoryAttribute(this.identity.address)) { - throw CoreErrors.attributes.isNotRepositoryAttribute(newDefaultAttribute.id); + throw ConsumptionCoreErrors.attributes.isNotRepositoryAttribute(newDefaultAttribute.id); } if (newDefaultAttribute.isDefault) return newDefaultAttribute; @@ -564,7 +564,7 @@ export class AttributesController extends ConsumptionBaseController { private async succeedChildrenOfComplexAttribute(parentSuccessorId: CoreId) { const parentSuccessor = await this.getLocalAttribute(parentSuccessorId); - if (!parentSuccessor) throw CoreErrors.attributes.invalidParentSuccessor(parentSuccessorId); + if (!parentSuccessor) throw ConsumptionCoreErrors.attributes.invalidParentSuccessor(parentSuccessorId); const childAttributeValues: AbstractAttributeValue[] = Object.values(parentSuccessor.content.value).filter((elem) => elem instanceof AbstractAttributeValue); @@ -616,7 +616,7 @@ export class AttributesController extends ConsumptionBaseController { successorParams: Parameters[0] ): Promise<{ predecessor: LocalAttribute; successor: LocalAttribute }> { const predecessor = await this.getLocalAttribute(predecessorId); - if (!predecessor) throw CoreErrors.attributes.predecessorDoesNotExist(); + if (!predecessor) throw ConsumptionCoreErrors.attributes.predecessorDoesNotExist(); const successor = await this.createAttributeUnsafe({ id: successorParams.id, @@ -653,7 +653,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -672,11 +672,11 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isRepositoryAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotRepositoryAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotRepositoryAttribute()); } if (!successor.isRepositoryAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotRepositoryAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotRepositoryAttribute()); } return ValidationResult.success(); @@ -690,7 +690,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -708,32 +708,32 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isOwnSharedIdentityAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotOwnSharedIdentityAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotOwnSharedIdentityAttribute()); } if (!successor.isOwnSharedIdentityAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotOwnSharedIdentityAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotOwnSharedIdentityAttribute()); } if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangePeer()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangePeer()); } if (!successor.shareInfo.sourceAttribute) { - return ValidationResult.error(CoreErrors.attributes.successorSourceAttributeIsNotSpecified()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorSourceAttributeIsNotSpecified()); } const successorSource = await this.getLocalAttribute(successor.shareInfo.sourceAttribute); if (!successorSource) { - return ValidationResult.error(CoreErrors.attributes.successorSourceAttributeDoesNotExist()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorSourceAttributeDoesNotExist()); } if (!successorSource.isRepositoryAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.successorSourceAttributeIsNotRepositoryAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorSourceAttributeIsNotRepositoryAttribute()); } if (!_.isEqual(successorSource.content, successor.content)) { - return ValidationResult.error(CoreErrors.attributes.successorSourceContentIsNotEqualToCopyContent()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorSourceContentIsNotEqualToCopyContent()); } let predecessorSource: any = undefined; @@ -741,16 +741,16 @@ export class AttributesController extends ConsumptionBaseController { if (predecessorSource) { if (!predecessorSource.isRepositoryAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.predecessorSourceAttributeIsNotRepositoryAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorSourceAttributeIsNotRepositoryAttribute()); } const successorSourceVersionIds = (await this.getVersionsOfAttribute(successorSource.id)).map((x) => x.id.toString()); if (!predecessorSource.succeededBy || !successorSourceVersionIds.some((id) => id === predecessorSource.succeededBy?.toString())) { - return ValidationResult.error(CoreErrors.attributes.successorSourceDoesNotSucceedPredecessorSource()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorSourceDoesNotSucceedPredecessorSource()); } if (!_.isEqual(predecessorSource.content, predecessor.content)) { - return ValidationResult.error(CoreErrors.attributes.predecessorSourceContentIsNotEqualToCopyContent()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorSourceContentIsNotEqualToCopyContent()); } } @@ -765,7 +765,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -783,19 +783,19 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isOwnSharedRelationshipAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotOwnSharedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotOwnSharedRelationshipAttribute()); } if (!successor.isOwnSharedRelationshipAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotOwnSharedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotOwnSharedRelationshipAttribute()); } if (successor.content.key !== predecessor.content.key) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeKey()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeKey()); } if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangePeer()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangePeer()); } return ValidationResult.success(); @@ -809,7 +809,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -827,15 +827,15 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isPeerSharedIdentityAttribute()) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotPeerSharedIdentityAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotPeerSharedIdentityAttribute()); } if (!successor.isPeerSharedIdentityAttribute()) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotPeerSharedIdentityAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotPeerSharedIdentityAttribute()); } if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangePeer()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangePeer()); } return ValidationResult.success(); @@ -849,7 +849,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -867,19 +867,19 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isPeerSharedRelationshipAttribute()) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotPeerSharedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotPeerSharedRelationshipAttribute()); } if (!successor.isPeerSharedRelationshipAttribute()) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotPeerSharedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotPeerSharedRelationshipAttribute()); } if (successor.content.key !== predecessor.content.key) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeKey()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeKey()); } if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangePeer()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangePeer()); } return ValidationResult.success(); @@ -893,7 +893,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams); @@ -911,19 +911,19 @@ export class AttributesController extends ConsumptionBaseController { }); if (!predecessor.isThirdPartyOwnedRelationshipAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.predecessorIsNotThirdPartyOwnedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorIsNotThirdPartyOwnedRelationshipAttribute()); } if (!successor.isThirdPartyOwnedRelationshipAttribute(this.identity.address)) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotThirdPartyOwnedRelationshipAttribute()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotThirdPartyOwnedRelationshipAttribute()); } if (successor.content.key !== predecessor.content.key) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeKey()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeKey()); } if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangePeer()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangePeer()); } return ValidationResult.success(); @@ -934,7 +934,7 @@ export class AttributesController extends ConsumptionBaseController { try { parsedSuccessorParams = AttributeSuccessorParams.from(successorParams); } catch (e: unknown) { - return ValidationResult.error(CoreErrors.attributes.successorIsNotAValidAttribute(e)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorIsNotAValidAttribute(e)); } const successor = LocalAttribute.from({ @@ -949,48 +949,48 @@ export class AttributesController extends ConsumptionBaseController { if (parsedSuccessorParams.id) { const successor = await this.getLocalAttribute(CoreId.from(parsedSuccessorParams.id)); - if (successor) return ValidationResult.error(CoreErrors.attributes.successorMustNotYetExist()); + if (successor) return ValidationResult.error(ConsumptionCoreErrors.attributes.successorMustNotYetExist()); } if (successor.succeeds && !predecessorId.equals(successor.succeeds.toString())) { - return ValidationResult.error(CoreErrors.attributes.setPredecessorIdDoesNotMatchActualPredecessorId()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.setPredecessorIdDoesNotMatchActualPredecessorId()); } if (successor.succeededBy) { - return ValidationResult.error(CoreErrors.attributes.successorMustNotHaveASuccessor()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorMustNotHaveASuccessor()); } if (successor.parentId) { - return ValidationResult.error(CoreErrors.attributes.cannotSucceedChildOfComplexAttribute(predecessorId.toString())); + return ValidationResult.error(ConsumptionCoreErrors.attributes.cannotSucceedChildOfComplexAttribute(predecessorId.toString())); } const predecessor = await this.getLocalAttribute(predecessorId); if (!predecessor) { - return ValidationResult.error(CoreErrors.attributes.predecessorDoesNotExist()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.predecessorDoesNotExist()); } if (predecessor.succeededBy) { - return ValidationResult.error(CoreErrors.attributes.cannotSucceedAttributesWithASuccessor(predecessor.succeededBy.toString())); + return ValidationResult.error(ConsumptionCoreErrors.attributes.cannotSucceedAttributesWithASuccessor(predecessor.succeededBy.toString())); } if (predecessor.parentId) { - return ValidationResult.error(CoreErrors.attributes.cannotSucceedChildOfComplexAttribute(predecessorId.toString())); + return ValidationResult.error(ConsumptionCoreErrors.attributes.cannotSucceedChildOfComplexAttribute(predecessorId.toString())); } if (!predecessor.content.owner.equals(CoreAddress.from(successor.content.owner))) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeOwner()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeOwner()); } if (successor.content.constructor !== predecessor.content.constructor) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeContentType()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeContentType()); } if (predecessor.content.value.constructor !== successor.content.value.constructor) { - return ValidationResult.error(CoreErrors.attributes.successionMustNotChangeValueType()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionMustNotChangeValueType()); } if (predecessor.hasDeletionInfo() && predecessor.deletionInfo.deletionStatus !== LocalAttributeDeletionStatus.DeletionRequestRejected) { - return ValidationResult.error(CoreErrors.attributes.cannotSucceedAttributesWithDeletionInfo()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.cannotSucceedAttributesWithDeletionInfo()); } return ValidationResult.success(); @@ -1050,7 +1050,7 @@ export class AttributesController extends ConsumptionBaseController { if (attr.succeededBy) { const successor = await this.getLocalAttribute(attr.succeededBy); if (!successor) { - throw CoreErrors.attributes.successorDoesNotExist(); + throw ConsumptionCoreErrors.attributes.successorDoesNotExist(); } await this.detachSuccessor(successor); } @@ -1104,7 +1104,7 @@ export class AttributesController extends ConsumptionBaseController { if (predecessor.succeededBy) { const successor = await this.getLocalAttribute(predecessor.succeededBy); if (!successor) { - return ValidationResult.error(CoreErrors.attributes.successorDoesNotExist()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successorDoesNotExist()); } } return ValidationResult.success(); @@ -1113,7 +1113,7 @@ export class AttributesController extends ConsumptionBaseController { private validateSharedAttributes(sharedAttributes: LocalAttribute[]): ValidationResult { for (const sharedAttribute of sharedAttributes) { if (!sharedAttribute.isShared()) { - return ValidationResult.error(CoreErrors.attributes.isNotSharedAttribute(sharedAttribute.id)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.isNotSharedAttribute(sharedAttribute.id)); } } return ValidationResult.success(); @@ -1127,7 +1127,7 @@ export class AttributesController extends ConsumptionBaseController { private async detachAttributeCopies(sharedAttributes: LocalAttribute[]): Promise { for (const sharedAttribute of sharedAttributes) { if (!sharedAttribute.isShared()) { - throw CoreErrors.attributes.isNotSharedAttribute(sharedAttribute.id); + throw ConsumptionCoreErrors.attributes.isNotSharedAttribute(sharedAttribute.id); } sharedAttribute.shareInfo.sourceAttribute = undefined; await this.updateAttributeUnsafe(sharedAttribute); @@ -1142,7 +1142,7 @@ export class AttributesController extends ConsumptionBaseController { } private async transferDefault(attribute: LocalAttribute): Promise { - if (!this.setDefaultRepositoryAttributes) throw CoreErrors.attributes.setDefaultRepositoryAttributesIsDisabled(); + if (!this.setDefaultRepositoryAttributes) throw ConsumptionCoreErrors.attributes.setDefaultRepositoryAttributesIsDisabled(); if (!attribute.isDefault) return; const valueType = attribute.content.value.constructor.name; diff --git a/packages/consumption/src/modules/attributes/local/LocalAttribute.ts b/packages/consumption/src/modules/attributes/local/LocalAttribute.ts index 78e3552e3..ca76282c0 100644 --- a/packages/consumption/src/modules/attributes/local/LocalAttribute.ts +++ b/packages/consumption/src/modules/attributes/local/LocalAttribute.ts @@ -11,8 +11,8 @@ import { import { CoreAddress, CoreDate, CoreId, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CoreSynchronizable, ICoreSynchronizable } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; +import { ConsumptionCoreErrors } from "../../../consumption/ConsumptionCoreErrors"; import { ConsumptionIds } from "../../../consumption/ConsumptionIds"; -import { CoreErrors } from "../../../consumption/CoreErrors"; import { ILocalAttributeDeletionInfo, LocalAttributeDeletionInfo, LocalAttributeDeletionInfoJSON, LocalAttributeDeletionStatus } from "./LocalAttributeDeletionInfo"; import { ILocalAttributeShareInfo, LocalAttributeShareInfo, LocalAttributeShareInfoJSON } from "./LocalAttributeShareInfo"; @@ -199,19 +199,19 @@ export class LocalAttribute extends CoreSynchronizable implements ILocalAttribut public setDeletionInfo(deletionInfo: LocalAttributeDeletionInfo, ownAddress: CoreAddress): this { if (this.isRepositoryAttribute(ownAddress)) { - throw CoreErrors.attributes.cannotSetDeletionInfoOfRepositoryAttributes(); + throw ConsumptionCoreErrors.attributes.cannotSetDeletionInfoOfRepositoryAttributes(); } if (this.isOwnSharedAttribute(ownAddress) && !this.isOwnSharedAttributeDeletionInfo(deletionInfo)) { - throw CoreErrors.attributes.invalidDeletionInfoOfOwnSharedAttribute(); + throw ConsumptionCoreErrors.attributes.invalidDeletionInfoOfOwnSharedAttribute(); } if (this.isPeerSharedAttribute() && !this.isPeerSharedAttributeDeletionInfo(deletionInfo)) { - throw CoreErrors.attributes.invalidDeletionInfoOfPeerSharedAttribute(); + throw ConsumptionCoreErrors.attributes.invalidDeletionInfoOfPeerSharedAttribute(); } if (this.isThirdPartyOwnedRelationshipAttribute(ownAddress) && !this.isThirdPartyOwnedRelationshipAttributeDeletionInfo(deletionInfo)) { - throw CoreErrors.attributes.invalidDeletionInfoOfThirdPartyOwnedRelationshipAttribute(); + throw ConsumptionCoreErrors.attributes.invalidDeletionInfoOfThirdPartyOwnedRelationshipAttribute(); } this.deletionInfo = deletionInfo; diff --git a/packages/consumption/src/modules/notifications/NotificationsController.ts b/packages/consumption/src/modules/notifications/NotificationsController.ts index 84544b746..f4b692cdb 100644 --- a/packages/consumption/src/modules/notifications/NotificationsController.ts +++ b/packages/consumption/src/modules/notifications/NotificationsController.ts @@ -1,7 +1,7 @@ import { Event, EventBus } from "@js-soft/ts-utils"; import { Notification, NotificationItem } from "@nmshd/content"; import { CoreAddress, CoreId } from "@nmshd/core-types"; -import { Message, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { Message, SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts index ab064c087..3ef94b1e6 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/OwnSharedAttributeDeletedByOwnerNotificationItemProcessor.ts @@ -3,7 +3,7 @@ import { OwnSharedAttributeDeletedByOwnerNotificationItem } from "@nmshd/content import { CoreDate } from "@nmshd/core-types"; import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus, OwnSharedAttributeDeletedByOwnerEvent } from "../../../attributes"; import { ValidationResult } from "../../../common"; import { LocalNotification } from "../../local/LocalNotification"; @@ -26,11 +26,11 @@ export class OwnSharedAttributeDeletedByOwnerNotificationItemProcessor extends A if (!attribute) return ValidationResult.success(); if (!attribute.isPeerSharedAttribute()) { - return ValidationResult.error(CoreErrors.attributes.isNotPeerSharedAttribute(notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.isNotPeerSharedAttribute(notificationItem.attributeId)); } if (!notification.peer.equals(attribute.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts index 7e23fe183..e8edccdb0 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/PeerSharedAttributeDeletedByPeerNotificationItemProcessor.ts @@ -3,7 +3,7 @@ import { PeerSharedAttributeDeletedByPeerNotificationItem } from "@nmshd/content import { CoreDate } from "@nmshd/core-types"; import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { PeerSharedAttributeDeletedByPeerEvent } from "../../../attributes"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../../attributes/local/LocalAttributeDeletionInfo"; import { ValidationResult } from "../../../common"; @@ -27,11 +27,11 @@ export class PeerSharedAttributeDeletedByPeerNotificationItemProcessor extends A if (!attribute) return ValidationResult.success(); if (!attribute.isOwnSharedAttribute(this.currentIdentityAddress)) { - return ValidationResult.error(CoreErrors.attributes.isNotOwnSharedAttribute(notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.isNotOwnSharedAttribute(notificationItem.attributeId)); } if (!notification.peer.equals(attribute.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts index 1c3a37c0d..3eddc64f2 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeDeleted/ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor.ts @@ -3,7 +3,7 @@ import { ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem } fro import { CoreDate } from "@nmshd/core-types"; import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { ThirdPartyOwnedRelationshipAttributeDeletedByPeerEvent } from "../../../attributes"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../../attributes/local/LocalAttributeDeletionInfo"; import { ValidationResult } from "../../../common"; @@ -27,11 +27,11 @@ export class ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemPr if (!attribute) return ValidationResult.success(); if (!attribute.isThirdPartyOwnedRelationshipAttribute(this.currentIdentityAddress)) { - return ValidationResult.error(CoreErrors.attributes.isNotThirdPartyOwnedRelationshipAttribute(notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.isNotThirdPartyOwnedRelationshipAttribute(notificationItem.attributeId)); } if (!notification.peer.equals(attribute.shareInfo.peer)) { - return ValidationResult.error(CoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); + return ValidationResult.error(ConsumptionCoreErrors.attributes.senderIsNotPeerOfSharedAttribute(notification.peer, notificationItem.attributeId)); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.ts b/packages/consumption/src/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.ts index 65f5544dd..c0b79fb8a 100644 --- a/packages/consumption/src/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.ts +++ b/packages/consumption/src/modules/notifications/itemProcessors/attributeSucceeded/PeerSharedAttributeSucceededNotificationItemProcessor.ts @@ -2,7 +2,7 @@ import { ILogger } from "@js-soft/logging-abstractions"; import { IdentityAttribute, PeerSharedAttributeSucceededNotificationItem } from "@nmshd/content"; import { TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionController } from "../../../../consumption/ConsumptionController"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { LocalAttribute, PeerSharedAttributeSucceededEvent } from "../../../attributes"; import { ValidationResult } from "../../../common"; import { LocalNotification } from "../../local/LocalNotification"; @@ -21,7 +21,7 @@ export class PeerSharedAttributeSucceededNotificationItemProcessor extends Abstr notification: LocalNotification ): Promise { if (!notification.peer.equals(notificationItem.successorContent.owner)) { - return ValidationResult.error(CoreErrors.attributes.successionPeerIsNotOwner()); + return ValidationResult.error(ConsumptionCoreErrors.attributes.successionPeerIsNotOwner()); } const successorParams = { diff --git a/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts b/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts index 75f9768c9..74b970f7b 100644 --- a/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts +++ b/packages/consumption/src/modules/requests/incoming/DecideRequestParametersValidator.ts @@ -1,6 +1,6 @@ import { RequestItem, RequestItemGroup } from "@nmshd/content"; import { CoreId } from "@nmshd/core-types"; -import { CoreErrors } from "../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../consumption/ConsumptionCoreErrors"; import { ValidationResult } from "../../common/ValidationResult"; import { LocalRequest } from "../local/LocalRequest"; import { DecideRequestItemGroupParametersJSON, isDecideRequestItemGroupParametersJSON } from "./decide/DecideRequestItemGroupParameters"; @@ -14,7 +14,9 @@ export class DecideRequestParametersValidator { } if (params.items.length !== request.content.items.length) { - return ValidationResult.error(CoreErrors.requests.decideValidation.invalidNumberOfItems("The number of items in the Request and the Response do not match.")); + return ValidationResult.error( + ConsumptionCoreErrors.requests.decideValidation.invalidNumberOfItems("The number of items in the Request and the Response do not match.") + ); } const validationResults = request.content.items.map((requestItem, index) => this.checkItemOrGroup(requestItem, params.items[index], params.accept)); @@ -35,18 +37,18 @@ export class DecideRequestParametersValidator { private checkItem(requestItem: RequestItem, response: DecideRequestItemParametersJSON | DecideRequestItemGroupParametersJSON, isRequestAccepted: boolean): ValidationResult { if (isDecideRequestItemGroupParametersJSON(response)) { - return ValidationResult.error(CoreErrors.requests.decideValidation.requestItemAnsweredAsRequestItemGroup()); + return ValidationResult.error(ConsumptionCoreErrors.requests.decideValidation.requestItemAnsweredAsRequestItemGroup()); } if (!isRequestAccepted && response.accept) { return ValidationResult.error( - CoreErrors.requests.decideValidation.itemAcceptedButRequestNotAccepted("The RequestItem was accepted, but the Request was not accepted.") + ConsumptionCoreErrors.requests.decideValidation.itemAcceptedButRequestNotAccepted("The RequestItem was accepted, but the Request was not accepted.") ); } if (isRequestAccepted && requestItem.mustBeAccepted && !response.accept) { return ValidationResult.error( - CoreErrors.requests.decideValidation.mustBeAcceptedItemNotAccepted("The RequestItem is flagged as 'mustBeAccepted', but it was not accepted.") + ConsumptionCoreErrors.requests.decideValidation.mustBeAcceptedItemNotAccepted("The RequestItem is flagged as 'mustBeAccepted', but it was not accepted.") ); } @@ -59,12 +61,12 @@ export class DecideRequestParametersValidator { isRequestAccepted: boolean ): ValidationResult { if (isDecideRequestItemParametersJSON(responseItemGroup)) { - return ValidationResult.error(CoreErrors.requests.decideValidation.requestItemGroupAnsweredAsRequestItem()); + return ValidationResult.error(ConsumptionCoreErrors.requests.decideValidation.requestItemGroupAnsweredAsRequestItem()); } if (responseItemGroup.items.length !== requestItemGroup.items.length) { return ValidationResult.error( - CoreErrors.requests.decideValidation.invalidNumberOfItems("The number of items in the RequestItemGroup and the ResponseItemGroup do not match.") + ConsumptionCoreErrors.requests.decideValidation.invalidNumberOfItems("The number of items in the RequestItemGroup and the ResponseItemGroup do not match.") ); } diff --git a/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts b/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts index 18e3bb185..7ccdd8819 100644 --- a/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts +++ b/packages/consumption/src/modules/requests/incoming/IncomingRequestsController.ts @@ -2,13 +2,13 @@ import { ServalError } from "@js-soft/ts-serval"; import { EventBus } from "@js-soft/ts-utils"; import { RequestItem, RequestItemGroup, Response, ResponseItemDerivations, ResponseItemGroup, ResponseResult } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; -import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../../consumption/ConsumptionControllerName"; +import { ConsumptionCoreErrors } from "../../../consumption/ConsumptionCoreErrors"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; import { ConsumptionIds } from "../../../consumption/ConsumptionIds"; -import { CoreErrors } from "../../../consumption/CoreErrors"; import { ValidationResult } from "../../common/ValidationResult"; import { IncomingRequestReceivedEvent, IncomingRequestStatusChangedEvent } from "../events"; import { RequestItemProcessorRegistry } from "../itemProcessors/RequestItemProcessorRegistry"; @@ -178,7 +178,7 @@ export class IncomingRequestsController extends ConsumptionBaseController { if (relationship && !possibleStatuses.includes(relationship.status)) { return ValidationResult.error( - CoreErrors.requests.wrongRelationshipStatus( + ConsumptionCoreErrors.requests.wrongRelationshipStatus( `You cannot decide a request from '${request.peer.toString()}' since the relationship is in status '${relationship.status}'.` ) ); @@ -231,10 +231,10 @@ export class IncomingRequestsController extends ConsumptionBaseController { return await processor.canReject(requestItem, params, request); } catch (e) { if (e instanceof ServalError) { - return ValidationResult.error(CoreErrors.requests.servalErrorDuringRequestItemProcessing(e)); + return ValidationResult.error(ConsumptionCoreErrors.requests.servalErrorDuringRequestItemProcessing(e)); } - return ValidationResult.error(CoreErrors.requests.unexpectedErrorDuringRequestItemProcessing(e)); + return ValidationResult.error(ConsumptionCoreErrors.requests.unexpectedErrorDuringRequestItemProcessing(e)); } } diff --git a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts index e7fefe558..043449215 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.ts @@ -1,6 +1,6 @@ import { CreateAttributeAcceptResponseItem, CreateAttributeRequestItem, IdentityAttribute, RejectResponseItem, Request, ResponseItemResult } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { LocalAttribute } from "../../../attributes"; import { ValidationResult } from "../../../common/ValidationResult"; import { AcceptRequestItemParametersJSON } from "../../incoming/decide/AcceptRequestItemParameters"; @@ -24,20 +24,22 @@ export class CreateAttributeRequestItemProcessor extends GenericRequestItemProce if (senderIsAttributeOwner) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("Cannot create own IdentityAttributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead.") + ConsumptionCoreErrors.requests.invalidRequestItem( + "Cannot create own IdentityAttributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead." + ) ); } if (typeof recipient !== "undefined") { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( "The owner of the provided IdentityAttribute for the `attribute` property can only be the Recipient's Address or an empty string. The latter will default to the Recipient's Address." ) ); } return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( "The owner of the provided IdentityAttribute for the `attribute` property can only be an empty string. It will default to the Recipient's Address." ) ); @@ -49,14 +51,14 @@ export class CreateAttributeRequestItemProcessor extends GenericRequestItemProce if (typeof recipient !== "undefined") { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address, the Recipient's Address or an empty string. The latter will default to the Recipient's Address." ) ); } return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( "The owner of the provided RelationshipAttribute for the `attribute` property can only be the Sender's Address or an empty string. The latter will default to the Recipient's Address." ) ); diff --git a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts index a3a09e5bc..baa3ebd8c 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts @@ -1,6 +1,6 @@ import { AcceptResponseItem, DeleteAttributeAcceptResponseItem, DeleteAttributeRequestItem, RejectResponseItem, Request, ResponseItemResult } from "@nmshd/content"; import { CoreAddress, CoreDate } from "@nmshd/core-types"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../../attributes"; import { ValidationResult } from "../../../common/ValidationResult"; import { GenericRequestItemProcessor } from "../GenericRequestItemProcessor"; @@ -10,27 +10,28 @@ import { AcceptDeleteAttributeRequestItemParameters, AcceptDeleteAttributeReques export class DeleteAttributeRequestItemProcessor extends GenericRequestItemProcessor { public override async canCreateOutgoingRequestItem(requestItem: DeleteAttributeRequestItem, _request: Request, recipient?: CoreAddress): Promise { const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId); - if (!attribute) return ValidationResult.error(CoreErrors.requests.invalidRequestItem(`The Attribute '${requestItem.attributeId.toString()}' could not be found.`)); + if (!attribute) + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem(`The Attribute '${requestItem.attributeId.toString()}' could not be found.`)); if (!attribute.isOwnSharedAttribute(this.accountController.identity.address)) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( `The Attribute '${requestItem.attributeId.toString()}' is not an own shared Attribute. You can only request the deletion of own shared Attributes.` ) ); } if (attribute.deletionInfo?.deletionStatus === LocalAttributeDeletionStatus.DeletedByPeer) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("The Attribute was already deleted by the peer.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem("The Attribute was already deleted by the peer.")); } if (attribute.deletionInfo?.deletionStatus === LocalAttributeDeletionStatus.ToBeDeletedByPeer) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("The peer already accepted the deletion of the Attribute.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem("The peer already accepted the deletion of the Attribute.")); } if (!attribute.shareInfo.peer.equals(recipient)) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("The deletion of a shared Attribute can only be requested from the peer the Attribute is shared with.") + ConsumptionCoreErrors.requests.invalidRequestItem("The deletion of a shared Attribute can only be requested from the peer the Attribute is shared with.") ); } @@ -49,11 +50,11 @@ export class DeleteAttributeRequestItemProcessor extends GenericRequestItemProce const deletionDate = parsedParams.deletionDate; if (!deletionDate.dateTime.isValid) { - return ValidationResult.error(CoreErrors.requests.invalidAcceptParameters("The deletionDate is invalid.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidAcceptParameters("The deletionDate is invalid.")); } if (deletionDate.isBefore(CoreDate.utc())) { - return ValidationResult.error(CoreErrors.requests.invalidAcceptParameters("The deletionDate must be in the future.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidAcceptParameters("The deletionDate must be in the future.")); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.ts index 3fc1f2f6a..0807776f3 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.ts @@ -3,7 +3,7 @@ import { FreeTextAcceptResponseItem, FreeTextRequestItem, ResponseItemResult } f import { ValidationResult } from "../../../common/ValidationResult"; import { GenericRequestItemProcessor } from "../GenericRequestItemProcessor"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { AcceptFreeTextRequestItemParameters, AcceptFreeTextRequestItemParametersJSON } from "./AcceptFreeTextRequestItemParameters"; export class FreeTextRequestItemProcessor extends GenericRequestItemProcessor { @@ -13,7 +13,7 @@ export class FreeTextRequestItemProcessor extends GenericRequestItemProcessor( (x) => x.attribute )} or ${nameof((x) => x.attributeId)}.` diff --git a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts index 633e36f07..7594babb6 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.ts @@ -14,9 +14,9 @@ import { ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; import { CoreAddress, CoreId } from "@nmshd/core-types"; -import { RelationshipStatus, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { RelationshipStatus, TransportCoreErrors } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { AttributeSuccessorParams, LocalAttributeDeletionStatus, LocalAttributeShareInfo, PeerSharedAttributeSucceededEvent } from "../../../attributes"; import { LocalAttribute } from "../../../attributes/local/LocalAttribute"; import { ValidationResult } from "../../../common/ValidationResult"; @@ -44,7 +44,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess if (requestItem.query instanceof RelationshipAttributeQuery && !["", this.currentIdentityAddress.toString()].includes(requestItem.query.owner.toString())) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( "The owner of the given `query` can only be an empty string or yourself. This is because you can only request RelationshipAttributes using a ReadAttributeRequestitem with a RelationshipAttributeQuery where the Recipient of the Request or yourself is the owner. And in order to avoid mistakes, the Recipient automatically will become the owner of the RelationshipAttribute later on if the owner of the `query` is an empty string." ) ); @@ -64,7 +64,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess if (parsedParams.isWithExistingAttribute()) { if (requestItem.query instanceof RelationshipAttributeQuery) { return ValidationResult.error( - CoreErrors.requests.invalidAcceptParameters("When responding to a RelationshipAttributeQuery, only new RelationshipAttributes may be provided.") + ConsumptionCoreErrors.requests.invalidAcceptParameters("When responding to a RelationshipAttributeQuery, only new RelationshipAttributes may be provided.") ); } @@ -79,7 +79,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess if (requestItem.query instanceof IdentityAttributeQuery && attribute instanceof IdentityAttribute && this.accountController.identity.isMe(attribute.owner)) { if (foundLocalAttribute.isShared()) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch( + ConsumptionCoreErrors.requests.attributeQueryMismatch( "The provided IdentityAttribute is a shared copy of a RepositoryAttribute. You can only share RepositoryAttributes." ) ); @@ -104,7 +104,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess } return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch( + ConsumptionCoreErrors.requests.attributeQueryMismatch( `The provided IdentityAttribute is outdated. You have already shared the successor '${ownSharedIdentityAttributeSuccessors[0].shareInfo.sourceAttribute}' of it.` ) ); @@ -120,7 +120,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess if (typeof foundLocalAttribute.shareInfo.sourceAttribute !== "undefined") { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch( + ConsumptionCoreErrors.requests.attributeQueryMismatch( "When responding to a ThirdPartyRelationshipAttributeQuery, only RelationshipAttributes that are not a copy of a sourceAttribute may be provided." ) ); @@ -134,7 +134,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess !queriedThirdParties.includes(foundLocalAttribute.shareInfo.peer.toString()) ) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch( + ConsumptionCoreErrors.requests.attributeQueryMismatch( "The provided RelationshipAttribute exists in the context of a Relationship with a third party that should not be involved." ) ); @@ -148,13 +148,13 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess const nonPendingRelationshipsToPeer = await this.accountController.relationships.getRelationships(queryForNonPendingRelationships); if (nonPendingRelationshipsToPeer.length === 0) { - return ValidationResult.error(CoreErrors.requests.cannotShareRelationshipAttributeOfPendingRelationship()); + return ValidationResult.error(ConsumptionCoreErrors.requests.cannotShareRelationshipAttributeOfPendingRelationship()); } } } else if (parsedParams.isWithNewAttribute()) { if (requestItem.query instanceof ThirdPartyRelationshipAttributeQuery) { return ValidationResult.error( - CoreErrors.requests.invalidAcceptParameters( + ConsumptionCoreErrors.requests.invalidAcceptParameters( "When responding to a ThirdPartyRelationshipAttributeQuery, only RelationshipAttributes that already exist may be provided." ) ); @@ -170,7 +170,7 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess if (typeof attribute === "undefined") { return ValidationResult.error( - CoreErrors.requests.invalidAcceptParameters( + ConsumptionCoreErrors.requests.invalidAcceptParameters( `You have to specify either ${nameof( (x) => x.newAttribute )} or ${nameof((x) => x.existingAttributeId)}.` @@ -187,7 +187,9 @@ export class ReadAttributeRequestItemProcessor extends GenericRequestItemProcess attribute.confidentiality === RelationshipAttributeConfidentiality.Private ) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The confidentiality of the provided RelationshipAttribute is private. Therefore you are not allowed to share it.") + ConsumptionCoreErrors.requests.attributeQueryMismatch( + "The confidentiality of the provided RelationshipAttribute is private. Therefore you are not allowed to share it." + ) ); } diff --git a/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts index c0b027040..21799071e 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.ts @@ -11,7 +11,7 @@ import { import { CoreAddress } from "@nmshd/core-types"; import { RelationshipStatus } from "@nmshd/transport"; import _ from "lodash"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { LocalAttributeDeletionStatus } from "../../../attributes"; import { ValidationResult } from "../../../common/ValidationResult"; import { AcceptRequestItemParametersJSON } from "../../incoming/decide/AcceptRequestItemParameters"; @@ -24,7 +24,9 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (typeof foundAttribute === "undefined") { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem(`The Attribute with the given sourceAttributeId '${requestItem.sourceAttributeId.toString()}' could not be found.`) + ConsumptionCoreErrors.requests.invalidRequestItem( + `The Attribute with the given sourceAttributeId '${requestItem.sourceAttributeId.toString()}' could not be found.` + ) ); } @@ -32,7 +34,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (!_.isEqual(foundAttribute.content.toJSON(), requestItemAttributeJSON)) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( `The Attribute with the given sourceAttributeId '${requestItem.sourceAttributeId.toString()}' does not match the given Attribute.` ) ); @@ -41,7 +43,9 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (requestItem.attribute instanceof IdentityAttribute && this.accountController.identity.isMe(requestItem.attribute.owner)) { if (foundAttribute.isShared()) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("The provided IdentityAttribute is a shared copy of a RepositoryAttribute. You can only share RepositoryAttributes.") + ConsumptionCoreErrors.requests.invalidRequestItem( + "The provided IdentityAttribute is a shared copy of a RepositoryAttribute. You can only share RepositoryAttributes." + ) ); } @@ -54,7 +58,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if ((await this.consumptionController.attributes.getLocalAttributes(query)).length > 0) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( `The IdentityAttribute with the given sourceAttributeId '${requestItem.sourceAttributeId.toString()}' is already shared with the peer.` ) ); @@ -67,7 +71,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (ownSharedIdentityAttributeSuccessors.length > 0) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( `The provided IdentityAttribute is outdated. Its successor '${ownSharedIdentityAttributeSuccessors[0].shareInfo?.sourceAttribute}' is already shared with the peer.` ) ); @@ -80,7 +84,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (ownSharedIdentityAttributePredecessors.length > 0) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem( + ConsumptionCoreErrors.requests.invalidRequestItem( `The predecessor '${ownSharedIdentityAttributePredecessors[0].shareInfo?.sourceAttribute}' of the IdentityAttribute is already shared with the peer. Instead of sharing it, you should notify the peer about the Attribute succession.` ) ); @@ -96,7 +100,9 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces } if (typeof foundAttribute.shareInfo.sourceAttribute !== "undefined") { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("You can only share RelationshipAttributes that are not a copy of a sourceAttribute.")); + return ValidationResult.error( + ConsumptionCoreErrors.requests.invalidRequestItem("You can only share RelationshipAttributes that are not a copy of a sourceAttribute.") + ); } if (typeof recipient !== "undefined") { @@ -109,7 +115,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces if (foundAttribute.shareInfo.peer.equals(recipient) || thirdPartyRelationshipAttribute.length > 0) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("The provided RelationshipAttribute already exists in the context of the Relationship with the peer.") + ConsumptionCoreErrors.requests.invalidRequestItem("The provided RelationshipAttribute already exists in the context of the Relationship with the peer.") ); } } @@ -122,7 +128,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces const nonPendingRelationshipsToPeer = await this.accountController.relationships.getRelationships(queryForNonPendingRelationships); if (nonPendingRelationshipsToPeer.length === 0) { - return ValidationResult.error(CoreErrors.requests.cannotShareRelationshipAttributeOfPendingRelationship()); + return ValidationResult.error(ConsumptionCoreErrors.requests.cannotShareRelationshipAttributeOfPendingRelationship()); } } @@ -137,7 +143,7 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces const ownerIsCurrentIdentity = requestItem.attribute.owner.equals(this.currentIdentityAddress); if (!ownerIsCurrentIdentity) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") + ConsumptionCoreErrors.requests.invalidRequestItem("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") ); } @@ -146,12 +152,12 @@ export class ShareAttributeRequestItemProcessor extends GenericRequestItemProces private static canCreateWithRelationshipAttribute(attribute: RelationshipAttribute, recipient?: CoreAddress) { if (attribute.owner.equals(recipient)) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("It doesn't make sense to share a RelationshipAttribute with its owner.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem("It doesn't make sense to share a RelationshipAttribute with its owner.")); } if (attribute.confidentiality === RelationshipAttributeConfidentiality.Private) { return ValidationResult.error( - CoreErrors.requests.invalidRequestItem("The confidentiality of the given `attribute` is private. Therefore you are not allowed to share it.") + ConsumptionCoreErrors.requests.invalidRequestItem("The confidentiality of the given `attribute` is private. Therefore you are not allowed to share it.") ); } diff --git a/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts b/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts index 3b6366ea7..4b4b5cc37 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/utility/validateAttributeMatchesWithQuery.ts @@ -8,7 +8,7 @@ import { ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { ValidationResult } from "../../../common/ValidationResult"; export default function validateAttributeMatchesWithQuery( @@ -31,7 +31,7 @@ export default function validateAttributeMatchesWithQuery( if (result.isError()) return result; } else { return ValidationResult.error( - CoreErrors.requests.unexpectedErrorDuringRequestItemProcessing( + ConsumptionCoreErrors.requests.unexpectedErrorDuringRequestItemProcessing( "The query is not of a known type. Only the IdentityAttributeQuery, IQLQuery, RelationshipAttributeQuery or ThirdPartyRelationshipAttributeQuery can be used." ) ); @@ -42,14 +42,14 @@ export default function validateAttributeMatchesWithQuery( (typeof query.validFrom === "undefined" && typeof attribute.validFrom !== "undefined") || (typeof query.validFrom !== "undefined" && typeof attribute.validFrom !== "undefined" && query.validFrom.isBefore(attribute.validFrom)) ) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not valid in the queried time frame.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided Attribute is not valid in the queried time frame.")); } if ( (typeof query.validTo === "undefined" && typeof attribute.validTo !== "undefined") || (typeof query.validTo !== "undefined" && typeof attribute.validTo !== "undefined" && query.validTo.isAfter(attribute.validTo)) ) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not valid in the queried time frame.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided Attribute is not valid in the queried time frame.")); } } @@ -62,24 +62,28 @@ function validateAttributeMatchesWithIdentityAttributeQuery( recipient: CoreAddress ): ValidationResult { if (!(attribute instanceof IdentityAttribute)) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not an IdentityAttribute, but an IdentityAttribute was queried.")); + return ValidationResult.error( + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided Attribute is not an IdentityAttribute, but an IdentityAttribute was queried.") + ); } const recipientIsAttributeOwner = recipient.equals(attribute.owner); if (!recipientIsAttributeOwner) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") ); } if (query.valueType !== attribute.value.constructor.name) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute is not of the queried IdentityAttribute value type.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute is not of the queried IdentityAttribute value type.")); } if (typeof query.tags !== "undefined" && query.tags.length !== 0) { if (attribute.tags === undefined || attribute.tags.length === 0 || !query.tags.some((aQueriedTag) => attribute.tags!.includes(aQueriedTag))) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The tags of the provided IdentityAttribute do not contain at least one queried tag.")); + return ValidationResult.error( + ConsumptionCoreErrors.requests.attributeQueryMismatch("The tags of the provided IdentityAttribute do not contain at least one queried tag.") + ); } } @@ -89,7 +93,9 @@ function validateAttributeMatchesWithIdentityAttributeQuery( function validateAttributeMatchesWithIQLQuery(query: IQLQuery, attribute: IdentityAttribute | RelationshipAttribute, recipient: CoreAddress): ValidationResult { if (!(attribute instanceof IdentityAttribute)) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not an IdentityAttribute. Currently, only IdentityAttributes can be queried by an IQLQuery.") + ConsumptionCoreErrors.requests.attributeQueryMismatch( + "The provided Attribute is not an IdentityAttribute. Currently, only IdentityAttributes can be queried by an IQLQuery." + ) ); } @@ -97,7 +103,7 @@ function validateAttributeMatchesWithIQLQuery(query: IQLQuery, attribute: Identi if (!recipientIsAttributeOwner) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided IdentityAttribute belongs to someone else. You can only share own IdentityAttributes.") ); } @@ -111,7 +117,7 @@ function validateAttributeMatchesWithRelationshipAttributeQuery( ): ValidationResult { if (!(attribute instanceof RelationshipAttribute)) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not a RelationshipAttribute, but a RelationshipAttribute was queried.") + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided Attribute is not a RelationshipAttribute, but a RelationshipAttribute was queried.") ); } @@ -119,34 +125,38 @@ function validateAttributeMatchesWithRelationshipAttributeQuery( const queriedOwnerIsEmpty = query.owner.equals(""); if (!queriedOwnerIsEmpty && !query.owner.equals(attribute.owner)) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not belong to the queried owner.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not belong to the queried owner.")); } if (queriedOwnerIsEmpty && !recipientIsAttributeOwner) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("You are not the owner of the provided RelationshipAttribute, but an empty string was specified for the owner of the query.") + ConsumptionCoreErrors.requests.attributeQueryMismatch( + "You are not the owner of the provided RelationshipAttribute, but an empty string was specified for the owner of the query." + ) ); } if (query.key !== attribute.key) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried key.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried key.")); } if (query.attributeCreationHints.confidentiality !== attribute.confidentiality) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried confidentiality.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried confidentiality.")); } if (query.attributeCreationHints.valueType !== attribute.value.constructor.name) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute is not of the queried RelationshipAttribute value type.")); + return ValidationResult.error( + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute is not of the queried RelationshipAttribute value type.") + ); } if (!(attribute.value instanceof Consent)) { if (query.attributeCreationHints.title !== attribute.value.title) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried title.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried title.")); } if (query.attributeCreationHints.description !== attribute.value.description) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried description.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried description.")); } } @@ -161,7 +171,7 @@ function validateAttributeMatchesWithThirdPartyRelationshipAttributeQuery( ): ValidationResult { if (!(attribute instanceof RelationshipAttribute)) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch("The provided Attribute is not a RelationshipAttribute, but a RelationshipAttribute was queried.") + ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided Attribute is not a RelationshipAttribute, but a RelationshipAttribute was queried.") ); } @@ -177,19 +187,19 @@ function validateAttributeMatchesWithThirdPartyRelationshipAttributeQuery( !queriedThirdParties.includes(attribute.owner.toString()) && (!queriedThirdParties.includes("") || (recipientIsAttributeOwner && !queriedThirdParties.includes(recipient.toString())))) ) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not belong to a queried owner.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not belong to a queried owner.")); } if (query.owner === "" && !recipientIsAttributeOwner && !queriedThirdParties.includes("") && !queriedThirdParties.includes(attribute.owner.toString())) { return ValidationResult.error( - CoreErrors.requests.attributeQueryMismatch( + ConsumptionCoreErrors.requests.attributeQueryMismatch( "Neither you nor one of the involved third parties is the owner of the provided RelationshipAttribute, but an empty string was specified for the owner of the query." ) ); } if (query.key !== attribute.key) { - return ValidationResult.error(CoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried key.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.attributeQueryMismatch("The provided RelationshipAttribute does not have the queried key.")); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts b/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts index c598eb8e8..4bb90f853 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/utility/validateQuery.ts @@ -1,7 +1,7 @@ import { IdentityAttributeQuery, IQLQuery, RelationshipAttributeQuery, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; import { validate as iqlValidate } from "@nmshd/iql"; -import { CoreErrors } from "../../../../consumption/CoreErrors"; +import { ConsumptionCoreErrors } from "../../../../consumption/ConsumptionCoreErrors"; import { ValidationResult } from "../../../common/ValidationResult"; export default function validateQuery( @@ -17,7 +17,7 @@ export default function validateQuery( } else if (query instanceof IQLQuery) { const validationResult = iqlValidate(query.queryString); if (!validationResult.isValid) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem(`IQL query syntax error at character ${validationResult.error.location.start.column}`)); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem(`IQL query syntax error at character ${validationResult.error.location.start.column}`)); } } @@ -26,11 +26,11 @@ export default function validateQuery( function validateThirdParty(thirdParty: CoreAddress, sender: CoreAddress, recipient?: CoreAddress): ValidationResult { if (thirdParty.equals(sender)) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party.")); } if (thirdParty.equals(recipient)) { - return ValidationResult.error(CoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party.")); + return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party.")); } return ValidationResult.success(); diff --git a/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts b/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts index 8d0fe37a7..76f95bf6d 100644 --- a/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts +++ b/packages/consumption/src/modules/requests/outgoing/OutgoingRequestsController.ts @@ -1,13 +1,13 @@ import { EventBus } from "@js-soft/ts-utils"; import { DeleteAttributeRequestItem, RelationshipTemplateContent, Request, RequestItem, RequestItemGroup, Response, ResponseItem, ResponseItemGroup } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId, ICoreId } from "@nmshd/core-types"; -import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { Message, Relationship, RelationshipStatus, RelationshipTemplate, SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../../consumption/ConsumptionControllerName"; +import { ConsumptionCoreErrors } from "../../../consumption/ConsumptionCoreErrors"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; import { ConsumptionIds } from "../../../consumption/ConsumptionIds"; -import { CoreErrors } from "../../../consumption/CoreErrors"; import { LocalAttributeDeletionInfo, LocalAttributeDeletionStatus } from "../../attributes"; import { ValidationResult } from "../../common/ValidationResult"; import { OutgoingRequestCreatedAndCompletedEvent, OutgoingRequestCreatedEvent, OutgoingRequestStatusChangedEvent } from "../events"; @@ -46,13 +46,13 @@ export class OutgoingRequestsController extends ConsumptionBaseController { // there should at minimum be a Pending relationship to the peer if (!relationship) { return ValidationResult.error( - CoreErrors.requests.missingRelationship(`You cannot create a request to '${parsedParams.peer.toString()}' since you are not in a relationship.`) + ConsumptionCoreErrors.requests.missingRelationship(`You cannot create a request to '${parsedParams.peer.toString()}' since you are not in a relationship.`) ); } if (!(relationship.status === RelationshipStatus.Pending || relationship.status === RelationshipStatus.Active)) { return ValidationResult.error( - CoreErrors.requests.wrongRelationshipStatus( + ConsumptionCoreErrors.requests.wrongRelationshipStatus( `You cannot create a request to '${parsedParams.peer.toString()}' since the relationship is in status '${relationship.status}'.` ) ); diff --git a/packages/consumption/src/modules/settings/SettingsController.ts b/packages/consumption/src/modules/settings/SettingsController.ts index 489f5a330..dc625514b 100644 --- a/packages/consumption/src/modules/settings/SettingsController.ts +++ b/packages/consumption/src/modules/settings/SettingsController.ts @@ -1,6 +1,6 @@ import { log } from "@js-soft/ts-utils"; import { CoreDate, CoreId } from "@nmshd/core-types"; -import { SynchronizedCollection, CoreErrors as TransportCoreErrors } from "@nmshd/transport"; +import { SynchronizedCollection, TransportCoreErrors } from "@nmshd/transport"; import { ConsumptionBaseController } from "../../consumption/ConsumptionBaseController"; import { ConsumptionController } from "../../consumption/ConsumptionController"; import { ConsumptionControllerName } from "../../consumption/ConsumptionControllerName"; diff --git a/packages/core-types/src/CoreError.ts b/packages/core-types/src/CoreError.ts index 5d3a650a9..49b6fd6b8 100644 --- a/packages/core-types/src/CoreError.ts +++ b/packages/core-types/src/CoreError.ts @@ -1 +1,74 @@ -export class CoreError extends Error {} +import { ILogger } from "@js-soft/logging-abstractions"; +import stringify from "json-stringify-safe"; + +export class CoreError extends Error { + private readonly _code: string; + public get code(): string { + return this._code; + } + + private readonly _reason: string; + public get reason(): string { + return this._reason; + } + + private readonly _data: string; + public get data(): string { + return this._data; + } + + // Intentionally using Date here instead of CoreDate - otherwise CoreError wouldn't be usable within CoreDate + private readonly _time: Date; + public get time(): Date { + return this._time; + } + + private readonly _rootError?: Error; + public get rootError(): Error | undefined { + return this._rootError; + } + + private readonly _context?: Function; + public get context(): Function | undefined { + return this._context; + } + + public constructor(code = "error.unknown", reason = "Operation failed unexpectedly.", data: any = null, time: Date = new Date(), rootError?: Error, context?: Function) { + const message = []; + message.push(code); + if (reason) { + message.push(": '", reason, "'"); + } + + message.push(" at ", time.toISOString()); + + if (data) { + if (typeof data["toJSON"] === "function") { + message.push(` with data ${data.toJSON(false)}`); + } else { + message.push(` with data ${stringify(data)}`); + } + } + super(message.join("")); + this._code = code; + this._reason = reason; + this._time = time; + this._data = data; + this.name = "CoreError"; + this._rootError = rootError; + this._context = context; + + if (typeof Error.captureStackTrace !== "undefined") { + Error.captureStackTrace(this, context ?? CoreError); + } + } + + public equals(error: CoreError): boolean { + return this.code === error.code; + } + + public logWith(logger: ILogger): this { + logger.error(this); + return this; + } +} diff --git a/packages/core-types/src/index.ts b/packages/core-types/src/index.ts index 49f818f92..afcaef552 100644 --- a/packages/core-types/src/index.ts +++ b/packages/core-types/src/index.ts @@ -1,5 +1,6 @@ export * from "./CoreAddress"; export * from "./CoreDate"; +export * from "./CoreError"; export * from "./CoreHash"; export * from "./CoreId"; export * from "./CoreSerializable"; diff --git a/packages/runtime/src/useCases/common/UseCase.ts b/packages/runtime/src/useCases/common/UseCase.ts index 614cc37f2..bcbb66b78 100644 --- a/packages/runtime/src/useCases/common/UseCase.ts +++ b/packages/runtime/src/useCases/common/UseCase.ts @@ -1,6 +1,7 @@ import { ParsingError, ServalError, ValidationError } from "@js-soft/ts-serval"; import { ApplicationError, Result } from "@js-soft/ts-utils"; -import { CoreError, RequestError } from "@nmshd/transport"; +import { CoreError } from "@nmshd/core-types"; +import { RequestError } from "@nmshd/transport"; import stringifySafe from "json-stringify-safe"; import { PlatformErrorCodes } from "./PlatformErrorCodes"; import { RuntimeErrors } from "./RuntimeErrors"; diff --git a/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts b/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts index 9f3bf2baa..20e2fd2d6 100644 --- a/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts +++ b/packages/runtime/src/useCases/consumption/attributes/SucceedRelationshipAttributeAndNotifyPeer.ts @@ -1,5 +1,5 @@ import { Result } from "@js-soft/ts-utils"; -import { AttributesController, AttributeSuccessorParams, ConsumptionIds, CoreErrors } from "@nmshd/consumption"; +import { AttributesController, AttributeSuccessorParams, ConsumptionCoreErrors, ConsumptionIds } from "@nmshd/consumption"; import { AttributeValues, Notification, PeerSharedAttributeSucceededNotificationItem, RelationshipAttribute, RelationshipAttributeJSON } from "@nmshd/content"; import { CoreId } from "@nmshd/core-types"; import { AccountController, MessageController } from "@nmshd/transport"; @@ -41,10 +41,10 @@ export class SucceedRelationshipAttributeAndNotifyPeerUseCase extends UseCase> { const predecessor = await this.attributeController.getLocalAttribute(CoreId.from(request.predecessorId)); - if (!predecessor) return Result.fail(CoreErrors.attributes.predecessorDoesNotExist()); + if (!predecessor) return Result.fail(ConsumptionCoreErrors.attributes.predecessorDoesNotExist()); if (!predecessor.isOwnSharedRelationshipAttribute(this.accountController.identity.address, predecessor.shareInfo?.peer)) { - return Result.fail(CoreErrors.attributes.predecessorIsNotOwnSharedRelationshipAttribute()); + return Result.fail(ConsumptionCoreErrors.attributes.predecessorIsNotOwnSharedRelationshipAttribute()); } const notificationId = await ConsumptionIds.notification.generate(); diff --git a/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts b/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts index 7fc3dd86c..0c72f9b1a 100644 --- a/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts +++ b/packages/runtime/src/useCases/consumption/attributes/SucceedRepositoryAttribute.ts @@ -1,5 +1,5 @@ import { Result } from "@js-soft/ts-utils"; -import { AttributesController, AttributeSuccessorParamsJSON, CoreErrors } from "@nmshd/consumption"; +import { AttributesController, AttributeSuccessorParamsJSON, ConsumptionCoreErrors } from "@nmshd/consumption"; import { AttributeValues } from "@nmshd/content"; import { CoreId } from "@nmshd/core-types"; import { AccountController } from "@nmshd/transport"; @@ -40,7 +40,7 @@ export class SucceedRepositoryAttributeUseCase extends UseCase> { const predecessor = await this.attributeController.getLocalAttribute(CoreId.from(request.predecessorId)); - if (!predecessor) return Result.fail(CoreErrors.attributes.predecessorDoesNotExist()); + if (!predecessor) return Result.fail(ConsumptionCoreErrors.attributes.predecessorDoesNotExist()); const successorParams: AttributeSuccessorParamsJSON = { content: { diff --git a/packages/runtime/src/useCases/transport/challenges/ValidateChallenge.ts b/packages/runtime/src/useCases/transport/challenges/ValidateChallenge.ts index e33e2cb83..bc4f961e7 100644 --- a/packages/runtime/src/useCases/transport/challenges/ValidateChallenge.ts +++ b/packages/runtime/src/useCases/transport/challenges/ValidateChallenge.ts @@ -1,6 +1,7 @@ import { Result } from "@js-soft/ts-utils"; +import { CoreError } from "@nmshd/core-types"; import { CryptoSignature } from "@nmshd/crypto"; -import { Challenge, ChallengeController, ChallengeSigned, CoreError } from "@nmshd/transport"; +import { Challenge, ChallengeController, ChallengeSigned } from "@nmshd/transport"; import { nameof } from "ts-simple-nameof"; import { Inject } from "typescript-ioc"; import { RelationshipDTO } from "../../../types"; diff --git a/packages/transport/src/core/CoreError.ts b/packages/transport/src/core/CoreError.ts deleted file mode 100644 index 49b6fd6b8..000000000 --- a/packages/transport/src/core/CoreError.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { ILogger } from "@js-soft/logging-abstractions"; -import stringify from "json-stringify-safe"; - -export class CoreError extends Error { - private readonly _code: string; - public get code(): string { - return this._code; - } - - private readonly _reason: string; - public get reason(): string { - return this._reason; - } - - private readonly _data: string; - public get data(): string { - return this._data; - } - - // Intentionally using Date here instead of CoreDate - otherwise CoreError wouldn't be usable within CoreDate - private readonly _time: Date; - public get time(): Date { - return this._time; - } - - private readonly _rootError?: Error; - public get rootError(): Error | undefined { - return this._rootError; - } - - private readonly _context?: Function; - public get context(): Function | undefined { - return this._context; - } - - public constructor(code = "error.unknown", reason = "Operation failed unexpectedly.", data: any = null, time: Date = new Date(), rootError?: Error, context?: Function) { - const message = []; - message.push(code); - if (reason) { - message.push(": '", reason, "'"); - } - - message.push(" at ", time.toISOString()); - - if (data) { - if (typeof data["toJSON"] === "function") { - message.push(` with data ${data.toJSON(false)}`); - } else { - message.push(` with data ${stringify(data)}`); - } - } - super(message.join("")); - this._code = code; - this._reason = reason; - this._time = time; - this._data = data; - this.name = "CoreError"; - this._rootError = rootError; - this._context = context; - - if (typeof Error.captureStackTrace !== "undefined") { - Error.captureStackTrace(this, context ?? CoreError); - } - } - - public equals(error: CoreError): boolean { - return this.code === error.code; - } - - public logWith(logger: ILogger): this { - logger.error(this); - return this; - } -} diff --git a/packages/transport/src/core/Reference.ts b/packages/transport/src/core/Reference.ts index bba57e367..93671c329 100644 --- a/packages/transport/src/core/Reference.ts +++ b/packages/transport/src/core/Reference.ts @@ -1,8 +1,8 @@ import { ISerializable, Serializable, serialize, validate, ValidationError } from "@js-soft/ts-serval"; import { CoreId, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; -import { CoreErrors } from "./CoreErrors"; import { CoreIdHelper } from "./CoreIdHelper"; +import { TransportCoreErrors } from "./TransportCoreErrors"; export interface IReference extends ISerializable { id: ICoreId; @@ -28,7 +28,7 @@ export class Reference extends Serializable implements IReference { const splitted = truncatedBuffer.toUtf8().split("|"); if (splitted.length !== 3) { - throw CoreErrors.general.invalidTruncatedReference(); + throw TransportCoreErrors.general.invalidTruncatedReference(); } try { @@ -45,7 +45,7 @@ export class Reference extends Serializable implements IReference { key: secretKey }); } catch (e) { - throw CoreErrors.general.invalidTruncatedReference(); + throw TransportCoreErrors.general.invalidTruncatedReference(); } } diff --git a/packages/transport/src/core/Transport.ts b/packages/transport/src/core/Transport.ts index a9f58bb41..b16010580 100644 --- a/packages/transport/src/core/Transport.ts +++ b/packages/transport/src/core/Transport.ts @@ -6,7 +6,7 @@ import { SodiumWrapper } from "@nmshd/crypto"; import { AgentOptions } from "http"; import { AgentOptions as HTTPSAgentOptions } from "https"; import _ from "lodash"; -import { CoreErrors } from "./CoreErrors"; +import { TransportCoreErrors } from "./TransportCoreErrors"; import { TransportError } from "./TransportError"; import { TransportLoggerFactory } from "./TransportLoggerFactory"; @@ -94,15 +94,15 @@ export class Transport { log = TransportLoggerFactory.getLogger(Transport); if (!this._config.platformClientId) { - throw CoreErrors.general.platformClientIdNotSet().logWith(log); + throw TransportCoreErrors.general.platformClientIdNotSet().logWith(log); } if (!this._config.platformClientSecret) { - throw CoreErrors.general.platformClientSecretNotSet().logWith(log); + throw TransportCoreErrors.general.platformClientSecretNotSet().logWith(log); } if (!this._config.baseUrl) { - throw CoreErrors.general.baseUrlNotSet().logWith(log); + throw TransportCoreErrors.general.baseUrlNotSet().logWith(log); } if (this._config.supportedDatawalletVersion < 1) { diff --git a/packages/transport/src/core/CoreErrors.ts b/packages/transport/src/core/TransportCoreErrors.ts similarity index 99% rename from packages/transport/src/core/CoreErrors.ts rename to packages/transport/src/core/TransportCoreErrors.ts index f028c5d32..15a6db820 100644 --- a/packages/transport/src/core/CoreErrors.ts +++ b/packages/transport/src/core/TransportCoreErrors.ts @@ -1,6 +1,6 @@ +import { CoreError } from "@nmshd/core-types"; import stringify from "json-stringify-safe"; import { RelationshipStatus } from "../modules"; -import { CoreError } from "./CoreError"; class Relationships { public operationOnlyAllowedForPeer(message: string) { @@ -199,7 +199,7 @@ class General { } } -export class CoreErrors { +export class TransportCoreErrors { public static readonly relationships = new Relationships(); public static readonly general = new General(); public static readonly messages = new Messages(); diff --git a/packages/transport/src/core/index.ts b/packages/transport/src/core/index.ts index e7dd7b924..8cf36c05e 100644 --- a/packages/transport/src/core/index.ts +++ b/packages/transport/src/core/index.ts @@ -1,7 +1,5 @@ export * from "./backbone"; export * from "./CoreCrypto"; -export * from "./CoreError"; -export * from "./CoreErrors"; export * from "./CoreIdHelper"; export * from "./CoreSynchronizable"; export * from "./CoreUtil"; @@ -10,6 +8,7 @@ export * from "./DependencyOverrides"; export * from "./Reference"; export * from "./Transport"; export * from "./TransportController"; +export * from "./TransportCoreErrors"; export * from "./TransportError"; export * from "./TransportIds"; export * from "./TransportLoggerFactory"; diff --git a/packages/transport/src/modules/accounts/AccountController.ts b/packages/transport/src/modules/accounts/AccountController.ts index ca66da128..902db8940 100644 --- a/packages/transport/src/modules/accounts/AccountController.ts +++ b/packages/transport/src/modules/accounts/AccountController.ts @@ -4,7 +4,7 @@ import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; import { PasswordGenerator } from "@nmshd/utils"; -import { AbstractAuthenticator, Authenticator, ControllerName, CoreErrors, IConfig, Transport, TransportError } from "../../core"; +import { AbstractAuthenticator, Authenticator, ControllerName, IConfig, Transport, TransportCoreErrors, TransportError } from "../../core"; import { CoreCrypto } from "../../core/CoreCrypto"; import { DbCollectionName } from "../../core/DbCollectionName"; import { DependencyOverrides } from "../../core/DependencyOverrides"; @@ -155,7 +155,7 @@ export class AccountController { } else if (!deviceSharedSecret && availableIdentityDoc && availableDeviceDoc) { // Login if (!availableBaseKeyDoc) { - throw CoreErrors.secrets.secretNotFound("BaseKey"); + throw TransportCoreErrors.secrets.secretNotFound("BaseKey"); } const availableIdentity = Identity.from(availableIdentityDoc); @@ -287,7 +287,7 @@ export class AccountController { if (deviceResponseResult.isError) { const error = deviceResponseResult.error; if (error.code === "error.platform.unauthorized") { - throw CoreErrors.general.platformClientInvalid(); + throw TransportCoreErrors.general.platformClientInvalid(); } } diff --git a/packages/transport/src/modules/accounts/IdentityController.ts b/packages/transport/src/modules/accounts/IdentityController.ts index f15ff37fb..fceba220a 100644 --- a/packages/transport/src/modules/accounts/IdentityController.ts +++ b/packages/transport/src/modules/accounts/IdentityController.ts @@ -1,7 +1,7 @@ import { log } from "@js-soft/ts-utils"; import { CoreAddress } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignature, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreCrypto, CoreErrors, TransportController } from "../../core"; +import { ControllerName, CoreCrypto, TransportController, TransportCoreErrors } from "../../core"; import { AccountController } from "../accounts/AccountController"; import { DeviceSecretType } from "../devices/DeviceSecretController"; import { Identity } from "./data/Identity"; @@ -44,7 +44,7 @@ export class IdentityController extends TransportController { public async sign(content: CoreBuffer): Promise { const privateKeyContainer = await this.parent.activeDevice.secrets.loadSecret(DeviceSecretType.IdentitySignature); if (!privateKeyContainer || !(privateKeyContainer.secret instanceof CryptoSignaturePrivateKey)) { - throw CoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySignature); + throw TransportCoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySignature); } const privateKey = privateKeyContainer.secret; diff --git a/packages/transport/src/modules/challenges/ChallengeController.ts b/packages/transport/src/modules/challenges/ChallengeController.ts index df2389ece..166ed2d5e 100644 --- a/packages/transport/src/modules/challenges/ChallengeController.ts +++ b/packages/transport/src/modules/challenges/ChallengeController.ts @@ -1,7 +1,7 @@ import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignatureKeypair } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors } from "../../core"; +import { CoreCrypto, TransportCoreErrors } from "../../core"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; import { Relationship } from "../relationships/local/Relationship"; @@ -33,7 +33,7 @@ export class ChallengeController extends TransportController { const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(challenge.createdBy); if (!relationship) { - throw CoreErrors.general.recordNotFound(Relationship, challenge.createdBy.toString()); + throw TransportCoreErrors.general.recordNotFound(Relationship, challenge.createdBy.toString()); } const challengeBuffer = CoreBuffer.fromUtf8(signedChallenge.challenge); let isValid = false; @@ -42,7 +42,7 @@ export class ChallengeController extends TransportController { isValid = await this.parent.relationships.verifyIdentity(relationship, challengeBuffer, signedChallenge.signature); break; case ChallengeType.Device: - throw CoreErrors.general.notSupported(); + throw TransportCoreErrors.general.notSupported(); case ChallengeType.Relationship: isValid = await this.parent.relationships.verify(relationship, challengeBuffer, signedChallenge.signature); break; @@ -90,7 +90,7 @@ export class ChallengeController extends TransportController { @log() public async createChallenge(type: ChallengeType = ChallengeType.Identity, relationship?: Relationship): Promise { if (type === ChallengeType.Relationship && relationship?.status !== RelationshipStatus.Active) { - throw CoreErrors.challenges.challengeTypeRequiresActiveRelationship(); + throw TransportCoreErrors.challenges.challengeTypeRequiresActiveRelationship(); } const backboneResponse = (await this.authClient.createChallenge()).value; diff --git a/packages/transport/src/modules/devices/DeviceController.ts b/packages/transport/src/modules/devices/DeviceController.ts index f572c484d..11100eba3 100644 --- a/packages/transport/src/modules/devices/DeviceController.ts +++ b/packages/transport/src/modules/devices/DeviceController.ts @@ -1,7 +1,7 @@ import { log } from "@js-soft/ts-utils"; import { CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSecretKey, CryptoSignature, CryptoSignaturePrivateKey, CryptoSignaturePublicKey } from "@nmshd/crypto"; -import { ControllerName, CoreCrypto, CoreErrors, CredentialsBasic, TransportController, TransportError } from "../../core"; +import { ControllerName, CoreCrypto, CredentialsBasic, TransportController, TransportCoreErrors, TransportError } from "../../core"; import { AccountController } from "../accounts/AccountController"; import { DeviceSecretController, DeviceSecretType } from "./DeviceSecretController"; import { Device, DeviceType } from "./local/Device"; @@ -103,7 +103,7 @@ export class DeviceController extends TransportController { public async sign(content: CoreBuffer): Promise { const privateKeyContainer = await this.secrets.loadSecret(DeviceSecretType.DeviceSignature); if (!privateKeyContainer || !(privateKeyContainer.secret instanceof CryptoSignaturePrivateKey)) { - throw CoreErrors.secrets.secretNotFound(DeviceSecretType.DeviceSignature); + throw TransportCoreErrors.secrets.secretNotFound(DeviceSecretType.DeviceSignature); } const privateKey = privateKeyContainer.secret; const signature = await CoreCrypto.sign(content, privateKey); @@ -126,16 +126,16 @@ export class DeviceController extends TransportController { const credentialContainer = await this.secrets.loadSecret(DeviceSecretType.DeviceCredentials); if (!credentialContainer) { - throw CoreErrors.secrets.secretNotFound(DeviceSecretType.DeviceCredentials); + throw TransportCoreErrors.secrets.secretNotFound(DeviceSecretType.DeviceCredentials); } if (!(credentialContainer.secret instanceof DeviceSecretCredentials)) { - throw CoreErrors.secrets.wrongSecretType(DeviceSecretType.DeviceCredentials); + throw TransportCoreErrors.secrets.wrongSecretType(DeviceSecretType.DeviceCredentials); } const credentials = credentialContainer.secret; if (!credentials.username || !credentials.password) { - throw CoreErrors.secrets.wrongSecretType(DeviceSecretType.DeviceCredentials); + throw TransportCoreErrors.secrets.wrongSecretType(DeviceSecretType.DeviceCredentials); } return { diff --git a/packages/transport/src/modules/devices/DeviceSecretController.ts b/packages/transport/src/modules/devices/DeviceSecretController.ts index d9bcc2014..2721aadac 100644 --- a/packages/transport/src/modules/devices/DeviceSecretController.ts +++ b/packages/transport/src/modules/devices/DeviceSecretController.ts @@ -3,7 +3,7 @@ import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; import { CoreDate } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoExchangeKeypair, CryptoExchangePrivateKey, CryptoSecretKey, CryptoSignatureKeypair, CryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors } from "../../core"; +import { CoreCrypto, TransportCoreErrors } from "../../core"; import { ControllerName, TransportController } from "../../core/TransportController"; import { TransportIds } from "../../core/TransportIds"; import { AccountController } from "../accounts/AccountController"; @@ -113,19 +113,19 @@ export class DeviceSecretController extends TransportController { public async createDeviceSharedSecret(device: Device, deviceIndex: number, includeIdentityPrivateKey = false, profileName?: string): Promise { const synchronizationKey = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster); if (!synchronizationKey || !(synchronizationKey.secret instanceof CryptoSecretKey)) { - throw CoreErrors.secrets.secretNotFound("SynchronizationKey"); + throw TransportCoreErrors.secrets.secretNotFound("SynchronizationKey"); } const baseKey = await this.loadSecret(DeviceSecretType.SharedSecretBaseKey); if (!baseKey || !(baseKey.secret instanceof CryptoSecretKey)) { - throw CoreErrors.secrets.secretNotFound("baseKey"); + throw TransportCoreErrors.secrets.secretNotFound("baseKey"); } let identityPrivateKey; if (includeIdentityPrivateKey) { identityPrivateKey = await this.loadSecret(DeviceSecretType.IdentitySignature); if (!identityPrivateKey || !(identityPrivateKey.secret instanceof CryptoSignaturePrivateKey)) { - throw CoreErrors.secrets.secretNotFound("IdentityKey"); + throw TransportCoreErrors.secrets.secretNotFound("IdentityKey"); } } @@ -157,7 +157,7 @@ export class DeviceSecretController extends TransportController { const serializedEvent = CoreBuffer.fromUtf8(JSON.stringify(event.payload)); const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster); if (!privSync || !(privSync.secret instanceof CryptoSecretKey)) { - throw CoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster); + throw TransportCoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster); } const encryptionKey = await CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync"); @@ -177,7 +177,7 @@ export class DeviceSecretController extends TransportController { const privSync = await this.loadSecret(DeviceSecretType.IdentitySynchronizationMaster); if (!privSync || !(privSync.secret instanceof CryptoSecretKey)) { - throw CoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster); + throw TransportCoreErrors.secrets.secretNotFound(DeviceSecretType.IdentitySynchronizationMaster); } const decryptionKey = await CoreCrypto.deriveKeyFromBase(privSync.secret, index, "DataSync"); @@ -193,7 +193,7 @@ export class DeviceSecretController extends TransportController { @log() private getBaseKey(): CryptoSecretKey { if (!this.baseKey) { - throw CoreErrors.general.recordNotFound(CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey); + throw TransportCoreErrors.general.recordNotFound(CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey); } return this.baseKey; diff --git a/packages/transport/src/modules/devices/DevicesController.ts b/packages/transport/src/modules/devices/DevicesController.ts index 26231578e..4ba6ce988 100644 --- a/packages/transport/src/modules/devices/DevicesController.ts +++ b/packages/transport/src/modules/devices/DevicesController.ts @@ -1,6 +1,6 @@ import { CoreDate, CoreId } from "@nmshd/core-types"; import { PasswordGenerator } from "@nmshd/utils"; -import { CoreErrors } from "../../core"; +import { TransportCoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; @@ -87,13 +87,13 @@ export class DevicesController extends TransportController { public async getSharedSecret(id: CoreId, profileName?: string): Promise { const deviceDoc = await this.devices.read(id.toString()); if (!deviceDoc) { - throw CoreErrors.general.recordNotFound(Device, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Device, id.toString()); } const count = await this.devices.count(); const device = Device.from(deviceDoc); - if (device.publicKey) throw CoreErrors.device.alreadyOnboarded(); + if (device.publicKey) throw TransportCoreErrors.device.alreadyOnboarded(); const isAdmin = device.isAdmin === true; @@ -104,17 +104,17 @@ export class DevicesController extends TransportController { public async update(device: Device): Promise { const deviceDoc = await this.devices.read(device.id.toString()); if (!deviceDoc) { - throw CoreErrors.general.recordNotFound(Device, device.id.toString()); + throw TransportCoreErrors.general.recordNotFound(Device, device.id.toString()); } await this.devices.update(deviceDoc, device); } public async delete(device: Device): Promise { - if (device.publicKey) throw CoreErrors.device.couldNotDeleteDevice("Device is already onboarded."); + if (device.publicKey) throw TransportCoreErrors.device.couldNotDeleteDevice("Device is already onboarded."); const result = await this.client.deleteDevice(device.id.toString()); if (result.isError) { - throw CoreErrors.device.couldNotDeleteDevice("Backbone did not authorize deletion.", result.error); + throw TransportCoreErrors.device.couldNotDeleteDevice("Backbone did not authorize deletion.", result.error); } await this.devices.delete(device); diff --git a/packages/transport/src/modules/files/FileController.ts b/packages/transport/src/modules/files/FileController.ts index 64701028f..51a334f28 100644 --- a/packages/transport/src/modules/files/FileController.ts +++ b/packages/transport/src/modules/files/FileController.ts @@ -2,7 +2,7 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreHash, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoHash, CryptoHashAlgorithm, CryptoSecretKey, Encoding } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors } from "../../core"; +import { CoreCrypto, TransportCoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; @@ -83,7 +83,7 @@ export class FileController extends TransportController { private async updateCacheOfExistingFileInDb(id: string, response?: BackboneGetFilesResponse) { const fileDoc = await this.files.read(id); if (!fileDoc) { - throw CoreErrors.general.recordNotFound(File, id); + throw TransportCoreErrors.general.recordNotFound(File, id); } const file = File.from(fileDoc); @@ -113,7 +113,7 @@ export class FileController extends TransportController { const plaintextMetadata = FileMetadata.deserialize(plaintextMetadataBuffer.toUtf8()); if (!(plaintextMetadata instanceof FileMetadata)) { - throw CoreErrors.files.invalidMetadata(response.id); + throw TransportCoreErrors.files.invalidMetadata(response.id); } const cachedFile = CachedFile.fromBackbone(response, plaintextMetadata); @@ -153,7 +153,7 @@ export class FileController extends TransportController { const id = idOrFile instanceof CoreId ? idOrFile.toString() : idOrFile.id.toString(); const fileDoc = await this.files.read(id); if (!fileDoc) { - throw CoreErrors.general.recordNotFound(File, id.toString()); + throw TransportCoreErrors.general.recordNotFound(File, id.toString()); } const file = File.from(fileDoc); @@ -169,7 +169,7 @@ export class FileController extends TransportController { const fileSize = content.length; if (fileSize > this.config.platformMaxUnencryptedFileSize) { - throw CoreErrors.files.maxFileSizeExceeded(fileSize, this.config.platformMaxUnencryptedFileSize); + throw TransportCoreErrors.files.maxFileSizeExceeded(fileSize, this.config.platformMaxUnencryptedFileSize); } const plaintextHashBuffer = await CryptoHash.hash(content, CryptoHashAlgorithm.SHA512); @@ -248,7 +248,7 @@ export class FileController extends TransportController { public async downloadFileContent(idOrFile: CoreId | File): Promise { const file = idOrFile instanceof File ? idOrFile : await this.getFile(idOrFile); if (!file) { - throw CoreErrors.general.recordNotFound(File, idOrFile.toString()); + throw TransportCoreErrors.general.recordNotFound(File, idOrFile.toString()); } if (!file.cache) throw this.newCacheEmptyError(File, file.id.toString()); @@ -260,7 +260,7 @@ export class FileController extends TransportController { const hashb64 = hash.toBase64URL(); if (hashb64 !== file.cache.cipherHash.hash) { - throw CoreErrors.files.cipherMismatch(); + throw TransportCoreErrors.files.cipherMismatch(); } const cipher = CryptoCipher.fromBase64(buffer.toBase64URL()); @@ -268,7 +268,7 @@ export class FileController extends TransportController { const plaintextHashesMatch = await file.cache.plaintextHash.verify(decrypt, CryptoHashAlgorithm.SHA512); if (!plaintextHashesMatch) { - throw CoreErrors.files.plaintextHashMismatch(); + throw TransportCoreErrors.files.plaintextHashMismatch(); } return decrypt; diff --git a/packages/transport/src/modules/messages/MessageController.ts b/packages/transport/src/modules/messages/MessageController.ts index fe62f2e48..f6631e618 100644 --- a/packages/transport/src/modules/messages/MessageController.ts +++ b/packages/transport/src/modules/messages/MessageController.ts @@ -3,7 +3,7 @@ import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; -import { CoreCrypto, CoreErrors, TransportError } from "../../core"; +import { CoreCrypto, TransportCoreErrors, TransportError } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { MessageSentEvent, MessageWasReadAtChangedEvent } from "../../events"; @@ -105,7 +105,7 @@ export class MessageController extends TransportController { public async getMessagesByAddress(address: CoreAddress): Promise { const relationship = await this.parent.relationships.getActiveRelationshipToIdentity(address); if (!relationship) { - throw CoreErrors.messages.missingOrInactiveRelationship(address.toString()); + throw TransportCoreErrors.messages.missingOrInactiveRelationship(address.toString()); } return await this.getMessagesByRelationshipId(relationship.id); } @@ -163,7 +163,7 @@ export class MessageController extends TransportController { private async updateCacheOfExistingMessageInDb(id: string, response?: BackboneGetMessagesResponse) { const messageDoc = await this.messages.read(id); if (!messageDoc) { - throw CoreErrors.general.recordNotFound(Message, id); + throw TransportCoreErrors.general.recordNotFound(Message, id); } const message = Message.from(messageDoc); @@ -195,7 +195,7 @@ export class MessageController extends TransportController { const [cachedMessage, messageKey, relationship] = await this.decryptMessage(envelope); if (!relationship) { - throw CoreErrors.general.recordNotFound(Relationship, envelope.id.toString()); + throw TransportCoreErrors.general.recordNotFound(Relationship, envelope.id.toString()); } const message = Message.from({ @@ -240,7 +240,7 @@ export class MessageController extends TransportController { const id = idOrMessage instanceof CoreId ? idOrMessage.toString() : idOrMessage.id.toString(); const messageDoc = await this.messages.read(id); if (!messageDoc) { - throw CoreErrors.general.recordNotFound(Message, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Message, id.toString()); } const message = Message.from(messageDoc); @@ -253,7 +253,7 @@ export class MessageController extends TransportController { public async markMessageAsRead(id: CoreId): Promise { const messageDoc = await this.messages.read(id.toString()); if (!messageDoc) { - throw CoreErrors.general.recordNotFound(Message, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Message, id.toString()); } const message = Message.from(messageDoc); @@ -270,7 +270,7 @@ export class MessageController extends TransportController { public async markMessageAsUnread(id: CoreId): Promise { const messageDoc = await this.messages.read(id.toString()); if (!messageDoc) { - throw CoreErrors.general.recordNotFound(Message, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Message, id.toString()); } const message = Message.from(messageDoc); @@ -296,7 +296,7 @@ export class MessageController extends TransportController { for (const recipient of parsedParams.recipients) { const relationship = await this.relationships.getActiveRelationshipToIdentity(recipient); if (!relationship) { - throw CoreErrors.messages.missingOrInactiveRelationship(recipient.toString()); + throw TransportCoreErrors.messages.missingOrInactiveRelationship(recipient.toString()); } const cipherForRecipient = await this.secrets.encrypt(relationship.relationshipSecretId, serializedSecret); @@ -335,7 +335,7 @@ export class MessageController extends TransportController { for (const recipient of parsedParams.recipients) { const relationship = await this.relationships.getActiveRelationshipToIdentity(CoreAddress.from(recipient)); if (!relationship) { - throw CoreErrors.messages.missingOrInactiveRelationship(recipient.toString()); + throw TransportCoreErrors.messages.missingOrInactiveRelationship(recipient.toString()); } const signature = await this.secrets.sign(relationship.relationshipSecretId, plaintextBuffer); @@ -426,7 +426,7 @@ export class MessageController extends TransportController { const ownKeyCipher = envelope.recipients.find((r) => this.parent.identity.isMe(r.address))?.encryptedKey; if (!ownKeyCipher) { - throw CoreErrors.messages.ownAddressNotInList(envelope.id.toString()); + throw TransportCoreErrors.messages.ownAddressNotInList(envelope.id.toString()); } const plaintextKeyBuffer = await this.secrets.decryptPeer(relationship.relationshipSecretId, ownKeyCipher, true); @@ -438,7 +438,7 @@ export class MessageController extends TransportController { const signature = signedMessage.signatures.find((s) => this.parent.identity.isMe(s.recipient))?.signature; if (!signature) { - throw CoreErrors.messages.signatureListMismatch(envelope.id.toString()); + throw TransportCoreErrors.messages.signatureListMismatch(envelope.id.toString()); } const messagePlain = MessageContentWrapper.from(JSON.parse(signedMessage.message)); @@ -449,7 +449,7 @@ export class MessageController extends TransportController { const plainMessageBuffer = CoreBuffer.fromUtf8(signedMessage.message); const validSignature = await this.secrets.verifyPeer(relationship.relationshipSecretId, plainMessageBuffer, signature); if (!validSignature) { - throw CoreErrors.messages.signatureNotValid(); + throw TransportCoreErrors.messages.signatureNotValid(); } if (messagePlain.recipients.length !== envelope.recipients.length) { @@ -463,7 +463,7 @@ export class MessageController extends TransportController { const recipientFound = messagePlain.recipients.some((r) => this.parent.identity.isMe(r)); if (!recipientFound) { - throw CoreErrors.messages.plaintextMismatch(envelope.id.toString()); + throw TransportCoreErrors.messages.plaintextMismatch(envelope.id.toString()); } return [messagePlain, plaintextKey]; @@ -510,7 +510,7 @@ export class MessageController extends TransportController { relationship = await this.relationships.getActiveRelationshipToIdentity(envelope.createdBy); if (!relationship) { - throw CoreErrors.messages.missingOrInactiveRelationship(envelope.createdBy.toString()); + throw TransportCoreErrors.messages.missingOrInactiveRelationship(envelope.createdBy.toString()); } const [peerMessage, peerKey] = await this.decryptPeerEnvelope(envelope, relationship); diff --git a/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts b/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts index 6cdba186c..26a4a4c20 100644 --- a/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts +++ b/packages/transport/src/modules/relationshipTemplates/RelationshipTemplateController.ts @@ -2,7 +2,7 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors } from "../../core"; +import { CoreCrypto, TransportCoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { PeerRelationshipTemplateLoadedEvent } from "../../events"; @@ -147,7 +147,7 @@ export class RelationshipTemplateController extends TransportController { private async updateCacheOfExistingTemplateInDb(id: string, response?: BackboneGetRelationshipTemplatesResponse) { const templateDoc = await this.templates.read(id); if (!templateDoc) { - throw CoreErrors.general.recordNotFound(RelationshipTemplate, id); + throw TransportCoreErrors.general.recordNotFound(RelationshipTemplate, id); } const template = RelationshipTemplate.from(templateDoc); @@ -184,7 +184,7 @@ export class RelationshipTemplateController extends TransportController { ); if (!templateSignatureValid) { - throw CoreErrors.general.signatureNotValid("template"); + throw TransportCoreErrors.general.signatureNotValid("template"); } const cachedTemplate = CachedRelationshipTemplate.from({ @@ -214,7 +214,7 @@ export class RelationshipTemplateController extends TransportController { const id = idOrTemplate instanceof CoreId ? idOrTemplate.toString() : idOrTemplate.id.toString(); const templateDoc = await this.templates.read(id); if (!templateDoc) { - throw CoreErrors.general.recordNotFound(RelationshipTemplate, id.toString()); + throw TransportCoreErrors.general.recordNotFound(RelationshipTemplate, id.toString()); } const template = RelationshipTemplate.from(templateDoc); diff --git a/packages/transport/src/modules/relationships/RelationshipSecretController.ts b/packages/transport/src/modules/relationships/RelationshipSecretController.ts index 74733d492..cf382bb92 100644 --- a/packages/transport/src/modules/relationships/RelationshipSecretController.ts +++ b/packages/transport/src/modules/relationships/RelationshipSecretController.ts @@ -14,8 +14,8 @@ import { CryptoSignaturePublicKey } from "@nmshd/crypto"; import { ControllerName, CoreCrypto } from "../../core"; -import { CoreErrors } from "../../core/CoreErrors"; import { CoreUtil } from "../../core/CoreUtil"; +import { TransportCoreErrors } from "../../core/TransportCoreErrors"; import { TransportIds } from "../../core/TransportIds"; import { AccountController } from "../accounts/AccountController"; import { CachedRelationshipTemplate } from "../relationshipTemplates/local/CachedRelationshipTemplate"; @@ -43,11 +43,11 @@ export class RelationshipSecretController extends SecretController { const secretContainer = await this.loadActiveSecretByName(secretIdAsString); if (!secretContainer) { - throw CoreErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString); + throw TransportCoreErrors.general.recordNotFound("CryptoRelationshipRequestSecrets | CryptoRelationshipSecrets", secretIdAsString); } if (!(secretContainer.secret instanceof CryptoRelationshipRequestSecrets) && !(secretContainer.secret instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secretIdAsString); + throw TransportCoreErrors.secrets.wrongSecretType(secretIdAsString); } const secret = secretContainer.secret; this.cache.set(relationshipSecretId, secret); @@ -72,11 +72,11 @@ export class RelationshipSecretController extends SecretController { const exchangeKeypairContainer = await this.loadActiveSecretByName(templateKeyId); if (!exchangeKeypairContainer) { - throw CoreErrors.general.recordNotFound(CryptoExchangeKeypair, templateKeyId); + throw TransportCoreErrors.general.recordNotFound(CryptoExchangeKeypair, templateKeyId); } if (!(exchangeKeypairContainer.secret instanceof CryptoExchangeKeypair)) { - throw CoreErrors.secrets.wrongSecretType(templateKeyId); + throw TransportCoreErrors.secrets.wrongSecretType(templateKeyId); } const exchangeKeypair = exchangeKeypairContainer.secret; @@ -91,11 +91,11 @@ export class RelationshipSecretController extends SecretController { public async getPublicCreationResponseContentCrypto(relationshipSecretId: CoreId): Promise { const secret = await this.loadActiveSecretByName(relationshipSecretId.toString()); if (!secret) { - throw CoreErrors.general.recordNotFound(CryptoRelationshipSecrets, relationshipSecretId.toString()); + throw TransportCoreErrors.general.recordNotFound(CryptoRelationshipSecrets, relationshipSecretId.toString()); } if (!(secret.secret instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secret.id.toString()); + throw TransportCoreErrors.secrets.wrongSecretType(secret.id.toString()); } const publicResponse = secret.secret.toPublicResponse(); return publicResponse; @@ -105,7 +105,7 @@ export class RelationshipSecretController extends SecretController { public async convertSecrets(relationshipSecretId: CoreId, response: CryptoRelationshipPublicResponse): Promise { const request = await this.getSecret(relationshipSecretId); if (request instanceof CryptoRelationshipSecrets) { - throw CoreErrors.secrets.wrongSecretType(); + throw TransportCoreErrors.secrets.wrongSecretType(); } const secrets = await CryptoRelationshipSecrets.fromRelationshipResponse(response, request); @@ -139,7 +139,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (!(secrets instanceof CryptoRelationshipRequestSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secrets.id); + throw TransportCoreErrors.secrets.wrongSecretType(secrets.id); } return await secrets.encryptRequest(buffer); @@ -151,7 +151,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (!(secrets instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secrets.id); + throw TransportCoreErrors.secrets.wrongSecretType(secrets.id); } return await secrets.encrypt(buffer); @@ -162,7 +162,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (!(secrets instanceof CryptoRelationshipRequestSecrets) && !(secrets instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(relationshipSecretId.toString()); + throw TransportCoreErrors.secrets.wrongSecretType(relationshipSecretId.toString()); } return await secrets.decryptRequest(cipher); @@ -184,7 +184,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (!(secrets instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secrets.id); + throw TransportCoreErrors.secrets.wrongSecretType(secrets.id); } return await secrets.decryptPeer(cipher, omitCounterCheck); @@ -200,7 +200,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (!(secrets instanceof CryptoRelationshipSecrets)) { - throw CoreErrors.secrets.wrongSecretType(secrets.id); + throw TransportCoreErrors.secrets.wrongSecretType(secrets.id); } return await secrets.decryptOwn(cipher); @@ -224,7 +224,7 @@ export class RelationshipSecretController extends SecretController { const secrets = await this.getSecret(relationshipSecretId); if (secrets instanceof CryptoRelationshipRequestSecrets) { - throw CoreErrors.secrets.wrongSecretType(secrets.id); + throw TransportCoreErrors.secrets.wrongSecretType(secrets.id); } const valid = await secrets.verifyPeer(bufferToVerify, signature); diff --git a/packages/transport/src/modules/relationships/RelationshipsController.ts b/packages/transport/src/modules/relationships/RelationshipsController.ts index 222c2c842..0d07cceef 100644 --- a/packages/transport/src/modules/relationships/RelationshipsController.ts +++ b/packages/transport/src/modules/relationships/RelationshipsController.ts @@ -4,9 +4,9 @@ import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoSignature } from "@nmshd/crypto"; import { nameof } from "ts-simple-nameof"; import { ControllerName, CoreCrypto, TransportController, TransportError } from "../../core"; -import { CoreErrors } from "../../core/CoreErrors"; import { CoreUtil } from "../../core/CoreUtil"; import { DbCollectionName } from "../../core/DbCollectionName"; +import { TransportCoreErrors } from "../../core/TransportCoreErrors"; import { TransportIds } from "../../core/TransportIds"; import { RelationshipChangedEvent, RelationshipDecomposedBySelfEvent, RelationshipReactivationCompletedEvent, RelationshipReactivationRequestedEvent } from "../../events"; import { AccountController } from "../accounts/AccountController"; @@ -97,7 +97,7 @@ export class RelationshipsController extends TransportController { @log() private async updateExistingRelationshipInDb(id: string, response: BackboneRelationship) { const relationshipDoc = await this.relationships.read(id); - if (!relationshipDoc) throw CoreErrors.general.recordNotFound(Relationship, id); + if (!relationshipDoc) throw TransportCoreErrors.general.recordNotFound(Relationship, id); const relationship = Relationship.from(relationshipDoc); @@ -164,7 +164,7 @@ export class RelationshipsController extends TransportController { const existingRelationshipsToPeer = await this.getRelationships(queryForExistingRelationships); if (existingRelationshipsToPeer.length !== 0) { - throw CoreErrors.relationships.relationshipCurrentlyExists(existingRelationshipsToPeer[0].status); + throw TransportCoreErrors.relationships.relationshipCurrentlyExists(existingRelationshipsToPeer[0].status); } const secretId = await TransportIds.relationshipSecret.generate(); @@ -178,11 +178,11 @@ export class RelationshipsController extends TransportController { if (result.isError) { if (result.error.code === "error.platform.validation.relationship.peerIsToBeDeleted") { - throw CoreErrors.relationships.activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate(); + throw TransportCoreErrors.relationships.activeIdentityDeletionProcessOfOwnerOfRelationshipTemplate(); } if (result.error.code === "error.platform.validation.relationshipRequest.relationshipToTargetAlreadyExists") { - throw CoreErrors.relationships.relationshipNotYetDecomposedByPeer(); + throw TransportCoreErrors.relationships.relationshipNotYetDecomposedByPeer(); } throw result.error; @@ -203,7 +203,7 @@ export class RelationshipsController extends TransportController { public async setRelationshipMetadata(idOrRelationship: CoreId | Relationship, metadata: ISerializable): Promise { const id = idOrRelationship instanceof CoreId ? idOrRelationship.toString() : idOrRelationship.id.toString(); const relationshipDoc = await this.relationships.read(id); - if (!relationshipDoc) throw CoreErrors.general.recordNotFound(Relationship, id.toString()); + if (!relationshipDoc) throw TransportCoreErrors.general.recordNotFound(Relationship, id.toString()); const relationship = Relationship.from(relationshipDoc); relationship.metadata = metadata; @@ -219,7 +219,7 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the relationship ${relationshipId.toString()}`); + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the relationship ${relationshipId.toString()}`); } return await this.completeOperationWithBackboneCall(RelationshipAuditLogEntryReason.AcceptanceOfCreation, relationshipId); } @@ -230,7 +230,9 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can reject the relationship ${relationshipId.toString()}. Revoke the relationship instead.`); + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer( + `Only your peer can reject the relationship ${relationshipId.toString()}. Revoke the relationship instead.` + ); } return await this.completeOperationWithBackboneCall(RelationshipAuditLogEntryReason.RejectionOfCreation, relationshipId); } @@ -241,7 +243,9 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can revoke the relationship ${relationshipId.toString()}. Reject the relationship instead.`); + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer( + `Only your peer can revoke the relationship ${relationshipId.toString()}. Reject the relationship instead.` + ); } return await this.completeOperationWithBackboneCall(RelationshipAuditLogEntryReason.RevocationOfCreation, relationshipId); } @@ -260,11 +264,11 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (lastAuditLogEntry.reason === RelationshipAuditLogEntryReason.ReactivationRequested) { if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.reactivationAlreadyRequested( + throw TransportCoreErrors.relationships.reactivationAlreadyRequested( `Your peer has already requested the reactivation of the relationship ${relationshipId.toString()}. You can accept the reactivation instead.` ); } - throw CoreErrors.relationships.reactivationAlreadyRequested(`You have already requested the reactivation of the relationship ${relationshipId.toString()}.`); + throw TransportCoreErrors.relationships.reactivationAlreadyRequested(`You have already requested the reactivation of the relationship ${relationshipId.toString()}.`); } return await this.completeOperationWithBackboneCall(RelationshipAuditLogEntryReason.ReactivationRequested, relationshipId); @@ -276,11 +280,11 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (lastAuditLogEntry.reason !== RelationshipAuditLogEntryReason.ReactivationRequested) { - throw CoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); + throw TransportCoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); } if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer( + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer( `Only your peer can reject the reactivation of the relationship ${relationshipId.toString()}. Revoke the relationship reactivation instead.` ); } @@ -293,10 +297,10 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (lastAuditLogEntry.reason !== RelationshipAuditLogEntryReason.ReactivationRequested) { - throw CoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); + throw TransportCoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); } if (lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer( + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer( `Only your peer can revoke the reactivation of the relationship ${relationshipId.toString()}. Reject the relationship reactivation instead.` ); } @@ -309,10 +313,10 @@ export class RelationshipsController extends TransportController { const lastAuditLogEntry = relationship.cache.auditLog[relationship.cache.auditLog.length - 1]; if (lastAuditLogEntry.reason !== RelationshipAuditLogEntryReason.ReactivationRequested) { - throw CoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); + throw TransportCoreErrors.relationships.reactivationNotRequested(relationshipId.toString()); } if (!lastAuditLogEntry.createdBy.equals(relationship.peer.address)) { - throw CoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the reactivation of the relationship ${relationshipId.toString()}.`); + throw TransportCoreErrors.relationships.operationOnlyAllowedForPeer(`Only your peer can accept the reactivation of the relationship ${relationshipId.toString()}.`); } return await this.completeOperationWithBackboneCall(RelationshipAuditLogEntryReason.AcceptanceOfReactivation, relationshipId); @@ -336,7 +340,7 @@ export class RelationshipsController extends TransportController { private async getRelationshipWithCache(id: CoreId): Promise { const relationship = await this.getRelationship(id); - if (!relationship) throw CoreErrors.general.recordNotFound(Relationship, id.toString()); + if (!relationship) throw TransportCoreErrors.general.recordNotFound(Relationship, id.toString()); if (!relationship.cache) await this.updateCacheOfRelationship(relationship); if (!relationship.cache) throw this.newCacheEmptyError(Relationship, id.toString()); @@ -346,7 +350,7 @@ export class RelationshipsController extends TransportController { private assertRelationshipStatus(relationship: Relationship, ...status: RelationshipStatus[]) { if (status.includes(relationship.status)) return; - throw CoreErrors.relationships.wrongRelationshipStatus(relationship.id.toString(), relationship.status); + throw TransportCoreErrors.relationships.wrongRelationshipStatus(relationship.id.toString(), relationship.status); } private async updateCacheOfRelationship(relationship: Relationship, response?: BackboneRelationship) { @@ -367,7 +371,7 @@ export class RelationshipsController extends TransportController { this._log.trace(`Parsing relationship template ${templateId} for ${response.id}...`); const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId); if (!template) { - throw CoreErrors.general.recordNotFound(RelationshipTemplate, templateId.toString()); + throw TransportCoreErrors.general.recordNotFound(RelationshipTemplate, templateId.toString()); } this._log.trace(`Parsing relationship creation content of ${response.id}...`); @@ -458,7 +462,7 @@ export class RelationshipsController extends TransportController { } if (!relationshipSignatureValid) { - throw CoreErrors.general.signatureNotValid("relationshipCreationContent"); + throw TransportCoreErrors.general.signatureNotValid("relationshipCreationContent"); } const creationContent = RelationshipCreationContentWrapper.deserialize(signedCreationContent.serializedCreationContent); @@ -474,7 +478,7 @@ export class RelationshipsController extends TransportController { const templateId = CoreId.from(backboneRelationship.relationshipTemplateId); const template = await this.parent.relationshipTemplates.getRelationshipTemplate(templateId); - if (!template) throw CoreErrors.general.recordNotFound(RelationshipTemplate, templateId.toString()); + if (!template) throw TransportCoreErrors.general.recordNotFound(RelationshipTemplate, templateId.toString()); if (!template.cache) throw this.newCacheEmptyError(RelationshipTemplate, template.id.toString()); const secretId = await TransportIds.relationshipSecret.generate(); @@ -534,7 +538,7 @@ export class RelationshipsController extends TransportController { private async completeOperationWithBackboneCall(operation: RelationshipAuditLogEntryReason, id: CoreId) { const relationshipDoc = await this.relationships.read(id.toString()); if (!relationshipDoc) { - throw CoreErrors.general.recordNotFound(Relationship, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Relationship, id.toString()); } const relationship = Relationship.from(relationshipDoc); diff --git a/packages/transport/src/modules/secrets/SecretController.ts b/packages/transport/src/modules/secrets/SecretController.ts index 5c066ea91..6717fae59 100644 --- a/packages/transport/src/modules/secrets/SecretController.ts +++ b/packages/transport/src/modules/secrets/SecretController.ts @@ -12,7 +12,7 @@ import { CryptoSignatureKeypair, CryptoSignaturePrivateKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors, TransportIds } from "../../core"; +import { CoreCrypto, TransportCoreErrors, TransportIds } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; @@ -217,7 +217,7 @@ export class SecretController extends TransportController { if (baseKey) { this.baseKey = baseKey.secret as CryptoSecretKey; } else { - throw CoreErrors.general.recordNotFound(CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey); + throw TransportCoreErrors.general.recordNotFound(CryptoSecretKey, DeviceSecretType.SharedSecretBaseKey); } return this.baseKey; diff --git a/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts b/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts index 46d7aef1a..922a25082 100644 --- a/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts +++ b/packages/transport/src/modules/sync/DatawalletModificationsProcessor.ts @@ -4,7 +4,7 @@ import { Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; import { CoreId } from "@nmshd/core-types"; import _ from "lodash"; -import { CoreErrors, TransportError, TransportIds } from "../../core"; +import { TransportCoreErrors, TransportError, TransportIds } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ICacheable } from "../../core/ICacheable"; import { CachedIdentityDeletionProcess } from "../accounts/data/CachedIdentityDeletionProcess"; @@ -177,7 +177,7 @@ export class DatawalletModificationsProcessor { const collectionsWithUncacheableItems = uniqueCollections.filter((c) => !this.collectionsWithCacheableItems.includes(c)); if (collectionsWithUncacheableItems.length > 0) { - throw CoreErrors.datawallet.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems); + throw TransportCoreErrors.datawallet.unsupportedModification("unsupportedCacheChangedModificationCollection", collectionsWithUncacheableItems); } } diff --git a/packages/transport/src/modules/sync/SyncController.ts b/packages/transport/src/modules/sync/SyncController.ts index 742f101e9..dc94ab45f 100644 --- a/packages/transport/src/modules/sync/SyncController.ts +++ b/packages/transport/src/modules/sync/SyncController.ts @@ -1,7 +1,7 @@ import { IDatabaseCollection, IDatabaseMap } from "@js-soft/docdb-access-abstractions"; import { log } from "@js-soft/ts-utils"; -import { CoreDate, CoreId } from "@nmshd/core-types"; -import { ControllerName, CoreError, CoreErrors, RequestError, TransportController, TransportError, TransportLoggerFactory } from "../../core"; +import { CoreDate, CoreError, CoreId } from "@nmshd/core-types"; +import { ControllerName, RequestError, TransportController, TransportCoreErrors, TransportError, TransportLoggerFactory } from "../../core"; import { DependencyOverrides } from "../../core/DependencyOverrides"; import { AccountController } from "../accounts/AccountController"; import { ChangedItems } from "./ChangedItems"; @@ -159,7 +159,7 @@ export class SyncController extends TransportController { if (this.config.supportedDatawalletVersion < identityDatawalletVersion) { // This means that the datawallet of the identity was upgraded by another device with a higher version. // It is necessary to update the current device. - throw CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); + throw TransportCoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); } this.log.trace("Synchronization of Datawallet events started..."); @@ -173,7 +173,7 @@ export class SyncController extends TransportController { const outdatedErrorCode = "error.platform.validation.datawallet.insufficientSupportedDatawalletVersion"; if (!(e instanceof RequestError) || e.code !== outdatedErrorCode) throw e; - throw CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); + throw TransportCoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); } this.log.trace("Synchronization of Datawallet events ended..."); @@ -184,7 +184,7 @@ export class SyncController extends TransportController { @log() private async checkDatawalletVersion(identityDatawalletVersion: number) { if (this.config.supportedDatawalletVersion < identityDatawalletVersion) { - throw CoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); + throw TransportCoreErrors.datawallet.insufficientSupportedDatawalletVersion(this.config.supportedDatawalletVersion, identityDatawalletVersion); } if (this.config.supportedDatawalletVersion > identityDatawalletVersion) { @@ -202,11 +202,11 @@ export class SyncController extends TransportController { if (identityDatawalletVersion === targetDatawalletVersion) return; if (this.config.supportedDatawalletVersion < targetDatawalletVersion) { - throw CoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion); + throw TransportCoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, identityDatawalletVersion); } if (identityDatawalletVersion > targetDatawalletVersion) { - throw CoreErrors.datawallet.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion); + throw TransportCoreErrors.datawallet.currentBiggerThanTarget(identityDatawalletVersion, targetDatawalletVersion); } while (identityDatawalletVersion < targetDatawalletVersion) { @@ -230,11 +230,11 @@ export class SyncController extends TransportController { if (deviceDatawalletVersion === targetDatawalletVersion) return; if (this.config.supportedDatawalletVersion < targetDatawalletVersion) { - throw CoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion); + throw TransportCoreErrors.datawallet.insufficientSupportedDatawalletVersion(targetDatawalletVersion, deviceDatawalletVersion); } if (deviceDatawalletVersion > targetDatawalletVersion) { - throw CoreErrors.datawallet.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion); + throw TransportCoreErrors.datawallet.currentBiggerThanTarget(deviceDatawalletVersion, targetDatawalletVersion); } while (deviceDatawalletVersion < targetDatawalletVersion) { diff --git a/packages/transport/src/modules/tokens/AnonymousTokenController.ts b/packages/transport/src/modules/tokens/AnonymousTokenController.ts index cefd20369..f92588ae5 100644 --- a/packages/transport/src/modules/tokens/AnonymousTokenController.ts +++ b/packages/transport/src/modules/tokens/AnonymousTokenController.ts @@ -1,7 +1,7 @@ import { Serializable } from "@js-soft/ts-serval"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors, IConfig } from "../../core"; +import { CoreCrypto, IConfig, TransportCoreErrors } from "../../core"; import { AnonymousTokenClient } from "./backbone/AnonymousTokenClient"; import { CachedToken } from "./local/CachedToken"; import { Token } from "./local/Token"; @@ -30,7 +30,7 @@ export class AnonymousTokenController { const plaintextTokenContent = Serializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); if (!(plaintextTokenContent instanceof Serializable)) { - throw CoreErrors.tokens.invalidTokenContent(id.toString()); + throw TransportCoreErrors.tokens.invalidTokenContent(id.toString()); } const token = Token.from({ id: id, diff --git a/packages/transport/src/modules/tokens/TokenController.ts b/packages/transport/src/modules/tokens/TokenController.ts index 234240cf3..2a9776811 100644 --- a/packages/transport/src/modules/tokens/TokenController.ts +++ b/packages/transport/src/modules/tokens/TokenController.ts @@ -2,7 +2,7 @@ import { ISerializable, Serializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoSecretKey } from "@nmshd/crypto"; -import { CoreCrypto, CoreErrors, TransportError } from "../../core"; +import { CoreCrypto, TransportCoreErrors, TransportError } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; @@ -79,7 +79,7 @@ export class TokenController extends TransportController { const id = idOrToken instanceof CoreId ? idOrToken.toString() : idOrToken.id.toString(); const tokenDoc = await this.tokens.read(id); if (!tokenDoc) { - throw CoreErrors.general.recordNotFound(Token, id.toString()); + throw TransportCoreErrors.general.recordNotFound(Token, id.toString()); } const token = Token.from(tokenDoc); @@ -136,7 +136,7 @@ export class TokenController extends TransportController { private async updateCacheOfExistingTokenInDb(id: string, response?: BackboneGetTokensResponse) { const tokenDoc = await this.tokens.read(id); if (!tokenDoc) { - CoreErrors.general.recordNotFound(Token, id); + TransportCoreErrors.general.recordNotFound(Token, id); return; } @@ -168,7 +168,7 @@ export class TokenController extends TransportController { const plaintextTokenContent = Serializable.deserializeUnknown(plaintextTokenBuffer.toUtf8()); if (!(plaintextTokenContent instanceof Serializable)) { - throw CoreErrors.tokens.invalidTokenContent(response.id); + throw TransportCoreErrors.tokens.invalidTokenContent(response.id); } const cachedToken = CachedToken.from({ From 897d8a88b97b831caf3b566e6244e60573dc51e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:34:52 +0200 Subject: [PATCH 06/16] fix: add references to core-types and utils to transport --- package-lock.json | 5 ++++- packages/transport/package.json | 4 +++- packages/transport/tsconfig.json | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc6d883b5..53c781b29 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9348,6 +9348,7 @@ "license": "MIT", "dependencies": { "@js-soft/logging-abstractions": "^1.0.1", + "@nmshd/core-types": "*", "@nmshd/iql": "^1.0.2", "ts-simple-nameof": "^1.3.1" }, @@ -9418,6 +9419,9 @@ "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/simple-logger": "1.0.5", "@js-soft/ts-utils": "^2.3.3", + "@nmshd/core-types": "*", + "@nmshd/crypto": "2.0.6", + "@nmshd/utils": "*", "axios": "^1.7.5", "fast-json-patch": "^3.1.1", "form-data": "^4.0.0", @@ -9436,7 +9440,6 @@ "@js-soft/node-logger": "1.2.0", "@js-soft/ts-serval": "2.0.10", "@js-soft/web-logger": "^1.0.4", - "@nmshd/crypto": "2.0.6", "@types/json-stringify-safe": "^5.0.3", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", diff --git a/packages/transport/package.json b/packages/transport/package.json index 37fd5d071..f254a0e04 100644 --- a/packages/transport/package.json +++ b/packages/transport/package.json @@ -70,6 +70,9 @@ "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/simple-logger": "1.0.5", "@js-soft/ts-utils": "^2.3.3", + "@nmshd/core-types": "*", + "@nmshd/crypto": "2.0.6", + "@nmshd/utils": "*", "axios": "^1.7.5", "fast-json-patch": "^3.1.1", "form-data": "^4.0.0", @@ -88,7 +91,6 @@ "@js-soft/node-logger": "1.2.0", "@js-soft/ts-serval": "2.0.10", "@js-soft/web-logger": "^1.0.4", - "@nmshd/crypto": "2.0.6", "@types/json-stringify-safe": "^5.0.3", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", diff --git a/packages/transport/tsconfig.json b/packages/transport/tsconfig.json index 0a8a33ee7..b446e3773 100644 --- a/packages/transport/tsconfig.json +++ b/packages/transport/tsconfig.json @@ -5,5 +5,6 @@ "rootDir": "src" }, "include": ["src/**/*.ts"], - "exclude": [] + "exclude": [], + "references": [{ "path": "../core-types" }, { "path": "../utils" }] } From 075711a175454b76c376d8525ae1d23f851b8f6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 09:47:43 +0200 Subject: [PATCH 07/16] refactor: undo utils extraction --- package-lock.json | 8 +-- package.json | 1 - .../multiAccount/MultiAccountController.ts | 6 +- packages/core-types/package.json | 1 - packages/core-types/src/CoreId.ts | 10 ---- packages/core-types/tsconfig.json | 2 +- .../test/consumption/attributes.test.ts | 5 +- .../runtime/test/dataViews/MessageDVO.test.ts | 7 ++- packages/transport/package.json | 1 - packages/transport/src/core/CoreCrypto.ts | 2 +- packages/transport/src/core/CoreIdHelper.ts | 7 ++- .../transport/src/core/GeneratableCoreId.ts | 13 +++++ .../transport/src/core/backbone/RESTClient.ts | 4 +- packages/transport/src/core/index.ts | 1 + packages/transport/src/index.ts | 1 + .../src/modules/accounts/AccountController.ts | 2 +- .../src/modules/devices/DevicesController.ts | 2 +- .../src/util}/PasswordGenerator.ts | 0 .../src => transport/src/util}/Random.ts | 0 .../src => transport/src/util}/index.ts | 0 .../test/utils}/PasswordGenerator.test.ts | 2 +- .../test/utils}/Random.test.ts | 2 +- packages/transport/tsconfig.json | 2 +- packages/utils/.gitignore | 12 ---- packages/utils/package.json | 57 ------------------- packages/utils/test/tsconfig.json | 11 ---- packages/utils/tsconfig.json | 9 --- 27 files changed, 39 insertions(+), 129 deletions(-) create mode 100644 packages/transport/src/core/GeneratableCoreId.ts rename packages/{utils/src => transport/src/util}/PasswordGenerator.ts (100%) rename packages/{utils/src => transport/src/util}/Random.ts (100%) rename packages/{utils/src => transport/src/util}/index.ts (100%) rename packages/{utils/test => transport/test/utils}/PasswordGenerator.test.ts (98%) rename packages/{utils/test => transport/test/utils}/Random.test.ts (98%) delete mode 100644 packages/utils/.gitignore delete mode 100644 packages/utils/package.json delete mode 100644 packages/utils/test/tsconfig.json delete mode 100644 packages/utils/tsconfig.json diff --git a/package-lock.json b/package-lock.json index 53c781b29..34de464b9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,6 @@ "name": "monorepo", "license": "MIT", "workspaces": [ - "packages/utils", "packages/core-types", "packages/transport", "packages/content", @@ -1410,10 +1409,6 @@ "resolved": "packages/transport", "link": true }, - "node_modules/@nmshd/utils": { - "resolved": "packages/utils", - "link": true - }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "dev": true, @@ -9363,7 +9358,6 @@ "license": "MIT", "dependencies": { "@js-soft/ts-serval": "2.0.10", - "@nmshd/utils": "*", "luxon": "^3.5.0" }, "devDependencies": { @@ -9421,7 +9415,6 @@ "@js-soft/ts-utils": "^2.3.3", "@nmshd/core-types": "*", "@nmshd/crypto": "2.0.6", - "@nmshd/utils": "*", "axios": "^1.7.5", "fast-json-patch": "^3.1.1", "form-data": "^4.0.0", @@ -9451,6 +9444,7 @@ }, "packages/utils": { "name": "@nmshd/utils", + "extraneous": true, "license": "MIT", "devDependencies": {} } diff --git a/package.json b/package.json index 83825dfc5..b31d2f6b9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "license": "MIT", "author": "j&s-soft GmbH", "workspaces": [ - "packages/utils", "packages/core-types", "packages/transport", "packages/content", diff --git a/packages/app-runtime/src/multiAccount/MultiAccountController.ts b/packages/app-runtime/src/multiAccount/MultiAccountController.ts index f926eac15..eb7200062 100644 --- a/packages/app-runtime/src/multiAccount/MultiAccountController.ts +++ b/packages/app-runtime/src/multiAccount/MultiAccountController.ts @@ -2,7 +2,7 @@ import { IDatabaseCollection, IDatabaseCollectionProvider } from "@js-soft/docdb import { LokiJsConnection } from "@js-soft/docdb-access-loki"; import { ILogger } from "@js-soft/logging-abstractions"; import { CoreAddress, CoreDate, CoreError, CoreId } from "@nmshd/core-types"; -import { AccountController, DeviceSharedSecret, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; +import { AccountController, DeviceSharedSecret, GeneratableCoreId, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; import { AppConfig } from "../AppConfig"; import { SessionStorage } from "../SessionStorage"; import { LocalAccount } from "./data/LocalAccount"; @@ -146,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 GeneratableCoreId.generate(); const localAccount = LocalAccount.from({ id, @@ -175,7 +175,7 @@ export class MultiAccountController { } public async createAccount(name: string): Promise<[LocalAccount, AccountController]> { - const id = await CoreId.generate(); + const id = await GeneratableCoreId.generate(); let localAccount = LocalAccount.from({ id, diff --git a/packages/core-types/package.json b/packages/core-types/package.json index 55614a78c..3f0526d7a 100644 --- a/packages/core-types/package.json +++ b/packages/core-types/package.json @@ -50,7 +50,6 @@ }, "dependencies": { "@js-soft/ts-serval": "2.0.10", - "@nmshd/utils": "*", "luxon": "^3.5.0" }, "devDependencies": { diff --git a/packages/core-types/src/CoreId.ts b/packages/core-types/src/CoreId.ts index a10da0ae5..ccb13b17b 100644 --- a/packages/core-types/src/CoreId.ts +++ b/packages/core-types/src/CoreId.ts @@ -1,5 +1,4 @@ import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -import { Random, RandomCharacterRange } from "@nmshd/utils"; import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; export interface ICoreId extends ICoreSerializable { @@ -24,15 +23,6 @@ export class CoreId extends CoreSerializable implements ICoreId { return this.id === id.toString(); } - public static async generate(prefix = ""): Promise { - if (prefix.length > 6) { - throw new Error(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`); - } - - const random = await Random.string(20 - prefix.length, RandomCharacterRange.Alphanumeric); - return this.from(prefix.toUpperCase() + random); - } - public static from(value: ICoreId | string): CoreId { return this.fromAny(value); } diff --git a/packages/core-types/tsconfig.json b/packages/core-types/tsconfig.json index 7ba274db4..a0c1fcab3 100644 --- a/packages/core-types/tsconfig.json +++ b/packages/core-types/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src/**/*.ts"], "exclude": [], - "references": [{ "path": "../utils" }] + "references": [] } diff --git a/packages/runtime/test/consumption/attributes.test.ts b/packages/runtime/test/consumption/attributes.test.ts index 9f6325244..785e0ccaa 100644 --- a/packages/runtime/test/consumption/attributes.test.ts +++ b/packages/runtime/test/consumption/attributes.test.ts @@ -12,6 +12,7 @@ import { ZipCodeJSON } from "@nmshd/content"; import { CoreDate, CoreId } from "@nmshd/core-types"; +import { GeneratableCoreId } from "@nmshd/transport"; import { AttributeCreatedEvent, ChangeDefaultRepositoryAttributeUseCase, @@ -973,7 +974,7 @@ describe(ShareRepositoryAttributeUseCase.name, () => { test("should throw if repository attribute doesn't exist", async () => { const shareRequest: ShareRepositoryAttributeRequest = { - attributeId: (await CoreId.generate("ATT")).toString(), + attributeId: (await GeneratableCoreId.generate("ATT")).toString(), peer: services1.address }; const shareRequestResult = await services1.consumption.attributes.shareRepositoryAttribute(shareRequest); @@ -1040,7 +1041,7 @@ describe(SucceedRepositoryAttributeUseCase.name, () => { test("should throw if predecessor doesn't exist", async () => { const succeedAttributeRequest: SucceedRepositoryAttributeRequest = { - predecessorId: (await CoreId.generate("ATT")).toString(), + predecessorId: (await GeneratableCoreId.generate("ATT")).toString(), successorContent: { value: { "@type": "GivenName", diff --git a/packages/runtime/test/dataViews/MessageDVO.test.ts b/packages/runtime/test/dataViews/MessageDVO.test.ts index 3e255db6f..a09f5aa01 100644 --- a/packages/runtime/test/dataViews/MessageDVO.test.ts +++ b/packages/runtime/test/dataViews/MessageDVO.test.ts @@ -10,7 +10,8 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { CoreAddress } from "@nmshd/core-types"; +import { GeneratableCoreId } from "@nmshd/transport"; import { DataViewExpander, MailDVO, SendMessageRequest, TransportServices } from "../../src"; import { establishRelationshipWithContents, getRelationship, RuntimeServiceProvider, syncUntilHasMessage, uploadFile } from "../lib"; @@ -47,11 +48,11 @@ beforeAll(async () => { response: { "@type": "Response", result: ResponseResult.Accepted, - requestId: (await CoreId.generate()).toString(), + requestId: (await GeneratableCoreId.generate()).toString(), items: [ ReadAttributeAcceptResponseItem.from({ result: ResponseItemResult.Accepted, - attributeId: await CoreId.generate(), + attributeId: await GeneratableCoreId.generate(), attribute: IdentityAttribute.from({ owner: CoreAddress.from((await transportServices1.account.getIdentityInfo()).value.address), value: GivenName.from("AGivenName") diff --git a/packages/transport/package.json b/packages/transport/package.json index f254a0e04..80cb8646c 100644 --- a/packages/transport/package.json +++ b/packages/transport/package.json @@ -72,7 +72,6 @@ "@js-soft/ts-utils": "^2.3.3", "@nmshd/core-types": "*", "@nmshd/crypto": "2.0.6", - "@nmshd/utils": "*", "axios": "^1.7.5", "fast-json-patch": "^3.1.1", "form-data": "^4.0.0", diff --git a/packages/transport/src/core/CoreCrypto.ts b/packages/transport/src/core/CoreCrypto.ts index 7ed771f70..8bf547a14 100644 --- a/packages/transport/src/core/CoreCrypto.ts +++ b/packages/transport/src/core/CoreCrypto.ts @@ -20,7 +20,7 @@ import { CryptoSignatures, Encoding } from "@nmshd/crypto"; -import { PasswordGenerator } from "@nmshd/utils"; +import { PasswordGenerator } from "../util"; import { TransportError } from "./TransportError"; import { TransportVersion } from "./types/TransportVersion"; diff --git a/packages/transport/src/core/CoreIdHelper.ts b/packages/transport/src/core/CoreIdHelper.ts index faca0d8ac..d72e33491 100644 --- a/packages/transport/src/core/CoreIdHelper.ts +++ b/packages/transport/src/core/CoreIdHelper.ts @@ -1,5 +1,6 @@ import { CoreId } from "@nmshd/core-types"; -import { RandomCharacterRange } from "@nmshd/utils"; +import { RandomCharacterRange } from "../util"; +import { GeneratableCoreId } from "./GeneratableCoreId"; import { TransportError } from "./TransportError"; export class CoreIdHelper { @@ -17,11 +18,11 @@ export class CoreIdHelper { throw new TransportError("This CoreIdHelper is set up for validation only."); } - return await CoreId.generate(this.prefix); + return await GeneratableCoreId.generate(this.prefix); } public async generateUnsafe(): Promise { - return await CoreId.generate(this.prefix); + return await GeneratableCoreId.generate(this.prefix); } public validate(id: string | CoreId): boolean { diff --git a/packages/transport/src/core/GeneratableCoreId.ts b/packages/transport/src/core/GeneratableCoreId.ts new file mode 100644 index 000000000..52d5f63b1 --- /dev/null +++ b/packages/transport/src/core/GeneratableCoreId.ts @@ -0,0 +1,13 @@ +import { CoreId } from "@nmshd/core-types"; +import { Random, RandomCharacterRange } from "../util"; + +export class GeneratableCoreId extends CoreId { + public static async generate(prefix = ""): Promise { + if (prefix.length > 6) { + throw new Error(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`); + } + + const random = await Random.string(20 - prefix.length, RandomCharacterRange.Alphanumeric); + return this.from(prefix.toUpperCase() + random); + } +} diff --git a/packages/transport/src/core/backbone/RESTClient.ts b/packages/transport/src/core/backbone/RESTClient.ts index 5d5ac112c..a9143583f 100644 --- a/packages/transport/src/core/backbone/RESTClient.ts +++ b/packages/transport/src/core/backbone/RESTClient.ts @@ -1,11 +1,11 @@ import { ILogger } from "@js-soft/logging-abstractions"; -import { CoreId } from "@nmshd/core-types"; import { CoreBuffer } from "@nmshd/crypto"; import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios"; import formDataLib from "form-data"; import { AgentOptions } from "http"; import { AgentOptions as HTTPSAgentOptions } from "https"; import _ from "lodash"; +import { GeneratableCoreId } from "../GeneratableCoreId"; import { TransportLoggerFactory } from "../TransportLoggerFactory"; import { ClientResult } from "./ClientResult"; import { IPaginationDataSource, Paginator, PaginatorPercentageCallback } from "./Paginator"; @@ -59,7 +59,7 @@ export class RESTClient { } private async generateRequestId(): Promise { - const id = await CoreId.generate("HTTP"); + const id = await GeneratableCoreId.generate("HTTP"); return id.toString(); } diff --git a/packages/transport/src/core/index.ts b/packages/transport/src/core/index.ts index 8cf36c05e..755775d18 100644 --- a/packages/transport/src/core/index.ts +++ b/packages/transport/src/core/index.ts @@ -5,6 +5,7 @@ export * from "./CoreSynchronizable"; export * from "./CoreUtil"; export * from "./DbCollectionName"; export * from "./DependencyOverrides"; +export * from "./GeneratableCoreId"; export * from "./Reference"; export * from "./Transport"; export * from "./TransportController"; diff --git a/packages/transport/src/index.ts b/packages/transport/src/index.ts index 2da1fed80..fb95430a8 100644 --- a/packages/transport/src/index.ts +++ b/packages/transport/src/index.ts @@ -2,3 +2,4 @@ export * from "./buildInformation"; export * from "./core"; export * from "./events"; export * from "./modules"; +export * from "./util"; diff --git a/packages/transport/src/modules/accounts/AccountController.ts b/packages/transport/src/modules/accounts/AccountController.ts index 902db8940..d535b1324 100644 --- a/packages/transport/src/modules/accounts/AccountController.ts +++ b/packages/transport/src/modules/accounts/AccountController.ts @@ -3,12 +3,12 @@ import { ILogger } from "@js-soft/logging-abstractions"; import { log } from "@js-soft/ts-utils"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoSecretKey } from "@nmshd/crypto"; -import { PasswordGenerator } from "@nmshd/utils"; import { AbstractAuthenticator, Authenticator, ControllerName, IConfig, Transport, TransportCoreErrors, TransportError } from "../../core"; import { CoreCrypto } from "../../core/CoreCrypto"; import { DbCollectionName } from "../../core/DbCollectionName"; import { DependencyOverrides } from "../../core/DependencyOverrides"; import { TransportLoggerFactory } from "../../core/TransportLoggerFactory"; +import { PasswordGenerator } from "../../util"; import { CertificateController } from "../certificates/CertificateController"; import { CertificateIssuer } from "../certificates/CertificateIssuer"; import { CertificateValidator } from "../certificates/CertificateValidator"; diff --git a/packages/transport/src/modules/devices/DevicesController.ts b/packages/transport/src/modules/devices/DevicesController.ts index 4ba6ce988..331de15dd 100644 --- a/packages/transport/src/modules/devices/DevicesController.ts +++ b/packages/transport/src/modules/devices/DevicesController.ts @@ -1,8 +1,8 @@ import { CoreDate, CoreId } from "@nmshd/core-types"; -import { PasswordGenerator } from "@nmshd/utils"; import { TransportCoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; +import { PasswordGenerator } from "../../util"; import { AccountController } from "../accounts/AccountController"; import { ChallengeType } from "../challenges/data/Challenge"; import { SynchronizedCollection } from "../sync/SynchronizedCollection"; diff --git a/packages/utils/src/PasswordGenerator.ts b/packages/transport/src/util/PasswordGenerator.ts similarity index 100% rename from packages/utils/src/PasswordGenerator.ts rename to packages/transport/src/util/PasswordGenerator.ts diff --git a/packages/utils/src/Random.ts b/packages/transport/src/util/Random.ts similarity index 100% rename from packages/utils/src/Random.ts rename to packages/transport/src/util/Random.ts diff --git a/packages/utils/src/index.ts b/packages/transport/src/util/index.ts similarity index 100% rename from packages/utils/src/index.ts rename to packages/transport/src/util/index.ts diff --git a/packages/utils/test/PasswordGenerator.test.ts b/packages/transport/test/utils/PasswordGenerator.test.ts similarity index 98% rename from packages/utils/test/PasswordGenerator.test.ts rename to packages/transport/test/utils/PasswordGenerator.test.ts index 702d88db5..3b55c2c7d 100644 --- a/packages/utils/test/PasswordGenerator.test.ts +++ b/packages/transport/test/utils/PasswordGenerator.test.ts @@ -1,4 +1,4 @@ -import { PasswordGenerator } from "../src"; +import { PasswordGenerator } from "../../src"; describe("PasswordGeneratorTest", function () { describe("CreatePassword", function () { diff --git a/packages/utils/test/Random.test.ts b/packages/transport/test/utils/Random.test.ts similarity index 98% rename from packages/utils/test/Random.test.ts rename to packages/transport/test/utils/Random.test.ts index 8faa33252..164bcd0d5 100644 --- a/packages/utils/test/Random.test.ts +++ b/packages/transport/test/utils/Random.test.ts @@ -1,4 +1,4 @@ -import { Random, RandomCharacterRange } from "../src"; +import { Random, RandomCharacterRange } from "../../src"; describe("RandomTest", function () { describe("IntBetween", function () { diff --git a/packages/transport/tsconfig.json b/packages/transport/tsconfig.json index b446e3773..27e162755 100644 --- a/packages/transport/tsconfig.json +++ b/packages/transport/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src/**/*.ts"], "exclude": [], - "references": [{ "path": "../core-types" }, { "path": "../utils" }] + "references": [{ "path": "../core-types" }] } diff --git a/packages/utils/.gitignore b/packages/utils/.gitignore deleted file mode 100644 index 586efae9b..000000000 --- a/packages/utils/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -node_modules -tmp-browser -dist-test -lib-web -dist -docs -*.log -*.log.* -_archive -.idea -coverage -.nyc_output diff --git a/packages/utils/package.json b/packages/utils/package.json deleted file mode 100644 index 720a49a92..000000000 --- a/packages/utils/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@nmshd/utils", - "description": "The enmeshed utils.", - "homepage": "https://enmeshed.eu", - "repository": { - "type": "git", - "url": "git+https://github.com/nmshd/runtime.git", - "directory": "packages/utils" - }, - "license": "MIT", - "author": "j&s-soft GmbH", - "main": "dist/index.js", - "types": "dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "tsc", - "build:ci": "tsc", - "cdep": "tsc && madge --circular dist", - "lint:tsc": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit", - "test": "jest -i", - "test:ci": "jest -i --coverage" - }, - "jest": { - "maxWorkers": 1, - "preset": "ts-jest", - "coverageProvider": "v8", - "coverageReporters": [ - "text-summary", - "cobertura", - "lcov" - ], - "collectCoverageFrom": [ - "./src/**" - ], - "setupFilesAfterEnv": [ - "jest-expect-message" - ], - "testEnvironment": "node", - "testTimeout": 60000, - "transform": { - "^.+\\.ts$": [ - "ts-jest", - { - "tsconfig": "test/tsconfig.json" - } - ] - } - }, - "dependencies": {}, - "devDependencies": {}, - "publishConfig": { - "access": "public", - "provenance": true - } -} diff --git a/packages/utils/test/tsconfig.json b/packages/utils/test/tsconfig.json deleted file mode 100644 index 50e8c5f15..000000000 --- a/packages/utils/test/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.base.json", - "compilerOptions": { - "baseUrl": "../", - "noEmit": true, - "composite": false - }, - "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], - "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], - "exclude": [] -} diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json deleted file mode 100644 index 0a8a33ee7..000000000 --- a/packages/utils/tsconfig.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../tsconfig.base.json", - "compilerOptions": { - "outDir": "dist", - "rootDir": "src" - }, - "include": ["src/**/*.ts"], - "exclude": [] -} From 175a93f614421642abccabeb7c33f72ba0365480 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:11:06 +0200 Subject: [PATCH 08/16] chore: undo some stuff --- .../modules/attributes/local/QueryTranslator.ts | 14 +++++++------- .../content/src/attributes/AbstractAttribute.ts | 8 ++++---- .../src/attributes/AbstractAttributeQuery.ts | 6 +++--- packages/content/src/buildInformation.ts | 6 +----- packages/content/test/attributes/BirthDate.test.ts | 2 +- .../items/ProposeAttributeRequestItem.test.ts | 3 +-- packages/core-types/src/CoreAddress.ts | 7 +++---- packages/core-types/src/CoreDate.ts | 7 +++---- packages/core-types/src/CoreId.ts | 7 +++---- packages/core-types/src/index.ts | 2 -- .../src => transport/src/core/types}/CoreHash.ts | 0 .../src/core/types}/CoreSerializable.ts | 0 packages/transport/src/core/types/index.ts | 2 ++ .../data/items/CertificatePrivateAttributeItem.ts | 2 +- .../items/CertificatePrivateAttributeItemSource.ts | 2 +- .../transport/src/modules/files/FileController.ts | 4 ++-- .../src/modules/files/local/CachedFile.ts | 5 +++-- .../src/modules/files/transmission/FileMetadata.ts | 3 ++- .../requests/RelationshipCreationContentCipher.ts | 6 +++--- .../RelationshipCreationResponseContentCipher.ts | 6 +++--- 20 files changed, 43 insertions(+), 49 deletions(-) rename packages/{core-types/src => transport/src/core/types}/CoreHash.ts (100%) rename packages/{core-types/src => transport/src/core/types}/CoreSerializable.ts (100%) diff --git a/packages/consumption/src/modules/attributes/local/QueryTranslator.ts b/packages/consumption/src/modules/attributes/local/QueryTranslator.ts index 675fd68f9..8593d924b 100644 --- a/packages/consumption/src/modules/attributes/local/QueryTranslator.ts +++ b/packages/consumption/src/modules/attributes/local/QueryTranslator.ts @@ -11,7 +11,7 @@ import { RelationshipAttributeQuery, ThirdPartyRelationshipAttributeQuery } from "@nmshd/content"; -import { DateTime } from "luxon"; +import { CoreDate } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; import { ConsumptionError } from "../../../consumption/ConsumptionError"; import { LocalAttribute } from "./LocalAttribute"; @@ -58,7 +58,7 @@ export class IdentityAttributeQueryTranslator { if (!input) { return; } - const validFromUtcString = DateTime.fromISO(input).toUTC().toString(); + const validFromUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validFrom)}`] = { $gte: validFromUtcString }; @@ -68,7 +68,7 @@ export class IdentityAttributeQueryTranslator { if (!input) { return; } - const validToUtcString = DateTime.fromISO(input).toUTC().toString(); + const validToUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validTo)}`] = { $lte: validToUtcString }; @@ -104,7 +104,7 @@ export class RelationshipAttributeQueryTranslator { if (!input) { return; } - const validFromUtcString = DateTime.fromISO(input).toUTC().toString(); + const validFromUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validFrom)}`] = { $gte: validFromUtcString }; @@ -114,7 +114,7 @@ export class RelationshipAttributeQueryTranslator { if (!input) { return; } - const validToUtcString = DateTime.fromISO(input).toUTC().toString(); + const validToUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validTo)}`] = { $lte: validToUtcString }; @@ -153,7 +153,7 @@ export class ThirdPartyRelationshipAttributeQueryTranslator { if (!input) { return; } - const validFromUtcString = DateTime.fromISO(input).toUTC().toString(); + const validFromUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validFrom)}`] = { $gte: validFromUtcString }; @@ -163,7 +163,7 @@ export class ThirdPartyRelationshipAttributeQueryTranslator { if (!input) { return; } - const validToUtcString = DateTime.fromISO(input).toUTC().toString(); + const validToUtcString = CoreDate.from(input).toISOString(); query[`${nameof((x) => x.content)}.${nameof((x) => x.validTo)}`] = { $lte: validToUtcString }; diff --git a/packages/content/src/attributes/AbstractAttribute.ts b/packages/content/src/attributes/AbstractAttribute.ts index c27de7720..8d206b105 100644 --- a/packages/content/src/attributes/AbstractAttribute.ts +++ b/packages/content/src/attributes/AbstractAttribute.ts @@ -1,5 +1,5 @@ -import { serialize, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreSerializable, ICoreAddress, ICoreDate, ICoreSerializable } from "@nmshd/core-types"; +import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; +import { CoreAddress, CoreDate, ICoreAddress, ICoreDate } from "@nmshd/core-types"; import { ContentJSON } from "../ContentJSON"; export interface AbstractAttributeJSON extends ContentJSON { @@ -8,13 +8,13 @@ export interface AbstractAttributeJSON extends ContentJSON { validTo?: string; } -export interface IAbstractAttribute extends ICoreSerializable { +export interface IAbstractAttribute extends ISerializable { owner: ICoreAddress; validFrom?: ICoreDate; validTo?: ICoreDate; } -export abstract class AbstractAttribute extends CoreSerializable implements IAbstractAttribute { +export abstract class AbstractAttribute extends Serializable implements IAbstractAttribute { @validate() @serialize() public owner: CoreAddress; diff --git a/packages/content/src/attributes/AbstractAttributeQuery.ts b/packages/content/src/attributes/AbstractAttributeQuery.ts index 5658b8abf..375722cba 100644 --- a/packages/content/src/attributes/AbstractAttributeQuery.ts +++ b/packages/content/src/attributes/AbstractAttributeQuery.ts @@ -1,6 +1,6 @@ -import { CoreSerializable, ICoreSerializable } from "@nmshd/core-types"; +import { ISerializable, Serializable } from "@js-soft/ts-serval"; import { ContentJSON } from "../ContentJSON"; export interface AbstractAttributeQueryJSON extends ContentJSON {} -export interface IAbstractAttributeQuery extends ICoreSerializable {} -export abstract class AbstractAttributeQuery extends CoreSerializable implements IAbstractAttributeQuery {} +export interface IAbstractAttributeQuery extends ISerializable {} +export abstract class AbstractAttributeQuery extends Serializable implements IAbstractAttributeQuery {} diff --git a/packages/content/src/buildInformation.ts b/packages/content/src/buildInformation.ts index f83c6d4d9..bc4780e22 100644 --- a/packages/content/src/buildInformation.ts +++ b/packages/content/src/buildInformation.ts @@ -1,5 +1,4 @@ import { buildInformation as servalBuildInformation } from "@js-soft/ts-serval"; -import { buildInformation as cryptoBuildInformation } from "@nmshd/crypto"; export const buildInformation = { version: "{{version}}", @@ -7,8 +6,5 @@ export const buildInformation = { date: "{{date}}", commit: "{{commit}}", dependencies: "{{dependencies}}", - libraries: { - serval: servalBuildInformation, - crypto: cryptoBuildInformation - } + libraries: { serval: servalBuildInformation } }; diff --git a/packages/content/test/attributes/BirthDate.test.ts b/packages/content/test/attributes/BirthDate.test.ts index d237f17bb..2158a0bd6 100644 --- a/packages/content/test/attributes/BirthDate.test.ts +++ b/packages/content/test/attributes/BirthDate.test.ts @@ -1,5 +1,5 @@ -import { BirthDate, ValidationErrorWithoutProperty } from "@nmshd/content"; import { DateTime } from "luxon"; +import { BirthDate, ValidationErrorWithoutProperty } from "../../src"; describe("creation of RepositoryAttributes of Attribute value type BirthDate", () => { test("can create a RepositoryAttribute of Attribute value type BirthDate", function () { diff --git a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts index 1b2d16a06..a32fd6ee2 100644 --- a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts +++ b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts @@ -1,8 +1,7 @@ import { ValidationError } from "@js-soft/ts-serval"; -import { TestObjectFactory } from "@nmshd/consumption/test/modules/requests/testHelpers/TestObjectFactory"; -import { IdentityAttributeQuery, IQLQuery, ProposeAttributeRequestItem, RelationshipAttributeConfidentiality, RelationshipAttributeQuery } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; +import { IdentityAttributeQuery, IQLQuery, ProposeAttributeRequestItem, RelationshipAttributeConfidentiality, RelationshipAttributeQuery } from "../../../src"; describe("creation of ProposeAttributeRequestItem", () => { describe("creation of ProposeAttributeRequestItem with IdentityAttributeQuery", () => { diff --git a/packages/core-types/src/CoreAddress.ts b/packages/core-types/src/CoreAddress.ts index f79320c68..5e34e9ce4 100644 --- a/packages/core-types/src/CoreAddress.ts +++ b/packages/core-types/src/CoreAddress.ts @@ -1,7 +1,6 @@ -import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; +import { ISerializable, Serializable, serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -export interface ICoreAddress extends ICoreSerializable { +export interface ICoreAddress extends ISerializable { address: string; } @@ -10,7 +9,7 @@ export interface ICoreAddress extends ICoreSerializable { */ @type("CoreAddress") @serializeOnly("address", "string") -export class CoreAddress extends CoreSerializable { +export class CoreAddress extends Serializable { @validate() @serialize() public address: string; diff --git a/packages/core-types/src/CoreDate.ts b/packages/core-types/src/CoreDate.ts index faae8a5b4..8cd6c052c 100644 --- a/packages/core-types/src/CoreDate.ts +++ b/packages/core-types/src/CoreDate.ts @@ -1,13 +1,12 @@ -import { type } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; import { DateTime, DateTimeUnit, Duration, DurationLike, Interval } from "luxon"; -import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; -export interface ICoreDate extends ICoreSerializable { +export interface ICoreDate extends ISerializable { date: string; } @type("CoreDate") -export class CoreDate extends CoreSerializable { +export class CoreDate extends Serializable { private readonly _dateTime: DateTime; public get dateTime(): DateTime { return this._dateTime; diff --git a/packages/core-types/src/CoreId.ts b/packages/core-types/src/CoreId.ts index ccb13b17b..67941720b 100644 --- a/packages/core-types/src/CoreId.ts +++ b/packages/core-types/src/CoreId.ts @@ -1,7 +1,6 @@ -import { serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; +import { ISerializable, Serializable, serialize, serializeOnly, type, validate } from "@js-soft/ts-serval"; -export interface ICoreId extends ICoreSerializable { +export interface ICoreId extends ISerializable { id: string; } @@ -10,7 +9,7 @@ export interface ICoreId extends ICoreSerializable { */ @type("CoreId") @serializeOnly("id", "string") -export class CoreId extends CoreSerializable implements ICoreId { +export class CoreId extends Serializable implements ICoreId { @validate() @serialize() public id: string; diff --git a/packages/core-types/src/index.ts b/packages/core-types/src/index.ts index afcaef552..d64ed0e0a 100644 --- a/packages/core-types/src/index.ts +++ b/packages/core-types/src/index.ts @@ -1,6 +1,4 @@ export * from "./CoreAddress"; export * from "./CoreDate"; export * from "./CoreError"; -export * from "./CoreHash"; export * from "./CoreId"; -export * from "./CoreSerializable"; diff --git a/packages/core-types/src/CoreHash.ts b/packages/transport/src/core/types/CoreHash.ts similarity index 100% rename from packages/core-types/src/CoreHash.ts rename to packages/transport/src/core/types/CoreHash.ts diff --git a/packages/core-types/src/CoreSerializable.ts b/packages/transport/src/core/types/CoreSerializable.ts similarity index 100% rename from packages/core-types/src/CoreSerializable.ts rename to packages/transport/src/core/types/CoreSerializable.ts diff --git a/packages/transport/src/core/types/index.ts b/packages/transport/src/core/types/index.ts index ee096449c..0339a5fdc 100644 --- a/packages/transport/src/core/types/index.ts +++ b/packages/transport/src/core/types/index.ts @@ -1 +1,3 @@ +export * from "./CoreHash"; +export * from "./CoreSerializable"; export * from "./TransportVersion"; diff --git a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts index 7fae2dc67..447dfad23 100644 --- a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts +++ b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItem.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreHash, ICoreHash } from "@nmshd/core-types"; +import { CoreHash, ICoreHash } from "../../../../core"; import { CertificateItem, ICertificateItem } from "../CertificateItem"; export interface ICertificatePrivateAttributeItem extends ICertificateItem { diff --git a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts index adcab3fae..e56c18215 100644 --- a/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts +++ b/packages/transport/src/modules/certificates/data/items/CertificatePrivateAttributeItemSource.ts @@ -1,5 +1,5 @@ import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreHash } from "@nmshd/core-types"; +import { CoreHash } from "../../../../core"; import { CertificateItem, ICertificateItem } from "../CertificateItem"; export interface ICertificatePrivateAttributeItemSource extends ICertificateItem { diff --git a/packages/transport/src/modules/files/FileController.ts b/packages/transport/src/modules/files/FileController.ts index 51a334f28..9247c6160 100644 --- a/packages/transport/src/modules/files/FileController.ts +++ b/packages/transport/src/modules/files/FileController.ts @@ -1,8 +1,8 @@ import { ISerializable } from "@js-soft/ts-serval"; import { log } from "@js-soft/ts-utils"; -import { CoreAddress, CoreDate, CoreHash, CoreId } from "@nmshd/core-types"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; import { CoreBuffer, CryptoCipher, CryptoHash, CryptoHashAlgorithm, CryptoSecretKey, Encoding } from "@nmshd/crypto"; -import { CoreCrypto, TransportCoreErrors } from "../../core"; +import { CoreCrypto, CoreHash, TransportCoreErrors } from "../../core"; import { DbCollectionName } from "../../core/DbCollectionName"; import { ControllerName, TransportController } from "../../core/TransportController"; import { AccountController } from "../accounts/AccountController"; diff --git a/packages/transport/src/modules/files/local/CachedFile.ts b/packages/transport/src/modules/files/local/CachedFile.ts index 7e09eb437..6090fe589 100644 --- a/packages/transport/src/modules/files/local/CachedFile.ts +++ b/packages/transport/src/modules/files/local/CachedFile.ts @@ -1,6 +1,7 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreAddress, CoreDate, CoreHash, CoreId, ICoreAddress, ICoreDate, ICoreHash, ICoreId } from "@nmshd/core-types"; +import { CoreAddress, CoreDate, CoreId, ICoreAddress, ICoreDate, ICoreId } from "@nmshd/core-types"; import { CryptoSecretKey, CryptoSignature, ICryptoSecretKey, ICryptoSignature } from "@nmshd/crypto"; +import { CoreHash, ICoreHash } from "../../../core"; import { BackboneGetFilesResponse } from "../backbone/BackboneGetFiles"; import { FileMetadata } from "../transmission/FileMetadata"; @@ -10,7 +11,7 @@ export interface ICachedFile extends ISerializable { filesize: number; filemodified?: CoreDate; mimetype: string; - cipherHash: CoreHash; + cipherHash: ICoreHash; createdAt: ICoreDate; expiresAt: ICoreDate; cipherKey: ICryptoSecretKey; diff --git a/packages/transport/src/modules/files/transmission/FileMetadata.ts b/packages/transport/src/modules/files/transmission/FileMetadata.ts index cb315fcfa..d215cbccf 100644 --- a/packages/transport/src/modules/files/transmission/FileMetadata.ts +++ b/packages/transport/src/modules/files/transmission/FileMetadata.ts @@ -1,6 +1,7 @@ import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreDate, CoreHash, ICoreDate, ICoreHash } from "@nmshd/core-types"; +import { CoreDate, ICoreDate } from "@nmshd/core-types"; import { CryptoSecretKey, ICryptoSecretKey } from "@nmshd/crypto"; +import { CoreHash, ICoreHash } from "../../../core"; export interface IFileMetadata extends ISerializable { title?: string; diff --git a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts index 887cb0eb9..7d7c32d42 100644 --- a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts @@ -1,8 +1,8 @@ -import { ISerializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable } from "@nmshd/core-types"; +import { serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoCipher, CryptoRelationshipPublicRequest, ICryptoCipher, ICryptoRelationshipPublicRequest } from "@nmshd/crypto"; +import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationContentCipher extends ISerializable { +export interface IRelationshipCreationContentCipher extends ICoreSerializable { cipher: ICryptoCipher; publicCreationContentCrypto: ICryptoRelationshipPublicRequest; } diff --git a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts index 4c2ea8dc8..b7b6c5b4a 100644 --- a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts @@ -1,8 +1,8 @@ -import { ISerializable, serialize, type, validate } from "@js-soft/ts-serval"; -import { CoreSerializable } from "@nmshd/core-types"; +import { serialize, type, validate } from "@js-soft/ts-serval"; import { CryptoCipher, CryptoRelationshipPublicResponse, ICryptoCipher, ICryptoRelationshipPublicResponse } from "@nmshd/crypto"; +import { CoreSerializable, ICoreSerializable } from "../../../../core"; -export interface IRelationshipCreationResponseContentCipher extends ISerializable { +export interface IRelationshipCreationResponseContentCipher extends ICoreSerializable { cipher: ICryptoCipher; publicCreationResponseContentCrypto: ICryptoRelationshipPublicResponse; } From 2fe63167cc6484a3cd3a5e1aae6da3af482832a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:14:51 +0200 Subject: [PATCH 09/16] refactor: update references and dependencies --- package-lock.json | 64 +++++++------------ packages/app-runtime/package.json | 14 ++-- packages/consumption/package.json | 23 +++---- packages/consumption/tsconfig.json | 2 +- packages/content/package.json | 15 ++--- packages/core-types/package.json | 12 ++-- packages/core-types/test/tsconfig.json | 2 +- packages/runtime/package.json | 12 ++-- .../test/lib/testUtilsWithInactiveModules.ts | 2 +- packages/transport/package.json | 11 ++-- packages/transport/test/tsconfig.json | 2 +- 11 files changed, 71 insertions(+), 88 deletions(-) diff --git a/package-lock.json b/package-lock.json index 34de464b9..cb80ac678 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1291,6 +1291,8 @@ }, "node_modules/@js-soft/logging-abstractions": { "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@js-soft/logging-abstractions/-/logging-abstractions-1.0.1.tgz", + "integrity": "sha512-giFnUcpfq07vNmMFetvI1bfKo8g5slIiQbSnwLF1dHU8gLE/hJmL3jTnchXFRTwSeMhTFCNg0GudsNMw1esMVQ==", "license": "MIT" }, "node_modules/@js-soft/node-logger": { @@ -2137,6 +2139,8 @@ }, "node_modules/@types/luxon": { "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", + "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", "dev": true, "license": "MIT" }, @@ -5559,6 +5563,8 @@ }, "node_modules/json-stringify-safe": { "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", "license": "ISC" }, "node_modules/json5": { @@ -5604,15 +5610,6 @@ "node": ">=6" } }, - "node_modules/leaked-handles": { - "version": "5.2.0", - "dev": true, - "dependencies": { - "process": "^0.10.0", - "weakmap-shim": "^1.1.0", - "xtend": "^4.0.0" - } - }, "node_modules/leven": { "version": "3.1.0", "dev": true, @@ -5765,6 +5762,8 @@ }, "node_modules/lodash": { "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "license": "MIT" }, "node_modules/lodash.get": { @@ -5831,6 +5830,7 @@ "version": "3.5.0", "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.5.0.tgz", "integrity": "sha512-rh+Zjr6DNfUYR3bPwJEnuwDdqMbxZW7LOQfUN4B54+Cl+0o5zaU9RJ6bcidfDtC1cWCZXQ+nvX8bf6bAji37QQ==", + "license": "MIT", "engines": { "node": ">=12" } @@ -7361,13 +7361,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/process": { - "version": "0.10.1", - "dev": true, - "engines": { - "node": ">= 0.6.0" - } - }, "node_modules/promise-inflight": { "version": "1.0.1", "dev": true, @@ -9078,10 +9071,6 @@ "defaults": "^1.0.3" } }, - "node_modules/weakmap-shim": { - "version": "1.1.1", - "dev": true - }, "node_modules/webidl-conversions": { "version": "7.0.0", "dev": true, @@ -9235,14 +9224,6 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, - "node_modules/xtend": { - "version": "4.0.2", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.4" - } - }, "node_modules/y18n": { "version": "5.0.8", "dev": true, @@ -9305,6 +9286,7 @@ "license": "MIT", "dependencies": { "@js-soft/docdb-access-loki": "^1.1.0", + "@nmshd/runtime": "*", "lodash": "^4.17.21" }, "devDependencies": { @@ -9312,9 +9294,6 @@ "@types/lodash": "^4.17.7", "@types/lokijs": "^1.5.14", "@types/luxon": "^3.4.2" - }, - "peerDependencies": { - "@nmshd/runtime": "*" } }, "packages/consumption": { @@ -9322,34 +9301,34 @@ "license": "MIT", "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", + "@js-soft/ts-serval": "2.0.10", + "@js-soft/ts-utils": "2.3.3", + "@nmshd/content": "*", + "@nmshd/core-types": "*", "@nmshd/iql": "^1.0.2", + "@nmshd/transport": "*", + "lodash": "^4.17.21", "ts-simple-nameof": "^1.3.1" }, "devDependencies": { "@js-soft/docdb-access-loki": "1.1.0", "@js-soft/docdb-access-mongo": "1.1.8", "@js-soft/node-logger": "1.2.0", - "@js-soft/ts-serval": "2.0.10", - "@js-soft/ts-utils": "2.3.3", - "@js-soft/web-logger": "^1.0.4", "@nmshd/crypto": "2.0.6", - "@types/lodash": "^4.17.7", - "@types/luxon": "^3.4.2", - "leaked-handles": "^5.2.0" + "@types/lodash": "^4.17.7" } }, "packages/content": { "name": "@nmshd/content", "license": "MIT", "dependencies": { - "@js-soft/logging-abstractions": "^1.0.1", + "@js-soft/ts-serval": "2.0.10", "@nmshd/core-types": "*", "@nmshd/iql": "^1.0.2", + "luxon": "^3.5.0", "ts-simple-nameof": "^1.3.1" }, "devDependencies": { - "@js-soft/ts-serval": "2.0.10", - "@nmshd/crypto": "2.0.6", "@types/luxon": "^3.4.2" } }, @@ -9357,7 +9336,9 @@ "name": "@nmshd/core-types", "license": "MIT", "dependencies": { + "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/ts-serval": "2.0.10", + "json-stringify-safe": "^5.0.1", "luxon": "^3.5.0" }, "devDependencies": { @@ -9374,7 +9355,9 @@ "@js-soft/ts-utils": "^2.3.3", "@nmshd/consumption": "*", "@nmshd/content": "*", + "@nmshd/core-types": "*", "@nmshd/crypto": "2.0.6", + "@nmshd/iql": "^1.0.2", "@nmshd/transport": "*", "ajv": "^8.17.1", "ajv-errors": "^3.0.0", @@ -9432,7 +9415,6 @@ "@js-soft/docdb-access-mongo": "1.1.8", "@js-soft/node-logger": "1.2.0", "@js-soft/ts-serval": "2.0.10", - "@js-soft/web-logger": "^1.0.4", "@types/json-stringify-safe": "^5.0.3", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", diff --git a/packages/app-runtime/package.json b/packages/app-runtime/package.json index 6ef49ef6f..17294ca5f 100644 --- a/packages/app-runtime/package.json +++ b/packages/app-runtime/package.json @@ -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" ], @@ -52,6 +52,7 @@ }, "dependencies": { "@js-soft/docdb-access-loki": "^1.1.0", + "@nmshd/runtime": "*", "lodash": "^4.17.21" }, "devDependencies": { @@ -60,9 +61,6 @@ "@types/lokijs": "^1.5.14", "@types/luxon": "^3.4.2" }, - "peerDependencies": { - "@nmshd/runtime": "*" - }, "publishConfig": { "access": "public", "provenance": true diff --git a/packages/consumption/package.json b/packages/consumption/package.json index 8e08e234c..4f0a0f969 100644 --- a/packages/consumption/package.json +++ b/packages/consumption/package.json @@ -32,17 +32,17 @@ "test:local:teardown": "docker compose -f ../../.dev/compose.yml rm -fsv" }, "jest": { - "maxWorkers": 1, - "preset": "ts-jest", + "collectCoverageFrom": [ + "./src/**" + ], "coverageProvider": "v8", "coverageReporters": [ "text-summary", "cobertura", "lcov" ], - "collectCoverageFrom": [ - "./src/**" - ], + "maxWorkers": 1, + "preset": "ts-jest", "setupFilesAfterEnv": [ "./test/customMatchers.ts", "jest-expect-message" @@ -60,20 +60,21 @@ }, "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", + "@js-soft/ts-serval": "2.0.10", + "@js-soft/ts-utils": "2.3.3", + "@nmshd/content": "*", + "@nmshd/core-types": "*", "@nmshd/iql": "^1.0.2", + "@nmshd/transport": "*", + "lodash": "^4.17.21", "ts-simple-nameof": "^1.3.1" }, "devDependencies": { "@js-soft/docdb-access-loki": "1.1.0", "@js-soft/docdb-access-mongo": "1.1.8", "@js-soft/node-logger": "1.2.0", - "@js-soft/ts-serval": "2.0.10", - "@js-soft/ts-utils": "2.3.3", - "@js-soft/web-logger": "^1.0.4", "@nmshd/crypto": "2.0.6", - "@types/lodash": "^4.17.7", - "@types/luxon": "^3.4.2", - "leaked-handles": "^5.2.0" + "@types/lodash": "^4.17.7" }, "publishConfig": { "access": "public", diff --git a/packages/consumption/tsconfig.json b/packages/consumption/tsconfig.json index 1c0b1de17..323399fff 100644 --- a/packages/consumption/tsconfig.json +++ b/packages/consumption/tsconfig.json @@ -6,5 +6,5 @@ }, "include": ["src/**/*.ts"], "exclude": [], - "references": [{ "path": "../transport" }, { "path": "../content" }] + "references": [{ "path": "../transport" }, { "path": "../content" }, { "path": "../core-types" }] } diff --git a/packages/content/package.json b/packages/content/package.json index 38999133f..cbbfb09a5 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -25,16 +25,16 @@ "test:ci": "jest -i --coverage" }, "jest": { - "maxWorkers": 5, + "collectCoverageFrom": [ + "./src/**" + ], "coverageProvider": "v8", "coverageReporters": [ "text-summary", "cobertura", "lcov" ], - "collectCoverageFrom": [ - "./src/**" - ], + "maxWorkers": 5, "preset": "ts-jest", "setupFilesAfterEnv": [ "jest-expect-message" @@ -51,14 +51,13 @@ } }, "dependencies": { - "@js-soft/logging-abstractions": "^1.0.1", - "@nmshd/iql": "^1.0.2", + "@js-soft/ts-serval": "2.0.10", "@nmshd/core-types": "*", + "@nmshd/iql": "^1.0.2", + "luxon": "^3.5.0", "ts-simple-nameof": "^1.3.1" }, "devDependencies": { - "@js-soft/ts-serval": "2.0.10", - "@nmshd/crypto": "2.0.6", "@types/luxon": "^3.4.2" }, "publishConfig": { diff --git a/packages/core-types/package.json b/packages/core-types/package.json index 3f0526d7a..324677371 100644 --- a/packages/core-types/package.json +++ b/packages/core-types/package.json @@ -23,17 +23,17 @@ "test:ci": "jest -i --coverage" }, "jest": { - "maxWorkers": 1, - "preset": "ts-jest", + "collectCoverageFrom": [ + "./src/**" + ], "coverageProvider": "v8", "coverageReporters": [ "text-summary", "cobertura", "lcov" ], - "collectCoverageFrom": [ - "./src/**" - ], + "maxWorkers": 1, + "preset": "ts-jest", "setupFilesAfterEnv": [ "jest-expect-message" ], @@ -49,7 +49,9 @@ } }, "dependencies": { + "@js-soft/logging-abstractions": "^1.0.1", "@js-soft/ts-serval": "2.0.10", + "json-stringify-safe": "^5.0.1", "luxon": "^3.5.0" }, "devDependencies": { diff --git a/packages/core-types/test/tsconfig.json b/packages/core-types/test/tsconfig.json index 50e8c5f15..db9a0d1ee 100644 --- a/packages/core-types/test/tsconfig.json +++ b/packages/core-types/test/tsconfig.json @@ -6,6 +6,6 @@ "composite": false }, "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], - "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], + "include": ["**/*.ts", "../src/**/*.ts"], "exclude": [] } diff --git a/packages/runtime/package.json b/packages/runtime/package.json index bb1fb2081..12f3a6f4d 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -32,17 +32,17 @@ "test:local:teardown": "docker compose -f ../../.dev/compose.yml rm -fsv" }, "jest": { - "maxWorkers": 1, - "preset": "ts-jest", + "collectCoverageFrom": [ + "./src/**" + ], "coverageProvider": "v8", "coverageReporters": [ "text-summary", "cobertura", "lcov" ], - "collectCoverageFrom": [ - "./src/**" - ], + "maxWorkers": 1, + "preset": "ts-jest", "setupFilesAfterEnv": [ "./test/customMatchers.ts", "./test/disableTimeoutForDebugging.ts", @@ -66,7 +66,9 @@ "@js-soft/ts-utils": "^2.3.3", "@nmshd/consumption": "*", "@nmshd/content": "*", + "@nmshd/core-types": "*", "@nmshd/crypto": "2.0.6", + "@nmshd/iql": "^1.0.2", "@nmshd/transport": "*", "ajv": "^8.17.1", "ajv-errors": "^3.0.0", diff --git a/packages/runtime/test/lib/testUtilsWithInactiveModules.ts b/packages/runtime/test/lib/testUtilsWithInactiveModules.ts index 73415903a..dbd282396 100644 --- a/packages/runtime/test/lib/testUtilsWithInactiveModules.ts +++ b/packages/runtime/test/lib/testUtilsWithInactiveModules.ts @@ -1,5 +1,5 @@ import { IResponse, RelationshipCreationContent, RelationshipTemplateContentJSON, ResponseWrapperJSON } from "@nmshd/content"; -import { CreateOutgoingRequestRequest, LocalRequestDTO, MessageDTO, RelationshipDTO } from "src"; +import { CreateOutgoingRequestRequest, LocalRequestDTO, MessageDTO, RelationshipDTO } from "../../src"; import { TestRuntimeServices } from "./RuntimeServiceProvider"; import { exchangeMessageWithRequest, exchangeTemplate, syncUntilHasMessageWithResponse } from "./testUtils"; diff --git a/packages/transport/package.json b/packages/transport/package.json index 80cb8646c..16d3ed285 100644 --- a/packages/transport/package.json +++ b/packages/transport/package.json @@ -35,17 +35,17 @@ "test:performance:kube:stop": "kubectl delete -f ./test/performance/k8s.yaml" }, "jest": { - "maxWorkers": 5, - "preset": "ts-jest", + "collectCoverageFrom": [ + "./src/**" + ], "coverageProvider": "v8", "coverageReporters": [ "text-summary", "cobertura", "lcov" ], - "collectCoverageFrom": [ - "./src/**" - ], + "maxWorkers": 5, + "preset": "ts-jest", "setupFilesAfterEnv": [ "./test/customMatchers.ts", "jest-expect-message" @@ -89,7 +89,6 @@ "@js-soft/docdb-access-mongo": "1.1.8", "@js-soft/node-logger": "1.2.0", "@js-soft/ts-serval": "2.0.10", - "@js-soft/web-logger": "^1.0.4", "@types/json-stringify-safe": "^5.0.3", "@types/lodash": "^4.17.7", "@types/luxon": "^3.4.2", diff --git a/packages/transport/test/tsconfig.json b/packages/transport/test/tsconfig.json index 50e8c5f15..db9a0d1ee 100644 --- a/packages/transport/test/tsconfig.json +++ b/packages/transport/test/tsconfig.json @@ -6,6 +6,6 @@ "composite": false }, "files": ["../../../node_modules/jest-expect-message/types/index.d.ts"], - "include": ["**/*.ts", "../src/**/*.ts", "../../core-types/src/CoreHash.ts"], + "include": ["**/*.ts", "../src/**/*.ts"], "exclude": [] } From a905480ac44ab71a69410db2e785027be98b5aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:18:28 +0200 Subject: [PATCH 10/16] chore: formatting --- .../deleteAttribute/DeleteAttributeRequestItemProcessor.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts index baa3ebd8c..895c7eb08 100644 --- a/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts +++ b/packages/consumption/src/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.ts @@ -10,8 +10,9 @@ import { AcceptDeleteAttributeRequestItemParameters, AcceptDeleteAttributeReques export class DeleteAttributeRequestItemProcessor extends GenericRequestItemProcessor { public override async canCreateOutgoingRequestItem(requestItem: DeleteAttributeRequestItem, _request: Request, recipient?: CoreAddress): Promise { const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId); - if (!attribute) + if (!attribute) { return ValidationResult.error(ConsumptionCoreErrors.requests.invalidRequestItem(`The Attribute '${requestItem.attributeId.toString()}' could not be found.`)); + } if (!attribute.isOwnSharedAttribute(this.accountController.identity.address)) { return ValidationResult.error( From 4288d715d2d2bc83cef2bac7777ec297b74e807e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:19:37 +0200 Subject: [PATCH 11/16] ci: add test for new package --- .github/workflows/test.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ebbe28eb0..6a944bbc5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: From 0f84d3aa46705fefb09d020c4d79e5d62996cd66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:28:05 +0200 Subject: [PATCH 12/16] fix: test issues --- .../DecideRequestParametersValidator.test.ts | 3 +- .../IncomingRequestsController.test.ts | 6 +-- .../requests/RequestsIntegrationTest.ts | 14 +++++- ...eleteAttributeRequestItemProcessor.test.ts | 6 +-- ...oposeAttributeRequestItemProcessor.test.ts | 20 ++++----- .../ReadAttributeRequestItemProcessor.test.ts | 36 +++++++-------- .../content/test/requests/Request.test.ts | 4 +- .../content/test/requests/Response.test.ts | 4 +- .../items/ProposeAttributeRequestItem.test.ts | 45 +++++++++++++++---- .../test/dataViews/RelationshipDVO.test.ts | 7 +-- .../transport/identityDeletionProcess.test.ts | 5 +-- .../sync/SynchronizedCollection.test.ts | 22 ++++----- .../test/modules/tokens/TokenContent.test.ts | 14 +++--- .../modules/tokens/TokenController.test.ts | 6 +-- .../test/testHelpers/FakeSyncClient.ts | 5 ++- 15 files changed, 119 insertions(+), 78 deletions(-) diff --git a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts index b1935407d..7ed371025 100644 --- a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts +++ b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts @@ -1,5 +1,6 @@ import { Request, RequestItemGroup } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { GeneratableCoreId } from "@nmshd/transport"; import { DecideRequestItemGroupParametersJSON, DecideRequestItemParametersJSON, @@ -284,7 +285,7 @@ describe("DecideRequestParametersValidator", function () { createdAt: CoreDate.utc(), isOwn: true, peer: CoreAddress.from("did:e:a-domain:dids:anidentity"), - source: { reference: await CoreId.generate(), type: "Message" }, + source: { reference: await GeneratableCoreId.generate(), type: "Message" }, status: LocalRequestStatus.Open, statusLog: [] }); diff --git a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts index b1cb0ecba..3b484cca7 100644 --- a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts +++ b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts @@ -1,7 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IRequest, IRequestItemGroup, Request, RequestItemGroup, ResponseItem, ResponseItemGroup, ResponseItemResult } from "@nmshd/content"; import { CoreDate, CoreId } from "@nmshd/core-types"; -import { TransportLoggerFactory } from "@nmshd/transport"; +import { GeneratableCoreId, TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionIds, DecideRequestItemGroupParametersJSON, @@ -66,7 +66,7 @@ describe("IncomingRequestsController", function () { }); test("uses the ID of the given Request if it exists", async function () { - const request = TestObjectFactory.createRequestWithOneItem({ id: await CoreId.generate() }); + const request = TestObjectFactory.createRequestWithOneItem({ id: await GeneratableCoreId.generate() }); await When.iCreateAnIncomingRequestWith({ receivedRequest: request }); await Then.theRequestHasTheId(request.id!); @@ -1032,7 +1032,7 @@ describe("IncomingRequestsController", function () { test("Incoming Request via Message", async function () { const request = Request.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), items: [TestRequestItem.from({ mustBeAccepted: false })] }); const incomingMessage = TestObjectFactory.createIncomingIMessage(context.currentIdentity); diff --git a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts index 8fbf85c74..62ff1a7f6 100644 --- a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts +++ b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts @@ -15,7 +15,17 @@ import { ResponseResult } from "@nmshd/content"; import { CoreAddress, CoreId, ICoreId } from "@nmshd/core-types"; -import { IConfigOverwrite, IMessage, IRelationshipTemplate, Message, Relationship, RelationshipTemplate, SynchronizedCollection, Transport } from "@nmshd/transport"; +import { + GeneratableCoreId, + IConfigOverwrite, + IMessage, + IRelationshipTemplate, + Message, + Relationship, + RelationshipTemplate, + SynchronizedCollection, + Transport +} from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, @@ -854,7 +864,7 @@ export class RequestsWhen { } public async iTryToGetARequestWithANonExistentId(): Promise { - this.context.localRequestAfterAction = (await this.context.incomingRequestsController.getIncomingRequest(await CoreId.generate()))!; + this.context.localRequestAfterAction = (await this.context.incomingRequestsController.getIncomingRequest(await GeneratableCoreId.generate()))!; } public iTryToCompleteTheIncomingRequestWith(params: Partial): Promise { diff --git a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts index d1c982aaf..d575f5c90 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts @@ -11,7 +11,7 @@ import { ResponseItemResult } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { AccountController, Transport } from "@nmshd/transport"; +import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; import { AcceptDeleteAttributeRequestItemParametersJSON, ConsumptionController, @@ -333,7 +333,7 @@ describe("DeleteAttributeRequestItemProcessor", function () { test("returns success when called with any deletionDate if Attribute doesn't exist", async function () { const requestItem = DeleteAttributeRequestItem.from({ mustBeAccepted: false, - attributeId: await CoreId.generate() + attributeId: await GeneratableCoreId.generate() }); const requestId = await ConsumptionIds.request.generate(); @@ -654,7 +654,7 @@ describe("DeleteAttributeRequestItemProcessor", function () { test("returns an AcceptResponseItem", async function () { const requestItem = DeleteAttributeRequestItem.from({ mustBeAccepted: false, - attributeId: (await CoreId.generate()).toString() + attributeId: (await GeneratableCoreId.generate()).toString() }); const requestId = await ConsumptionIds.request.generate(); diff --git a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts index eeb752c07..325df7ca1 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts @@ -14,8 +14,8 @@ import { Request, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { AccountController, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate } from "@nmshd/core-types"; +import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; import { AcceptProposeAttributeRequestItemParametersWithExistingAttributeJSON, AcceptProposeAttributeRequestItemParametersWithNewAttributeJSON, @@ -557,7 +557,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: successorRepositoryAttribute.id, peer: sender, - requestReference: await CoreId.generate() + requestReference: await GeneratableCoreId.generate() }); const requestItem = ProposeAttributeRequestItem.from({ @@ -792,7 +792,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { const predecessorOwnSharedIdentityAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorRepositoryAttribute.id, peer: sender, - requestReference: CoreId.from("initialRequest") + requestReference: GeneratableCoreId.from("initialRequest") }); const { successor: successorRepositoryAttribute } = await consumptionController.attributes.succeedRepositoryAttribute(predecessorRepositoryAttribute.id, { @@ -870,7 +870,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -937,7 +937,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -990,7 +990,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { const alreadySharedAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: repositoryAttribute.id, peer: sender, - requestReference: await CoreId.generate() + requestReference: await GeneratableCoreId.generate() }); const requestItem = ProposeAttributeRequestItem.from({ @@ -1039,7 +1039,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1095,7 +1095,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1185,7 +1185,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { owner: sender }), peer: sender, - requestReference: CoreId.from("oldReqRef") + requestReference: GeneratableCoreId.from("oldReqRef") }); const requestItem = ProposeAttributeRequestItem.from({ diff --git a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts index 98d73c6a1..b709a9936 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts @@ -16,8 +16,8 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryOwner } from "@nmshd/content"; -import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { AccountController, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate } from "@nmshd/core-types"; +import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; import { AcceptReadAttributeRequestItemParametersWithExistingAttributeJSON, AcceptReadAttributeRequestItemParametersWithNewAttributeJSON, @@ -438,7 +438,7 @@ describe("ReadAttributeRequestItemProcessor", function () { await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: successorRepositoryAttribute.id, peer: sender, - requestReference: await CoreId.generate() + requestReference: await GeneratableCoreId.generate() }); const requestItem = ReadAttributeRequestItem.from({ @@ -859,7 +859,7 @@ describe("ReadAttributeRequestItemProcessor", function () { shareInfo: { peer: aThirdParty, requestReference: await ConsumptionIds.request.generate(), - sourceAttribute: CoreId.from("sourceAttributeId") + sourceAttribute: GeneratableCoreId.from("sourceAttributeId") } }); @@ -1293,7 +1293,7 @@ describe("ReadAttributeRequestItemProcessor", function () { const predecessorOwnSharedIdentityAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorRepositoryAttribute.id, peer: sender, - requestReference: CoreId.from("initialRequest") + requestReference: GeneratableCoreId.from("initialRequest") }); const { successor: successorRepositoryAttribute } = await consumptionController.attributes.succeedRepositoryAttribute(predecessorRepositoryAttribute.id, { @@ -1367,7 +1367,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1430,7 +1430,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1479,7 +1479,7 @@ describe("ReadAttributeRequestItemProcessor", function () { const alreadySharedAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: repositoryAttribute.id, peer: sender, - requestReference: await CoreId.generate() + requestReference: await GeneratableCoreId.generate() }); const requestItem = ReadAttributeRequestItem.from({ @@ -1524,7 +1524,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1576,7 +1576,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1621,13 +1621,13 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: accountController.identity.address }), peer: thirdPartyAddress, - requestReference: CoreId.from("reqRef") + requestReference: GeneratableCoreId.from("reqRef") }); const predecessorOwnSharedRelationshipAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorSourceAttribute.id, peer: sender, - requestReference: CoreId.from("initialRequest") + requestReference: GeneratableCoreId.from("initialRequest") }); const { successor: successorSourceAttribute } = await consumptionController.attributes.succeedOwnSharedRelationshipAttribute(predecessorSourceAttribute.id, { @@ -1643,7 +1643,7 @@ describe("ReadAttributeRequestItemProcessor", function () { }), shareInfo: LocalAttributeShareInfo.from({ peer: thirdPartyAddress, - notificationReference: CoreId.from("successionNotification") + notificationReference: GeneratableCoreId.from("successionNotification") }) }); @@ -1698,13 +1698,13 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: thirdPartyAddress }), peer: thirdPartyAddress, - requestReference: CoreId.from("reqRef") + requestReference: GeneratableCoreId.from("reqRef") }); const predecessorOwnSharedRelationshipAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorSourceAttribute.id, peer: sender, - requestReference: CoreId.from("initialRequest") + requestReference: GeneratableCoreId.from("initialRequest") }); const { successor: successorSourceAttribute } = await consumptionController.attributes.succeedPeerSharedRelationshipAttribute(predecessorSourceAttribute.id, { @@ -1720,7 +1720,7 @@ describe("ReadAttributeRequestItemProcessor", function () { }), shareInfo: LocalAttributeShareInfo.from({ peer: thirdPartyAddress, - notificationReference: CoreId.from("successionNotification") + notificationReference: GeneratableCoreId.from("successionNotification") }) }); @@ -1815,7 +1815,7 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: recipient }), peer: recipient, - requestReference: CoreId.from("oldReqRef") + requestReference: GeneratableCoreId.from("oldReqRef") }); const requestItem = ReadAttributeRequestItem.from({ @@ -1870,7 +1870,7 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: thirdPartyAddress }), peer: recipient, - requestReference: CoreId.from("oldReqRef") + requestReference: GeneratableCoreId.from("oldReqRef") }); const requestItem = ReadAttributeRequestItem.from({ diff --git a/packages/content/test/requests/Request.test.ts b/packages/content/test/requests/Request.test.ts index 07b34f267..f3fe17fac 100644 --- a/packages/content/test/requests/Request.test.ts +++ b/packages/content/test/requests/Request.test.ts @@ -47,10 +47,10 @@ describe("Request", function () { expect(requestItemGroup.items).toHaveLength(1); }); - test("creates a Request and items from serval interface", async function () { + test("creates a Request and items from serval interface", function () { const requestInterface = { "@type": "Request", - id: await CoreId.generate(), + id: CoreId.from("REQ1"), items: [ { "@type": "TestRequestItem", diff --git a/packages/content/test/requests/Response.test.ts b/packages/content/test/requests/Response.test.ts index 5579bb4cd..724bf3556 100644 --- a/packages/content/test/requests/Response.test.ts +++ b/packages/content/test/requests/Response.test.ts @@ -72,11 +72,11 @@ describe("Response", function () { expect(responseItemGroup.items).toHaveLength(1); }); - test("creates a Response and items from interface object", async function () { + test("creates a Response and items from interface object", function () { const responseInterface = { "@type": "Response", result: ResponseResult.Accepted, - requestId: await CoreId.generate(), + requestId: CoreId.from("RES1"), items: [ { "@type": "AcceptResponseItem", diff --git a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts index a32fd6ee2..72e58f32e 100644 --- a/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts +++ b/packages/content/test/requests/items/ProposeAttributeRequestItem.test.ts @@ -1,14 +1,26 @@ import { ValidationError } from "@js-soft/ts-serval"; import { CoreAddress } from "@nmshd/core-types"; import { nameof } from "ts-simple-nameof"; -import { IdentityAttributeQuery, IQLQuery, ProposeAttributeRequestItem, RelationshipAttributeConfidentiality, RelationshipAttributeQuery } from "../../../src"; +import { + GivenName, + IdentityAttribute, + IdentityAttributeQuery, + IIdentityAttribute, + IQLQuery, + IRelationshipAttribute, + ProposeAttributeRequestItem, + ProprietaryString, + RelationshipAttribute, + RelationshipAttributeConfidentiality, + RelationshipAttributeQuery +} from "../../../src"; describe("creation of ProposeAttributeRequestItem", () => { describe("creation of ProposeAttributeRequestItem with IdentityAttributeQuery", () => { test("can create a ProposeAttributeRequestItem with IdentityAttributeQuery", function () { const validProposeAttributeRequestItem = ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createIdentityAttribute({ + attribute: createIdentityAttribute({ owner: CoreAddress.from("") }), query: IdentityAttributeQuery.from({ valueType: "GivenName" }) @@ -24,7 +36,7 @@ describe("creation of ProposeAttributeRequestItem", () => { const invalidProposeAttributeRequestItemCall = () => { ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createRelationshipAttribute({ + attribute: createRelationshipAttribute({ owner: CoreAddress.from("") }), query: IdentityAttributeQuery.from({ valueType: "GivenName" }) @@ -39,7 +51,7 @@ describe("creation of ProposeAttributeRequestItem", () => { const invalidProposeAttributeRequestItemCall = () => { ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createIdentityAttribute({ + attribute: createIdentityAttribute({ owner: CoreAddress.from("") }), query: IdentityAttributeQuery.from({ valueType: "DisplayName" }) @@ -60,7 +72,7 @@ describe("creation of ProposeAttributeRequestItem", () => { const invalidProposeAttributeRequestItemCall = () => { ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createIdentityAttribute({ + attribute: createIdentityAttribute({ owner: CoreAddress.from("") }), query: IQLQuery.from({ queryString: "DisplayName", attributeCreationHints: { valueType: "DisplayName" } }) @@ -80,7 +92,7 @@ describe("creation of ProposeAttributeRequestItem", () => { test("can create a ProposeAttributeRequestItem with RelationshipAttributeQuery", function () { const validProposeAttributeRequestItem = ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createRelationshipAttribute({ + attribute: createRelationshipAttribute({ owner: CoreAddress.from("") }), query: RelationshipAttributeQuery.from({ @@ -104,7 +116,7 @@ describe("creation of ProposeAttributeRequestItem", () => { const invalidProposeAttributeRequestItemCall = () => { ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createIdentityAttribute({ + attribute: createIdentityAttribute({ owner: CoreAddress.from("") }), query: RelationshipAttributeQuery.from({ @@ -131,7 +143,7 @@ describe("creation of ProposeAttributeRequestItem", () => { const invalidProposeAttributeRequestItemCall = () => { ProposeAttributeRequestItem.from({ mustBeAccepted: true, - attribute: TestObjectFactory.createRelationshipAttribute({ + attribute: createRelationshipAttribute({ owner: CoreAddress.from("") }), query: RelationshipAttributeQuery.from({ @@ -155,3 +167,20 @@ describe("creation of ProposeAttributeRequestItem", () => { }); }); }); + +function createIdentityAttribute(properties?: Partial): IdentityAttribute { + return IdentityAttribute.from({ + value: properties?.value ?? GivenName.fromAny({ value: "AGivenName" }), + owner: properties?.owner ?? CoreAddress.from("did:e:a-domain:dids:anidentity") + }); +} + +function createRelationshipAttribute(properties?: Partial): RelationshipAttribute { + return RelationshipAttribute.from({ + value: properties?.value ?? ProprietaryString.from({ title: "ATitle", value: "AProprietaryStringValue" }), + confidentiality: RelationshipAttributeConfidentiality.Public, + key: "AKey", + isTechnical: false, + owner: properties?.owner ?? CoreAddress.from("did:e:a-domain:dids:anidentity") + }); +} diff --git a/packages/runtime/test/dataViews/RelationshipDVO.test.ts b/packages/runtime/test/dataViews/RelationshipDVO.test.ts index e360b36f2..3f2938007 100644 --- a/packages/runtime/test/dataViews/RelationshipDVO.test.ts +++ b/packages/runtime/test/dataViews/RelationshipDVO.test.ts @@ -8,7 +8,8 @@ import { ResponseItemResult, ResponseResult } from "@nmshd/content"; -import { CoreAddress, CoreId } from "@nmshd/core-types"; +import { CoreAddress } from "@nmshd/core-types"; +import { GeneratableCoreId } from "@nmshd/transport"; import { DataViewExpander, TransportServices } from "../../src"; import { establishRelationshipWithContents, RuntimeServiceProvider } from "../lib"; @@ -46,11 +47,11 @@ beforeAll(async () => { response: { "@type": "Response", result: ResponseResult.Accepted, - requestId: (await CoreId.generate()).toString(), + requestId: (await GeneratableCoreId.generate()).toString(), items: [ ReadAttributeAcceptResponseItem.from({ result: ResponseItemResult.Accepted, - attributeId: await CoreId.generate(), + attributeId: await GeneratableCoreId.generate(), attribute: IdentityAttribute.from({ owner: CoreAddress.from((await transportServices1.account.getIdentityInfo()).value.address), value: GivenName.from("AGivenName") diff --git a/packages/runtime/test/transport/identityDeletionProcess.test.ts b/packages/runtime/test/transport/identityDeletionProcess.test.ts index 0c575877f..e8b55999b 100644 --- a/packages/runtime/test/transport/identityDeletionProcess.test.ts +++ b/packages/runtime/test/transport/identityDeletionProcess.test.ts @@ -1,5 +1,4 @@ -import { CoreId } from "@nmshd/core-types"; -import { IdentityDeletionProcessStatus } from "@nmshd/transport"; +import { GeneratableCoreId, IdentityDeletionProcessStatus } from "@nmshd/transport"; import { ApproveIdentityDeletionProcessUseCase, CancelIdentityDeletionProcessUseCase, @@ -132,7 +131,7 @@ describe("IdentityDeletionProcess", () => { }); test("should return an error trying to get an IdentityDeletionProcess specifying an unknown ID", async function () { - const unknownId = (await CoreId.generate("IDP")).toString(); + const unknownId = (await GeneratableCoreId.generate("IDP")).toString(); const result = await transportService.identityDeletionProcesses.getIdentityDeletionProcess({ id: unknownId }); expect(result).toBeAnError("IdentityDeletionProcess not found. Make sure the ID exists and the record is not expired.", "error.runtime.recordNotFound"); }); diff --git a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts index d6e29bf80..33f0bcdc4 100644 --- a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts +++ b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts @@ -1,5 +1,5 @@ import { IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; -import { CoreDate, CoreId } from "@nmshd/core-types"; +import { CoreDate, GeneratableCoreId } from "@nmshd/core-types"; import { instance, mock, verify } from "ts-mockito"; import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, SynchronizedCollection } from "../../../src"; import { ACacheableSynchronizedCollectionItem, CachedACacheableSynchronizedCollectionItem } from "../../testHelpers/ACacheableSynchronizedCollectionItem"; @@ -22,7 +22,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new item, datawallet modifications are created for each category of data", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalStringProperty: "SomeValue", someMetadataStringProperty: "SomeValue", someUserdataStringProperty: "SomeValue" @@ -66,7 +66,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new non-cacheable item, no CacheChanged modification is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalStringProperty: "SomeValue" }); @@ -85,7 +85,7 @@ describe("SynchronizedCollection", function () { test("when updating a cacheable item with a changed cache, a CacheChanged modification is created", async function () { const item = ACacheableSynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalProperty: "SomeValue", cache: { someCacheProperty: "cachedValue" }, cachedAt: CoreDate.utc() @@ -112,7 +112,7 @@ describe("SynchronizedCollection", function () { test("when updating a cacheable item without a changed cache, no CacheChanged modification is created", async function () { const item = ACacheableSynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalProperty: "SomeValue", cache: { someCacheProperty: "cachedValue" }, cachedAt: CoreDate.utc() @@ -137,7 +137,7 @@ describe("SynchronizedCollection", function () { test("when updating a non-cacheable item, no CacheChanged modification is created", async function () { const item = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalStringProperty: "SomeValue" }); @@ -160,7 +160,7 @@ describe("SynchronizedCollection", function () { test("when a inserting a new item, a datawallet modification for technical data is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someTechnicalStringProperty: "SomeValue", someTechnicalNumberProperty: 1, someTechnicalBooleanProperty: true @@ -183,7 +183,7 @@ describe("SynchronizedCollection", function () { test("when a inserting a new item, a datawallet modification for metadata is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someMetadataStringProperty: "SomeValue", someMetadataNumberProperty: 1, someMetadataBooleanProperty: true @@ -206,7 +206,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new item, a datawallet modification for userdata is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate(), + id: await GeneratableCoreId.generate(), someUserdataStringProperty: "SomeValue", someUserdataNumberProperty: 1, someUserdataBooleanProperty: true @@ -228,7 +228,7 @@ describe("SynchronizedCollection", function () { }); test("when updating an item, should add every property of a category to the payload even if only one was changed", async function () { - const itemId = await CoreId.generate(); + const itemId = await GeneratableCoreId.generate(); await synchronizedCollection.create( ASynchronizedCollectionItem.from({ id: itemId, @@ -273,7 +273,7 @@ describe("SynchronizedCollection", function () { } ])("$payloadCategory datawallet modifications with type 'Create' have all necessary properties set", async function (params) { const newItem = ASynchronizedCollectionItem.from({ - id: await CoreId.generate() + id: await GeneratableCoreId.generate() }); (newItem as any)[params.payloadCategory] = "someValue"; diff --git a/packages/transport/test/modules/tokens/TokenContent.test.ts b/packages/transport/test/modules/tokens/TokenContent.test.ts index 99e965f9e..082279dae 100644 --- a/packages/transport/test/modules/tokens/TokenContent.test.ts +++ b/packages/transport/test/modules/tokens/TokenContent.test.ts @@ -1,6 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; -import { CoreDate, CoreId } from "@nmshd/core-types"; +import { CoreDate, CoreId, GeneratableCoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; import { AccountController, DeviceSharedSecret, TokenContentDeviceSharedSecret, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; @@ -64,7 +64,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (verbose)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await CoreId.generate() + templateId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -85,7 +85,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (no type information)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await CoreId.generate() + templateId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -105,7 +105,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (from unknown type)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await CoreId.generate() + templateId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -201,7 +201,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (verbose)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await CoreId.generate() + fileId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); @@ -222,7 +222,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (no type information)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await CoreId.generate() + fileId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); @@ -242,7 +242,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (from unknown type)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await CoreId.generate() + fileId: await GeneratableCoreId.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); diff --git a/packages/transport/test/modules/tokens/TokenController.test.ts b/packages/transport/test/modules/tokens/TokenController.test.ts index be91e667e..0dd42c4b1 100644 --- a/packages/transport/test/modules/tokens/TokenController.test.ts +++ b/packages/transport/test/modules/tokens/TokenController.test.ts @@ -2,7 +2,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; +import { AccountController, GeneratableCoreId, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenController", function () { @@ -82,7 +82,7 @@ describe("TokenController", function () { test("should send and receive a TokenContentFile", async function () { const expiresAt = CoreDate.utc().add({ minutes: 5 }); const content = TokenContentFile.from({ - fileId: await CoreId.generate(), + fileId: await GeneratableCoreId.generate(), secretKey: await CryptoEncryption.generateKey() }); const sentToken = await sender.tokens.sendToken({ @@ -111,7 +111,7 @@ describe("TokenController", function () { test("should send and receive a TokenContentRelationshipTemplate", async function () { const expiresAt = CoreDate.utc().add({ minutes: 5 }); const content = TokenContentRelationshipTemplate.from({ - templateId: await CoreId.generate(), + templateId: await GeneratableCoreId.generate(), secretKey: await CryptoEncryption.generateKey() }); const sentToken = await sender.tokens.sendToken({ diff --git a/packages/transport/test/testHelpers/FakeSyncClient.ts b/packages/transport/test/testHelpers/FakeSyncClient.ts index cb830bb09..c5cb660e6 100644 --- a/packages/transport/test/testHelpers/FakeSyncClient.ts +++ b/packages/transport/test/testHelpers/FakeSyncClient.ts @@ -1,4 +1,4 @@ -import { CoreDate, CoreId } from "@nmshd/core-types"; +import { CoreDate } from "@nmshd/core-types"; import { BackboneDatawalletModification, BackboneExternalEvent, @@ -9,6 +9,7 @@ import { FinalizeDatawalletVersionUpgradeResponse, FinalizeExternalEventSyncRequest, FinalizeExternalEventSyncResponse, + GeneratableCoreId, GetDatawalletModificationsRequest, GetDatawalletResponse, ISyncClient, @@ -90,7 +91,7 @@ export class FakeSyncClient implements ISyncClient { // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < request.modifications.length; i++) { response.modifications.push({ - id: (await CoreId.generate()).serialize(), + id: (await GeneratableCoreId.generate()).serialize(), index: response.modifications.length, createdAt: CoreDate.utc().toISOString() }); From f0f07c9a8bb0e04600dcb8e9783c0c47da9d445e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:29:14 +0200 Subject: [PATCH 13/16] fix: test issues --- .../test/modules/sync/SynchronizedCollection.test.ts | 4 ++-- .../test/modules/tokens/TokenContent.test.ts | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts index 33f0bcdc4..f53b386b6 100644 --- a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts +++ b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts @@ -1,7 +1,7 @@ import { IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; -import { CoreDate, GeneratableCoreId } from "@nmshd/core-types"; +import { CoreDate } from "@nmshd/core-types"; import { instance, mock, verify } from "ts-mockito"; -import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, SynchronizedCollection } from "../../../src"; +import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, GeneratableCoreId, SynchronizedCollection } from "../../../src"; import { ACacheableSynchronizedCollectionItem, CachedACacheableSynchronizedCollectionItem } from "../../testHelpers/ACacheableSynchronizedCollectionItem"; import { ASynchronizedCollectionItem } from "../../testHelpers/ASynchronizedCollectionItem"; import { FakeDatabaseCollection } from "../../testHelpers/FakeDatabaseCollection"; diff --git a/packages/transport/test/modules/tokens/TokenContent.test.ts b/packages/transport/test/modules/tokens/TokenContent.test.ts index 082279dae..41a5db1cb 100644 --- a/packages/transport/test/modules/tokens/TokenContent.test.ts +++ b/packages/transport/test/modules/tokens/TokenContent.test.ts @@ -1,8 +1,16 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; -import { CoreDate, CoreId, GeneratableCoreId } from "@nmshd/core-types"; +import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, DeviceSharedSecret, TokenContentDeviceSharedSecret, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; +import { + AccountController, + DeviceSharedSecret, + GeneratableCoreId, + TokenContentDeviceSharedSecret, + TokenContentFile, + TokenContentRelationshipTemplate, + Transport +} from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenContent", function () { From 4704f16e29f789549463f5fa0a383e5ef1ce2cec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:39:31 +0200 Subject: [PATCH 14/16] refactor: move CoreId generation to CoreIdHelper --- .../multiAccount/MultiAccountController.ts | 6 +-- .../DecideRequestParametersValidator.test.ts | 4 +- .../IncomingRequestsController.test.ts | 6 +-- .../requests/RequestsIntegrationTest.ts | 14 +----- ...eleteAttributeRequestItemProcessor.test.ts | 6 +-- ...oposeAttributeRequestItemProcessor.test.ts | 28 +++++++----- .../ReadAttributeRequestItemProcessor.test.ts | 44 +++++++++++-------- .../test/consumption/attributes.test.ts | 6 +-- .../runtime/test/dataViews/MessageDVO.test.ts | 6 +-- .../test/dataViews/RelationshipDVO.test.ts | 6 +-- .../transport/identityDeletionProcess.test.ts | 4 +- packages/transport/src/core/CoreIdHelper.ts | 14 ++++-- .../transport/src/core/GeneratableCoreId.ts | 13 ------ .../transport/src/core/backbone/RESTClient.ts | 4 +- packages/transport/src/core/index.ts | 1 - .../sync/SynchronizedCollection.test.ts | 22 +++++----- .../test/modules/tokens/TokenContent.test.ts | 22 +++------- .../modules/tokens/TokenController.test.ts | 6 +-- .../test/testHelpers/FakeSyncClient.ts | 4 +- 19 files changed, 103 insertions(+), 113 deletions(-) delete mode 100644 packages/transport/src/core/GeneratableCoreId.ts diff --git a/packages/app-runtime/src/multiAccount/MultiAccountController.ts b/packages/app-runtime/src/multiAccount/MultiAccountController.ts index eb7200062..c8a0eef5f 100644 --- a/packages/app-runtime/src/multiAccount/MultiAccountController.ts +++ b/packages/app-runtime/src/multiAccount/MultiAccountController.ts @@ -2,7 +2,7 @@ import { IDatabaseCollection, IDatabaseCollectionProvider } from "@js-soft/docdb import { LokiJsConnection } from "@js-soft/docdb-access-loki"; import { ILogger } from "@js-soft/logging-abstractions"; import { CoreAddress, CoreDate, CoreError, CoreId } from "@nmshd/core-types"; -import { AccountController, DeviceSharedSecret, GeneratableCoreId, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; +import { AccountController, CoreIdHelper, DeviceSharedSecret, Transport, TransportCoreErrors, TransportLoggerFactory } from "@nmshd/transport"; import { AppConfig } from "../AppConfig"; import { SessionStorage } from "../SessionStorage"; import { LocalAccount } from "./data/LocalAccount"; @@ -146,7 +146,7 @@ export class MultiAccountController { this._log.trace(`Onboarding device ${deviceSharedSecret.id} for identity ${deviceSharedSecret.identity.address}...`); - const id = await GeneratableCoreId.generate(); + const id = await CoreIdHelper.notPrefixed.generate(); const localAccount = LocalAccount.from({ id, @@ -175,7 +175,7 @@ export class MultiAccountController { } public async createAccount(name: string): Promise<[LocalAccount, AccountController]> { - const id = await GeneratableCoreId.generate(); + const id = await CoreIdHelper.notPrefixed.generate(); let localAccount = LocalAccount.from({ id, diff --git a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts index 7ed371025..17f6735ab 100644 --- a/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts +++ b/packages/consumption/test/modules/requests/DecideRequestParametersValidator.test.ts @@ -1,6 +1,6 @@ import { Request, RequestItemGroup } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { GeneratableCoreId } from "@nmshd/transport"; +import { CoreIdHelper } from "@nmshd/transport"; import { DecideRequestItemGroupParametersJSON, DecideRequestItemParametersJSON, @@ -285,7 +285,7 @@ describe("DecideRequestParametersValidator", function () { createdAt: CoreDate.utc(), isOwn: true, peer: CoreAddress.from("did:e:a-domain:dids:anidentity"), - source: { reference: await GeneratableCoreId.generate(), type: "Message" }, + source: { reference: await CoreIdHelper.notPrefixed.generate(), type: "Message" }, status: LocalRequestStatus.Open, statusLog: [] }); diff --git a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts index 3b484cca7..b70f9ff56 100644 --- a/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts +++ b/packages/consumption/test/modules/requests/IncomingRequestsController.test.ts @@ -1,7 +1,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { IRequest, IRequestItemGroup, Request, RequestItemGroup, ResponseItem, ResponseItemGroup, ResponseItemResult } from "@nmshd/content"; import { CoreDate, CoreId } from "@nmshd/core-types"; -import { GeneratableCoreId, TransportLoggerFactory } from "@nmshd/transport"; +import { CoreIdHelper, TransportLoggerFactory } from "@nmshd/transport"; import { ConsumptionIds, DecideRequestItemGroupParametersJSON, @@ -66,7 +66,7 @@ describe("IncomingRequestsController", function () { }); test("uses the ID of the given Request if it exists", async function () { - const request = TestObjectFactory.createRequestWithOneItem({ id: await GeneratableCoreId.generate() }); + const request = TestObjectFactory.createRequestWithOneItem({ id: await CoreIdHelper.notPrefixed.generate() }); await When.iCreateAnIncomingRequestWith({ receivedRequest: request }); await Then.theRequestHasTheId(request.id!); @@ -1032,7 +1032,7 @@ describe("IncomingRequestsController", function () { test("Incoming Request via Message", async function () { const request = Request.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), items: [TestRequestItem.from({ mustBeAccepted: false })] }); const incomingMessage = TestObjectFactory.createIncomingIMessage(context.currentIdentity); diff --git a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts index 62ff1a7f6..d84d9f0cc 100644 --- a/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts +++ b/packages/consumption/test/modules/requests/RequestsIntegrationTest.ts @@ -15,17 +15,7 @@ import { ResponseResult } from "@nmshd/content"; import { CoreAddress, CoreId, ICoreId } from "@nmshd/core-types"; -import { - GeneratableCoreId, - IConfigOverwrite, - IMessage, - IRelationshipTemplate, - Message, - Relationship, - RelationshipTemplate, - SynchronizedCollection, - Transport -} from "@nmshd/transport"; +import { CoreIdHelper, IConfigOverwrite, IMessage, IRelationshipTemplate, Message, Relationship, RelationshipTemplate, SynchronizedCollection, Transport } from "@nmshd/transport"; import { ConsumptionController, ConsumptionIds, @@ -864,7 +854,7 @@ export class RequestsWhen { } public async iTryToGetARequestWithANonExistentId(): Promise { - this.context.localRequestAfterAction = (await this.context.incomingRequestsController.getIncomingRequest(await GeneratableCoreId.generate()))!; + this.context.localRequestAfterAction = (await this.context.incomingRequestsController.getIncomingRequest(await CoreIdHelper.notPrefixed.generate()))!; } public iTryToCompleteTheIncomingRequestWith(params: Partial): Promise { diff --git a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts index d575f5c90..116eb6b94 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/deleteAttribute/DeleteAttributeRequestItemProcessor.test.ts @@ -11,7 +11,7 @@ import { ResponseItemResult } from "@nmshd/content"; import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; -import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; +import { AccountController, CoreIdHelper, Transport } from "@nmshd/transport"; import { AcceptDeleteAttributeRequestItemParametersJSON, ConsumptionController, @@ -333,7 +333,7 @@ describe("DeleteAttributeRequestItemProcessor", function () { test("returns success when called with any deletionDate if Attribute doesn't exist", async function () { const requestItem = DeleteAttributeRequestItem.from({ mustBeAccepted: false, - attributeId: await GeneratableCoreId.generate() + attributeId: await CoreIdHelper.notPrefixed.generate() }); const requestId = await ConsumptionIds.request.generate(); @@ -654,7 +654,7 @@ describe("DeleteAttributeRequestItemProcessor", function () { test("returns an AcceptResponseItem", async function () { const requestItem = DeleteAttributeRequestItem.from({ mustBeAccepted: false, - attributeId: (await GeneratableCoreId.generate()).toString() + attributeId: (await CoreIdHelper.notPrefixed.generate()).toString() }); const requestId = await ConsumptionIds.request.generate(); diff --git a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts index 325df7ca1..075df0d30 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.test.ts @@ -14,8 +14,8 @@ import { Request, ResponseItemResult } from "@nmshd/content"; -import { CoreAddress, CoreDate } from "@nmshd/core-types"; -import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, CoreIdHelper, Transport } from "@nmshd/transport"; import { AcceptProposeAttributeRequestItemParametersWithExistingAttributeJSON, AcceptProposeAttributeRequestItemParametersWithNewAttributeJSON, @@ -557,7 +557,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: successorRepositoryAttribute.id, peer: sender, - requestReference: await GeneratableCoreId.generate() + requestReference: await CoreIdHelper.notPrefixed.generate() }); const requestItem = ProposeAttributeRequestItem.from({ @@ -792,7 +792,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { const predecessorOwnSharedIdentityAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorRepositoryAttribute.id, peer: sender, - requestReference: GeneratableCoreId.from("initialRequest") + requestReference: CoreId.from("initialRequest") }); const { successor: successorRepositoryAttribute } = await consumptionController.attributes.succeedRepositoryAttribute(predecessorRepositoryAttribute.id, { @@ -870,7 +870,11 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ + sourceAttribute: predecessorRepositoryAttribute.id, + peer: sender, + requestReference: await CoreIdHelper.notPrefixed.generate() + }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -937,7 +941,11 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ + sourceAttribute: predecessorRepositoryAttribute.id, + peer: sender, + requestReference: await CoreIdHelper.notPrefixed.generate() + }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -990,7 +998,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { const alreadySharedAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: repositoryAttribute.id, peer: sender, - requestReference: await GeneratableCoreId.generate() + requestReference: await CoreIdHelper.notPrefixed.generate() }); const requestItem = ProposeAttributeRequestItem.from({ @@ -1039,7 +1047,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreIdHelper.notPrefixed.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1095,7 +1103,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreIdHelper.notPrefixed.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1185,7 +1193,7 @@ describe("ProposeAttributeRequestItemProcessor", function () { owner: sender }), peer: sender, - requestReference: GeneratableCoreId.from("oldReqRef") + requestReference: CoreId.from("oldReqRef") }); const requestItem = ProposeAttributeRequestItem.from({ diff --git a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts index b709a9936..2a5f8af9b 100644 --- a/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts +++ b/packages/consumption/test/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.test.ts @@ -16,8 +16,8 @@ import { ThirdPartyRelationshipAttributeQuery, ThirdPartyRelationshipAttributeQueryOwner } from "@nmshd/content"; -import { CoreAddress, CoreDate } from "@nmshd/core-types"; -import { AccountController, GeneratableCoreId, Transport } from "@nmshd/transport"; +import { CoreAddress, CoreDate, CoreId } from "@nmshd/core-types"; +import { AccountController, CoreIdHelper, Transport } from "@nmshd/transport"; import { AcceptReadAttributeRequestItemParametersWithExistingAttributeJSON, AcceptReadAttributeRequestItemParametersWithNewAttributeJSON, @@ -438,7 +438,7 @@ describe("ReadAttributeRequestItemProcessor", function () { await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: successorRepositoryAttribute.id, peer: sender, - requestReference: await GeneratableCoreId.generate() + requestReference: await CoreIdHelper.notPrefixed.generate() }); const requestItem = ReadAttributeRequestItem.from({ @@ -859,7 +859,7 @@ describe("ReadAttributeRequestItemProcessor", function () { shareInfo: { peer: aThirdParty, requestReference: await ConsumptionIds.request.generate(), - sourceAttribute: GeneratableCoreId.from("sourceAttributeId") + sourceAttribute: CoreId.from("sourceAttributeId") } }); @@ -1293,7 +1293,7 @@ describe("ReadAttributeRequestItemProcessor", function () { const predecessorOwnSharedIdentityAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorRepositoryAttribute.id, peer: sender, - requestReference: GeneratableCoreId.from("initialRequest") + requestReference: CoreId.from("initialRequest") }); const { successor: successorRepositoryAttribute } = await consumptionController.attributes.succeedRepositoryAttribute(predecessorRepositoryAttribute.id, { @@ -1367,7 +1367,11 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ + sourceAttribute: predecessorRepositoryAttribute.id, + peer: sender, + requestReference: await CoreIdHelper.notPrefixed.generate() + }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1430,7 +1434,11 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: predecessorRepositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ + sourceAttribute: predecessorRepositoryAttribute.id, + peer: sender, + requestReference: await CoreIdHelper.notPrefixed.generate() + }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1479,7 +1487,7 @@ describe("ReadAttributeRequestItemProcessor", function () { const alreadySharedAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: repositoryAttribute.id, peer: sender, - requestReference: await GeneratableCoreId.generate() + requestReference: await CoreIdHelper.notPrefixed.generate() }); const requestItem = ReadAttributeRequestItem.from({ @@ -1524,7 +1532,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: accountController.identity.address }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreIdHelper.notPrefixed.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.DeletedByPeer, deletionDate: CoreDate.utc().subtract({ days: 1 }) @@ -1576,7 +1584,7 @@ describe("ReadAttributeRequestItemProcessor", function () { content: TestObjectFactory.createIdentityAttribute({ owner: CoreAddress.from(accountController.identity.address) }), - shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await GeneratableCoreId.generate() }), + shareInfo: LocalAttributeShareInfo.from({ sourceAttribute: repositoryAttribute.id, peer: sender, requestReference: await CoreIdHelper.notPrefixed.generate() }), deletionInfo: LocalAttributeDeletionInfo.from({ deletionStatus: LocalAttributeDeletionStatus.ToBeDeletedByPeer, deletionDate: CoreDate.utc().add({ days: 1 }) }) }); @@ -1621,13 +1629,13 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: accountController.identity.address }), peer: thirdPartyAddress, - requestReference: GeneratableCoreId.from("reqRef") + requestReference: CoreId.from("reqRef") }); const predecessorOwnSharedRelationshipAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorSourceAttribute.id, peer: sender, - requestReference: GeneratableCoreId.from("initialRequest") + requestReference: CoreId.from("initialRequest") }); const { successor: successorSourceAttribute } = await consumptionController.attributes.succeedOwnSharedRelationshipAttribute(predecessorSourceAttribute.id, { @@ -1643,7 +1651,7 @@ describe("ReadAttributeRequestItemProcessor", function () { }), shareInfo: LocalAttributeShareInfo.from({ peer: thirdPartyAddress, - notificationReference: GeneratableCoreId.from("successionNotification") + notificationReference: CoreId.from("successionNotification") }) }); @@ -1698,13 +1706,13 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: thirdPartyAddress }), peer: thirdPartyAddress, - requestReference: GeneratableCoreId.from("reqRef") + requestReference: CoreId.from("reqRef") }); const predecessorOwnSharedRelationshipAttribute = await consumptionController.attributes.createSharedLocalAttributeCopy({ sourceAttributeId: predecessorSourceAttribute.id, peer: sender, - requestReference: GeneratableCoreId.from("initialRequest") + requestReference: CoreId.from("initialRequest") }); const { successor: successorSourceAttribute } = await consumptionController.attributes.succeedPeerSharedRelationshipAttribute(predecessorSourceAttribute.id, { @@ -1720,7 +1728,7 @@ describe("ReadAttributeRequestItemProcessor", function () { }), shareInfo: LocalAttributeShareInfo.from({ peer: thirdPartyAddress, - notificationReference: GeneratableCoreId.from("successionNotification") + notificationReference: CoreId.from("successionNotification") }) }); @@ -1815,7 +1823,7 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: recipient }), peer: recipient, - requestReference: GeneratableCoreId.from("oldReqRef") + requestReference: CoreId.from("oldReqRef") }); const requestItem = ReadAttributeRequestItem.from({ @@ -1870,7 +1878,7 @@ describe("ReadAttributeRequestItemProcessor", function () { owner: thirdPartyAddress }), peer: recipient, - requestReference: GeneratableCoreId.from("oldReqRef") + requestReference: CoreId.from("oldReqRef") }); const requestItem = ReadAttributeRequestItem.from({ diff --git a/packages/runtime/test/consumption/attributes.test.ts b/packages/runtime/test/consumption/attributes.test.ts index 785e0ccaa..589fcb01a 100644 --- a/packages/runtime/test/consumption/attributes.test.ts +++ b/packages/runtime/test/consumption/attributes.test.ts @@ -12,7 +12,7 @@ import { ZipCodeJSON } from "@nmshd/content"; import { CoreDate, CoreId } from "@nmshd/core-types"; -import { GeneratableCoreId } from "@nmshd/transport"; +import { CoreIdHelper } from "@nmshd/transport"; import { AttributeCreatedEvent, ChangeDefaultRepositoryAttributeUseCase, @@ -974,7 +974,7 @@ describe(ShareRepositoryAttributeUseCase.name, () => { test("should throw if repository attribute doesn't exist", async () => { const shareRequest: ShareRepositoryAttributeRequest = { - attributeId: (await GeneratableCoreId.generate("ATT")).toString(), + attributeId: (await new CoreIdHelper("ATT").generate()).toString(), peer: services1.address }; const shareRequestResult = await services1.consumption.attributes.shareRepositoryAttribute(shareRequest); @@ -1041,7 +1041,7 @@ describe(SucceedRepositoryAttributeUseCase.name, () => { test("should throw if predecessor doesn't exist", async () => { const succeedAttributeRequest: SucceedRepositoryAttributeRequest = { - predecessorId: (await GeneratableCoreId.generate("ATT")).toString(), + predecessorId: (await new CoreIdHelper("ATT").generate()).toString(), successorContent: { value: { "@type": "GivenName", diff --git a/packages/runtime/test/dataViews/MessageDVO.test.ts b/packages/runtime/test/dataViews/MessageDVO.test.ts index a09f5aa01..326b18532 100644 --- a/packages/runtime/test/dataViews/MessageDVO.test.ts +++ b/packages/runtime/test/dataViews/MessageDVO.test.ts @@ -11,7 +11,7 @@ import { ResponseResult } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; -import { GeneratableCoreId } from "@nmshd/transport"; +import { CoreIdHelper } from "@nmshd/transport"; import { DataViewExpander, MailDVO, SendMessageRequest, TransportServices } from "../../src"; import { establishRelationshipWithContents, getRelationship, RuntimeServiceProvider, syncUntilHasMessage, uploadFile } from "../lib"; @@ -48,11 +48,11 @@ beforeAll(async () => { response: { "@type": "Response", result: ResponseResult.Accepted, - requestId: (await GeneratableCoreId.generate()).toString(), + requestId: (await CoreIdHelper.notPrefixed.generate()).toString(), items: [ ReadAttributeAcceptResponseItem.from({ result: ResponseItemResult.Accepted, - attributeId: await GeneratableCoreId.generate(), + attributeId: await CoreIdHelper.notPrefixed.generate(), attribute: IdentityAttribute.from({ owner: CoreAddress.from((await transportServices1.account.getIdentityInfo()).value.address), value: GivenName.from("AGivenName") diff --git a/packages/runtime/test/dataViews/RelationshipDVO.test.ts b/packages/runtime/test/dataViews/RelationshipDVO.test.ts index 3f2938007..31fd4704a 100644 --- a/packages/runtime/test/dataViews/RelationshipDVO.test.ts +++ b/packages/runtime/test/dataViews/RelationshipDVO.test.ts @@ -9,7 +9,7 @@ import { ResponseResult } from "@nmshd/content"; import { CoreAddress } from "@nmshd/core-types"; -import { GeneratableCoreId } from "@nmshd/transport"; +import { CoreIdHelper } from "@nmshd/transport"; import { DataViewExpander, TransportServices } from "../../src"; import { establishRelationshipWithContents, RuntimeServiceProvider } from "../lib"; @@ -47,11 +47,11 @@ beforeAll(async () => { response: { "@type": "Response", result: ResponseResult.Accepted, - requestId: (await GeneratableCoreId.generate()).toString(), + requestId: (await CoreIdHelper.notPrefixed.generate()).toString(), items: [ ReadAttributeAcceptResponseItem.from({ result: ResponseItemResult.Accepted, - attributeId: await GeneratableCoreId.generate(), + attributeId: await CoreIdHelper.notPrefixed.generate(), attribute: IdentityAttribute.from({ owner: CoreAddress.from((await transportServices1.account.getIdentityInfo()).value.address), value: GivenName.from("AGivenName") diff --git a/packages/runtime/test/transport/identityDeletionProcess.test.ts b/packages/runtime/test/transport/identityDeletionProcess.test.ts index e8b55999b..f40c0d773 100644 --- a/packages/runtime/test/transport/identityDeletionProcess.test.ts +++ b/packages/runtime/test/transport/identityDeletionProcess.test.ts @@ -1,4 +1,4 @@ -import { GeneratableCoreId, IdentityDeletionProcessStatus } from "@nmshd/transport"; +import { CoreIdHelper, IdentityDeletionProcessStatus } from "@nmshd/transport"; import { ApproveIdentityDeletionProcessUseCase, CancelIdentityDeletionProcessUseCase, @@ -131,7 +131,7 @@ describe("IdentityDeletionProcess", () => { }); test("should return an error trying to get an IdentityDeletionProcess specifying an unknown ID", async function () { - const unknownId = (await GeneratableCoreId.generate("IDP")).toString(); + const unknownId = (await new CoreIdHelper("IDP").generate()).toString(); const result = await transportService.identityDeletionProcesses.getIdentityDeletionProcess({ id: unknownId }); expect(result).toBeAnError("IdentityDeletionProcess not found. Make sure the ID exists and the record is not expired.", "error.runtime.recordNotFound"); }); diff --git a/packages/transport/src/core/CoreIdHelper.ts b/packages/transport/src/core/CoreIdHelper.ts index d72e33491..4ca022860 100644 --- a/packages/transport/src/core/CoreIdHelper.ts +++ b/packages/transport/src/core/CoreIdHelper.ts @@ -1,9 +1,10 @@ import { CoreId } from "@nmshd/core-types"; -import { RandomCharacterRange } from "../util"; -import { GeneratableCoreId } from "./GeneratableCoreId"; +import { Random, RandomCharacterRange } from "../util"; import { TransportError } from "./TransportError"; export class CoreIdHelper { + public static notPrefixed = new CoreIdHelper(""); + private readonly coreIdRegex: RegExp; public constructor( @@ -18,11 +19,16 @@ export class CoreIdHelper { throw new TransportError("This CoreIdHelper is set up for validation only."); } - return await GeneratableCoreId.generate(this.prefix); + return await this.generateUnsafe(); } public async generateUnsafe(): Promise { - return await GeneratableCoreId.generate(this.prefix); + if (this.prefix.length > 6) { + throw new Error(`The prefix "${this.prefix}" is too long. It must not be longer than 6 characters.`); + } + + const random = await Random.string(20 - this.prefix.length, RandomCharacterRange.Alphanumeric); + return CoreId.from(this.prefix.toUpperCase() + random); } public validate(id: string | CoreId): boolean { diff --git a/packages/transport/src/core/GeneratableCoreId.ts b/packages/transport/src/core/GeneratableCoreId.ts deleted file mode 100644 index 52d5f63b1..000000000 --- a/packages/transport/src/core/GeneratableCoreId.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { CoreId } from "@nmshd/core-types"; -import { Random, RandomCharacterRange } from "../util"; - -export class GeneratableCoreId extends CoreId { - public static async generate(prefix = ""): Promise { - if (prefix.length > 6) { - throw new Error(`The prefix "${prefix}" is too long. It must not be longer than 6 characters.`); - } - - const random = await Random.string(20 - prefix.length, RandomCharacterRange.Alphanumeric); - return this.from(prefix.toUpperCase() + random); - } -} diff --git a/packages/transport/src/core/backbone/RESTClient.ts b/packages/transport/src/core/backbone/RESTClient.ts index a9143583f..17ecfd39e 100644 --- a/packages/transport/src/core/backbone/RESTClient.ts +++ b/packages/transport/src/core/backbone/RESTClient.ts @@ -5,7 +5,7 @@ import formDataLib from "form-data"; import { AgentOptions } from "http"; import { AgentOptions as HTTPSAgentOptions } from "https"; import _ from "lodash"; -import { GeneratableCoreId } from "../GeneratableCoreId"; +import { CoreIdHelper } from "../CoreIdHelper"; import { TransportLoggerFactory } from "../TransportLoggerFactory"; import { ClientResult } from "./ClientResult"; import { IPaginationDataSource, Paginator, PaginatorPercentageCallback } from "./Paginator"; @@ -59,7 +59,7 @@ export class RESTClient { } private async generateRequestId(): Promise { - const id = await GeneratableCoreId.generate("HTTP"); + const id = await new CoreIdHelper("HTTP").generate(); return id.toString(); } diff --git a/packages/transport/src/core/index.ts b/packages/transport/src/core/index.ts index 755775d18..8cf36c05e 100644 --- a/packages/transport/src/core/index.ts +++ b/packages/transport/src/core/index.ts @@ -5,7 +5,6 @@ export * from "./CoreSynchronizable"; export * from "./CoreUtil"; export * from "./DbCollectionName"; export * from "./DependencyOverrides"; -export * from "./GeneratableCoreId"; export * from "./Reference"; export * from "./Transport"; export * from "./TransportController"; diff --git a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts index f53b386b6..d7abf6cbe 100644 --- a/packages/transport/test/modules/sync/SynchronizedCollection.test.ts +++ b/packages/transport/test/modules/sync/SynchronizedCollection.test.ts @@ -1,7 +1,7 @@ import { IDatabaseCollection } from "@js-soft/docdb-access-abstractions"; import { CoreDate } from "@nmshd/core-types"; import { instance, mock, verify } from "ts-mockito"; -import { DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, GeneratableCoreId, SynchronizedCollection } from "../../../src"; +import { CoreIdHelper, DatawalletModification, DatawalletModificationCategory, DatawalletModificationType, SynchronizedCollection } from "../../../src"; import { ACacheableSynchronizedCollectionItem, CachedACacheableSynchronizedCollectionItem } from "../../testHelpers/ACacheableSynchronizedCollectionItem"; import { ASynchronizedCollectionItem } from "../../testHelpers/ASynchronizedCollectionItem"; import { FakeDatabaseCollection } from "../../testHelpers/FakeDatabaseCollection"; @@ -22,7 +22,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new item, datawallet modifications are created for each category of data", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalStringProperty: "SomeValue", someMetadataStringProperty: "SomeValue", someUserdataStringProperty: "SomeValue" @@ -66,7 +66,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new non-cacheable item, no CacheChanged modification is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalStringProperty: "SomeValue" }); @@ -85,7 +85,7 @@ describe("SynchronizedCollection", function () { test("when updating a cacheable item with a changed cache, a CacheChanged modification is created", async function () { const item = ACacheableSynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalProperty: "SomeValue", cache: { someCacheProperty: "cachedValue" }, cachedAt: CoreDate.utc() @@ -112,7 +112,7 @@ describe("SynchronizedCollection", function () { test("when updating a cacheable item without a changed cache, no CacheChanged modification is created", async function () { const item = ACacheableSynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalProperty: "SomeValue", cache: { someCacheProperty: "cachedValue" }, cachedAt: CoreDate.utc() @@ -137,7 +137,7 @@ describe("SynchronizedCollection", function () { test("when updating a non-cacheable item, no CacheChanged modification is created", async function () { const item = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalStringProperty: "SomeValue" }); @@ -160,7 +160,7 @@ describe("SynchronizedCollection", function () { test("when a inserting a new item, a datawallet modification for technical data is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someTechnicalStringProperty: "SomeValue", someTechnicalNumberProperty: 1, someTechnicalBooleanProperty: true @@ -183,7 +183,7 @@ describe("SynchronizedCollection", function () { test("when a inserting a new item, a datawallet modification for metadata is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someMetadataStringProperty: "SomeValue", someMetadataNumberProperty: 1, someMetadataBooleanProperty: true @@ -206,7 +206,7 @@ describe("SynchronizedCollection", function () { test("when inserting a new item, a datawallet modification for userdata is created", async function () { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate(), + id: await CoreIdHelper.notPrefixed.generate(), someUserdataStringProperty: "SomeValue", someUserdataNumberProperty: 1, someUserdataBooleanProperty: true @@ -228,7 +228,7 @@ describe("SynchronizedCollection", function () { }); test("when updating an item, should add every property of a category to the payload even if only one was changed", async function () { - const itemId = await GeneratableCoreId.generate(); + const itemId = await CoreIdHelper.notPrefixed.generate(); await synchronizedCollection.create( ASynchronizedCollectionItem.from({ id: itemId, @@ -273,7 +273,7 @@ describe("SynchronizedCollection", function () { } ])("$payloadCategory datawallet modifications with type 'Create' have all necessary properties set", async function (params) { const newItem = ASynchronizedCollectionItem.from({ - id: await GeneratableCoreId.generate() + id: await CoreIdHelper.notPrefixed.generate() }); (newItem as any)[params.payloadCategory] = "someValue"; diff --git a/packages/transport/test/modules/tokens/TokenContent.test.ts b/packages/transport/test/modules/tokens/TokenContent.test.ts index 41a5db1cb..a8da8939e 100644 --- a/packages/transport/test/modules/tokens/TokenContent.test.ts +++ b/packages/transport/test/modules/tokens/TokenContent.test.ts @@ -2,15 +2,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { - AccountController, - DeviceSharedSecret, - GeneratableCoreId, - TokenContentDeviceSharedSecret, - TokenContentFile, - TokenContentRelationshipTemplate, - Transport -} from "../../../src"; +import { AccountController, CoreIdHelper, DeviceSharedSecret, TokenContentDeviceSharedSecret, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenContent", function () { @@ -72,7 +64,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (verbose)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await GeneratableCoreId.generate() + templateId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -93,7 +85,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (no type information)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await GeneratableCoreId.generate() + templateId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -113,7 +105,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (from unknown type)", async function () { const token = TokenContentRelationshipTemplate.from({ secretKey: await CryptoEncryption.generateKey(), - templateId: await GeneratableCoreId.generate() + templateId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentRelationshipTemplate); @@ -209,7 +201,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (verbose)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await GeneratableCoreId.generate() + fileId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); @@ -230,7 +222,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (no type information)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await GeneratableCoreId.generate() + fileId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); @@ -250,7 +242,7 @@ describe("TokenContent", function () { test("should serialize and deserialize correctly (from unknown type)", async function () { const token = TokenContentFile.from({ secretKey: await CryptoEncryption.generateKey(), - fileId: await GeneratableCoreId.generate() + fileId: await CoreIdHelper.notPrefixed.generate() }); expect(token).toBeInstanceOf(Serializable); expect(token).toBeInstanceOf(TokenContentFile); diff --git a/packages/transport/test/modules/tokens/TokenController.test.ts b/packages/transport/test/modules/tokens/TokenController.test.ts index 0dd42c4b1..80494c22d 100644 --- a/packages/transport/test/modules/tokens/TokenController.test.ts +++ b/packages/transport/test/modules/tokens/TokenController.test.ts @@ -2,7 +2,7 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; import { JSONWrapper, Serializable } from "@js-soft/ts-serval"; import { CoreDate, CoreId } from "@nmshd/core-types"; import { CryptoEncryption, CryptoSecretKey } from "@nmshd/crypto"; -import { AccountController, GeneratableCoreId, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; +import { AccountController, CoreIdHelper, Token, TokenContentFile, TokenContentRelationshipTemplate, Transport } from "../../../src"; import { TestUtil } from "../../testHelpers/TestUtil"; describe("TokenController", function () { @@ -82,7 +82,7 @@ describe("TokenController", function () { test("should send and receive a TokenContentFile", async function () { const expiresAt = CoreDate.utc().add({ minutes: 5 }); const content = TokenContentFile.from({ - fileId: await GeneratableCoreId.generate(), + fileId: await CoreIdHelper.notPrefixed.generate(), secretKey: await CryptoEncryption.generateKey() }); const sentToken = await sender.tokens.sendToken({ @@ -111,7 +111,7 @@ describe("TokenController", function () { test("should send and receive a TokenContentRelationshipTemplate", async function () { const expiresAt = CoreDate.utc().add({ minutes: 5 }); const content = TokenContentRelationshipTemplate.from({ - templateId: await GeneratableCoreId.generate(), + templateId: await CoreIdHelper.notPrefixed.generate(), secretKey: await CryptoEncryption.generateKey() }); const sentToken = await sender.tokens.sendToken({ diff --git a/packages/transport/test/testHelpers/FakeSyncClient.ts b/packages/transport/test/testHelpers/FakeSyncClient.ts index c5cb660e6..ea08a722b 100644 --- a/packages/transport/test/testHelpers/FakeSyncClient.ts +++ b/packages/transport/test/testHelpers/FakeSyncClient.ts @@ -3,13 +3,13 @@ import { BackboneDatawalletModification, BackboneExternalEvent, ClientResult, + CoreIdHelper, CreateDatawalletModificationsRequest, CreateDatawalletModificationsResponse, FinalizeDatawalletVersionUpgradeRequest, FinalizeDatawalletVersionUpgradeResponse, FinalizeExternalEventSyncRequest, FinalizeExternalEventSyncResponse, - GeneratableCoreId, GetDatawalletModificationsRequest, GetDatawalletResponse, ISyncClient, @@ -91,7 +91,7 @@ export class FakeSyncClient implements ISyncClient { // eslint-disable-next-line @typescript-eslint/prefer-for-of for (let i = 0; i < request.modifications.length; i++) { response.modifications.push({ - id: (await GeneratableCoreId.generate()).serialize(), + id: (await CoreIdHelper.notPrefixed.generate()).serialize(), index: response.modifications.length, createdAt: CoreDate.utc().toISOString() }); From 45de6702ae5f5a87ac050735a0ddd7efed967033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 10:57:42 +0200 Subject: [PATCH 15/16] fix: compiler errors --- .../src/modules/relationships/RelationshipsController.ts | 2 +- .../PeerDeletedExternalEventProcessor.ts | 2 +- .../PeerDeletionCancelledExternalEventProcessor.ts | 2 +- .../PeerToBeDeletedExternalEventProcessor.ts | 2 +- .../PeerDeletedExternalEventProcessor.test.ts | 3 ++- .../PeerDeletionCancelledExternalEvent.test.ts | 3 ++- .../PeerToBeDeletedExternalEventProcessor.test.ts | 3 ++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/transport/src/modules/relationships/RelationshipsController.ts b/packages/transport/src/modules/relationships/RelationshipsController.ts index 4b676cffd..7fe176e67 100644 --- a/packages/transport/src/modules/relationships/RelationshipsController.ts +++ b/packages/transport/src/modules/relationships/RelationshipsController.ts @@ -616,7 +616,7 @@ export class RelationshipsController extends TransportController { public async setPeerDeletionInfo(relationshipId: CoreId, deletionInfo?: PeerDeletionInfo): Promise { const relationshipDoc = await this.relationships.read(relationshipId.toString()); - if (!relationshipDoc) throw CoreErrors.general.recordNotFound(Relationship, relationshipId.toString()); + if (!relationshipDoc) throw TransportCoreErrors.general.recordNotFound(Relationship, relationshipId.toString()); const relationship = Relationship.from(relationshipDoc); relationship.peerDeletionInfo = deletionInfo; diff --git a/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.ts b/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.ts index 388d3cb13..02d7399b1 100644 --- a/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.ts +++ b/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId } from "../../../core"; +import { CoreId } from "@nmshd/core-types"; import { PeerDeletedEvent } from "../../../events"; import { PeerDeletionInfo, PeerDeletionStatus } from "../../relationships/local/PeerDeletionInfo"; import { Relationship } from "../../relationships/local/Relationship"; diff --git a/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEventProcessor.ts b/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEventProcessor.ts index 45e695a25..f34284e4e 100644 --- a/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEventProcessor.ts +++ b/packages/transport/src/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEventProcessor.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId } from "../../../core"; +import { CoreId } from "@nmshd/core-types"; import { PeerDeletionCancelledEvent } from "../../../events"; import { Relationship } from "../../relationships/local/Relationship"; import { BackboneExternalEvent } from "../backbone/BackboneExternalEvent"; diff --git a/packages/transport/src/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.ts b/packages/transport/src/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.ts index a016ad6a6..9d4bc9267 100644 --- a/packages/transport/src/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.ts +++ b/packages/transport/src/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.ts @@ -1,5 +1,5 @@ import { Serializable, serialize, validate } from "@js-soft/ts-serval"; -import { CoreId } from "../../../core"; +import { CoreId } from "@nmshd/core-types"; import { PeerToBeDeletedEvent } from "../../../events"; import { PeerDeletionInfo, PeerDeletionStatus } from "../../relationships/local/PeerDeletionInfo"; import { Relationship } from "../../relationships/local/Relationship"; diff --git a/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.test.ts b/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.test.ts index 10fc6b01e..280bbfdbd 100644 --- a/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.test.ts +++ b/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreId, PeerDeletionStatus, Transport } from "../../../../src"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, PeerDeletionStatus, Transport } from "../../../../src"; import { PeerDeletedExternalEventProcessor } from "../../../../src/modules/sync/externalEventProcessors/PeerDeletedExternalEventProcessor"; import { TestUtil } from "../../../testHelpers/TestUtil"; diff --git a/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEvent.test.ts b/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEvent.test.ts index 34d405b47..dffe1af78 100644 --- a/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEvent.test.ts +++ b/packages/transport/test/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEvent.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreId, Transport } from "../../../../src"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, Transport } from "../../../../src"; import { PeerDeletionCancelledExternalEventProcessor } from "../../../../src/modules/sync/externalEventProcessors/PeerDeletionCancelledExternalEventProcessor"; import { TestUtil } from "../../../testHelpers/TestUtil"; diff --git a/packages/transport/test/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.test.ts b/packages/transport/test/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.test.ts index f2a668d29..75d613417 100644 --- a/packages/transport/test/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.test.ts +++ b/packages/transport/test/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor.test.ts @@ -1,5 +1,6 @@ import { IDatabaseConnection } from "@js-soft/docdb-access-abstractions"; -import { AccountController, CoreId, PeerDeletionStatus, Transport } from "../../../../src"; +import { CoreId } from "@nmshd/core-types"; +import { AccountController, PeerDeletionStatus, Transport } from "../../../../src"; import { PeerToBeDeletedExternalEventProcessor } from "../../../../src/modules/sync/externalEventProcessors/PeerToBeDeletedExternalEventProcessor"; import { TestUtil } from "../../../testHelpers/TestUtil"; From ebe2bf24a0a3fc1f6e05e3ee3edeeaec050e34ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 28 Aug 2024 13:55:34 +0200 Subject: [PATCH 16/16] chore: do not use CoreSerializable anymore --- packages/transport/src/core/types/CoreHash.ts | 19 ++++++++---- .../src/core/types/CoreSerializable.ts | 30 ------------------- packages/transport/src/core/types/index.ts | 1 - .../relationships/local/PeerDeletionInfo.ts | 7 ++--- .../RelationshipCreationContentCipher.ts | 21 +++++++++---- ...lationshipCreationResponseContentCipher.ts | 16 ++++++---- 6 files changed, 42 insertions(+), 52 deletions(-) delete mode 100644 packages/transport/src/core/types/CoreSerializable.ts diff --git a/packages/transport/src/core/types/CoreHash.ts b/packages/transport/src/core/types/CoreHash.ts index 7a0da300f..5dd4b6bf8 100644 --- a/packages/transport/src/core/types/CoreHash.ts +++ b/packages/transport/src/core/types/CoreHash.ts @@ -1,8 +1,7 @@ -import { serialize, serializeOnly, validate } from "@js-soft/ts-serval"; +import { ISerializable, Serializable, serialize, serializeOnly, validate } from "@js-soft/ts-serval"; import { CoreBuffer, CryptoHash, CryptoHashAlgorithm, Encoding, ICoreBuffer } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "./CoreSerializable"; -export interface ICoreHash extends ICoreSerializable { +export interface ICoreHash extends ISerializable { hash: string; } @@ -10,7 +9,7 @@ export interface ICoreHash extends ICoreSerializable { * Hash wraps a hash */ @serializeOnly("hash", "string") -export class CoreHash extends CoreSerializable { +export class CoreHash extends Serializable { @validate() @serialize() public hash: string; @@ -63,7 +62,17 @@ export class CoreHash extends CoreSerializable { return this.hash; } - public override toBase64(): string { + public toBase64(): string { return this.hash; } + + public static fromBase64T(value: string): T { + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return (this as any).deserialize(serialized); + } + + public static fromBase64Unknown(value: string): Serializable { + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return Serializable.deserializeUnknown(serialized); + } } diff --git a/packages/transport/src/core/types/CoreSerializable.ts b/packages/transport/src/core/types/CoreSerializable.ts deleted file mode 100644 index 57e032f75..000000000 --- a/packages/transport/src/core/types/CoreSerializable.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ISerializable, Serializable, type } from "@js-soft/ts-serval"; -import { CoreBuffer } from "@nmshd/crypto"; - -export interface ICoreSerializable extends ISerializable {} - -/** - * CoreSerializable is the local pendant of the Serializable class which - * automatically validates, serializes, deserializes and validates again. - * - * With the synchronous class, the deserialize methods (from and deserialize) - * are called synchronous. Please be aware, that CoreSerializable classes should - * have no CoreSerializableAsync properties. - */ - -@type("CoreSerializable") -export class CoreSerializable extends Serializable implements ISerializable { - public toBase64(): string { - return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); - } - - public static fromBase64T(value: string): T { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - return (this as any).deserialize(serialized); - } - - public static fromBase64Unknown(value: string): Serializable { - const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); - return Serializable.deserializeUnknown(serialized); - } -} diff --git a/packages/transport/src/core/types/index.ts b/packages/transport/src/core/types/index.ts index 0339a5fdc..34d5d158c 100644 --- a/packages/transport/src/core/types/index.ts +++ b/packages/transport/src/core/types/index.ts @@ -1,3 +1,2 @@ export * from "./CoreHash"; -export * from "./CoreSerializable"; export * from "./TransportVersion"; diff --git a/packages/transport/src/modules/relationships/local/PeerDeletionInfo.ts b/packages/transport/src/modules/relationships/local/PeerDeletionInfo.ts index c09dc1ba5..007a9d55a 100644 --- a/packages/transport/src/modules/relationships/local/PeerDeletionInfo.ts +++ b/packages/transport/src/modules/relationships/local/PeerDeletionInfo.ts @@ -1,5 +1,4 @@ -import { serialize, validate } from "@js-soft/ts-serval"; -import { CoreSerializable, ICoreSerializable } from "../../../core"; +import { ISerializable, Serializable, serialize, validate } from "@js-soft/ts-serval"; export enum PeerDeletionStatus { ToBeDeleted = "ToBeDeleted", @@ -10,11 +9,11 @@ export interface PeerDeletionInfoJSON { deletionStatus: PeerDeletionStatus; } -export interface IPeerDeletionInfo extends ICoreSerializable { +export interface IPeerDeletionInfo extends ISerializable { deletionStatus: PeerDeletionStatus; } -export class PeerDeletionInfo extends CoreSerializable implements IPeerDeletionInfo { +export class PeerDeletionInfo extends Serializable implements IPeerDeletionInfo { @serialize() @validate({ customValidator: (v) => (!Object.values(PeerDeletionStatus).includes(v) ? `must be one of: ${Object.values(PeerDeletionStatus).map((o) => `"${o}"`)}` : undefined) diff --git a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts index 7d7c32d42..189a5bd26 100644 --- a/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/requests/RelationshipCreationContentCipher.ts @@ -1,14 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CryptoCipher, CryptoRelationshipPublicRequest, ICryptoCipher, ICryptoRelationshipPublicRequest } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreBuffer, CryptoCipher, CryptoRelationshipPublicRequest, ICryptoCipher, ICryptoRelationshipPublicRequest } from "@nmshd/crypto"; -export interface IRelationshipCreationContentCipher extends ICoreSerializable { +export interface IRelationshipCreationContentCipher extends ISerializable { cipher: ICryptoCipher; publicCreationContentCrypto: ICryptoRelationshipPublicRequest; } @type("RelationshipCreationContentCipher") -export class RelationshipCreationContentCipher extends CoreSerializable implements IRelationshipCreationContentCipher { +export class RelationshipCreationContentCipher extends Serializable implements IRelationshipCreationContentCipher { @validate() @serialize() public cipher: CryptoCipher; @@ -22,6 +21,16 @@ export class RelationshipCreationContentCipher extends CoreSerializable implemen } public static fromBase64(value: string): RelationshipCreationContentCipher { - return super.fromBase64T(value); + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return (this as any).deserialize(serialized); + } + + public toBase64(): string { + return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); + } + + public static fromBase64Unknown(value: string): Serializable { + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return Serializable.deserializeUnknown(serialized); } } diff --git a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts index b7b6c5b4a..c6795f61e 100644 --- a/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts +++ b/packages/transport/src/modules/relationships/transmission/responses/RelationshipCreationResponseContentCipher.ts @@ -1,14 +1,13 @@ -import { serialize, type, validate } from "@js-soft/ts-serval"; -import { CryptoCipher, CryptoRelationshipPublicResponse, ICryptoCipher, ICryptoRelationshipPublicResponse } from "@nmshd/crypto"; -import { CoreSerializable, ICoreSerializable } from "../../../../core"; +import { ISerializable, Serializable, serialize, type, validate } from "@js-soft/ts-serval"; +import { CoreBuffer, CryptoCipher, CryptoRelationshipPublicResponse, ICryptoCipher, ICryptoRelationshipPublicResponse } from "@nmshd/crypto"; -export interface IRelationshipCreationResponseContentCipher extends ICoreSerializable { +export interface IRelationshipCreationResponseContentCipher extends ISerializable { cipher: ICryptoCipher; publicCreationResponseContentCrypto: ICryptoRelationshipPublicResponse; } @type("RelationshipCreationResponseContentCipher") -export class RelationshipCreationResponseContentCipher extends CoreSerializable implements IRelationshipCreationResponseContentCipher { +export class RelationshipCreationResponseContentCipher extends Serializable implements IRelationshipCreationResponseContentCipher { @validate() @serialize() public cipher: CryptoCipher; @@ -21,7 +20,12 @@ export class RelationshipCreationResponseContentCipher extends CoreSerializable return this.fromAny(value); } + public toBase64(): string { + return CoreBuffer.fromUtf8(this.serialize()).toBase64URL(); + } + public static fromBase64(value: string): RelationshipCreationResponseContentCipher { - return super.fromBase64T(value); + const serialized = CoreBuffer.fromBase64URL(value).toUtf8(); + return (this as any).deserialize(serialized); } }