Compare commits

...

4 Commits

Author SHA1 Message Date
standardci 5ae5c83bf5 chore(release): publish new version
- @standardnotes/analytics@2.11.12
 - @standardnotes/domain-core@1.5.0
 - @standardnotes/revisions-server@1.4.7
 - @standardnotes/syncing-server@1.18.11
2022-11-24 20:13:47 +00:00
Karol Sójko 9d90f276de feat(domain-core): add methods to check role power 2022-11-24 21:11:08 +01:00
standardci 245f091e22 chore(release): publish new version
- @standardnotes/analytics@2.11.11
 - @standardnotes/domain-core@1.4.0
 - @standardnotes/revisions-server@1.4.6
 - @standardnotes/syncing-server@1.18.10
2022-11-24 10:36:50 +00:00
Karol Sójko ae2f8f086b feat(domain-core): add role name collection value object 2022-11-24 11:34:43 +01:00
14 changed files with 207 additions and 4 deletions
+8
View File
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.11.12](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.11...@standardnotes/analytics@2.11.12) (2022-11-24)
**Note:** Version bump only for package @standardnotes/analytics
## [2.11.11](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.10...@standardnotes/analytics@2.11.11) (2022-11-24)
**Note:** Version bump only for package @standardnotes/analytics
## [2.11.10](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.9...@standardnotes/analytics@2.11.10) (2022-11-24)
**Note:** Version bump only for package @standardnotes/analytics
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.11.10",
"version": "2.11.12",
"engines": {
"node": ">=18.0.0 <19.0.0"
},
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.5.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.4.0...@standardnotes/domain-core@1.5.0) (2022-11-24)
### Features
* **domain-core:** add methods to check role power ([9d90f27](https://github.com/standardnotes/server/commit/9d90f276de8915d91d009909154036ba128687e0))
# [1.4.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.3.0...@standardnotes/domain-core@1.4.0) (2022-11-24)
### Features
* **domain-core:** add role name collection value object ([ae2f8f0](https://github.com/standardnotes/server/commit/ae2f8f086b9f647bb98c59f32375b45243cb0af9))
# [1.3.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.2.2...@standardnotes/domain-core@1.3.0) (2022-11-24)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-core",
"version": "1.3.0",
"version": "1.5.0",
"engines": {
"node": ">=18.0.0 <19.0.0"
},
@@ -15,4 +15,22 @@ describe('RoleName', () => {
expect(valueOrError.isFailed()).toBeTruthy()
}
})
it('should say if a role has more power or equal power to another role', () => {
const proUserRole = RoleName.create('PRO_USER').getValue()
const plusUserRole = RoleName.create('PLUS_USER').getValue()
const coreUser = RoleName.create('CORE_USER').getValue()
expect(proUserRole.hasMoreOrEqualPowerTo(proUserRole)).toBeTruthy()
expect(proUserRole.hasMoreOrEqualPowerTo(plusUserRole)).toBeTruthy()
expect(proUserRole.hasMoreOrEqualPowerTo(coreUser)).toBeTruthy()
expect(plusUserRole.hasMoreOrEqualPowerTo(proUserRole)).toBeFalsy()
expect(plusUserRole.hasMoreOrEqualPowerTo(plusUserRole)).toBeTruthy()
expect(plusUserRole.hasMoreOrEqualPowerTo(coreUser)).toBeTruthy()
expect(coreUser.hasMoreOrEqualPowerTo(proUserRole)).toBeFalsy()
expect(coreUser.hasMoreOrEqualPowerTo(plusUserRole)).toBeFalsy()
expect(coreUser.hasMoreOrEqualPowerTo(coreUser)).toBeTruthy()
})
})
@@ -14,6 +14,19 @@ export class RoleName extends ValueObject<RoleNameProps> {
return this.props.value
}
hasMoreOrEqualPowerTo(roleName: RoleName): boolean {
switch (this.value) {
case RoleName.NAMES.ProUser:
return true
case RoleName.NAMES.PlusUser:
return [RoleName.NAMES.CoreUser, RoleName.NAMES.PlusUser].includes(roleName.value)
case RoleName.NAMES.CoreUser:
return [RoleName.NAMES.CoreUser].includes(roleName.value)
default:
return false
}
}
private constructor(props: RoleNameProps) {
super(props)
}
@@ -0,0 +1,77 @@
import { RoleName } from './RoleName'
import { RoleNameCollection } from './RoleNameCollection'
describe('RoleNameCollection', () => {
it('should create a value object', () => {
const role1 = RoleName.create('PRO_USER').getValue()
const valueOrError = RoleNameCollection.create([role1])
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().value).toEqual([role1])
})
it('should tell if collections are not equal', () => {
const roles1 = [RoleName.create('PRO_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
const roles2 = RoleNameCollection.create([
RoleName.create('PRO_USER').getValue(),
RoleName.create('CORE_USER').getValue(),
]).getValue()
const valueOrError = RoleNameCollection.create(roles1)
expect(valueOrError.getValue().equals(roles2)).toBeFalsy()
})
it('should tell if collections are equal', () => {
const roles1 = [RoleName.create('PRO_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
const roles2 = RoleNameCollection.create([
RoleName.create('PRO_USER').getValue(),
RoleName.create('PLUS_USER').getValue(),
]).getValue()
const valueOrError = RoleNameCollection.create(roles1)
expect(valueOrError.getValue().equals(roles2)).toBeTruthy()
})
it('should tell if collection includes element', () => {
const roles1 = [RoleName.create('PRO_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
const valueOrError = RoleNameCollection.create(roles1)
expect(valueOrError.getValue().includes(RoleName.create('PRO_USER').getValue())).toBeTruthy()
})
it('should tell if collection does not includes element', () => {
const roles1 = [RoleName.create('PRO_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
const valueOrError = RoleNameCollection.create(roles1)
expect(valueOrError.getValue().includes(RoleName.create('CORE_USER').getValue())).toBeFalsy()
})
it('should tell if collection has a role with more or equal power to', () => {
let roles = [RoleName.create('CORE_USER').getValue()]
let valueOrError = RoleNameCollection.create(roles)
let roleNames = valueOrError.getValue()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PLUS_USER').getValue())).toBeFalsy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PRO_USER').getValue())).toBeFalsy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('CORE_USER').getValue())).toBeTruthy()
roles = [RoleName.create('CORE_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
valueOrError = RoleNameCollection.create(roles)
roleNames = valueOrError.getValue()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PLUS_USER').getValue())).toBeTruthy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PRO_USER').getValue())).toBeFalsy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('CORE_USER').getValue())).toBeTruthy()
roles = [RoleName.create('PRO_USER').getValue(), RoleName.create('PLUS_USER').getValue()]
valueOrError = RoleNameCollection.create(roles)
roleNames = valueOrError.getValue()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PLUS_USER').getValue())).toBeTruthy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('PRO_USER').getValue())).toBeTruthy()
expect(roleNames.hasARoleNameWithMoreOrEqualPowerTo(RoleName.create('CORE_USER').getValue())).toBeTruthy()
})
})
@@ -0,0 +1,52 @@
import { ValueObject } from '../Core/ValueObject'
import { Result } from '../Core/Result'
import { RoleNameCollectionProps } from './RoleNameCollectionProps'
import { RoleName } from './RoleName'
export class RoleNameCollection extends ValueObject<RoleNameCollectionProps> {
get value(): RoleName[] {
return this.props.value
}
includes(roleName: RoleName): boolean {
for (const existingRoleName of this.props.value) {
if (existingRoleName.equals(roleName)) {
return true
}
}
return false
}
hasARoleNameWithMoreOrEqualPowerTo(roleName: RoleName): boolean {
for (const existingRoleName of this.props.value) {
if (existingRoleName.hasMoreOrEqualPowerTo(roleName)) {
return true
}
}
return false
}
override equals(roleNameCollection: RoleNameCollection): boolean {
if (this.props.value.length !== roleNameCollection.value.length) {
return false
}
for (const roleName of roleNameCollection.value) {
if (!this.includes(roleName)) {
return false
}
}
return true
}
private constructor(props: RoleNameCollectionProps) {
super(props)
}
static create(roleName: RoleName[]): Result<RoleNameCollection> {
return Result.ok<RoleNameCollection>(new RoleNameCollection({ value: roleName }))
}
}
@@ -0,0 +1,5 @@
import { RoleName } from './RoleName'
export interface RoleNameCollectionProps {
value: RoleName[]
}
+2
View File
@@ -2,6 +2,8 @@ export * from './Common/Email'
export * from './Common/EmailProps'
export * from './Common/RoleName'
export * from './Common/RoleNameProps'
export * from './Common/RoleNameCollection'
export * from './Common/RoleNameCollectionProps'
export * from './Common/Timestamps'
export * from './Common/TimestampsProps'
export * from './Common/Uuid'
+8
View File
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.7](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.4.6...@standardnotes/revisions-server@1.4.7) (2022-11-24)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.4.6](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.4.5...@standardnotes/revisions-server@1.4.6) (2022-11-24)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.4.5](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.4.4...@standardnotes/revisions-server@1.4.5) (2022-11-24)
**Note:** Version bump only for package @standardnotes/revisions-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.4.5",
"version": "1.4.7",
"engines": {
"node": ">=18.0.0 <19.0.0"
},
+8
View File
@@ -3,6 +3,14 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.18.11](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.18.10...@standardnotes/syncing-server@1.18.11) (2022-11-24)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.18.10](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.18.9...@standardnotes/syncing-server@1.18.10) (2022-11-24)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.18.9](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.18.8...@standardnotes/syncing-server@1.18.9) (2022-11-24)
**Note:** Version bump only for package @standardnotes/syncing-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.18.9",
"version": "1.18.11",
"engines": {
"node": ">=18.0.0 <19.0.0"
},