Compare commits

..

3 Commits

Author SHA1 Message Date
standardci
0acc9d8d68 chore(release): publish new version
- @standardnotes/revisions-server@1.4.1
 - @standardnotes/syncing-server@1.18.0
2022-11-22 11:20:59 +00:00
Karol Sójko
daa7a9ff61 fix(revisions): add more verbose error messages 2022-11-22 12:18:26 +01:00
Karol Sójko
455f35e0c1 feat(syncing-server): add dump projection for revisions 2022-11-22 12:18:26 +01:00
10 changed files with 51 additions and 10 deletions

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.4.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.4.0...@standardnotes/revisions-server@1.4.1) (2022-11-22)
### Bug Fixes
* **revisions:** add more verbose error messages ([daa7a9f](https://github.com/standardnotes/server/commit/daa7a9ff61d389e573960b443faff77e0abe01dc))
# [1.4.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.3.0...@standardnotes/revisions-server@1.4.0) (2022-11-22)
### Features

View File

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

View File

@@ -9,19 +9,19 @@ export class RevisionItemStringMapper implements MapperInterface<Revision, strin
const contentTypeOrError = ContentType.create(item.content_type)
if (contentTypeOrError.isFailed()) {
throw new Error(`Could not map item string to revision: ${contentTypeOrError.getError()}`)
throw new Error(`Could not map item string to revision [content type]: ${contentTypeOrError.getError()}`)
}
const contentType = contentTypeOrError.getValue()
const itemUuidOrError = Uuid.create(item.uuid)
if (itemUuidOrError.isFailed()) {
throw new Error(`Could not map item string to revision: ${itemUuidOrError.getError()}`)
throw new Error(`Could not map item string to revision [item uuid]: ${itemUuidOrError.getError()}`)
}
const itemUuid = itemUuidOrError.getValue()
const userUuidOrError = Uuid.create(item.user_uuid)
if (userUuidOrError.isFailed()) {
throw new Error(`Could not map item string to revision: ${userUuidOrError.getError()}`)
throw new Error(`Could not map item string to revision [user uuid]: ${userUuidOrError.getError()}`)
}
const userUuid = userUuidOrError.getValue()
@@ -38,7 +38,7 @@ export class RevisionItemStringMapper implements MapperInterface<Revision, strin
})
if (revisionOrError.isFailed()) {
throw new Error(`Could not map item string to revision: ${revisionOrError.getError()}`)
throw new Error(`Could not map item string to revision [revision]: ${revisionOrError.getError()}`)
}
return revisionOrError.getValue()

View File

@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.18.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.17.0...@standardnotes/syncing-server@1.18.0) (2022-11-22)
### Features
* **syncing-server:** add dump projection for revisions ([455f35e](https://github.com/standardnotes/syncing-server-js/commit/455f35e0c1ac811720b67592a9017a3470a7740c))
# [1.17.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.16.1...@standardnotes/syncing-server@1.17.0) (2022-11-22)
### Features

View File

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

View File

@@ -22,7 +22,7 @@ export class FSItemBackupService implements ItemBackupServiceInterface {
async dump(item: Item): Promise<string> {
const contents = JSON.stringify({
item: await this.itemProjector.projectFull(item),
item: await this.itemProjector.projectCustom('dump', item),
})
const path = `${this.fileUploadPath}/dumps/${uuid.v4()}`

View File

@@ -31,7 +31,7 @@ export class S3ItemBackupService implements ItemBackupServiceInterface {
Bucket: this.s3BackupBucketName,
Key: uuid.v4(),
Body: JSON.stringify({
item: await this.itemProjector.projectFull(item),
item: await this.itemProjector.projectCustom('dump', item),
}),
})
.promise()

View File

@@ -0,0 +1,5 @@
import { ItemProjection } from './ItemProjection'
export type ItemProjectionWithUser = ItemProjection & {
user_uuid: string
}

View File

@@ -27,6 +27,7 @@ describe('ItemProjector', () => {
item.createdAtTimestamp = 123
item.updatedAtTimestamp = 123
item.updatedWithSession = '7-6-5'
item.userUuid = 'u1-2-3'
})
it('should create a full projection of an item', async () => {
@@ -45,6 +46,23 @@ describe('ItemProjector', () => {
})
})
it('should create a custom projection of an item', async () => {
expect(await createProjector().projectCustom('dump', item)).toMatchObject({
uuid: '1-2-3',
items_key_id: '2-3-4',
duplicate_of: null,
enc_item_key: '3-4-5',
content: 'test',
content_type: 'Note',
auth_hash: 'asd',
deleted: false,
created_at: '2021-04-15T08:00:00.123456Z',
updated_at: '2021-04-15T08:00:00.123456Z',
updated_with_session: '7-6-5',
user_uuid: 'u1-2-3',
})
})
it('should throw error on custom projection', async () => {
let error = null
try {

View File

@@ -5,6 +5,7 @@ import { ProjectorInterface } from './ProjectorInterface'
import { Item } from '../Domain/Item/Item'
import { ItemProjection } from './ItemProjection'
import { ItemProjectionWithUser } from './ItemProjectionWithUser'
@injectable()
export class ItemProjector implements ProjectorInterface<Item, ItemProjection> {
@@ -14,8 +15,13 @@ export class ItemProjector implements ProjectorInterface<Item, ItemProjection> {
throw Error('not implemented')
}
async projectCustom(_projectionType: string, _item: Item): Promise<ItemProjection> {
throw Error('not implemented')
async projectCustom(_projectionType: string, item: Item): Promise<ItemProjectionWithUser> {
const fullProjection = await this.projectFull(item)
return {
...fullProjection,
user_uuid: item.userUuid,
}
}
async projectFull(item: Item): Promise<ItemProjection> {