Compare commits

...

10 Commits

Author SHA1 Message Date
standardci
ae56126585 chore(release): publish new version
- @standardnotes/syncing-server@1.26.10
2022-12-15 14:41:40 +00:00
Karol Sójko
6dcf0ac124 fix(syncing-server): item query created_at condition 2022-12-15 15:38:56 +01:00
standardci
63e2ce43c2 chore(release): publish new version
- @standardnotes/syncing-server@1.26.9
2022-12-15 13:40:30 +00:00
Karol Sójko
f27aa21eb5 fix(syncing-server): fetching items in raw mode 2022-12-15 14:38:32 +01:00
standardci
42926c663b chore(release): publish new version
- @standardnotes/syncing-server@1.26.8
2022-12-15 11:37:14 +00:00
Karol Sójko
d38116183c fix(syncing-server): select fields in query 2022-12-15 12:35:26 +01:00
standardci
9ca373e208 chore(release): publish new version
- @standardnotes/analytics@2.12.27
 - @standardnotes/auth-server@1.67.3
 - @standardnotes/domain-core@1.11.0
 - @standardnotes/revisions-server@1.9.28
 - @standardnotes/scheduler-server@1.15.8
 - @standardnotes/syncing-server@1.26.7
 - @standardnotes/workspace-server@1.18.6
2022-12-15 11:26:36 +00:00
Karol Sójko
4084f2f5ec feat(domain-core): add legacy session model 2022-12-15 12:24:11 +01:00
standardci
684ffbadbc chore(release): publish new version
- @standardnotes/analytics@2.12.26
 - @standardnotes/auth-server@1.67.2
 - @standardnotes/domain-core@1.10.0
 - @standardnotes/revisions-server@1.9.27
 - @standardnotes/scheduler-server@1.15.7
 - @standardnotes/syncing-server@1.26.6
 - @standardnotes/workspace-server@1.18.5
2022-12-15 10:38:10 +00:00
Karol Sójko
1c4d4c57de feat(domain-core): add session model 2022-12-15 11:35:49 +01:00
30 changed files with 258 additions and 26 deletions

4
.pnp.cjs generated
View File

@@ -2737,10 +2737,6 @@ const RAW_RUNTIME_STATE =
"packageLocation": "./packages/domain-core/",\
"packageDependencies": [\
["@standardnotes/domain-core", "workspace:packages/domain-core"],\
["@standardnotes/common", "workspace:packages/common"],\
["@standardnotes/features", "npm:1.53.1"],\
["@standardnotes/predicates", "workspace:packages/predicates"],\
["@standardnotes/security", "workspace:packages/security"],\
["@types/jest", "npm:29.1.1"],\
["@types/uuid", "npm:8.3.4"],\
["@typescript-eslint/eslint-plugin", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:5.30.5"],\

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.12.27](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.12.26...@standardnotes/analytics@2.12.27) (2022-12-15)
**Note:** Version bump only for package @standardnotes/analytics
## [2.12.26](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.12.25...@standardnotes/analytics@2.12.26) (2022-12-15)
**Note:** Version bump only for package @standardnotes/analytics
## [2.12.25](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.12.24...@standardnotes/analytics@2.12.25) (2022-12-12)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.12.25",
"version": "2.12.27",
"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.67.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.67.2...@standardnotes/auth-server@1.67.3) (2022-12-15)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.67.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.67.1...@standardnotes/auth-server@1.67.2) (2022-12-15)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.67.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.67.0...@standardnotes/auth-server@1.67.1) (2022-12-12)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.67.1",
"version": "1.67.3",
"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.11.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.10.0...@standardnotes/domain-core@1.11.0) (2022-12-15)
### Features
* **domain-core:** add legacy session model ([4084f2f](https://github.com/standardnotes/server/commit/4084f2f5ecf8379ff69d619d3d12495c010c3980))
# [1.10.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.9.0...@standardnotes/domain-core@1.10.0) (2022-12-15)
### Features
* **domain-core:** add session model ([1c4d4c5](https://github.com/standardnotes/server/commit/1c4d4c57dea1187dc130f1ae8b7dc8ede332320f))
# [1.9.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-core@1.8.0...@standardnotes/domain-core@1.9.0) (2022-12-07)
### Features

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-core",
"version": "1.9.0",
"version": "1.11.0",
"engines": {
"node": ">=18.0.0 <19.0.0"
},
@@ -23,10 +23,6 @@
"test": "jest spec --coverage --passWithNoTests"
},
"dependencies": {
"@standardnotes/common": "workspace:*",
"@standardnotes/features": "^1.52.1",
"@standardnotes/predicates": "workspace:*",
"@standardnotes/security": "workspace:*",
"reflect-metadata": "^0.1.13",
"shallow-equal-object": "^1.1.1",
"uuid": "^9.0.0"

View File

@@ -0,0 +1,16 @@
import { LegacySession } from './LegacySession'
describe('LegacySession', () => {
it('should create a value object', () => {
const valueOrError = LegacySession.create('foobar')
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().accessToken).toEqual('foobar')
})
it('should not create an invalid value object', () => {
const valueOrError = LegacySession.create('')
expect(valueOrError.isFailed()).toBeTruthy()
})
})

View File

@@ -0,0 +1,22 @@
import { ValueObject } from '../Core/ValueObject'
import { Result } from '../Core/Result'
import { LegacySessionProps } from './LegacySessionProps'
import { Validator } from '../Core/Validator'
export class LegacySession extends ValueObject<LegacySessionProps> {
get accessToken(): string {
return this.props.token
}
private constructor(props: LegacySessionProps) {
super(props)
}
static create(token: string): Result<LegacySession> {
if (Validator.isNotEmpty(token).isFailed()) {
return Result.fail<LegacySession>('Could not create legacy session. Token value is empty')
}
return Result.ok<LegacySession>(new LegacySession({ token }))
}
}

View File

@@ -0,0 +1,3 @@
export interface LegacySessionProps {
token: string
}

View File

@@ -0,0 +1,26 @@
import { Session } from './Session'
import { SessionToken } from './SessionToken'
describe('Session', () => {
it('should create a session value object', () => {
const accessToken = SessionToken.create('foobar1', 1234567890).getValue()
const refreshToken = SessionToken.create('foobar2', 1234567890).getValue()
const valueOrError = Session.create(accessToken, refreshToken)
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().accessToken.value).toEqual('foobar1')
expect(valueOrError.getValue().refreshToken.value).toEqual('foobar2')
expect(valueOrError.getValue().isReadOnly()).toEqual(false)
})
it('should create a session reado-only value object', () => {
const accessToken = SessionToken.create('foobar', 1234567890).getValue()
const refreshToken = SessionToken.create('foobar', 1234567890).getValue()
const valueOrError = Session.create(accessToken, refreshToken, true)
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().isReadOnly()).toEqual(true)
})
})

View File

@@ -0,0 +1,26 @@
import { ValueObject } from '../Core/ValueObject'
import { Result } from '../Core/Result'
import { SessionProps } from './SessionProps'
import { SessionToken } from './SessionToken'
export class Session extends ValueObject<SessionProps> {
get accessToken(): SessionToken {
return this.props.accessToken
}
get refreshToken(): SessionToken {
return this.props.refreshToken
}
isReadOnly(): boolean {
return this.props.readonlyAccess || false
}
private constructor(props: SessionProps) {
super(props)
}
static create(accessToken: SessionToken, refreshToken: SessionToken, readonlyAccess?: boolean): Result<Session> {
return Result.ok<Session>(new Session({ accessToken, refreshToken, readonlyAccess }))
}
}

View File

@@ -0,0 +1,7 @@
import { SessionToken } from './SessionToken'
export interface SessionProps {
accessToken: SessionToken
refreshToken: SessionToken
readonlyAccess?: boolean
}

View File

@@ -0,0 +1,21 @@
import { SessionToken } from './SessionToken'
describe('SessionToken', () => {
it('should create a value object', () => {
const valueOrError = SessionToken.create('foobar', 1234567890)
expect(valueOrError.isFailed()).toBeFalsy()
expect(valueOrError.getValue().value).toEqual('foobar')
expect(valueOrError.getValue().expiresAt).toEqual(1234567890)
})
it('should not create an invalid value object', () => {
let valueOrError = SessionToken.create('', 1234567890)
expect(valueOrError.isFailed()).toBeTruthy()
valueOrError = SessionToken.create('foobar', undefined as unknown as number)
expect(valueOrError.isFailed()).toBeTruthy()
})
})

View File

@@ -0,0 +1,29 @@
import { ValueObject } from '../Core/ValueObject'
import { Result } from '../Core/Result'
import { SessionTokenProps } from './SessionTokenProps'
import { Validator } from '../Core/Validator'
export class SessionToken extends ValueObject<SessionTokenProps> {
get value(): string {
return this.props.value
}
get expiresAt(): number {
return this.props.expiresAt
}
private constructor(props: SessionTokenProps) {
super(props)
}
static create(value: string, expiresAt: number): Result<SessionToken> {
if (Validator.isNotEmpty(value).isFailed()) {
return Result.fail<SessionToken>('Could not create session token. Token value is empty')
}
if (Validator.isNotEmpty(expiresAt).isFailed()) {
return Result.fail<SessionToken>('Could not create session token. Token expiration is empty')
}
return Result.ok<SessionToken>(new SessionToken({ value, expiresAt }))
}
}

View File

@@ -0,0 +1,4 @@
export interface SessionTokenProps {
value: string
expiresAt: number
}

View File

@@ -1,3 +1,10 @@
export * from './Auth/LegacySession'
export * from './Auth/LegacySessionProps'
export * from './Auth/Session'
export * from './Auth/SessionProps'
export * from './Auth/SessionToken'
export * from './Auth/SessionTokenProps'
export * from './Common/Dates'
export * from './Common/DatesProps'
export * from './Common/Email'

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.9.28](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.9.27...@standardnotes/revisions-server@1.9.28) (2022-12-15)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.9.27](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.9.26...@standardnotes/revisions-server@1.9.27) (2022-12-15)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.9.26](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.9.25...@standardnotes/revisions-server@1.9.26) (2022-12-12)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.9.26",
"version": "1.9.28",
"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.15.8](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.15.7...@standardnotes/scheduler-server@1.15.8) (2022-12-15)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.15.7](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.15.6...@standardnotes/scheduler-server@1.15.7) (2022-12-15)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.15.6](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.15.5...@standardnotes/scheduler-server@1.15.6) (2022-12-12)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.15.6",
"version": "1.15.8",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -3,6 +3,32 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.26.10](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.9...@standardnotes/syncing-server@1.26.10) (2022-12-15)
### Bug Fixes
* **syncing-server:** item query created_at condition ([6dcf0ac](https://github.com/standardnotes/syncing-server-js/commit/6dcf0ac124252c441d08a67f2954441ab6266bdf))
## [1.26.9](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.8...@standardnotes/syncing-server@1.26.9) (2022-12-15)
### Bug Fixes
* **syncing-server:** fetching items in raw mode ([f27aa21](https://github.com/standardnotes/syncing-server-js/commit/f27aa21eb52a73b748e3a555bf201c834fd34aad))
## [1.26.8](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.7...@standardnotes/syncing-server@1.26.8) (2022-12-15)
### Bug Fixes
* **syncing-server:** select fields in query ([d381161](https://github.com/standardnotes/syncing-server-js/commit/d38116183c9f7b6fb6d13d9076571fef72be555c))
## [1.26.7](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.6...@standardnotes/syncing-server@1.26.7) (2022-12-15)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.26.6](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.5...@standardnotes/syncing-server@1.26.6) (2022-12-15)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.26.5](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.26.4...@standardnotes/syncing-server@1.26.5) (2022-12-15)
### Bug Fixes

View File

@@ -28,7 +28,7 @@ const fixRevisionsOwnership = async (
const itemsCount = await itemRepository.countAll({
createdBetween: [createdAfter, createdBefore],
selectFields: ['uuid', 'user_uuid'],
selectString: 'item.uuid as uuid, item.user_uuid as userUuid',
contentType: [ContentType.Note, ContentType.File],
sortOrder: 'ASC',
sortBy: 'uuid',
@@ -52,9 +52,9 @@ const fixRevisionsOwnership = async (
)
}
const items = await itemRepository.findAll({
const items = await itemRepository.findAllRaw<{ uuid: string; userUuid: string }>({
createdBetween: [createdAfter, createdBefore],
selectFields: ['uuid', 'user_uuid'],
selectString: 'item.uuid as uuid, item.user_uuid as userUuid',
contentType: [ContentType.Note, ContentType.File],
offset: (page - 1) * revisionsProcessingLimit,
limit: revisionsProcessingLimit,

View File

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

View File

@@ -10,5 +10,5 @@ export type ItemQuery = {
offset?: number
limit?: number
createdBetween?: Date[]
selectFields?: string[]
selectString?: string
}

View File

@@ -6,6 +6,7 @@ import { ExtendedIntegrityPayload } from './ExtendedIntegrityPayload'
export interface ItemRepositoryInterface {
deleteByUserUuid(userUuid: string): Promise<void>
findAll(query: ItemQuery): Promise<Item[]>
findAllRaw<T>(query: ItemQuery): Promise<T[]>
streamAll(query: ItemQuery): Promise<ReadStream>
countAll(query: ItemQuery): Promise<number>
findContentSizeForComputingTransferLimit(

View File

@@ -103,6 +103,10 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
return this.createFindAllQueryBuilder(query).getMany()
}
async findAllRaw<T>(query: ItemQuery): Promise<T[]> {
return this.createFindAllQueryBuilder(query).getRawMany<T>()
}
async streamAll(query: ItemQuery): Promise<ReadStream> {
return this.createFindAllQueryBuilder(query).stream()
}
@@ -135,8 +139,8 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
queryBuilder.orderBy(`item.${query.sortBy}`, query.sortOrder)
}
if (query.selectFields !== undefined) {
queryBuilder.select(query.selectFields)
if (query.selectString !== undefined) {
queryBuilder.select(query.selectString)
}
if (query.userUuid !== undefined) {
queryBuilder.where('item.user_uuid = :userUuid', { userUuid: query.userUuid })
@@ -160,7 +164,7 @@ export class MySQLItemRepository implements ItemRepositoryInterface {
})
}
if (query.createdBetween !== undefined) {
queryBuilder.andWhere('item.created_at BETWEEN :createdAfter AND :createdBefore', {
queryBuilder.andWhere('item.created_at >= :createdAfter AND item.created_at <= :createdBefore', {
createdAfter: query.createdBetween[0].toISOString(),
createdBefore: query.createdBetween[1].toISOString(),
})

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.6](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.18.5...@standardnotes/workspace-server@1.18.6) (2022-12-15)
**Note:** Version bump only for package @standardnotes/workspace-server
## [1.18.5](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.18.4...@standardnotes/workspace-server@1.18.5) (2022-12-15)
**Note:** Version bump only for package @standardnotes/workspace-server
## [1.18.4](https://github.com/standardnotes/server/compare/@standardnotes/workspace-server@1.18.3...@standardnotes/workspace-server@1.18.4) (2022-12-12)
**Note:** Version bump only for package @standardnotes/workspace-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/workspace-server",
"version": "1.18.4",
"version": "1.18.6",
"engines": {
"node": ">=18.0.0 <19.0.0"
},

View File

@@ -1981,10 +1981,6 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/domain-core@workspace:packages/domain-core"
dependencies:
"@standardnotes/common": "workspace:*"
"@standardnotes/features": "npm:^1.52.1"
"@standardnotes/predicates": "workspace:*"
"@standardnotes/security": "workspace:*"
"@types/jest": "npm:^29.1.1"
"@types/uuid": "npm:^8.3.0"
"@typescript-eslint/eslint-plugin": "npm:^5.30.0"