Compare commits

...

4 Commits

Author SHA1 Message Date
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
standardci
5e5eb7f937 chore(release): publish new version
- @standardnotes/analytics@2.11.10
 - @standardnotes/domain-core@1.3.0
 - @standardnotes/revisions-server@1.4.5
 - @standardnotes/syncing-server@1.18.9
2022-11-24 09:49:56 +00:00
Karol Sójko
748630e1f1 feat(domain-core): add role name value object 2022-11-24 10:48:00 +01:00
15 changed files with 192 additions and 4 deletions

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.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
## [2.11.9](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.11.8...@standardnotes/analytics@2.11.9) (2022-11-24)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.11.9",
"version": "2.11.11",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

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.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
* **domain-core:** add role name value object ([748630e](https://github.com/standardnotes/server/commit/748630e1f1ed1dfae2e743cd2b3d3fd91967088c))
## [1.2.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.2.1...@standardnotes/domain-core@1.2.2) (2022-11-22)
**Note:** Version bump only for package @standardnotes/domain-core

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-core",
"version": "1.2.2",
"version": "1.4.0",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -0,0 +1,18 @@
import { RoleName } from './RoleName'
describe('RoleName', () => {
it('should create a value object', () => {
const valueOrError = RoleName.create('PRO_USER')
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().value).toEqual('PRO_USER')
})
it('should not create an invalid value object', () => {
for (const value of ['', undefined, null, 0, 'SOME_USER']) {
const valueOrError = RoleName.create(value as string)
expect(valueOrError.isFailed()).toBeTruthy()
}
})
})

View File

@@ -0,0 +1,29 @@
import { ValueObject } from '../Core/ValueObject'
import { Result } from '../Core/Result'
import { RoleNameProps } from './RoleNameProps'
export class RoleName extends ValueObject<RoleNameProps> {
private static readonly NAMES = {
CoreUser: 'CORE_USER',
PlusUser: 'PLUS_USER',
ProUser: 'PRO_USER',
FilesBetaUser: 'FILES_BETA_USER',
}
get value(): string {
return this.props.value
}
private constructor(props: RoleNameProps) {
super(props)
}
static create(name: string): Result<RoleName> {
const isValidName = Object.values(this.NAMES).includes(name)
if (!isValidName) {
return Result.fail<RoleName>(`Invalid role name: ${name}`)
} else {
return Result.ok<RoleName>(new RoleName({ value: name }))
}
}
}

View File

@@ -0,0 +1,51 @@
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()
})
})

View File

@@ -0,0 +1,42 @@
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
}
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 }))
}
}

View File

@@ -0,0 +1,5 @@
import { RoleName } from './RoleName'
export interface RoleNameCollectionProps {
value: RoleName[]
}

View File

@@ -0,0 +1,3 @@
export interface RoleNameProps {
value: string
}

View File

@@ -1,5 +1,9 @@
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'

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.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.4.4](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.4.3...@standardnotes/revisions-server@1.4.4) (2022-11-24)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.4.4",
"version": "1.4.6",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

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.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.18.8](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.18.7...@standardnotes/syncing-server@1.18.8) (2022-11-24)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.18.8",
"version": "1.18.10",
"engines": {
"node": ">=18.0.0 <19.0.0"
},