Compare commits

..

4 Commits

Author SHA1 Message Date
standardci b1665779b5 chore(release): publish new version
- @standardnotes/api-gateway@1.87.4
 - @standardnotes/home-server@1.22.7
 - @standardnotes/syncing-server@1.127.5
2023-12-01 08:53:10 +00:00
Karol Sójko a82192db42 fix(api-gateway): home server home page (#949)
* feat: add home server home page message

* fix: upgrade yarn
2023-12-01 09:32:56 +01:00
Karol Sójko 589b740f49 fix(syncing-server): remove the dice roll on whether to inform the client on items changed (#950) 2023-12-01 09:24:20 +01:00
Karol Sójko 3c10de3e5d fix: localstack version in docker compose example 2023-11-30 13:45:59 +01:00
18 changed files with 1053 additions and 1002 deletions
Generated
+45 -25
View File
@@ -18048,14 +18048,16 @@ const Filename = {
const npath = Object.create(path__default.default);
const ppath = Object.create(path__default.default.posix);
npath.cwd = () => process.cwd();
ppath.cwd = () => toPortablePath(process.cwd());
ppath.resolve = (...segments) => {
if (segments.length > 0 && ppath.isAbsolute(segments[0])) {
return path__default.default.posix.resolve(...segments);
} else {
return path__default.default.posix.resolve(ppath.cwd(), ...segments);
}
};
ppath.cwd = process.platform === `win32` ? () => toPortablePath(process.cwd()) : process.cwd;
if (process.platform === `win32`) {
ppath.resolve = (...segments) => {
if (segments.length > 0 && ppath.isAbsolute(segments[0])) {
return path__default.default.posix.resolve(...segments);
} else {
return path__default.default.posix.resolve(ppath.cwd(), ...segments);
}
};
}
const contains = function(pathUtils, from, to) {
from = pathUtils.normalize(from);
to = pathUtils.normalize(to);
@@ -18069,17 +18071,13 @@ const contains = function(pathUtils, from, to) {
return null;
}
};
npath.fromPortablePath = fromPortablePath;
npath.toPortablePath = toPortablePath;
npath.contains = (from, to) => contains(npath, from, to);
ppath.contains = (from, to) => contains(ppath, from, to);
const WINDOWS_PATH_REGEXP = /^([a-zA-Z]:.*)$/;
const UNC_WINDOWS_PATH_REGEXP = /^\/\/(\.\/)?(.*)$/;
const PORTABLE_PATH_REGEXP = /^\/([a-zA-Z]:.*)$/;
const UNC_PORTABLE_PATH_REGEXP = /^\/unc\/(\.dot\/)?(.*)$/;
function fromPortablePath(p) {
if (process.platform !== `win32`)
return p;
function fromPortablePathWin32(p) {
let portablePathMatch, uncPortablePathMatch;
if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP))
p = portablePathMatch[1];
@@ -18089,9 +18087,7 @@ function fromPortablePath(p) {
return p;
return p.replace(/\//g, `\\`);
}
function toPortablePath(p) {
if (process.platform !== `win32`)
return p;
function toPortablePathWin32(p) {
p = p.replace(/\\/g, `/`);
let windowsPathMatch, uncWindowsPathMatch;
if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP))
@@ -18100,6 +18096,10 @@ function toPortablePath(p) {
p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`;
return p;
}
const toPortablePath = process.platform === `win32` ? toPortablePathWin32 : (p) => p;
const fromPortablePath = process.platform === `win32` ? fromPortablePathWin32 : (p) => p;
npath.fromPortablePath = fromPortablePath;
npath.toPortablePath = toPortablePath;
function convertPath(targetPathUtils, sourcePath) {
return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath);
}
@@ -19144,6 +19144,12 @@ class ProxiedFS extends FakeFS {
}
}
function direntToPortable(dirent) {
const portableDirent = dirent;
if (typeof dirent.path === `string`)
portableDirent.path = npath.toPortablePath(dirent.path);
return portableDirent;
}
class NodeFS extends BasePortableFakeFS {
constructor(realFs = fs__default.default) {
super();
@@ -19470,15 +19476,31 @@ class NodeFS extends BasePortableFakeFS {
async readdirPromise(p, opts) {
return await new Promise((resolve, reject) => {
if (opts) {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject));
if (opts.recursive && process.platform === `win32`) {
if (opts.withFileTypes) {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject));
} else {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject));
}
} else {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject));
}
} else {
this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject));
this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject));
}
});
}
readdirSync(p, opts) {
if (opts) {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts);
if (opts.recursive && process.platform === `win32`) {
if (opts.withFileTypes) {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable);
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath);
}
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts);
}
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p));
}
@@ -23032,8 +23054,6 @@ function getPathForDisplay(p) {
const [major, minor] = process.versions.node.split(`.`).map((value) => parseInt(value, 10));
const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13;
const builtinModules = new Set(require$$0.Module.builtinModules || Object.keys(process.binding(`natives`)));
const isBuiltinModule = (request) => request.startsWith(`node:`) || builtinModules.has(request);
function readPackageScope(checkPath) {
const rootSeparatorIndex = checkPath.indexOf(npath.sep);
let separatorIndex;
@@ -23142,7 +23162,7 @@ function applyPatch(pnpapi, opts) {
const pathRegExp = /^(?![a-zA-Z]:[\\/]|\\\\|\.{0,2}(?:\/|$))((?:@[^/]+\/)?[^/]+)\/*(.*|)$/;
const originalModuleResolveFilename = require$$0.Module._resolveFilename;
require$$0.Module._resolveFilename = function(request, parent, isMain, options) {
if (isBuiltinModule(request))
if (require$$0.isBuiltin(request))
return request;
if (!enableNativeHooks)
return originalModuleResolveFilename.call(require$$0.Module, request, parent, isMain, options);
@@ -24504,7 +24524,7 @@ function makeApi(runtimeState, opts) {
throw new Error(`resolveToUnqualified can not handle private import mappings`);
if (request === `pnpapi`)
return npath.toPortablePath(opts.pnpapiResolution);
if (considerBuiltins && isBuiltinModule(request))
if (considerBuiltins && require$$0.isBuiltin(request))
return null;
const requestForDisplay = getPathForDisplay(request);
const issuerForDisplay = issuer && getPathForDisplay(issuer);
@@ -24642,7 +24662,7 @@ ${brokenAncestors.map((ancestorLocator) => `Ancestor breaking the chain: ${ances
}
}
} else if (dependencyReference === void 0) {
if (!considerBuiltins && isBuiltinModule(request)) {
if (!considerBuiltins && require$$0.isBuiltin(request)) {
if (isDependencyTreeRoot(issuerLocator)) {
error = makeError(
ErrorCode.UNDECLARED_DEPENDENCY,
@@ -24809,7 +24829,7 @@ ${candidates.map((candidate) => `Not found: ${getPathForDisplay(candidate)}
if (unqualifiedPath === null)
return null;
const isIssuerIgnored = () => issuer !== null ? isPathIgnored(issuer) : false;
const remappedPath = (!considerBuiltins || !isBuiltinModule(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions, issuer) : unqualifiedPath;
const remappedPath = (!considerBuiltins || !require$$0.isBuiltin(request)) && !isIssuerIgnored() ? resolveUnqualifiedExport(request, unqualifiedPath, conditions, issuer) : unqualifiedPath;
return resolveUnqualified(remappedPath, { extensions });
} catch (error) {
if (Object.hasOwn(error, `pnpCode`))
+81 -46
View File
@@ -1,9 +1,9 @@
import fs from 'fs';
import { URL as URL$1, fileURLToPath, pathToFileURL } from 'url';
import path from 'path';
import moduleExports, { Module } from 'module';
import { createHash } from 'crypto';
import { EOL } from 'os';
import moduleExports, { isBuiltin } from 'module';
import assert from 'assert';
const SAFE_TIME = 456789e3;
@@ -16,14 +16,16 @@ const PortablePath = {
const npath = Object.create(path);
const ppath = Object.create(path.posix);
npath.cwd = () => process.cwd();
ppath.cwd = () => toPortablePath(process.cwd());
ppath.resolve = (...segments) => {
if (segments.length > 0 && ppath.isAbsolute(segments[0])) {
return path.posix.resolve(...segments);
} else {
return path.posix.resolve(ppath.cwd(), ...segments);
}
};
ppath.cwd = process.platform === `win32` ? () => toPortablePath(process.cwd()) : process.cwd;
if (process.platform === `win32`) {
ppath.resolve = (...segments) => {
if (segments.length > 0 && ppath.isAbsolute(segments[0])) {
return path.posix.resolve(...segments);
} else {
return path.posix.resolve(ppath.cwd(), ...segments);
}
};
}
const contains = function(pathUtils, from, to) {
from = pathUtils.normalize(from);
to = pathUtils.normalize(to);
@@ -37,17 +39,13 @@ const contains = function(pathUtils, from, to) {
return null;
}
};
npath.fromPortablePath = fromPortablePath;
npath.toPortablePath = toPortablePath;
npath.contains = (from, to) => contains(npath, from, to);
ppath.contains = (from, to) => contains(ppath, from, to);
const WINDOWS_PATH_REGEXP = /^([a-zA-Z]:.*)$/;
const UNC_WINDOWS_PATH_REGEXP = /^\/\/(\.\/)?(.*)$/;
const PORTABLE_PATH_REGEXP = /^\/([a-zA-Z]:.*)$/;
const UNC_PORTABLE_PATH_REGEXP = /^\/unc\/(\.dot\/)?(.*)$/;
function fromPortablePath(p) {
if (process.platform !== `win32`)
return p;
function fromPortablePathWin32(p) {
let portablePathMatch, uncPortablePathMatch;
if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP))
p = portablePathMatch[1];
@@ -57,9 +55,7 @@ function fromPortablePath(p) {
return p;
return p.replace(/\//g, `\\`);
}
function toPortablePath(p) {
if (process.platform !== `win32`)
return p;
function toPortablePathWin32(p) {
p = p.replace(/\\/g, `/`);
let windowsPathMatch, uncWindowsPathMatch;
if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP))
@@ -68,6 +64,10 @@ function toPortablePath(p) {
p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`;
return p;
}
const toPortablePath = process.platform === `win32` ? toPortablePathWin32 : (p) => p;
const fromPortablePath = process.platform === `win32` ? fromPortablePathWin32 : (p) => p;
npath.fromPortablePath = fromPortablePath;
npath.toPortablePath = toPortablePath;
function convertPath(targetPathUtils, sourcePath) {
return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath);
}
@@ -902,6 +902,12 @@ class ProxiedFS extends FakeFS {
}
}
function direntToPortable(dirent) {
const portableDirent = dirent;
if (typeof dirent.path === `string`)
portableDirent.path = npath.toPortablePath(dirent.path);
return portableDirent;
}
class NodeFS extends BasePortableFakeFS {
constructor(realFs = fs) {
super();
@@ -1228,15 +1234,31 @@ class NodeFS extends BasePortableFakeFS {
async readdirPromise(p, opts) {
return await new Promise((resolve, reject) => {
if (opts) {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject));
if (opts.recursive && process.platform === `win32`) {
if (opts.withFileTypes) {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(direntToPortable)), reject));
} else {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback((results) => resolve(results.map(npath.toPortablePath)), reject));
}
} else {
this.realFs.readdir(npath.fromPortablePath(p), opts, this.makeCallback(resolve, reject));
}
} else {
this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback((value) => resolve(value), reject));
this.realFs.readdir(npath.fromPortablePath(p), this.makeCallback(resolve, reject));
}
});
}
readdirSync(p, opts) {
if (opts) {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts);
if (opts.recursive && process.platform === `win32`) {
if (opts.withFileTypes) {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(direntToPortable);
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts).map(npath.toPortablePath);
}
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p), opts);
}
} else {
return this.realFs.readdirSync(npath.fromPortablePath(p));
}
@@ -1372,10 +1394,8 @@ class VirtualFS extends ProxiedFS {
const [major, minor] = process.versions.node.split(`.`).map((value) => parseInt(value, 10));
const WATCH_MODE_MESSAGE_USES_ARRAYS = major > 19 || major === 19 && minor >= 2 || major === 18 && minor >= 13;
const HAS_LAZY_LOADED_TRANSLATORS = major > 19 || major === 19 && minor >= 3;
const HAS_LAZY_LOADED_TRANSLATORS = major === 20 && minor < 6 || major === 19 && minor >= 3;
const builtinModules = new Set(Module.builtinModules || Object.keys(process.binding(`natives`)));
const isBuiltinModule = (request) => request.startsWith(`node:`) || builtinModules.has(request);
function readPackageScope(checkPath) {
const rootSeparatorIndex = checkPath.indexOf(npath.sep);
let separatorIndex;
@@ -1963,7 +1983,7 @@ async function resolvePrivateRequest(specifier, issuer, context, nextResolve) {
}
async function resolve$1(originalSpecifier, context, nextResolve) {
const { findPnpApi } = moduleExports;
if (!findPnpApi || isBuiltinModule(originalSpecifier))
if (!findPnpApi || isBuiltin(originalSpecifier))
return nextResolve(originalSpecifier, context, nextResolve);
let specifier = originalSpecifier;
const url = tryParseURL(specifier, isRelativeRegexp.test(specifier) ? context.parentURL : void 0);
@@ -2022,31 +2042,46 @@ async function resolve$1(originalSpecifier, context, nextResolve) {
if (!HAS_LAZY_LOADED_TRANSLATORS) {
const binding = process.binding(`fs`);
const originalfstat = binding.fstat;
const ZIP_MASK = 4278190080;
const ZIP_MAGIC = 704643072;
binding.fstat = function(...args) {
const [fd, useBigint, req] = args;
if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) {
const originalReadFile = binding.readFileUtf8 || binding.readFileSync;
if (originalReadFile) {
binding[originalReadFile.name] = function(...args) {
try {
const stats = fs.fstatSync(fd);
return new Float64Array([
stats.dev,
stats.mode,
stats.nlink,
stats.uid,
stats.gid,
stats.rdev,
stats.blksize,
stats.ino,
stats.size,
stats.blocks
]);
return fs.readFileSync(args[0], {
encoding: `utf8`,
flag: args[1]
});
} catch {
}
}
return originalfstat.apply(this, args);
};
return originalReadFile.apply(this, args);
};
} else {
const binding2 = process.binding(`fs`);
const originalfstat = binding2.fstat;
const ZIP_MASK = 4278190080;
const ZIP_MAGIC = 704643072;
binding2.fstat = function(...args) {
const [fd, useBigint, req] = args;
if ((fd & ZIP_MASK) === ZIP_MAGIC && useBigint === false && req === void 0) {
try {
const stats = fs.fstatSync(fd);
return new Float64Array([
stats.dev,
stats.mode,
stats.nlink,
stats.uid,
stats.gid,
stats.rdev,
stats.blksize,
stats.ino,
stats.size,
stats.blocks
]);
} catch {
}
}
return originalfstat.apply(this, args);
};
}
}
const resolve = resolve$1;
File diff suppressed because one or more lines are too long
+893
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -2,4 +2,4 @@ compressionLevel: mixed
enableGlobalCache: false
yarnPath: .yarn/releases/yarn-4.0.0-rc.51.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
+1 -1
View File
@@ -14,7 +14,7 @@ services:
- standardnotes_self_hosted
localstack:
image: localstack/localstack:1.3
image: localstack/localstack:3.0
container_name: localstack_self_hosted
expose:
- 4566
+1 -1
View File
@@ -39,7 +39,7 @@
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
},
"packageManager": "yarn@4.0.0-rc.51",
"packageManager": "yarn@4.0.2",
"dependenciesMeta": {
"grpc-tools@1.12.4": {
"unplugged": true
+6
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.87.4](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.87.3...@standardnotes/api-gateway@1.87.4) (2023-12-01)
### Bug Fixes
* **api-gateway:** home server home page ([#949](https://github.com/standardnotes/server/issues/949)) ([a82192d](https://github.com/standardnotes/server/commit/a82192db42dfbb3eea4ac6af40ef2b3d6126e5a3))
## [1.87.3](https://github.com/standardnotes/server/compare/@standardnotes/api-gateway@1.87.2...@standardnotes/api-gateway@1.87.3) (2023-11-28)
### Bug Fixes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.87.3",
"version": "1.87.4",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -1,9 +1,18 @@
import { Request, Response } from 'express'
import { BaseHttpController, all, controller, results } from 'inversify-express-utils'
@controller('')
export class FallbackController extends BaseHttpController {
@all('*')
public async fallback(): Promise<results.NotFoundResult> {
public async fallback(request: Request, response: Response): Promise<void | results.NotFoundResult> {
if (request.path === '/' && request.method === 'GET') {
response.send(
'<!DOCTYPE html><html lang="en"><head><meta name="robots" content="noindex"></head><body>Your home server is up and running! Enter the URL of this page into Standard Notes when registering or signing in to begin using your home server.</body></html>',
)
return
}
return this.notFound()
}
}
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.22.7](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.6...@standardnotes/home-server@1.22.7) (2023-12-01)
**Note:** Version bump only for package @standardnotes/home-server
## [1.22.6](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.22.5...@standardnotes/home-server@1.22.6) (2023-11-30)
**Note:** Version bump only for package @standardnotes/home-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.22.6",
"version": "1.22.7",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
+6
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.127.5](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.127.4...@standardnotes/syncing-server@1.127.5) (2023-12-01)
### Bug Fixes
* **syncing-server:** remove the dice roll on whether to inform the client on items changed ([#950](https://github.com/standardnotes/server/issues/950)) ([589b740](https://github.com/standardnotes/server/commit/589b740f4995d6f68d7fe9a366ce160d80344eac))
## [1.127.4](https://github.com/standardnotes/server/compare/@standardnotes/syncing-server@1.127.3...@standardnotes/syncing-server@1.127.4) (2023-11-30)
### Bug Fixes
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.127.4",
"version": "1.127.5",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -114,13 +114,7 @@ import { GetSharedVaults } from '../Domain/UseCase/SharedVaults/GetSharedVaults/
import { CreateSharedVault } from '../Domain/UseCase/SharedVaults/CreateSharedVault/CreateSharedVault'
import { DeleteSharedVault } from '../Domain/UseCase/SharedVaults/DeleteSharedVault/DeleteSharedVault'
import { CreateSharedVaultFileValetToken } from '../Domain/UseCase/SharedVaults/CreateSharedVaultFileValetToken/CreateSharedVaultFileValetToken'
import {
DeterministicSelector,
SelectorInterface,
SharedVaultValetTokenData,
TokenEncoder,
TokenEncoderInterface,
} from '@standardnotes/security'
import { SharedVaultValetTokenData, TokenEncoder, TokenEncoderInterface } from '@standardnotes/security'
import { SharedVaultHttpRepresentation } from '../Mapping/Http/SharedVaultHttpRepresentation'
import { SharedVaultHttpMapper } from '../Mapping/Http/SharedVaultHttpMapper'
import { SharedVaultInviteHttpRepresentation } from '../Mapping/Http/SharedVaultInviteHttpRepresentation'
@@ -206,10 +200,6 @@ export class ContainerConfigLoader {
}
container.bind<winston.Logger>(TYPES.Sync_Logger).toConstantValue(logger)
container
.bind<SelectorInterface<number>>(TYPES.Sync_NumberSelector)
.toConstantValue(new DeterministicSelector<number>())
const appDataSource = new AppDataSource({ env, runMigrations: this.mode === 'server' })
await appDataSource.initialize()
@@ -618,7 +608,6 @@ export class ContainerConfigLoader {
container.get<UpdateExistingItem>(TYPES.Sync_UpdateExistingItem),
container.get<SendEventToClient>(TYPES.Sync_SendEventToClient),
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
container.get<SelectorInterface<number>>(TYPES.Sync_NumberSelector),
container.get<Logger>(TYPES.Sync_Logger),
),
)
@@ -6,7 +6,6 @@ const TYPES = {
Sync_SQS: Symbol.for('Sync_SQS'),
Sync_S3: Symbol.for('Sync_S3'),
Sync_Env: Symbol.for('Sync_Env'),
Sync_NumberSelector: Symbol.for('Sync_NumberSelector'),
// Repositories
Sync_SQLItemRepository: Symbol.for('Sync_SQLItemRepository'),
Sync_SharedVaultRepository: Symbol.for('Sync_SharedVaultRepository'),
@@ -11,7 +11,6 @@ import { Item } from '../../../Item/Item'
import { SendEventToClient } from '../SendEventToClient/SendEventToClient'
import { DomainEventFactoryInterface } from '../../../Event/DomainEventFactoryInterface'
import { ItemsChangedOnServerEvent } from '@standardnotes/domain-events'
import { SelectorInterface } from '@standardnotes/security'
describe('SaveItems', () => {
let itemSaveValidator: ItemSaveValidatorInterface
@@ -24,7 +23,6 @@ describe('SaveItems', () => {
let savedItem: Item
let sendEventToClient: SendEventToClient
let domainEventFactory: DomainEventFactoryInterface
let deterministicSelector: SelectorInterface<number>
const createUseCase = () =>
new SaveItems(
@@ -35,14 +33,10 @@ describe('SaveItems', () => {
updateExistingItem,
sendEventToClient,
domainEventFactory,
deterministicSelector,
logger,
)
beforeEach(() => {
deterministicSelector = {} as jest.Mocked<SelectorInterface<number>>
deterministicSelector.select = jest.fn().mockReturnValue(1)
sendEventToClient = {} as jest.Mocked<SendEventToClient>
sendEventToClient.execute = jest.fn().mockReturnValue(Result.ok())
@@ -228,8 +222,6 @@ describe('SaveItems', () => {
})
it('should update existing items', async () => {
deterministicSelector.select = jest.fn().mockReturnValue(9)
const useCase = createUseCase()
itemRepository.findByUuid = jest.fn().mockResolvedValue(savedItem)
@@ -250,7 +242,7 @@ describe('SaveItems', () => {
sessionUuid: 'session-uuid',
performingUserUuid: '00000000-0000-0000-0000-000000000000',
})
expect(sendEventToClient.execute).not.toHaveBeenCalled()
expect(sendEventToClient.execute).toHaveBeenCalled()
})
it('should mark items as conflicts if updating existing item fails', async () => {
@@ -13,7 +13,6 @@ import { UpdateExistingItem } from '../UpdateExistingItem/UpdateExistingItem'
import { ItemRepositoryInterface } from '../../../Item/ItemRepositoryInterface'
import { SendEventToClient } from '../SendEventToClient/SendEventToClient'
import { DomainEventFactoryInterface } from '../../../Event/DomainEventFactoryInterface'
import { SelectorInterface } from '@standardnotes/security'
export class SaveItems implements UseCaseInterface<SaveItemsResult> {
private readonly SYNC_TOKEN_VERSION = 2
@@ -26,7 +25,6 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
private updateExistingItem: UpdateExistingItem,
private sendEventToClient: SendEventToClient,
private domainEventFactory: DomainEventFactoryInterface,
private deterministicSelector: SelectorInterface<number>,
private logger: Logger,
) {}
@@ -157,15 +155,6 @@ export class SaveItems implements UseCaseInterface<SaveItemsResult> {
return
}
const tenPercentSpreadArray = Array.from(Array(10).keys())
const diceRoll = this.deterministicSelector.select(dto.userUuid, tenPercentSpreadArray)
if (diceRoll > 6) {
this.logger.debug(`[${dto.userUuid}] Not sending items changed event to client.`)
return
}
this.logger.debug(`[${dto.userUuid}] Sending items changed event to client.`)
const itemsChangedEvent = this.domainEventFactory.createItemsChangedOnServerEvent({
userUuid: dto.userUuid,
sessionUuid: dto.sessionUuid,