Skip to content

Commit 16ed9d6

Browse files
committed
migrate to hefty v2
1 parent a071700 commit 16ed9d6

File tree

112 files changed

+745
-749
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+745
-749
lines changed

_templates/service/new/factory.ejs.t

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@ import <%= h.changeCase.pascal(name) %> from '../../src/entities/<%= name %>'
77

88
export default class <%= h.changeCase.pascal(name) %>Factory extends Factory<<%= h.changeCase.pascal(name) %>> {
99
constructor() {
10-
super(<%= h.changeCase.pascal(name) %>, 'base')
11-
this.register('base', this.base)
10+
super(<%= h.changeCase.pascal(name) %>)
1211
}
1312

14-
protected base(): Partial<<%= h.changeCase.pascal(name) %>> {
15-
return {
16-
17-
}
13+
protected definition(): void {
14+
this.state(() => ({
15+
// TODO
16+
}))
1817
}
1918
}

package-lock.json

Lines changed: 4 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@vitest/coverage-v8": "^1.5.2",
3636
"axios-mock-adapter": "^1.22.0",
3737
"eslint": "^8.26.0",
38-
"hefty": "^1.1.0",
3938
"husky": "^9.0.11",
4039
"hygen": "^6.2.11",
4140
"lint-staged": ">=10",
@@ -65,6 +64,7 @@
6564
"dinero.js": "^2.0.0-alpha.14",
6665
"dotenv": "^16.0.0",
6766
"handlebars": "^4.7.7",
67+
"hefty": "^2.0.0",
6868
"ioredis": "^5.2.4",
6969
"jsonwebtoken": "^9.0.0",
7070
"koa": "^2.13.4",

tests/entities/player-group-rule/casting.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('PlayerGroupRule casting', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with((player) => ({
14+
const player1 = await new PlayerFactory([game]).state((player) => ({
1515
props: new Collection<PlayerProp>(player, [
1616
new PlayerProp(player, 'currentLevel', '80')
1717
])
@@ -42,7 +42,7 @@ describe('PlayerGroupRule casting', () => {
4242
const [organisation, game] = await createOrganisationAndGame()
4343
const [token] = await createUserAndToken({}, organisation)
4444

45-
const player1 = await new PlayerFactory([game]).with((player) => ({
45+
const player1 = await new PlayerFactory([game]).state((player) => ({
4646
props: new Collection<PlayerProp>(player, [
4747
new PlayerProp(player, 'currentLevel', '80')
4848
])
@@ -73,7 +73,7 @@ describe('PlayerGroupRule casting', () => {
7373
const [organisation, game] = await createOrganisationAndGame()
7474
const [token] = await createUserAndToken({}, organisation)
7575

76-
const player1 = await new PlayerFactory([game]).with((player) => ({
76+
const player1 = await new PlayerFactory([game]).state((player) => ({
7777
props: new Collection<PlayerProp>(player, [
7878
new PlayerProp(player, 'firstLoginAt', '2022-05-03 00:00:00')
7979
])
@@ -104,7 +104,7 @@ describe('PlayerGroupRule casting', () => {
104104
const [organisation, game] = await createOrganisationAndGame()
105105
const [token] = await createUserAndToken({}, organisation)
106106

107-
const player1 = await new PlayerFactory([game]).with((player) => ({
107+
const player1 = await new PlayerFactory([game]).state((player) => ({
108108
props: new Collection<PlayerProp>(player, [
109109
new PlayerProp(player, 'firstLoginAt', '2022-05-03 08:59:36')
110110
])

tests/entities/player-group-rule/equals-rule.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('EQUALS rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
14+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
1515
const player2 = await new PlayerFactory([game]).one()
1616
await (<EntityManager>global.em).persistAndFlush([player1, player2])
1717

@@ -38,7 +38,7 @@ describe('EQUALS rule', () => {
3838
const [organisation, game] = await createOrganisationAndGame()
3939
const [token] = await createUserAndToken({}, organisation)
4040

41-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
41+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
4242
const player2 = await new PlayerFactory([game]).one()
4343
await (<EntityManager>global.em).persistAndFlush([player1, player2])
4444

@@ -65,7 +65,7 @@ describe('EQUALS rule', () => {
6565
const [organisation, game] = await createOrganisationAndGame()
6666
const [token] = await createUserAndToken({}, organisation)
6767

68-
const player1 = await new PlayerFactory([game]).with((player) => ({
68+
const player1 = await new PlayerFactory([game]).state((player) => ({
6969
props: new Collection<PlayerProp>(player, [
7070
new PlayerProp(player, 'currentLevel', '80')
7171
])
@@ -96,7 +96,7 @@ describe('EQUALS rule', () => {
9696
const [organisation, game] = await createOrganisationAndGame()
9797
const [token] = await createUserAndToken({}, organisation)
9898

99-
const player1 = await new PlayerFactory([game]).with((player) => ({
99+
const player1 = await new PlayerFactory([game]).state((player) => ({
100100
props: new Collection<PlayerProp>(player, [
101101
new PlayerProp(player, 'currentLevel', '80')
102102
])

tests/entities/player-group-rule/gt-rule.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe('GT rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
14+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
1616
await (<EntityManager>global.em).persistAndFlush([player1, player2])
1717

1818
const rules: Partial<PlayerGroupRule>[] = [
@@ -38,8 +38,8 @@ describe('GT rule', () => {
3838
const [organisation, game] = await createOrganisationAndGame()
3939
const [token] = await createUserAndToken({}, organisation)
4040

41-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
41+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
4343
await (<EntityManager>global.em).persistAndFlush([player1, player2])
4444

4545
const rules: Partial<PlayerGroupRule>[] = [
@@ -65,12 +65,12 @@ describe('GT rule', () => {
6565
const [organisation, game] = await createOrganisationAndGame()
6666
const [token] = await createUserAndToken({}, organisation)
6767

68-
const player1 = await new PlayerFactory([game]).with((player) => ({
68+
const player1 = await new PlayerFactory([game]).state((player) => ({
6969
props: new Collection<PlayerProp>(player, [
7070
new PlayerProp(player, 'currentLevel', '80')
7171
])
7272
})).one()
73-
const player2 = await new PlayerFactory([game]).with((player) => ({
73+
const player2 = await new PlayerFactory([game]).state((player) => ({
7474
props: new Collection<PlayerProp>(player, [
7575
new PlayerProp(player, 'currentLevel', '70')
7676
])
@@ -100,12 +100,12 @@ describe('GT rule', () => {
100100
const [organisation, game] = await createOrganisationAndGame()
101101
const [token] = await createUserAndToken({}, organisation)
102102

103-
const player1 = await new PlayerFactory([game]).with((player) => ({
103+
const player1 = await new PlayerFactory([game]).state((player) => ({
104104
props: new Collection<PlayerProp>(player, [
105105
new PlayerProp(player, 'currentLevel', '80')
106106
])
107107
})).one()
108-
const player2 = await new PlayerFactory([game]).with((player) => ({
108+
const player2 = await new PlayerFactory([game]).state((player) => ({
109109
props: new Collection<PlayerProp>(player, [
110110
new PlayerProp(player, 'currentLevel', '70')
111111
])

tests/entities/player-group-rule/gte-rule.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe('GTE rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
14+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
1616
await (<EntityManager>global.em).persistAndFlush([player1, player2])
1717

1818
const rules: Partial<PlayerGroupRule>[] = [
@@ -38,8 +38,8 @@ describe('GTE rule', () => {
3838
const [organisation, game] = await createOrganisationAndGame()
3939
const [token] = await createUserAndToken({}, organisation)
4040

41-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
41+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
4343
await (<EntityManager>global.em).persistAndFlush([player1, player2])
4444

4545
const rules: Partial<PlayerGroupRule>[] = [
@@ -65,12 +65,12 @@ describe('GTE rule', () => {
6565
const [organisation, game] = await createOrganisationAndGame()
6666
const [token] = await createUserAndToken({}, organisation)
6767

68-
const player1 = await new PlayerFactory([game]).with((player) => ({
68+
const player1 = await new PlayerFactory([game]).state((player) => ({
6969
props: new Collection<PlayerProp>(player, [
7070
new PlayerProp(player, 'currentLevel', '80')
7171
])
7272
})).one()
73-
const player2 = await new PlayerFactory([game]).with((player) => ({
73+
const player2 = await new PlayerFactory([game]).state((player) => ({
7474
props: new Collection<PlayerProp>(player, [
7575
new PlayerProp(player, 'currentLevel', '70')
7676
])
@@ -100,12 +100,12 @@ describe('GTE rule', () => {
100100
const [organisation, game] = await createOrganisationAndGame()
101101
const [token] = await createUserAndToken({}, organisation)
102102

103-
const player1 = await new PlayerFactory([game]).with((player) => ({
103+
const player1 = await new PlayerFactory([game]).state((player) => ({
104104
props: new Collection<PlayerProp>(player, [
105105
new PlayerProp(player, 'currentLevel', '80')
106106
])
107107
})).one()
108-
const player2 = await new PlayerFactory([game]).with((player) => ({
108+
const player2 = await new PlayerFactory([game]).state((player) => ({
109109
props: new Collection<PlayerProp>(player, [
110110
new PlayerProp(player, 'currentLevel', '69')
111111
])

tests/entities/player-group-rule/lt-rule.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe('LT rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
14+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
1616
await (<EntityManager>global.em).persistAndFlush([player1, player2])
1717

1818
const rules: Partial<PlayerGroupRule>[] = [
@@ -38,8 +38,8 @@ describe('LT rule', () => {
3838
const [organisation, game] = await createOrganisationAndGame()
3939
const [token] = await createUserAndToken({}, organisation)
4040

41-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
41+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
4343
await (<EntityManager>global.em).persistAndFlush([player1, player2])
4444

4545
const rules: Partial<PlayerGroupRule>[] = [
@@ -65,12 +65,12 @@ describe('LT rule', () => {
6565
const [organisation, game] = await createOrganisationAndGame()
6666
const [token] = await createUserAndToken({}, organisation)
6767

68-
const player1 = await new PlayerFactory([game]).with((player) => ({
68+
const player1 = await new PlayerFactory([game]).state((player) => ({
6969
props: new Collection<PlayerProp>(player, [
7070
new PlayerProp(player, 'currentLevel', '80')
7171
])
7272
})).one()
73-
const player2 = await new PlayerFactory([game]).with((player) => ({
73+
const player2 = await new PlayerFactory([game]).state((player) => ({
7474
props: new Collection<PlayerProp>(player, [
7575
new PlayerProp(player, 'currentLevel', '69')
7676
])
@@ -100,12 +100,12 @@ describe('LT rule', () => {
100100
const [organisation, game] = await createOrganisationAndGame()
101101
const [token] = await createUserAndToken({}, organisation)
102102

103-
const player1 = await new PlayerFactory([game]).with((player) => ({
103+
const player1 = await new PlayerFactory([game]).state((player) => ({
104104
props: new Collection<PlayerProp>(player, [
105105
new PlayerProp(player, 'currentLevel', '80')
106106
])
107107
})).one()
108-
const player2 = await new PlayerFactory([game]).with((player) => ({
108+
const player2 = await new PlayerFactory([game]).state((player) => ({
109109
props: new Collection<PlayerProp>(player, [
110110
new PlayerProp(player, 'currentLevel', '70')
111111
])

tests/entities/player-group-rule/lte-rule.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe('LTE rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
14+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
15+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 1, 3) })).one()
1616
await (<EntityManager>global.em).persistAndFlush([player1, player2])
1717

1818
const rules: Partial<PlayerGroupRule>[] = [
@@ -38,8 +38,8 @@ describe('LTE rule', () => {
3838
const [organisation, game] = await createOrganisationAndGame()
3939
const [token] = await createUserAndToken({}, organisation)
4040

41-
const player1 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42-
const player2 = await new PlayerFactory([game]).with(() => ({ lastSeenAt: new Date(2022, 6, 3) })).one()
41+
const player1 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 4, 3) })).one()
42+
const player2 = await new PlayerFactory([game]).state(() => ({ lastSeenAt: new Date(2022, 6, 3) })).one()
4343
await (<EntityManager>global.em).persistAndFlush([player1, player2])
4444

4545
const rules: Partial<PlayerGroupRule>[] = [
@@ -65,12 +65,12 @@ describe('LTE rule', () => {
6565
const [organisation, game] = await createOrganisationAndGame()
6666
const [token] = await createUserAndToken({}, organisation)
6767

68-
const player1 = await new PlayerFactory([game]).with((player) => ({
68+
const player1 = await new PlayerFactory([game]).state((player) => ({
6969
props: new Collection<PlayerProp>(player, [
7070
new PlayerProp(player, 'currentLevel', '80')
7171
])
7272
})).one()
73-
const player2 = await new PlayerFactory([game]).with((player) => ({
73+
const player2 = await new PlayerFactory([game]).state((player) => ({
7474
props: new Collection<PlayerProp>(player, [
7575
new PlayerProp(player, 'currentLevel', '70')
7676
])
@@ -100,12 +100,12 @@ describe('LTE rule', () => {
100100
const [organisation, game] = await createOrganisationAndGame()
101101
const [token] = await createUserAndToken({}, organisation)
102102

103-
const player1 = await new PlayerFactory([game]).with((player) => ({
103+
const player1 = await new PlayerFactory([game]).state((player) => ({
104104
props: new Collection<PlayerProp>(player, [
105105
new PlayerProp(player, 'currentLevel', '80')
106106
])
107107
})).one()
108-
const player2 = await new PlayerFactory([game]).with((player) => ({
108+
const player2 = await new PlayerFactory([game]).state((player) => ({
109109
props: new Collection<PlayerProp>(player, [
110110
new PlayerProp(player, 'currentLevel', '69')
111111
])

tests/entities/player-group-rule/set-rule.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('SET rule', () => {
1111
const [organisation, game] = await createOrganisationAndGame()
1212
const [token] = await createUserAndToken({}, organisation)
1313

14-
const player1 = await new PlayerFactory([game]).with((player) => ({
14+
const player1 = await new PlayerFactory([game]).state((player) => ({
1515
props: new Collection<PlayerProp>(player, [
1616
new PlayerProp(player, 'hasFinishedGame', '1')
1717
])
@@ -42,7 +42,7 @@ describe('SET rule', () => {
4242
const [organisation, game] = await createOrganisationAndGame()
4343
const [token] = await createUserAndToken({}, organisation)
4444

45-
const player1 = await new PlayerFactory([game]).with((player) => ({
45+
const player1 = await new PlayerFactory([game]).state((player) => ({
4646
props: new Collection<PlayerProp>(player, [
4747
new PlayerProp(player, 'hasFinishedGame', '1')
4848
])

0 commit comments

Comments
 (0)