Skip to content

Commit

Permalink
Refactoring (#72)
Browse files Browse the repository at this point in the history
* Refactoring
* Add moduleNameMapper for @akd-studios/framework
* Update version to 0.6.0 in package.json
* Update devDependencies versions in package.json
* Update @microsoft/api-extractor version
* Update Node version to 18.x in GitHub Actions workflow
  • Loading branch information
akdasa authored Jan 26, 2024
1 parent a332d34 commit 95a684f
Show file tree
Hide file tree
Showing 32 changed files with 2,008 additions and 1,629 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: 📦 Install Node
uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://npm.pkg.github.com'
cache: npm

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
- name: 📦 Install Node
uses: actions/setup-node@v2
with:
node-version: '16.x'
node-version: '18.x'
registry-url: 'https://npm.pkg.github.com'
cache: npm

Expand Down
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"overrideTsconfig": {
"compilerOptions": {
"paths": {
"@lib/*": [
"@akd-studios/framework/*": [
"./temp/*"
]
}
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
'<rootDir>/tests/**/*.spec.ts'
],
moduleNameMapper: {
'^@lib/(.*)': '<rootDir>/lib/$1',
'^@akd-studios/framework/(.*)': '<rootDir>/lib/$1',
'^@tests/(.*)': '<rootDir>/tests/$1',
}
}
4 changes: 2 additions & 2 deletions lib/commands/Command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AnyResult } from '@lib/core'
import { type AnyResult } from '@akd-studios/framework/core'


/**
Expand All @@ -19,7 +19,7 @@ export interface Command<
* Reverts the command.
* @param context The context in which the command is reverted.
*/
revert(context: TContext)
revert(context: TContext): Promise<void>
}

/**
Expand Down
3 changes: 1 addition & 2 deletions lib/commands/ExecutionStack.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { AnyCommand } from './Command'
import { Transaction } from './Transaction'
import { type AnyCommand, Transaction } from '@akd-studios/framework/commands'


/**
Expand Down
6 changes: 2 additions & 4 deletions lib/commands/Processor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { AnyResult, Event } from '@lib/core'
import { AnyCommand, Command } from './Command'
import { ExecutionStack } from './ExecutionStack'
import { Transaction } from './Transaction'
import { type AnyResult, Event } from '@akd-studios/framework/core'
import { type AnyCommand, type Command, ExecutionStack, Transaction } from '@akd-studios/framework/commands'


/**
Expand Down
3 changes: 1 addition & 2 deletions lib/domain/models/Aggregate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Entity } from './Entity'
import { Identity } from './Identity'
import { Entity, Identity } from '@akd-studios/framework/domain/models'


/**
Expand Down
2 changes: 1 addition & 1 deletion lib/domain/models/Builder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Result } from '../../core'
import { Result } from '@akd-studios/framework/core'

/**
* Builds a new instance of the specified type or returns a failure result.
Expand Down
4 changes: 1 addition & 3 deletions lib/domain/models/Entity.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Identity } from './Identity'
import { Equalable, Identifiable } from './Interfaces'

import { type Equalable, type Identifiable, Identity } from '@akd-studios/framework/domain/models'

/**
* Base class for all entities.
Expand Down
2 changes: 2 additions & 0 deletions lib/domain/models/Identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class Identity<
/**
* Identity brand
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
private __type__: TIdentityType
}

Expand Down
3 changes: 1 addition & 2 deletions lib/domain/models/Interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Identity } from './Identity'

import { Identity } from '@akd-studios/framework/domain/models'

/**
* Identifiable is an interface for all objects that have an identity.
Expand Down
7 changes: 6 additions & 1 deletion lib/domain/models/Value.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Equalable } from './Interfaces'
import { type Equalable } from '@akd-studios/framework/domain/models'


export class Value<TValueType> implements Equalable<Value<TValueType>> {
/**
Expand All @@ -12,12 +13,16 @@ export class Value<TValueType> implements Equalable<Value<TValueType>> {
this.__type__ === value.__type__ &&
// Stryker disable next-line all
Object.keys(this).length === Object.keys(value).length &&
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Object.keys(this).every(key => this[key] === value[key])
)
}

/**
* Value type
*/
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
private __type__: TValueType
}
2 changes: 1 addition & 1 deletion lib/domain/models/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './Entity'
export * from './Aggregate'
export * from './Builder'
export * from './Entity'
export * from './Identity'
export * from './Interfaces'
export * from './Value'
2 changes: 1 addition & 1 deletion lib/persistence/Query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Aggregate, AnyIdentity } from '../domain'
import { Aggregate, type AnyIdentity } from '@akd-studios/framework/domain/models'

/**
* Comparison operators. These are used to compare a field with a value.
Expand Down
5 changes: 3 additions & 2 deletions lib/persistence/Repository.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Aggregate, AnyIdentity } from '../domain/models'
import { Query } from '../persistence'
import { Aggregate, type AnyIdentity } from '@akd-studios/framework/domain'
import { type Query } from '@akd-studios/framework/persistence'


export interface ResultSetSlice {
start: number
Expand Down
7 changes: 5 additions & 2 deletions lib/persistence/memory/InMemoryQueryProcessor.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Aggregate, AnyIdentity, Identity, Value } from '../../domain/models'
import { Binding, Expression, LogicalOperators, Operators, Predicate, Query } from '../Query'
import { Aggregate, type AnyIdentity, Identity, Value } from '@akd-studios/framework/domain/models'
import { type Binding, Expression, LogicalOperators, Operators, Predicate, type Query } from '@akd-studios/framework/persistence'


export class InMemoryQueryProcessor<
TEntity extends Aggregate<AnyIdentity>
Expand Down Expand Up @@ -116,6 +117,8 @@ export class InMemoryQueryProcessor<
const fields = f.split('.')
let value = o
for (const field of fields) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
value = value[field]
}
return value
Expand Down
5 changes: 2 additions & 3 deletions lib/persistence/memory/InMemoryRepository.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Aggregate, AnyIdentity } from '../../domain/models'
import { Query } from '../Query'
import { QueryOptions, Repository, ResultSet } from '../Repository'
import { Aggregate, type AnyIdentity } from '@akd-studios/framework/domain/models'
import { type Query, type QueryOptions, type Repository, ResultSet } from '@akd-studios/framework/persistence'
import { InMemoryQueryProcessor } from './InMemoryQueryProcessor'


Expand Down
Loading

0 comments on commit 95a684f

Please sign in to comment.