Skip to content

Commit

Permalink
fix(api): workspace creation arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Karol Sójko committed Oct 10, 2022
1 parent 8863ee8 commit a275a45
Show file tree
Hide file tree
Showing 19 changed files with 61 additions and 41 deletions.
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"typescript": "*"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { WorkspaceType } from '@standardnotes/common'
import { WorkspaceCreationResponse } from '../../Response/Workspace/WorkspaceCreationResponse'
import { WorkspaceServerInterface } from '../../Server/Workspace/WorkspaceServerInterface'

Expand All @@ -18,6 +19,7 @@ describe('WorkspaceApiService', () => {

it('should create a workspace', async () => {
const response = await createService().createWorkspace({
workspaceType: WorkspaceType.Private,
encryptedPrivateKey: 'foo',
encryptedWorkspaceKey: 'bar',
publicKey: 'buzz',
Expand All @@ -44,6 +46,7 @@ describe('WorkspaceApiService', () => {
let error = null
try {
await service.createWorkspace({
workspaceType: WorkspaceType.Private,
encryptedPrivateKey: 'foo',
encryptedWorkspaceKey: 'bar',
publicKey: 'buzz',
Expand All @@ -63,6 +66,7 @@ describe('WorkspaceApiService', () => {
let error = null
try {
await createService().createWorkspace({
workspaceType: WorkspaceType.Private,
encryptedPrivateKey: 'foo',
encryptedWorkspaceKey: 'bar',
publicKey: 'buzz',
Expand Down
10 changes: 7 additions & 3 deletions packages/api/src/Domain/Client/Workspace/WorkspaceApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { WorkspaceServerInterface } from '../../Server/Workspace/WorkspaceServer
import { WorkspaceApiServiceInterface } from './WorkspaceApiServiceInterface'
import { WorkspaceApiOperations } from './WorkspaceApiOperations'

import { WorkspaceType } from '@standardnotes/common'

export class WorkspaceApiService implements WorkspaceApiServiceInterface {
private operationsInProgress: Map<WorkspaceApiOperations, boolean>

Expand All @@ -14,9 +16,10 @@ export class WorkspaceApiService implements WorkspaceApiServiceInterface {
}

async createWorkspace(dto: {
encryptedWorkspaceKey: string
encryptedPrivateKey: string
publicKey: string
workspaceType: WorkspaceType,
encryptedWorkspaceKey?: string
encryptedPrivateKey?: string
publicKey?: string
workspaceName?: string
}): Promise<WorkspaceCreationResponse> {
if (this.operationsInProgress.get(WorkspaceApiOperations.Creating)) {
Expand All @@ -27,6 +30,7 @@ export class WorkspaceApiService implements WorkspaceApiServiceInterface {

try {
const response = await this.workspaceServer.createWorkspace({
workspaceType: dto.workspaceType,
encryptedPrivateKey: dto.encryptedPrivateKey,
encryptedWorkspaceKey: dto.encryptedWorkspaceKey,
publicKey: dto.publicKey,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { WorkspaceType } from '@standardnotes/common'

import { WorkspaceCreationResponse } from '../../Response'

export interface WorkspaceApiServiceInterface {
createWorkspace(dto: {
encryptedWorkspaceKey: string
encryptedPrivateKey: string
publicKey: string
workspaceType: WorkspaceType
encryptedWorkspaceKey?: string
encryptedPrivateKey?: string
publicKey?: string
workspaceName?: string
}): Promise<WorkspaceCreationResponse>
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { WorkspaceType } from '@standardnotes/common'

export type WorkspaceCreationRequestParams = {
encryptedWorkspaceKey: string
encryptedPrivateKey: string
publicKey: string
workspaceType: WorkspaceType
encryptedWorkspaceKey?: string
encryptedPrivateKey?: string
publicKey?: string
workspaceName?: string
[additionalParam: string]: unknown
}
2 changes: 1 addition & 1 deletion packages/encryption/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"typescript": "*"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*",
"@standardnotes/sncrypto-common": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@standardnotes/auth": "^3.19.4",
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/security": "^1.2.0",
"reflect-metadata": "^0.1.13"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/filepicker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ts-node": "^10.5.0"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/files": "workspace:*",
"@standardnotes/utils": "workspace:*",
"@types/wicg-file-system-access": "^2020.9.5",
Expand Down
2 changes: 1 addition & 1 deletion packages/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ts-jest": "^28.0.5"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/models": "workspace:*",
"@standardnotes/responses": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/models/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"typescript": "*"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/features": "workspace:*",
"@standardnotes/responses": "workspace:*",
"@standardnotes/utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/responses/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ts-jest": "^28.0.5"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/features": "workspace:*",
"@standardnotes/security": "^1.1.0",
"reflect-metadata": "^0.1.13"
Expand Down
2 changes: 1 addition & 1 deletion packages/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@standardnotes/api": "workspace:^",
"@standardnotes/auth": "^3.19.4",
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/encryption": "workspace:^",
"@standardnotes/files": "workspace:^",
"@standardnotes/models": "workspace:^",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { WorkspaceType } from '@standardnotes/common'

export interface WorkspaceClientInterface {
createWorkspace(dto: {
encryptedWorkspaceKey: string
encryptedPrivateKey: string
publicKey: string
workspaceType: WorkspaceType
encryptedWorkspaceKey?: string
encryptedPrivateKey?: string
publicKey?: string
workspaceName?: string
}): Promise<{ uuid: string } | null>
}
9 changes: 6 additions & 3 deletions packages/services/src/Domain/Workspace/WorkspaceManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { WorkspaceApiServiceInterface } from '@standardnotes/api'
import { WorkspaceType } from '@standardnotes/common'

import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { AbstractService } from '../Service/AbstractService'
import { WorkspaceClientInterface } from './WorkspaceClientInterface'
Expand All @@ -12,9 +14,10 @@ export class WorkspaceManager extends AbstractService implements WorkspaceClient
}

async createWorkspace(dto: {
encryptedWorkspaceKey: string
encryptedPrivateKey: string
publicKey: string
workspaceType: WorkspaceType,
encryptedWorkspaceKey?: string
encryptedPrivateKey?: string
publicKey?: string
workspaceName?: string
}): Promise<{ uuid: string } | null> {
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/snjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
},
"dependencies": {
"@standardnotes/api": "workspace:*",
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/domain-events": "^2.39.0",
"@standardnotes/encryption": "workspace:*",
"@standardnotes/features": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test": "jest spec --coverage --passWithNoTests"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"@standardnotes/filepicker": "workspace:^",
"@standardnotes/services": "workspace:^",
"@standardnotes/styles": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"test": "jest spec"
},
"dependencies": {
"@standardnotes/common": "^1.32.0",
"@standardnotes/common": "^1.36.1",
"dompurify": "^2.3.8",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13"
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6068,7 +6068,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/api@workspace:packages/api"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/encryption": "workspace:*"
"@standardnotes/models": "workspace:*"
"@standardnotes/responses": "workspace:*"
Expand Down Expand Up @@ -6251,12 +6251,12 @@ __metadata:
languageName: node
linkType: hard

"@standardnotes/common@npm:^1.32.0":
version: 1.32.0
resolution: "@standardnotes/common@npm:1.32.0"
"@standardnotes/common@npm:^1.36.1":
version: 1.36.1
resolution: "@standardnotes/common@npm:1.36.1"
dependencies:
reflect-metadata: ^0.1.13
checksum: 52d33f385e4cc26ac8d2f723c3a5e12bb8a2c4a17f08700ca5843810583ca722475a83b71f86bb1402fda7c7c66e8149beb3f70848efc90da4aafef663d7ffbe
checksum: 4f2367d461aa1cd4e3ec132520310773183c3c9f8e423565aec315f5e5dffdce79f9704307a32fbfec17157f99d37d49982ad4272eee5aac0dbe37da34be054c
languageName: node
linkType: hard

Expand Down Expand Up @@ -6443,7 +6443,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/encryption@workspace:packages/encryption"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/config": 2.4.3
"@standardnotes/models": "workspace:*"
"@standardnotes/responses": "workspace:*"
Expand Down Expand Up @@ -6485,7 +6485,7 @@ __metadata:
resolution: "@standardnotes/features@workspace:packages/features"
dependencies:
"@standardnotes/auth": ^3.19.4
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/security": ^1.2.0
"@types/jest": ^28.1.5
"@typescript-eslint/eslint-plugin": ^5.30.0
Expand All @@ -6501,7 +6501,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/filepicker@workspace:packages/filepicker"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/files": "workspace:*"
"@standardnotes/utils": "workspace:*"
"@types/jest": ^28.1.5
Expand All @@ -6519,7 +6519,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/files@workspace:packages/files"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/encryption": "workspace:*"
"@standardnotes/models": "workspace:*"
"@standardnotes/responses": "workspace:*"
Expand Down Expand Up @@ -6905,7 +6905,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/models@workspace:packages/models"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/features": "workspace:*"
"@standardnotes/responses": "workspace:*"
"@standardnotes/utils": "workspace:*"
Expand Down Expand Up @@ -6972,7 +6972,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/responses@workspace:packages/responses"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/features": "workspace:*"
"@standardnotes/security": ^1.1.0
"@types/jest": ^28.1.5
Expand Down Expand Up @@ -7041,7 +7041,7 @@ __metadata:
dependencies:
"@standardnotes/api": "workspace:^"
"@standardnotes/auth": ^3.19.4
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/encryption": "workspace:^"
"@standardnotes/files": "workspace:^"
"@standardnotes/models": "workspace:^"
Expand Down Expand Up @@ -7156,7 +7156,7 @@ __metadata:
"@babel/core": "*"
"@babel/preset-env": "*"
"@standardnotes/api": "workspace:*"
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/domain-events": ^2.39.0
"@standardnotes/encryption": "workspace:*"
"@standardnotes/features": "workspace:*"
Expand Down Expand Up @@ -7309,7 +7309,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/ui-services@workspace:packages/ui-services"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@standardnotes/filepicker": "workspace:^"
"@standardnotes/services": "workspace:^"
"@standardnotes/styles": "workspace:^"
Expand All @@ -7329,7 +7329,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@standardnotes/utils@workspace:packages/utils"
dependencies:
"@standardnotes/common": ^1.32.0
"@standardnotes/common": ^1.36.1
"@types/dompurify": ^2.3.3
"@types/jest": ^28.1.5
"@types/jsdom": ^16.2.14
Expand Down

0 comments on commit a275a45

Please sign in to comment.