Compare commits

...

29 Commits

Author SHA1 Message Date
standardci
27d04c95a1 chore(release): publish new version
- @standardnotes/analytics@2.32.0
 - @standardnotes/api-gateway@1.79.13
 - @standardnotes/auth-server@1.159.0
 - @standardnotes/domain-events-infra@1.20.0
 - @standardnotes/event-store@1.13.13
 - @standardnotes/files-server@1.31.0
 - @standardnotes/home-server@1.17.15
 - @standardnotes/revisions-server@1.46.0
 - @standardnotes/scheduler-server@1.26.0
 - @standardnotes/syncing-server@1.118.0
 - @standardnotes/websockets-server@1.17.0
2023-10-17 09:03:21 +00:00
Karol Sójko
cd830cdf25 fix: allow mutable yarn install on PR for dependabot purposes 2023-10-17 10:47:32 +02:00
Karol Sójko
5b06ea94f9 fix(syncing-server): binding 2023-10-17 10:41:55 +02:00
Karol Sójko
aba4f90485 feat: add wrapping sqs receive message with open telemetry 2023-10-17 10:14:26 +02:00
Karol Sójko
350621ed52 fix: remove secondary db from docker ci setup 2023-10-16 12:26:57 +02:00
Karol Sójko
69b4324c78 fix: remove unused variables in ci 2023-10-16 12:26:07 +02:00
Karol Sójko
b2be0a7c0b fix: remove secondary db from e2e test suites 2023-10-16 12:24:17 +02:00
Karol Sójko
cab0dfba39 fix: scheduled test suite to run only base tests 2023-10-16 12:04:34 +02:00
standardci
296ca47d63 chore(release): publish new version
- @standardnotes/auth-server@1.158.8
 - @standardnotes/home-server@1.17.14
2023-10-16 06:35:52 +00:00
Karol Sójko
1cad18a681 fix(auth): logs for triggering transition 2023-10-16 08:15:53 +02:00
standardci
bdd052f90c chore(release): publish new version
- @standardnotes/analytics@2.31.7
 - @standardnotes/api-gateway@1.79.12
 - @standardnotes/auth-server@1.158.7
 - @standardnotes/domain-events-infra@1.19.7
 - @standardnotes/event-store@1.13.12
 - @standardnotes/files-server@1.30.7
 - @standardnotes/home-server@1.17.13
 - @standardnotes/revisions-server@1.45.7
 - @standardnotes/scheduler-server@1.25.7
 - @standardnotes/syncing-server@1.117.7
 - @standardnotes/websockets-server@1.16.7
2023-10-13 08:38:45 +00:00
Karol Sójko
32fe8d0a85 fix: reduce the amount of metrics gathered in telemetery 2023-10-13 10:19:33 +02:00
standardci
31338066ef chore(release): publish new version
- @standardnotes/analytics@2.31.6
 - @standardnotes/api-gateway@1.79.11
 - @standardnotes/auth-server@1.158.6
 - @standardnotes/domain-events-infra@1.19.6
 - @standardnotes/domain-events@2.132.3
 - @standardnotes/event-store@1.13.11
 - @standardnotes/files-server@1.30.6
 - @standardnotes/home-server@1.17.12
 - @standardnotes/revisions-server@1.45.6
 - @standardnotes/scheduler-server@1.25.6
 - @standardnotes/syncing-server@1.117.6
 - @standardnotes/websockets-server@1.16.6
2023-10-12 13:57:28 +00:00
Karol Sójko
07398169c8 fix: passing key params for backup requests (#867) 2023-10-12 15:37:20 +02:00
standardci
1632c83217 chore(release): publish new version
- @standardnotes/analytics@2.31.5
 - @standardnotes/api-gateway@1.79.10
 - @standardnotes/auth-server@1.158.5
 - @standardnotes/domain-events-infra@1.19.5
 - @standardnotes/event-store@1.13.10
 - @standardnotes/files-server@1.30.5
 - @standardnotes/home-server@1.17.11
 - @standardnotes/revisions-server@1.45.5
 - @standardnotes/scheduler-server@1.25.5
 - @standardnotes/syncing-server@1.117.5
 - @standardnotes/websockets-server@1.16.5
2023-10-12 09:29:55 +00:00
Karol Sójko
0c29ff1ab4 fix(domain-events-infra): retrieve all message attributes from sqs 2023-10-12 11:09:43 +02:00
standardci
2a8029ba02 chore(release): publish new version
- @standardnotes/analytics@2.31.4
 - @standardnotes/api-gateway@1.79.9
 - @standardnotes/auth-server@1.158.4
 - @standardnotes/domain-events-infra@1.19.4
 - @standardnotes/domain-events@2.132.2
 - @standardnotes/event-store@1.13.9
 - @standardnotes/files-server@1.30.4
 - @standardnotes/home-server@1.17.10
 - @standardnotes/revisions-server@1.45.4
 - @standardnotes/scheduler-server@1.25.4
 - @standardnotes/syncing-server@1.117.4
 - @standardnotes/websockets-server@1.16.4
2023-10-12 08:34:51 +00:00
Karol Sójko
337eae73c6 fix: disable sqs open telemetry manual tracing in favour of automated instrumentation 2023-10-12 10:17:04 +02:00
Karol Sójko
0a90502658 fix: enable opentelemetry tracing on async workers via sqs/sns automation 2023-10-12 10:07:55 +02:00
Karol Sójko
1246af2551 fix(domain-events-infra): supress typeorm internal instrumentation 2023-10-12 09:54:41 +02:00
Karol Sójko
e0b19ef011 fix: disable opentelemetry tracing on async worker jobs 2023-10-12 09:41:20 +02:00
standardci
63201934a5 chore(release): publish new version
- @standardnotes/analytics@2.31.3
 - @standardnotes/api-gateway@1.79.8
 - @standardnotes/auth-server@1.158.3
 - @standardnotes/domain-events-infra@1.19.3
 - @standardnotes/domain-events@2.132.1
 - @standardnotes/event-store@1.13.8
 - @standardnotes/files-server@1.30.3
 - @standardnotes/home-server@1.17.9
 - @standardnotes/revisions-server@1.45.3
 - @standardnotes/scheduler-server@1.25.3
 - @standardnotes/syncing-server@1.117.3
 - @standardnotes/websockets-server@1.16.3
2023-10-12 06:11:53 +00:00
Karol Sójko
4a6f90b95b fix: injecting opentelemetry trace into sqs/sns coms 2023-10-12 07:50:18 +02:00
standardci
a747f4fc46 chore(release): publish new version
- @standardnotes/analytics@2.31.2
 - @standardnotes/api-gateway@1.79.7
 - @standardnotes/auth-server@1.158.2
 - @standardnotes/domain-events-infra@1.19.2
 - @standardnotes/event-store@1.13.7
 - @standardnotes/files-server@1.30.2
 - @standardnotes/home-server@1.17.8
 - @standardnotes/revisions-server@1.45.2
 - @standardnotes/scheduler-server@1.25.2
 - @standardnotes/syncing-server@1.117.2
 - @standardnotes/websockets-server@1.16.2
2023-10-11 13:40:28 +00:00
Karol Sójko
b782cedc85 fix(domain-events-infra): logs severity 2023-10-11 15:22:07 +02:00
standardci
7435a7ebba chore(release): publish new version
- @standardnotes/analytics@2.31.1
 - @standardnotes/api-gateway@1.79.6
 - @standardnotes/auth-server@1.158.1
 - @standardnotes/domain-events-infra@1.19.1
 - @standardnotes/event-store@1.13.6
 - @standardnotes/files-server@1.30.1
 - @standardnotes/home-server@1.17.7
 - @standardnotes/revisions-server@1.45.1
 - @standardnotes/scheduler-server@1.25.1
 - @standardnotes/syncing-server@1.117.1
 - @standardnotes/websockets-server@1.16.1
2023-10-11 13:07:22 +00:00
Karol Sójko
48c6d97d69 fix(domain-events-infra): add info if event has trace 2023-10-11 14:47:37 +02:00
standardci
9a45aeb3e6 chore(release): publish new version
- @standardnotes/analytics@2.31.0
 - @standardnotes/api-gateway@1.79.5
 - @standardnotes/auth-server@1.158.0
 - @standardnotes/domain-events-infra@1.19.0
 - @standardnotes/domain-events@2.132.0
 - @standardnotes/event-store@1.13.5
 - @standardnotes/files-server@1.30.0
 - @standardnotes/home-server@1.17.6
 - @standardnotes/revisions-server@1.45.0
 - @standardnotes/scheduler-server@1.25.0
 - @standardnotes/syncing-server@1.117.0
 - @standardnotes/websockets-server@1.16.0
2023-10-11 12:08:57 +00:00
Karol Sójko
72c9b28ebe feat: add opentelemetry tracing in distributed system 2023-10-11 13:52:02 +02:00
87 changed files with 988 additions and 615 deletions

6
.github/ci.env vendored
View File

@@ -23,12 +23,6 @@ MYSQL_USER=std_notes_user
MYSQL_PASSWORD=changeme123
MYSQL_ROOT_PASSWORD=changeme123
MONGO_HOST=secondary_db
MONGO_PORT=27017
MONGO_USERNAME=standardnotes
MONGO_PASSWORD=standardnotes
MONGO_DATABASE=standardnotes
AUTH_JWT_SECRET=f95259c5e441f5a4646d76422cfb3df4c4488842901aa50b6c51b8be2e0040e9
AUTH_SERVER_ENCRYPTION_SERVER_KEY=1087415dfde3093797f9a7ca93a49e7d7aa1861735eb0d32aae9c303b8c3d060
VALET_TOKEN_SECRET=4b886819ebe1e908077c6cae96311b48a8416bd60cc91c03060e15bdf6b30d1f

View File

@@ -29,7 +29,6 @@ jobs:
matrix:
db_type: [mysql, sqlite]
cache_type: [redis, memory]
secondary_db_enabled: [true, false]
runs-on: ubuntu-latest
@@ -51,14 +50,6 @@ jobs:
MYSQL_DATABASE: standardnotes
MYSQL_USER: standardnotes
MYSQL_PASSWORD: standardnotes
secondary_db:
image: mongo:5.0
ports:
- 27017:27017
env:
MONGO_INITDB_ROOT_USERNAME: standardnotes
MONGO_INITDB_ROOT_PASSWORD: standardnotes
MONGO_INITDB_DATABASE: standardnotes
steps:
- uses: actions/checkout@v3
@@ -98,12 +89,6 @@ jobs:
echo "DB_DEBUG_LEVEL=all" >> packages/home-server/.env
echo "REDIS_URL=redis://localhost:6379" >> packages/home-server/.env
echo "CACHE_TYPE=${{ matrix.cache_type }}" >> packages/home-server/.env
echo "SECONDARY_DB_ENABLED=${{ matrix.secondary_db_enabled }}" >> packages/home-server/.env
echo "MONGO_HOST=localhost" >> packages/home-server/.env
echo "MONGO_PORT=27017" >> packages/home-server/.env
echo "MONGO_DATABASE=standardnotes" >> packages/home-server/.env
echo "MONGO_USERNAME=standardnotes" >> packages/home-server/.env
echo "MONGO_PASSWORD=standardnotes" >> packages/home-server/.env
echo "FILES_SERVER_URL=http://localhost:3123" >> packages/home-server/.env
echo "E2E_TESTING=true" >> packages/home-server/.env
@@ -122,7 +107,7 @@ jobs:
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: home-server-failure-logs-${{ inputs.suite }}-${{ matrix.db_type }}-${{ matrix.cache_type }}-${{ matrix.secondary_db_enabled }}
name: home-server-failure-logs-${{ inputs.suite }}-${{ matrix.db_type }}-${{ matrix.cache_type }}
retention-days: 5
path: |
logs/output.log

View File

@@ -26,8 +26,6 @@ jobs:
name: (Self Hosting) E2E Test Suite
strategy:
fail-fast: false
matrix:
secondary_db_enabled: [true, false]
runs-on: ubuntu-latest
services:
@@ -53,7 +51,6 @@ jobs:
env:
DB_TYPE: mysql
CACHE_TYPE: redis
SECONDARY_DB_ENABLED: ${{ matrix.secondary_db_enabled }}
- name: Wait for server to start
run: docker/is-available.sh http://localhost:3123 $(pwd)/logs
@@ -65,7 +62,7 @@ jobs:
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
name: self-hosted-failure-logs-${{ inputs.suite }}-${{ matrix.secondary_db_enabled }}
name: self-hosted-failure-logs-${{ inputs.suite }}
retention-days: 5
path: |
logs/*.err

View File

@@ -26,7 +26,7 @@ jobs:
node-version-file: '.nvmrc'
- name: Install
run: yarn install --immutable
run: yarn install
- name: Build
run: yarn build
@@ -54,7 +54,7 @@ jobs:
node-version-file: '.nvmrc'
- name: Install
run: yarn install --immutable
run: yarn install
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'
@@ -86,7 +86,7 @@ jobs:
node-version-file: '.nvmrc'
- name: Install
run: yarn install --immutable
run: yarn install
- name: Build
if: steps.cache-build.outputs.cache-hit != 'true'

14
.pnp.cjs generated
View File

@@ -5627,7 +5627,7 @@ const RAW_RUNTIME_STATE =
["opentelemetry-instrumentation-typeorm", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:0.39.1"],\
["prettier", "npm:3.0.3"],\
["reflect-metadata", "npm:0.1.13"],\
["sqs-consumer", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.3.0"],\
["sqs-consumer", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.4.0-canary.0"],\
["ts-jest", "virtual:fd909b174d079e30b336c4ce72c38a88c1e447767b1a8dd7655e07719a1e31b97807f0931368724fc78897ff15e6a6d00b83316c0f76d11f85111f342e08bb79#npm:29.1.0"],\
["typescript", "patch:typescript@npm%3A5.0.4#optional!builtin<compat/typescript>::version=5.0.4&hash=b5f058"],\
["winston", "npm:3.9.0"]\
@@ -15107,17 +15107,17 @@ const RAW_RUNTIME_STATE =
}]\
]],\
["sqs-consumer", [\
["npm:7.3.0", {\
"packageLocation": "./.yarn/cache/sqs-consumer-npm-7.3.0-a47c08ef71-367ea2a6f3.zip/node_modules/sqs-consumer/",\
["npm:7.4.0-canary.0", {\
"packageLocation": "./.yarn/cache/sqs-consumer-npm-7.4.0-canary.0-2eeb36c4ab-7ecff41c97.zip/node_modules/sqs-consumer/",\
"packageDependencies": [\
["sqs-consumer", "npm:7.3.0"]\
["sqs-consumer", "npm:7.4.0-canary.0"]\
],\
"linkType": "SOFT"\
}],\
["virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.3.0", {\
"packageLocation": "./.yarn/__virtual__/sqs-consumer-virtual-bf07118bf0/0/cache/sqs-consumer-npm-7.3.0-a47c08ef71-367ea2a6f3.zip/node_modules/sqs-consumer/",\
["virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.4.0-canary.0", {\
"packageLocation": "./.yarn/__virtual__/sqs-consumer-virtual-6da87e1296/0/cache/sqs-consumer-npm-7.4.0-canary.0-2eeb36c4ab-7ecff41c97.zip/node_modules/sqs-consumer/",\
"packageDependencies": [\
["sqs-consumer", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.3.0"],\
["sqs-consumer", "virtual:685a6222c3349423674bb7f0684ba34e2ab20912010f352e04dcf707a156e13183fc382e2417cb37a60f3e7b52fd0178c53181674890e1773eb83e190dc13378#npm:7.4.0-canary.0"],\
["@aws-sdk/client-sqs", "npm:3.427.0"],\
["@types/aws-sdk__client-sqs", null],\
["debug", "virtual:ac3d8e680759ce54399273724d44e041d6c9b73454d191d411a8c44bb27e22f02aaf6ed9d3ad0ac1c298eac4833cff369c9c7b84c573016112c4f84be2cd8543#npm:4.3.4"]\

View File

@@ -22,7 +22,6 @@ services:
environment:
DB_TYPE: "${DB_TYPE}"
CACHE_TYPE: "${CACHE_TYPE}"
SECONDARY_DB_ENABLED: "${SECONDARY_DB_ENABLED}"
container_name: server-ci
ports:
- 3123:3000
@@ -61,21 +60,6 @@ services:
networks:
- standardnotes_self_hosted
secondary_db:
image: mongo:5.0
container_name: secondary_db-ci
ports:
- 27017
restart: unless-stopped
volumes:
- ./data/mongo:/data/db
environment:
MONGO_INITDB_ROOT_USERNAME: standardnotes
MONGO_INITDB_ROOT_PASSWORD: standardnotes
MONGO_INITDB_DATABASE: standardnotes
networks:
- standardnotes_self_hosted
cache:
image: redis:6.0-alpine
container_name: cache-ci

View File

@@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.32.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.7...@standardnotes/analytics@2.32.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [2.31.7](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.6...@standardnotes/analytics@2.31.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [2.31.6](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.5...@standardnotes/analytics@2.31.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.31.5](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.4...@standardnotes/analytics@2.31.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.31.4](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.3...@standardnotes/analytics@2.31.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/server/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [2.31.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.2...@standardnotes/analytics@2.31.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/analytics
## [2.31.2](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.1...@standardnotes/analytics@2.31.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/analytics
## [2.31.1](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.31.0...@standardnotes/analytics@2.31.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/analytics
# [2.31.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.30.3...@standardnotes/analytics@2.31.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [2.30.3](https://github.com/standardnotes/server/compare/@standardnotes/analytics@2.30.2...@standardnotes/analytics@2.30.3) (2023-10-11)
**Note:** Version bump only for package @standardnotes/analytics

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { EmailLevel, ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AnalyticsScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AnalyticsScheduledTask })
sdk.start()
import { Logger } from 'winston'

View File

@@ -3,11 +3,11 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AnalyticsWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AnalyticsWorker })
sdk.start()
import { Logger } from 'winston'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
@@ -26,6 +26,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(TYPES.DomainEventSubscriberFactory)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "2.30.3",
"version": "2.32.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -4,7 +4,8 @@ import { Container } from 'inversify'
import {
DomainEventHandlerInterface,
DomainEventMessageHandlerInterface,
DomainEventSubscriberFactoryInterface,
DomainEventPublisherInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import { MapperInterface, ServiceIdentifier } from '@standardnotes/domain-core'
// eslint-disable-next-line @typescript-eslint/no-var-requires
@@ -15,9 +16,9 @@ import TYPES from './Types'
import { AppDataSource } from './DataSource'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSOpenTelemetryEventMessageHandler,
SNSOpenTelemetryDomainEventPublisher,
SQSEventMessageHandler,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { Timer, TimerInterface } from '@standardnotes/time'
import { PeriodKeyGeneratorInterface } from '../Domain/Time/PeriodKeyGeneratorInterface'
@@ -137,8 +138,10 @@ export class ContainerConfigLoader {
container.bind<TimerInterface>(TYPES.Timer).toConstantValue(new Timer())
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
.bind<DomainEventPublisherInterface>(TYPES.DomainEventPublisher)
.toConstantValue(
new SNSOpenTelemetryDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)),
)
if (env.get('MIXPANEL_TOKEN', true)) {
container.bind<Mixpanel>(TYPES.MixpanelClient).toConstantValue(Mixpanel.init(env.get('MIXPANEL_TOKEN', true)))
}
@@ -235,20 +238,16 @@ export class ContainerConfigLoader {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.AnalyticsWorker,
eventHandlers,
container.get(TYPES.Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.bind<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.AnalyticsWorker,
container.get<SQSClient>(TYPES.SQS),
container.get<string>(TYPES.SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Logger),
),
)

View File

@@ -42,7 +42,7 @@ const TYPES = {
RevenueModificationMap: Symbol.for('RevenueModificationMap'),
// Services
DomainEventPublisher: Symbol.for('DomainEventPublisher'),
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
DomainEventSubscriber: Symbol.for('DomainEventSubscriber'),
DomainEventFactory: Symbol.for('DomainEventFactory'),
DomainEventMessageHandler: Symbol.for('DomainEventMessageHandler'),
AnalyticsStore: Symbol.for('AnalyticsStore'),

View File

@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.79.13](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.12...@standardnotes/api-gateway@1.79.13) (2023-10-17)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.12](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.11...@standardnotes/api-gateway@1.79.12) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/api-gateway/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.79.11](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.10...@standardnotes/api-gateway@1.79.11) (2023-10-12)
### Bug Fixes
* passing key params for backup requests ([#867](https://github.com/standardnotes/api-gateway/issues/867)) ([0739816](https://github.com/standardnotes/api-gateway/commit/07398169c80e7871cd04d889f471c3eef70e1aae))
## [1.79.10](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.9...@standardnotes/api-gateway@1.79.10) (2023-10-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.9](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.8...@standardnotes/api-gateway@1.79.9) (2023-10-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.8](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.7...@standardnotes/api-gateway@1.79.8) (2023-10-12)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.7](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.6...@standardnotes/api-gateway@1.79.7) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.6](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.5...@standardnotes/api-gateway@1.79.6) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.4...@standardnotes/api-gateway@1.79.5) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway
## [1.79.4](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.79.3...@standardnotes/api-gateway@1.79.4) (2023-10-11)
**Note:** Version bump only for package @standardnotes/api-gateway

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.ApiGateway)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.ApiGateway })
sdk.start()
import '../src/Controller/LegacyController'

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.79.4",
"version": "1.79.13",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -42,7 +42,6 @@ export class EndpointResolver implements EndpointResolverInterface {
// Users Controller
['[PATCH]:users/:userId', 'auth.users.update'],
['[PUT]:users/:userUuid/attributes/credentials', 'auth.users.updateCredentials'],
['[GET]:users/params', 'auth.users.getKeyParams'],
['[DELETE]:users/:userUuid', 'auth.users.delete'],
['[POST]:listed', 'auth.users.createListedAccount'],
['[POST]:auth', 'auth.users.register'],

View File

@@ -3,6 +3,59 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.159.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.8...@standardnotes/auth-server@1.159.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.158.8](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.7...@standardnotes/auth-server@1.158.8) (2023-10-16)
### Bug Fixes
* **auth:** logs for triggering transition ([1cad18a](https://github.com/standardnotes/server/commit/1cad18a681d933c67244d43dd6f3c2ec405149be))
## [1.158.7](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.6...@standardnotes/auth-server@1.158.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.158.6](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.5...@standardnotes/auth-server@1.158.6) (2023-10-12)
### Bug Fixes
* passing key params for backup requests ([#867](https://github.com/standardnotes/server/issues/867)) ([0739816](https://github.com/standardnotes/server/commit/07398169c80e7871cd04d889f471c3eef70e1aae))
## [1.158.5](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.4...@standardnotes/auth-server@1.158.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.158.4](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.3...@standardnotes/auth-server@1.158.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/server/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.158.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.2...@standardnotes/auth-server@1.158.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.158.2](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.1...@standardnotes/auth-server@1.158.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/auth-server
## [1.158.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.158.0...@standardnotes/auth-server@1.158.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/auth-server
# [1.158.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.157.3...@standardnotes/auth-server@1.158.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.157.3](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.157.2...@standardnotes/auth-server@1.157.3) (2023-10-11)
**Note:** Version bump only for package @standardnotes/auth-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthScheduledTask })
sdk.start()
import { Stream } from 'stream'
@@ -21,6 +21,7 @@ import { SettingRepositoryInterface } from '../src/Domain/Setting/SettingReposit
import { MuteFailedBackupsEmailsOption, SettingName } from '@standardnotes/settings'
import { RoleServiceInterface } from '../src/Domain/Role/RoleServiceInterface'
import { PermissionName } from '@standardnotes/features'
import { GetUserKeyParams } from '../src/Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
const inputArgs = process.argv.slice(2)
const backupProvider = inputArgs[0]
@@ -31,6 +32,7 @@ const requestBackups = async (
roleService: RoleServiceInterface,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
getUserKeyParamsUseCase: GetUserKeyParams,
): Promise<void> => {
const settingName = SettingName.create(SettingName.NAMES.EmailBackupFrequency).getValue()
const permissionName = PermissionName.DailyEmailBackup
@@ -64,11 +66,17 @@ const requestBackups = async (
userHasEmailsMuted = emailsMutedSetting.value === muteEmailsSettingValue
}
const keyParamsResponse = await getUserKeyParamsUseCase.execute({
userUuid: setting.setting_user_uuid,
authenticated: false,
})
await domainEventPublisher.publish(
domainEventFactory.createEmailBackupRequestedEvent(
setting.setting_user_uuid,
emailsMutedSetting?.uuid as string,
userHasEmailsMuted,
keyParamsResponse.keyParams,
),
)
@@ -96,11 +104,14 @@ void container.load().then((container) => {
const roleService: RoleServiceInterface = container.get(TYPES.Auth_RoleService)
const domainEventFactory: DomainEventFactoryInterface = container.get(TYPES.Auth_DomainEventFactory)
const domainEventPublisher: DomainEventPublisherInterface = container.get(TYPES.Auth_DomainEventPublisher)
const getUserKeyParamsUseCase: GetUserKeyParams = container.get(TYPES.Auth_GetUserKeyParams)
const tracer = new OpenTelemetryTracer()
tracer.startSpan(ServiceIdentifier.NAMES.AuthScheduledTask, 'backup')
Promise.resolve(requestBackups(settingRepository, roleService, domainEventFactory, domainEventPublisher))
Promise.resolve(
requestBackups(settingRepository, roleService, domainEventFactory, domainEventPublisher, getUserKeyParamsUseCase),
)
.then(() => {
logger.info(`${backupFrequency} ${backupProvider} backup requesting complete`)

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthScheduledTask })
sdk.start()
import { Logger } from 'winston'

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Auth)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.Auth })
sdk.start()
import '../src/Infra/InversifyExpressUtils/AnnotatedAuthController'

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthScheduledTask })
sdk.start()
import { Logger } from 'winston'

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier, RoleName, TransitionStatus } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthScheduledTask })
sdk.start()
import { Logger } from 'winston'
@@ -43,7 +43,8 @@ const requestTransition = async (
`[TRANSITION ${timestamp}] Found ${users.length} users created between ${startDateString} and ${endDateString}`,
)
let usersTriggered = 0
let itemTransitionsTriggered = 0
let revisionTransitionsTriggered = 0
const forceRun = forceRunParam === 'true'
for (const user of users) {
const itemsTransitionStatus = await transitionStatusRepository.getStatus(user.uuid, 'items')
@@ -60,14 +61,15 @@ const requestTransition = async (
continue
}
let wasTransitionRequested = false
logger.info(
`[TRANSITION ${timestamp}] Transition status for user ${user.uuid} - items status: ${itemsTransitionStatus?.value}, revisions status: ${revisionsTransitionStatus?.value}, has transition role: ${userHasTransitionRole}`,
)
if (
itemsTransitionStatus === null ||
itemsTransitionStatus.value === TransitionStatus.STATUSES.Failed ||
(itemsTransitionStatus.value === TransitionStatus.STATUSES.InProgress && forceRun)
) {
wasTransitionRequested = true
await transitionStatusRepository.remove(user.uuid, 'items')
await domainEventPublisher.publish(
@@ -77,6 +79,8 @@ const requestTransition = async (
timestamp,
}),
)
itemTransitionsTriggered++
}
if (
@@ -84,7 +88,6 @@ const requestTransition = async (
revisionsTransitionStatus.value === TransitionStatus.STATUSES.Failed ||
(revisionsTransitionStatus.value === TransitionStatus.STATUSES.InProgress && forceRun)
) {
wasTransitionRequested = true
await transitionStatusRepository.remove(user.uuid, 'revisions')
await domainEventPublisher.publish(
@@ -94,19 +97,13 @@ const requestTransition = async (
timestamp,
}),
)
}
usersTriggered += 1
if (wasTransitionRequested) {
logger.info(
`[TRANSITION ${timestamp}] Transition requested for user ${user.uuid} - items status: ${itemsTransitionStatus?.value}, revisions status: ${revisionsTransitionStatus?.value}, has transition role: ${userHasTransitionRole}`,
)
revisionTransitionsTriggered++
}
}
logger.info(
`[TRANSITION ${timestamp}] Triggered transition for ${usersTriggered} users created between ${startDateString} and ${endDateString}`,
`[TRANSITION ${timestamp}] Triggered ${itemTransitionsTriggered} item transitions and ${revisionTransitionsTriggered} revision transitions for users created between ${startDateString} and ${endDateString}`,
)
}

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { Email, ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthScheduledTask })
sdk.start()
import { Logger } from 'winston'
@@ -20,6 +20,7 @@ import { MuteFailedBackupsEmailsOption, SettingName } from '@standardnotes/setti
import { RoleServiceInterface } from '../src/Domain/Role/RoleServiceInterface'
import { PermissionName } from '@standardnotes/features'
import { UserRepositoryInterface } from '../src/Domain/User/UserRepositoryInterface'
import { GetUserKeyParams } from '../src/Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
const inputArgs = process.argv.slice(2)
const backupEmail = inputArgs[0]
@@ -30,6 +31,7 @@ const requestBackups = async (
roleService: RoleServiceInterface,
domainEventFactory: DomainEventFactoryInterface,
domainEventPublisher: DomainEventPublisherInterface,
getUserKeyParamsUseCase: GetUserKeyParams,
): Promise<void> => {
const permissionName = PermissionName.DailyEmailBackup
const muteEmailsSettingName = SettingName.NAMES.MuteFailedBackupsEmails
@@ -57,11 +59,17 @@ const requestBackups = async (
userHasEmailsMuted = emailsMutedSetting.value === muteEmailsSettingValue
}
const keyParamsResponse = await getUserKeyParamsUseCase.execute({
userUuid: user.uuid,
authenticated: false,
})
await domainEventPublisher.publish(
domainEventFactory.createEmailBackupRequestedEvent(
user.uuid,
emailsMutedSetting?.uuid as string,
userHasEmailsMuted,
keyParamsResponse.keyParams,
),
)
@@ -84,12 +92,20 @@ void container.load().then((container) => {
const roleService: RoleServiceInterface = container.get(TYPES.Auth_RoleService)
const domainEventFactory: DomainEventFactoryInterface = container.get(TYPES.Auth_DomainEventFactory)
const domainEventPublisher: DomainEventPublisherInterface = container.get(TYPES.Auth_DomainEventPublisher)
const getUserKeyParamsUseCase: GetUserKeyParams = container.get(TYPES.Auth_GetUserKeyParams)
const tracer = new OpenTelemetryTracer()
tracer.startSpan(ServiceIdentifier.NAMES.AuthScheduledTask, 'user_email_backup')
Promise.resolve(
requestBackups(userRepository, settingRepository, roleService, domainEventFactory, domainEventPublisher),
requestBackups(
userRepository,
settingRepository,
roleService,
domainEventFactory,
domainEventPublisher,
getUserKeyParamsUseCase,
),
)
.then(() => {
logger.info(`Email backup requesting complete for ${backupEmail}`)

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.AuthWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.AuthWorker })
sdk.start()
import { Logger } from 'winston'
@@ -11,7 +11,7 @@ import { Logger } from 'winston'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
@@ -26,8 +26,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
TYPES.Auth_DomainEventSubscriberFactory,
)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.Auth_DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.157.3",
"version": "1.159.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -7,7 +7,7 @@ import {
DomainEventHandlerInterface,
DomainEventMessageHandlerInterface,
DomainEventPublisherInterface,
DomainEventSubscriberFactoryInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import { TimerInterface, Timer } from '@standardnotes/time'
import { UAParser } from 'ua-parser-js'
@@ -89,10 +89,9 @@ import { ExtensionKeyGrantedEventHandler } from '../Domain/Handler/ExtensionKeyG
import {
DirectCallDomainEventPublisher,
DirectCallEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SNSOpenTelemetryDomainEventPublisher,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { GetUserSubscription } from '../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ChangeCredentials } from '../Domain/UseCase/ChangeCredentials/ChangeCredentials'
@@ -275,6 +274,8 @@ import { UserRemovedFromSharedVaultEventHandler } from '../Domain/Handler/UserRe
import { DesignateSurvivor } from '../Domain/UseCase/DesignateSurvivor/DesignateSurvivor'
import { UserDesignatedAsSurvivorInSharedVaultEventHandler } from '../Domain/Handler/UserDesignatedAsSurvivorInSharedVaultEventHandler'
import { DisableEmailSettingBasedOnEmailSubscription } from '../Domain/UseCase/DisableEmailSettingBasedOnEmailSubscription/DisableEmailSettingBasedOnEmailSubscription'
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
import { KeyParamsFactoryInterface } from '../Domain/User/KeyParamsFactoryInterface'
export class ContainerConfigLoader {
constructor(private mode: 'server' | 'worker' = 'server') {}
@@ -308,6 +309,8 @@ export class ContainerConfigLoader {
}
container.bind<winston.Logger>(TYPES.Auth_Logger).toConstantValue(logger)
container.bind<CryptoNode>(TYPES.Auth_CryptoNode).toConstantValue(new CryptoNode())
const appDataSource = new AppDataSource({ env, runMigrations: this.mode === 'server' })
await appDataSource.initialize()
@@ -369,6 +372,19 @@ export class ContainerConfigLoader {
container.bind<SQSClient>(TYPES.Auth_SQS).toConstantValue(sqsClient)
}
container.bind(TYPES.Auth_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container
.bind<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher)
.toConstantValue(
isConfiguredForHomeServer
? directCallDomainEventPublisher
: new SNSOpenTelemetryDomainEventPublisher(
container.get(TYPES.Auth_SNS),
container.get(TYPES.Auth_SNS_TOPIC_ARN),
),
)
// Mapping
container
.bind<MapperInterface<SessionTrace, TypeORMSessionTrace>>(TYPES.Auth_SessionTracePersistenceMapper)
@@ -549,7 +565,6 @@ export class ContainerConfigLoader {
container
.bind(TYPES.Auth_DISABLE_USER_REGISTRATION)
.toConstantValue(env.get('DISABLE_USER_REGISTRATION', true) === 'true')
container.bind(TYPES.Auth_SNS_TOPIC_ARN).toConstantValue(env.get('SNS_TOPIC_ARN', true))
container.bind(TYPES.Auth_SNS_AWS_REGION).toConstantValue(env.get('SNS_AWS_REGION', true))
container.bind(TYPES.Auth_SQS_QUEUE_URL).toConstantValue(env.get('SQS_QUEUE_URL', true))
container
@@ -651,6 +666,9 @@ export class ContainerConfigLoader {
}
// Services
container
.bind<SelectorInterface<ProtocolVersion>>(TYPES.Auth_ProtocolVersionSelector)
.toConstantValue(new DeterministicSelector<ProtocolVersion>())
container.bind<UAParser>(TYPES.Auth_DeviceDetector).toConstantValue(new UAParser())
container.bind<SessionService>(TYPES.Auth_SessionService).to(SessionService)
container.bind<AuthResponseFactory20161215>(TYPES.Auth_AuthResponseFactory20161215).to(AuthResponseFactory20161215)
@@ -693,41 +711,61 @@ export class ContainerConfigLoader {
container.bind<DomainEventFactory>(TYPES.Auth_DomainEventFactory).to(DomainEventFactory)
container.bind<AxiosInstance>(TYPES.Auth_HTTPClient).toConstantValue(axios.create())
container.bind<CrypterInterface>(TYPES.Auth_Crypter).to(CrypterNode)
container.bind<SettingServiceInterface>(TYPES.Auth_SettingService).to(SettingService)
container
.bind<SettingsAssociationServiceInterface>(TYPES.Auth_SettingsAssociationService)
.to(SettingsAssociationService)
container.bind<SettingDecrypterInterface>(TYPES.Auth_SettingDecrypter).to(SettingDecrypter)
container
.bind<GetUserKeyParams>(TYPES.Auth_GetUserKeyParams)
.toConstantValue(
new GetUserKeyParams(
container.get<KeyParamsFactoryInterface>(TYPES.Auth_KeyParamsFactory),
container.get<UserRepositoryInterface>(TYPES.Auth_UserRepository),
container.get<PKCERepositoryInterface>(TYPES.Auth_PKCERepository),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<SettingInterpreterInterface>(TYPES.Auth_SettingInterpreter)
.toConstantValue(
new SettingInterpreter(
container.get<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher),
container.get<DomainEventFactoryInterface>(TYPES.Auth_DomainEventFactory),
container.get<SettingRepositoryInterface>(TYPES.Auth_SettingRepository),
container.get<GetUserKeyParams>(TYPES.Auth_GetUserKeyParams),
),
)
container
.bind<SettingServiceInterface>(TYPES.Auth_SettingService)
.toConstantValue(
new SettingService(
container.get<SettingFactoryInterface>(TYPES.Auth_SettingFactory),
container.get<SettingRepositoryInterface>(TYPES.Auth_SettingRepository),
container.get<SettingsAssociationServiceInterface>(TYPES.Auth_SettingsAssociationService),
container.get<SettingInterpreterInterface>(TYPES.Auth_SettingInterpreter),
container.get<SettingDecrypterInterface>(TYPES.Auth_SettingDecrypter),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
container
.bind<SubscriptionSettingServiceInterface>(TYPES.Auth_SubscriptionSettingService)
.to(SubscriptionSettingService)
container.bind<OfflineSettingServiceInterface>(TYPES.Auth_OfflineSettingService).to(OfflineSettingService)
container.bind<CryptoNode>(TYPES.Auth_CryptoNode).toConstantValue(new CryptoNode())
container.bind<ContentDecoderInterface>(TYPES.Auth_ContenDecoder).toConstantValue(new ContentDecoder())
container.bind<ClientServiceInterface>(TYPES.Auth_WebSocketsClientService).to(WebSocketsClientService)
container.bind<RoleServiceInterface>(TYPES.Auth_RoleService).to(RoleService)
container.bind<RoleToSubscriptionMapInterface>(TYPES.Auth_RoleToSubscriptionMap).to(RoleToSubscriptionMap)
container
.bind<SettingsAssociationServiceInterface>(TYPES.Auth_SettingsAssociationService)
.to(SettingsAssociationService)
container
.bind<SubscriptionSettingsAssociationServiceInterface>(TYPES.Auth_SubscriptionSettingsAssociationService)
.to(SubscriptionSettingsAssociationService)
container.bind<FeatureServiceInterface>(TYPES.Auth_FeatureService).to(FeatureService)
container.bind<SettingInterpreterInterface>(TYPES.Auth_SettingInterpreter).to(SettingInterpreter)
container.bind<SettingDecrypterInterface>(TYPES.Auth_SettingDecrypter).to(SettingDecrypter)
container
.bind<SelectorInterface<ProtocolVersion>>(TYPES.Auth_ProtocolVersionSelector)
.toConstantValue(new DeterministicSelector<ProtocolVersion>())
container
.bind<SelectorInterface<boolean>>(TYPES.Auth_BooleanSelector)
.toConstantValue(new DeterministicSelector<boolean>())
container.bind<UserSubscriptionServiceInterface>(TYPES.Auth_UserSubscriptionService).to(UserSubscriptionService)
container
.bind<DomainEventPublisherInterface>(TYPES.Auth_DomainEventPublisher)
.toConstantValue(
isConfiguredForHomeServer
? directCallDomainEventPublisher
: new SNSDomainEventPublisher(container.get(TYPES.Auth_SNS), container.get(TYPES.Auth_SNS_TOPIC_ARN)),
)
// Middleware
container.bind<SessionMiddleware>(TYPES.Auth_SessionMiddleware).to(SessionMiddleware)
container.bind<LockMiddleware>(TYPES.Auth_LockMiddleware).to(LockMiddleware)
@@ -880,7 +918,6 @@ export class ContainerConfigLoader {
container.get(TYPES.Auth_SettingService),
),
)
container.bind<GetUserKeyParams>(TYPES.Auth_GetUserKeyParams).to(GetUserKeyParams)
container.bind<UpdateUser>(TYPES.Auth_UpdateUser).to(UpdateUser)
container.bind<Register>(TYPES.Auth_Register).to(Register)
container.bind<GetActiveSessionsForUser>(TYPES.Auth_GetActiveSessionsForUser).to(GetActiveSessionsForUser)
@@ -1223,23 +1260,17 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Auth_DomainEventMessageHandler)
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.AuthWorker,
eventHandlers,
container.get(TYPES.Auth_Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Auth_Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Auth_DomainEventSubscriberFactory)
.bind<DomainEventSubscriberInterface>(TYPES.Auth_DomainEventSubscriber)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.Auth_SQS),
container.get(TYPES.Auth_SQS_QUEUE_URL),
container.get(TYPES.Auth_DomainEventMessageHandler),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.AuthWorker,
container.get<SQSClient>(TYPES.Auth_SQS),
container.get<string>(TYPES.Auth_SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.Auth_DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Auth_Logger),
),
)
}
@@ -1318,7 +1349,6 @@ export class ContainerConfigLoader {
.toConstantValue(
new BaseUsersController(
container.get<UpdateUser>(TYPES.Auth_UpdateUser),
container.get<GetUserKeyParams>(TYPES.Auth_GetUserKeyParams),
container.get<DeleteAccount>(TYPES.Auth_DeleteAccount),
container.get<GetUserSubscription>(TYPES.Auth_GetUserSubscription),
container.get<ClearLoginAttempts>(TYPES.Auth_ClearLoginAttempts),

View File

@@ -218,7 +218,7 @@ const TYPES = {
Auth_WebSocketConnectionTokenDecoder: Symbol.for('Auth_WebSocketConnectionTokenDecoder'),
Auth_AuthenticationMethodResolver: Symbol.for('Auth_AuthenticationMethodResolver'),
Auth_DomainEventPublisher: Symbol.for('Auth_DomainEventPublisher'),
Auth_DomainEventSubscriberFactory: Symbol.for('Auth_DomainEventSubscriberFactory'),
Auth_DomainEventSubscriber: Symbol.for('Auth_DomainEventSubscriber'),
Auth_DomainEventFactory: Symbol.for('Auth_DomainEventFactory'),
Auth_DomainEventMessageHandler: Symbol.for('Auth_DomainEventMessageHandler'),
Auth_HTTPClient: Symbol.for('Auth_HTTPClient'),

View File

@@ -28,6 +28,7 @@ import { inject, injectable } from 'inversify'
import TYPES from '../../Bootstrap/Types'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
import { DomainEventFactoryInterface } from './DomainEventFactoryInterface'
import { KeyParamsData } from '@standardnotes/responses'
@injectable()
export class DomainEventFactory implements DomainEventFactoryInterface {
@@ -277,6 +278,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
userUuid: string,
muteEmailsSettingUuid: string,
userHasEmailsMuted: boolean,
keyParams: KeyParamsData,
): EmailBackupRequestedEvent {
return {
type: 'EMAIL_BACKUP_REQUESTED',
@@ -292,6 +294,7 @@ export class DomainEventFactory implements DomainEventFactoryInterface {
userUuid,
userHasEmailsMuted,
muteEmailsSettingUuid,
keyParams,
},
}
}

View File

@@ -21,6 +21,7 @@ import {
TransitionRequestedEvent,
} from '@standardnotes/domain-events'
import { InviteeIdentifierType } from '../SharedSubscription/InviteeIdentifierType'
import { KeyParamsData } from '@standardnotes/responses'
export interface DomainEventFactoryInterface {
createWebSocketMessageRequestedEvent(dto: { userUuid: string; message: JSONString }): WebSocketMessageRequestedEvent
@@ -41,6 +42,7 @@ export interface DomainEventFactoryInterface {
userUuid: string,
muteEmailsSettingUuid: string,
userHasEmailsMuted: boolean,
keyParams: KeyParamsData,
): EmailBackupRequestedEvent
createAccountDeletionRequestedEvent(dto: {
userUuid: string

View File

@@ -19,6 +19,8 @@ import { SettingDecrypterInterface } from './SettingDecrypterInterface'
import { SettingInterpreter } from './SettingInterpreter'
import { SettingRepositoryInterface } from './SettingRepositoryInterface'
import { GetUserKeyParams } from '../UseCase/GetUserKeyParams/GetUserKeyParams'
import { KeyParamsData } from '@standardnotes/responses'
describe('SettingInterpreter', () => {
let user: User
@@ -27,8 +29,10 @@ describe('SettingInterpreter', () => {
let settingRepository: SettingRepositoryInterface
let settingDecrypter: SettingDecrypterInterface
let logger: Logger
let getUserKeyParams: GetUserKeyParams
const createInterpreter = () => new SettingInterpreter(domainEventPublisher, domainEventFactory, settingRepository)
const createInterpreter = () =>
new SettingInterpreter(domainEventPublisher, domainEventFactory, settingRepository, getUserKeyParams)
beforeEach(() => {
user = {
@@ -61,6 +65,9 @@ describe('SettingInterpreter', () => {
logger.debug = jest.fn()
logger.warn = jest.fn()
logger.error = jest.fn()
getUserKeyParams = {} as jest.Mocked<GetUserKeyParams>
getUserKeyParams.execute = jest.fn().mockReturnValue({ keyParams: {} as jest.Mocked<KeyParamsData> })
})
it('should trigger session cleanup if user is disabling session user agent logging', async () => {
@@ -85,7 +92,7 @@ describe('SettingInterpreter', () => {
)
expect(domainEventPublisher.publish).toHaveBeenCalled()
expect(domainEventFactory.createEmailBackupRequestedEvent).toHaveBeenCalledWith('4-5-6', '', false)
expect(domainEventFactory.createEmailBackupRequestedEvent).toHaveBeenCalledWith('4-5-6', '', false, {})
})
it('should trigger backup if email backup setting is created - emails muted', async () => {
@@ -102,7 +109,7 @@ describe('SettingInterpreter', () => {
)
expect(domainEventPublisher.publish).toHaveBeenCalled()
expect(domainEventFactory.createEmailBackupRequestedEvent).toHaveBeenCalledWith('4-5-6', '6-7-8', true)
expect(domainEventFactory.createEmailBackupRequestedEvent).toHaveBeenCalledWith('4-5-6', '6-7-8', true, {})
})
it('should not trigger backup if email backup setting is disabled', async () => {

View File

@@ -6,15 +6,13 @@ import {
MuteFailedBackupsEmailsOption,
SettingName,
} from '@standardnotes/settings'
import { inject, injectable } from 'inversify'
import TYPES from '../../Bootstrap/Types'
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
import { User } from '../User/User'
import { SettingInterpreterInterface } from './SettingInterpreterInterface'
import { SettingRepositoryInterface } from './SettingRepositoryInterface'
import { GetUserKeyParams } from '../UseCase/GetUserKeyParams/GetUserKeyParams'
@injectable()
export class SettingInterpreter implements SettingInterpreterInterface {
private readonly emailSettingToSubscriptionRejectionLevelMap: Map<string, string> = new Map([
[SettingName.NAMES.MuteFailedBackupsEmails, EmailLevel.LEVELS.FailedEmailBackup],
@@ -24,9 +22,10 @@ export class SettingInterpreter implements SettingInterpreterInterface {
])
constructor(
@inject(TYPES.Auth_DomainEventPublisher) private domainEventPublisher: DomainEventPublisherInterface,
@inject(TYPES.Auth_DomainEventFactory) private domainEventFactory: DomainEventFactoryInterface,
@inject(TYPES.Auth_SettingRepository) private settingRepository: SettingRepositoryInterface,
private domainEventPublisher: DomainEventPublisherInterface,
private domainEventFactory: DomainEventFactoryInterface,
private settingRepository: SettingRepositoryInterface,
private getUserKeyParams: GetUserKeyParams,
) {}
async interpretSettingUpdated(
@@ -59,8 +58,18 @@ export class SettingInterpreter implements SettingInterpreterInterface {
muteEmailsSettingUuid = muteFailedEmailsBackupSetting.uuid
}
const keyParamsResponse = await this.getUserKeyParams.execute({
authenticated: false,
userUuid,
})
await this.domainEventPublisher.publish(
this.domainEventFactory.createEmailBackupRequestedEvent(userUuid, muteEmailsSettingUuid, userHasEmailsMuted),
this.domainEventFactory.createEmailBackupRequestedEvent(
userUuid,
muteEmailsSettingUuid,
userHasEmailsMuted,
keyParamsResponse.keyParams,
),
)
}

View File

@@ -1,7 +1,6 @@
import { SettingName } from '@standardnotes/settings'
import { inject, injectable } from 'inversify'
import { Logger } from 'winston'
import TYPES from '../../Bootstrap/Types'
import { User } from '../User/User'
import { CreateOrReplaceSettingDto } from './CreateOrReplaceSettingDto'
import { CreateOrReplaceSettingResponse } from './CreateOrReplaceSettingResponse'
@@ -14,16 +13,14 @@ import { SettingInterpreterInterface } from './SettingInterpreterInterface'
import { SettingDecrypterInterface } from './SettingDecrypterInterface'
import { SettingFactoryInterface } from './SettingFactoryInterface'
@injectable()
export class SettingService implements SettingServiceInterface {
constructor(
@inject(TYPES.Auth_SettingFactory) private factory: SettingFactoryInterface,
@inject(TYPES.Auth_SettingRepository) private settingRepository: SettingRepositoryInterface,
@inject(TYPES.Auth_SettingsAssociationService)
private factory: SettingFactoryInterface,
private settingRepository: SettingRepositoryInterface,
private settingsAssociationService: SettingsAssociationServiceInterface,
@inject(TYPES.Auth_SettingInterpreter) private settingInterpreter: SettingInterpreterInterface,
@inject(TYPES.Auth_SettingDecrypter) private settingDecrypter: SettingDecrypterInterface,
@inject(TYPES.Auth_Logger) private logger: Logger,
private settingInterpreter: SettingInterpreterInterface,
private settingDecrypter: SettingDecrypterInterface,
private logger: Logger,
) {}
async applyDefaultSettingsUponRegistration(user: User): Promise<void> {

View File

@@ -1,24 +1,22 @@
import { inject, injectable } from 'inversify'
import TYPES from '../../../Bootstrap/Types'
import { KeyParamsData } from '@standardnotes/responses'
import { Logger } from 'winston'
import { Username, Uuid } from '@standardnotes/domain-core'
import { KeyParamsFactoryInterface } from '../../User/KeyParamsFactoryInterface'
import { UserRepositoryInterface } from '../../User/UserRepositoryInterface'
import { GetUserKeyParamsDTO } from './GetUserKeyParamsDTO'
import { GetUserKeyParamsResponse } from './GetUserKeyParamsResponse'
import { UseCaseInterface } from '../UseCaseInterface'
import { Logger } from 'winston'
import { User } from '../../User/User'
import { PKCERepositoryInterface } from '../../User/PKCERepositoryInterface'
import { GetUserKeyParamsDTOV2Challenged } from './GetUserKeyParamsDTOV2Challenged'
import { KeyParamsData } from '@standardnotes/responses'
import { Username, Uuid } from '@standardnotes/domain-core'
@injectable()
export class GetUserKeyParams implements UseCaseInterface {
constructor(
@inject(TYPES.Auth_KeyParamsFactory) private keyParamsFactory: KeyParamsFactoryInterface,
@inject(TYPES.Auth_UserRepository) private userRepository: UserRepositoryInterface,
@inject(TYPES.Auth_PKCERepository) private pkceRepository: PKCERepositoryInterface,
@inject(TYPES.Auth_Logger) private logger: Logger,
private keyParamsFactory: KeyParamsFactoryInterface,
private userRepository: UserRepositoryInterface,
private pkceRepository: PKCERepositoryInterface,
private logger: Logger,
) {}
async execute(dto: GetUserKeyParamsDTO): Promise<GetUserKeyParamsResponse> {

View File

@@ -8,7 +8,6 @@ import { Result, Username } from '@standardnotes/domain-core'
import { DeleteAccount } from '../../Domain/UseCase/DeleteAccount/DeleteAccount'
import { ChangeCredentials } from '../../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { ClearLoginAttempts } from '../../Domain/UseCase/ClearLoginAttempts'
import { GetUserKeyParams } from '../../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { GetUserSubscription } from '../../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { IncreaseLoginAttempts } from '../../Domain/UseCase/IncreaseLoginAttempts'
import { InviteToSharedSubscription } from '../../Domain/UseCase/InviteToSharedSubscription/InviteToSharedSubscription'
@@ -18,7 +17,6 @@ import { User } from '../../Domain/User/User'
describe('AnnotatedUsersController', () => {
let updateUser: UpdateUser
let deleteAccount: DeleteAccount
let getUserKeyParams: GetUserKeyParams
let getUserSubscription: GetUserSubscription
let clearLoginAttempts: ClearLoginAttempts
let increaseLoginAttempts: IncreaseLoginAttempts
@@ -32,7 +30,6 @@ describe('AnnotatedUsersController', () => {
const createController = () =>
new AnnotatedUsersController(
updateUser,
getUserKeyParams,
deleteAccount,
getUserSubscription,
clearLoginAttempts,
@@ -51,9 +48,6 @@ describe('AnnotatedUsersController', () => {
user.uuid = '123'
user.email = 'test@test.te'
getUserKeyParams = {} as jest.Mocked<GetUserKeyParams>
getUserKeyParams.execute = jest.fn()
getUserSubscription = {} as jest.Mocked<GetUserSubscription>
getUserSubscription.execute = jest.fn()
@@ -213,60 +207,6 @@ describe('AnnotatedUsersController', () => {
expect(result.statusCode).toEqual(401)
})
it('should get user key params', async () => {
request.query = {
email: 'test@test.te',
uuid: '1-2-3',
}
getUserKeyParams.execute = jest.fn().mockReturnValue({ foo: 'bar' })
const httpResponse = <results.JsonResult>await createController().keyParams(request)
const result = await httpResponse.executeAsync()
expect(getUserKeyParams.execute).toHaveBeenCalledWith({
email: 'test@test.te',
userUuid: '1-2-3',
authenticated: false,
})
expect(result.statusCode).toEqual(200)
})
it('should get authenticated user key params', async () => {
request.query = {
email: 'test@test.te',
uuid: '1-2-3',
authenticated: 'true',
}
getUserKeyParams.execute = jest.fn().mockReturnValue({ foo: 'bar' })
const httpResponse = <results.JsonResult>await createController().keyParams(request)
const result = await httpResponse.executeAsync()
expect(getUserKeyParams.execute).toHaveBeenCalledWith({
email: 'test@test.te',
userUuid: '1-2-3',
authenticated: true,
})
expect(result.statusCode).toEqual(200)
})
it('should not get user key params if email and user uuid is missing', async () => {
request.query = {}
getUserKeyParams.execute = jest.fn().mockReturnValue({ foo: 'bar' })
const httpResponse = <results.JsonResult>await createController().keyParams(request)
const result = await httpResponse.executeAsync()
expect(getUserKeyParams.execute).not.toHaveBeenCalled()
expect(result.statusCode).toEqual(400)
})
it('should get user subscription', async () => {
request.params.userUuid = '1-2-3'
response.locals.user = {

View File

@@ -11,7 +11,6 @@ import {
} from 'inversify-express-utils'
import TYPES from '../../Bootstrap/Types'
import { DeleteAccount } from '../../Domain/UseCase/DeleteAccount/DeleteAccount'
import { GetUserKeyParams } from '../../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { UpdateUser } from '../../Domain/UseCase/UpdateUser'
import { GetUserSubscription } from '../../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { ClearLoginAttempts } from '../../Domain/UseCase/ClearLoginAttempts'
@@ -23,7 +22,6 @@ import { BaseUsersController } from './Base/BaseUsersController'
export class AnnotatedUsersController extends BaseUsersController {
constructor(
@inject(TYPES.Auth_UpdateUser) override updateUser: UpdateUser,
@inject(TYPES.Auth_GetUserKeyParams) override getUserKeyParams: GetUserKeyParams,
@inject(TYPES.Auth_DeleteAccount) override doDeleteAccount: DeleteAccount,
@inject(TYPES.Auth_GetUserSubscription) override doGetUserSubscription: GetUserSubscription,
@inject(TYPES.Auth_ClearLoginAttempts) override clearLoginAttempts: ClearLoginAttempts,
@@ -32,7 +30,6 @@ export class AnnotatedUsersController extends BaseUsersController {
) {
super(
updateUser,
getUserKeyParams,
doDeleteAccount,
doGetUserSubscription,
clearLoginAttempts,
@@ -46,11 +43,6 @@ export class AnnotatedUsersController extends BaseUsersController {
return super.update(request, response)
}
@httpGet('/params')
override async keyParams(request: Request): Promise<results.JsonResult> {
return super.keyParams(request)
}
@httpDelete('/:userUuid', TYPES.Auth_RequiredCrossServiceTokenMiddleware)
override async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> {
return super.deleteAccount(request, response)

View File

@@ -5,7 +5,6 @@ import { BaseHttpController, results } from 'inversify-express-utils'
import { ChangeCredentials } from '../../../Domain/UseCase/ChangeCredentials/ChangeCredentials'
import { ClearLoginAttempts } from '../../../Domain/UseCase/ClearLoginAttempts'
import { DeleteAccount } from '../../../Domain/UseCase/DeleteAccount/DeleteAccount'
import { GetUserKeyParams } from '../../../Domain/UseCase/GetUserKeyParams/GetUserKeyParams'
import { GetUserSubscription } from '../../../Domain/UseCase/GetUserSubscription/GetUserSubscription'
import { IncreaseLoginAttempts } from '../../../Domain/UseCase/IncreaseLoginAttempts'
import { UpdateUser } from '../../../Domain/UseCase/UpdateUser'
@@ -14,7 +13,6 @@ import { ErrorTag } from '@standardnotes/responses'
export class BaseUsersController extends BaseHttpController {
constructor(
protected updateUser: UpdateUser,
protected getUserKeyParams: GetUserKeyParams,
protected doDeleteAccount: DeleteAccount,
protected doGetUserSubscription: GetUserSubscription,
protected clearLoginAttempts: ClearLoginAttempts,
@@ -26,7 +24,6 @@ export class BaseUsersController extends BaseHttpController {
if (this.controllerContainer !== undefined) {
this.controllerContainer.register('auth.users.update', this.update.bind(this))
this.controllerContainer.register('auth.users.getKeyParams', this.keyParams.bind(this))
this.controllerContainer.register('auth.users.getSubscription', this.getSubscription.bind(this))
this.controllerContainer.register('auth.users.updateCredentials', this.changeCredentials.bind(this))
this.controllerContainer.register('auth.users.delete', this.deleteAccount.bind(this))
@@ -79,30 +76,6 @@ export class BaseUsersController extends BaseHttpController {
)
}
async keyParams(request: Request): Promise<results.JsonResult> {
const email = 'email' in request.query ? <string>request.query.email : undefined
const userUuid = 'uuid' in request.query ? <string>request.query.uuid : undefined
if (!email && !userUuid) {
return this.json(
{
error: {
message: 'Missing mandatory request query parameters.',
},
},
400,
)
}
const result = await this.getUserKeyParams.execute({
email,
userUuid,
authenticated: request.query.authenticated === 'true',
})
return this.json(result.keyParams)
}
async deleteAccount(request: Request, response: Response): Promise<results.JsonResult> {
if (request.params.userUuid !== response.locals.user.uuid) {
return this.json(

View File

@@ -3,6 +3,60 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.20.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.7...@standardnotes/domain-events-infra@1.20.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.19.7](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.6...@standardnotes/domain-events-infra@1.19.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.19.6](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.5...@standardnotes/domain-events-infra@1.19.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.19.5](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.4...@standardnotes/domain-events-infra@1.19.5) (2023-10-12)
### Bug Fixes
* **domain-events-infra:** retrieve all message attributes from sqs ([0c29ff1](https://github.com/standardnotes/server/commit/0c29ff1ab4886a73eae8079e80d7ff779c0e3859))
## [1.19.4](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.3...@standardnotes/domain-events-infra@1.19.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* **domain-events-infra:** supress typeorm internal instrumentation ([1246af2](https://github.com/standardnotes/server/commit/1246af2551ae3502734583fbc7dcebc91c16eb6b))
* enable opentelemetry tracing on async workers via sqs/sns automation ([0a90502](https://github.com/standardnotes/server/commit/0a90502658ce6f60f4a3100a518d522d6209a8fd))
## [1.19.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.2...@standardnotes/domain-events-infra@1.19.3) (2023-10-12)
### Bug Fixes
* injecting opentelemetry trace into sqs/sns coms ([4a6f90b](https://github.com/standardnotes/server/commit/4a6f90b95b39e7990b10dd4b96d549e1366383fe))
## [1.19.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.1...@standardnotes/domain-events-infra@1.19.2) (2023-10-11)
### Bug Fixes
* **domain-events-infra:** logs severity ([b782ced](https://github.com/standardnotes/server/commit/b782cedc85e0dff1f94163b908d98005b30f119e))
## [1.19.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.19.0...@standardnotes/domain-events-infra@1.19.1) (2023-10-11)
### Bug Fixes
* **domain-events-infra:** add info if event has trace ([48c6d97](https://github.com/standardnotes/server/commit/48c6d97d697a740c262495eff87c6db65ebb38d9))
# [1.19.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.18.2...@standardnotes/domain-events-infra@1.19.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.18.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.18.1...@standardnotes/domain-events-infra@1.18.2) (2023-10-11)
### Bug Fixes

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.18.2",
"version": "1.20.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},
@@ -43,7 +43,7 @@
"ioredis": "^5.2.4",
"opentelemetry-instrumentation-typeorm": "^0.39.1",
"reflect-metadata": "^0.1.13",
"sqs-consumer": "^7.3.0",
"sqs-consumer": "7.4.0-canary.0",
"winston": "^3.8.1"
},
"devDependencies": {

View File

@@ -18,8 +18,11 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
private declare sdk: OpenTelemetrySDKNode.NodeSDK
constructor(
private serviceName: string,
private spanRatio?: number,
private options: {
serviceName: string
spanRatio?: number
metricExportIntervalMillis?: number
},
) {
this.build()
}
@@ -27,24 +30,28 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
build(): void {
const otResource = OpenTelemetrySDKNode.resources.Resource.default().merge(
new OpenTelemetrySDKNode.resources.Resource({
[SemanticResourceAttributes.SERVICE_NAME]: this.serviceName,
[SemanticResourceAttributes.SERVICE_NAME]: this.options.serviceName,
}),
)
const traceExporter = new OTLPTraceExporter()
const spanProcessor = new OpenTelemetrySDKNode.tracing.BatchSpanProcessor(traceExporter)
const metricExportIntervalMillis = this.options.metricExportIntervalMillis ?? 300_000
const metricReader = new OpenTelemetrySDKNode.metrics.PeriodicExportingMetricReader({
exportIntervalMillis: 1_000,
exportIntervalMillis: metricExportIntervalMillis,
exporter: new OTLPMetricExporter(),
})
const serviceName = this.serviceName
const serviceName = this.options.serviceName
const winstonInstrumentation = new WinstonInstrumentation({
logHook: (_span, record) => {
record['resource.service.name'] = serviceName
},
})
const ratio = this.spanRatio ?? 0.01
const ratio = this.options.spanRatio ?? 0.01
this.sdk = new OpenTelemetrySDKNode.NodeSDK({
sampler: new OpenTelemetrySDKNode.tracing.TraceIdRatioBasedSampler(ratio),
@@ -60,8 +67,12 @@ export class OpenTelemetrySDK implements OpenTelemetrySDKInterface {
new ExpressInstrumentation(),
new AwsInstrumentation({
suppressInternalInstrumentation: true,
sqsExtractContextPropagationFromPayload: true,
}),
new TypeormInstrumentation({
collectParameters: false,
suppressInternalInstrumentation: true,
}),
new TypeormInstrumentation(),
winstonInstrumentation,
new IORedisInstrumentation(),
],

View File

@@ -1,45 +0,0 @@
import 'reflect-metadata'
import { DomainEventInterface, DomainEventService } from '@standardnotes/domain-events'
import { SNSClient } from '@aws-sdk/client-sns'
import { SNSDomainEventPublisher } from './SNSDomainEventPublisher'
describe('SNSDomainEventPublisher', () => {
let sns: SNSClient
const topicArn = 'test-topic-arn'
let event: DomainEventInterface
const createPublisher = () => new SNSDomainEventPublisher(sns, topicArn)
beforeEach(() => {
sns = {} as jest.Mocked<SNSClient>
sns.send = jest.fn()
event = {} as jest.Mocked<DomainEventInterface>
event.type = 'TEST'
event.payload = { foo: 'bar' }
event.createdAt = new Date(1)
event.meta = {
correlation: {
userIdentifier: '1-2-3',
userIdentifierType: 'uuid',
},
origin: DomainEventService.Auth,
}
})
it('should publish a domain event', async () => {
await createPublisher().publish(event)
expect(sns.send).toHaveBeenCalled()
})
it('should publish a targeted domain event', async () => {
event.meta.target = DomainEventService.SyncingServer
await createPublisher().publish(event)
expect(sns.send).toHaveBeenCalled()
})
})

View File

@@ -0,0 +1,43 @@
import * as zlib from 'zlib'
import { MessageAttributeValue, PublishCommand, PublishCommandInput, SNSClient } from '@aws-sdk/client-sns'
import { DomainEventInterface, DomainEventPublisherInterface } from '@standardnotes/domain-events'
export class SNSOpenTelemetryDomainEventPublisher implements DomainEventPublisherInterface {
constructor(
private snsClient: SNSClient,
private topicArn: string,
) {}
async publish(event: DomainEventInterface): Promise<void> {
const message: PublishCommandInput = {
TopicArn: this.topicArn,
MessageAttributes: {
event: {
DataType: 'String',
StringValue: event.type,
},
compression: {
DataType: 'String',
StringValue: 'true',
},
origin: {
DataType: 'String',
StringValue: event.meta.origin,
},
},
Message: zlib.deflateSync(JSON.stringify(event)).toString('base64'),
}
if (event.meta.target !== undefined) {
;(message.MessageAttributes as Record<string, MessageAttributeValue>).target = {
DataType: 'String',
StringValue: event.meta.target,
}
}
const command = new PublishCommand(message)
await this.snsClient.send(command)
}
}

View File

@@ -16,7 +16,7 @@ export class SQSDomainEventSubscriberFactory implements DomainEventSubscriberFac
create(): DomainEventSubscriberInterface {
const sqsConsumer = Consumer.create({
attributeNames: ['All'],
messageAttributeNames: ['compression', 'event'],
messageAttributeNames: ['All'],
queueUrl: this.queueUrl,
sqs: this.sqs,
handleMessage:

View File

@@ -0,0 +1,58 @@
import { Consumer } from 'sqs-consumer'
import * as OpenTelemetryApi from '@opentelemetry/api'
import { Message, SQSClient } from '@aws-sdk/client-sqs'
import { DomainEventSubscriberInterface, DomainEventMessageHandlerInterface } from '@standardnotes/domain-events'
import { Logger } from 'winston'
export class SQSOpenTelemetryDomainEventSubscriber implements DomainEventSubscriberInterface {
private currentSpan: OpenTelemetryApi.Span | undefined
constructor(
private serviceName: string,
private sqs: SQSClient,
private queueUrl: string,
private domainEventMessageHandler: DomainEventMessageHandlerInterface,
private logger: Logger,
) {}
start(): void {
const sqsConsumer = Consumer.create({
attributeNames: ['All'],
messageAttributeNames: ['All'],
queueUrl: this.queueUrl,
sqs: this.sqs,
preReceiveMessageCallback: this.startParentSpan.bind(this),
handleMessage: this.handleMessage.bind(this),
})
sqsConsumer.on('error', this.handleError.bind(this))
sqsConsumer.on('processing_error', this.handleError.bind(this))
sqsConsumer.start()
}
async startParentSpan(): Promise<void> {
const tracer = OpenTelemetryApi.trace.getTracer(`${this.serviceName}-domain-event-subscriber`)
this.currentSpan = tracer.startSpan(this.serviceName, { kind: OpenTelemetryApi.SpanKind.CONSUMER })
}
async handleMessage(message: Message): Promise<void> {
await this.domainEventMessageHandler.handleMessage(<string>message.Body)
if (this.currentSpan) {
this.currentSpan.end()
this.currentSpan = undefined
}
}
handleError(error: Error): void {
this.logger.error('Error occured while handling SQS message: %O', error)
if (this.currentSpan) {
this.currentSpan.recordException(error)
this.currentSpan.end()
this.currentSpan = undefined
}
}
}

View File

@@ -1,56 +0,0 @@
import { Logger } from 'winston'
import * as zlib from 'zlib'
import {
DomainEventHandlerInterface,
DomainEventInterface,
DomainEventMessageHandlerInterface,
} from '@standardnotes/domain-events'
import { OpenTelemetryTracer } from '../OpenTelemetry/OpenTelemetryTracer'
import { OpenTelemetryTracerInterface } from '../OpenTelemetry/OpenTelemetryTracerInterface'
export class SQSOpenTelemetryEventMessageHandler implements DomainEventMessageHandlerInterface {
private tracer: OpenTelemetryTracerInterface | undefined
constructor(
private serviceName: string,
private handlers: Map<string, DomainEventHandlerInterface>,
private logger: Logger,
) {}
async handleMessage(message: string): Promise<void> {
const messageParsed = JSON.parse(message)
const domainEventJson = zlib.unzipSync(Buffer.from(messageParsed.Message, 'base64')).toString()
const domainEvent: DomainEventInterface = JSON.parse(domainEventJson)
domainEvent.createdAt = new Date(domainEvent.createdAt)
const handler = this.handlers.get(domainEvent.type)
if (!handler) {
this.logger.debug(`Event handler for event type ${domainEvent.type} does not exist`)
return
}
this.logger.info(`Received event: ${domainEvent.type}`)
this.tracer = new OpenTelemetryTracer()
this.tracer.startSpan(this.serviceName, domainEvent.type)
try {
await handler.handle(domainEvent)
} catch (error) {
this.tracer.stopSpanWithError(error as Error)
throw error
}
this.tracer.stopSpan()
}
async handleError(error: Error): Promise<void> {
this.logger.error('Error occured while handling SQS message: %O', error)
}
}

View File

@@ -12,8 +12,9 @@ export * from './Redis/RedisDomainEventSubscriberFactory'
export * from './Redis/RedisEventMessageHandler'
export * from './SNS/SNSDomainEventPublisher'
export * from './SNS/SNSOpenTelemetryDomainEventPublisher'
export * from './SQS/SQSBounceNotificiationHandler'
export * from './SQS/SQSDomainEventSubscriberFactory'
export * from './SQS/SQSEventMessageHandler'
export * from './SQS/SQSOpenTelemetryEventMessageHandler'
export * from './SQS/SQSOpenTelemetryDomainEventSubscriber'

View File

@@ -3,6 +3,30 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [2.132.3](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.132.2...@standardnotes/domain-events@2.132.3) (2023-10-12)
### Bug Fixes
* passing key params for backup requests ([#867](https://github.com/standardnotes/server/issues/867)) ([0739816](https://github.com/standardnotes/server/commit/07398169c80e7871cd04d889f471c3eef70e1aae))
## [2.132.2](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.132.1...@standardnotes/domain-events@2.132.2) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
## [2.132.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.132.0...@standardnotes/domain-events@2.132.1) (2023-10-12)
### Bug Fixes
* injecting opentelemetry trace into sqs/sns coms ([4a6f90b](https://github.com/standardnotes/server/commit/4a6f90b95b39e7990b10dd4b96d549e1366383fe))
# [2.132.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.131.1...@standardnotes/domain-events@2.132.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [2.131.1](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.131.0...@standardnotes/domain-events@2.131.1) (2023-09-28)
**Note:** Version bump only for package @standardnotes/domain-events

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.131.1",
"version": "2.132.3",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -2,4 +2,5 @@ export interface EmailBackupRequestedEventPayload {
userUuid: string
userHasEmailsMuted: boolean
muteEmailsSettingUuid: string
keyParams: Record<string, unknown>
}

View File

@@ -3,6 +3,42 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.13.13](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.12...@standardnotes/event-store@1.13.13) (2023-10-17)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.12](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.11...@standardnotes/event-store@1.13.12) (2023-10-13)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.11](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.10...@standardnotes/event-store@1.13.11) (2023-10-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.10](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.9...@standardnotes/event-store@1.13.10) (2023-10-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.9](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.8...@standardnotes/event-store@1.13.9) (2023-10-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.8](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.7...@standardnotes/event-store@1.13.8) (2023-10-12)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.7](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.6...@standardnotes/event-store@1.13.7) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.6](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.5...@standardnotes/event-store@1.13.6) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.5](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.4...@standardnotes/event-store@1.13.5) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store
## [1.13.4](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.13.3...@standardnotes/event-store@1.13.4) (2023-10-11)
**Note:** Version bump only for package @standardnotes/event-store

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.13.4",
"version": "1.13.13",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",

View File

@@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.31.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.7...@standardnotes/files-server@1.31.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/files/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.30.7](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.6...@standardnotes/files-server@1.30.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/files/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.30.6](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.5...@standardnotes/files-server@1.30.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/files-server
## [1.30.5](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.4...@standardnotes/files-server@1.30.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/files-server
## [1.30.4](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.3...@standardnotes/files-server@1.30.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/files/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/files/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.30.3](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.2...@standardnotes/files-server@1.30.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/files-server
## [1.30.2](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.1...@standardnotes/files-server@1.30.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/files-server
## [1.30.1](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.30.0...@standardnotes/files-server@1.30.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/files-server
# [1.30.0](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.29.4...@standardnotes/files-server@1.30.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/files/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.29.4](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.29.3...@standardnotes/files-server@1.29.4) (2023-10-11)
**Note:** Version bump only for package @standardnotes/files-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Files)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.Files })
sdk.start()
import * as busboy from 'connect-busboy'

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.FilesWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.FilesWorker })
sdk.start()
import { Logger } from 'winston'
@@ -11,7 +11,7 @@ import { Logger } from 'winston'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
@@ -26,8 +26,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
TYPES.Files_DomainEventSubscriberFactory,
)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.Files_DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.29.4",
"version": "1.31.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -16,10 +16,9 @@ import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
DirectCallDomainEventPublisher,
DirectCallEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SNSOpenTelemetryDomainEventPublisher,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { StreamDownloadFile } from '../Domain/UseCase/StreamDownloadFile/StreamDownloadFile'
import { FileDownloaderInterface } from '../Domain/Services/FileDownloaderInterface'
@@ -41,7 +40,7 @@ import {
DomainEventHandlerInterface,
DomainEventMessageHandlerInterface,
DomainEventPublisherInterface,
DomainEventSubscriberFactoryInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import { MarkFilesToBeRemoved } from '../Domain/UseCase/MarkFilesToBeRemoved/MarkFilesToBeRemoved'
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
@@ -176,7 +175,10 @@ export class ContainerConfigLoader {
container
.bind<DomainEventPublisherInterface>(TYPES.Files_DomainEventPublisher)
.toConstantValue(
new SNSDomainEventPublisher(container.get(TYPES.Files_SNS), container.get(TYPES.Files_SNS_TOPIC_ARN)),
new SNSOpenTelemetryDomainEventPublisher(
container.get(TYPES.Files_SNS),
container.get(TYPES.Files_SNS_TOPIC_ARN),
),
)
}
@@ -295,22 +297,16 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Files_DomainEventMessageHandler)
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.FilesWorker,
eventHandlers,
container.get(TYPES.Files_Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Files_Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Files_DomainEventSubscriberFactory)
.bind<DomainEventSubscriberInterface>(TYPES.Files_DomainEventSubscriber)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.Files_SQS),
container.get(TYPES.Files_SQS_QUEUE_URL),
container.get(TYPES.Files_DomainEventMessageHandler),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.FilesWorker,
container.get<SQSClient>(TYPES.Files_SQS),
container.get<string>(TYPES.Files_SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.Files_DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Files_Logger),
),
)
}

View File

@@ -52,7 +52,7 @@ const TYPES = {
// Handlers
Files_DomainEventMessageHandler: Symbol.for('Files_DomainEventMessageHandler'),
Files_DomainEventSubscriberFactory: Symbol.for('Files_DomainEventSubscriberFactory'),
Files_DomainEventSubscriber: Symbol.for('Files_DomainEventSubscriber'),
Files_AccountDeletionRequestedEventHandler: Symbol.for('Files_AccountDeletionRequestedEventHandler'),
Files_SharedSubscriptionInvitationCanceledEventHandler: Symbol.for(
'Files_SharedSubscriptionInvitationCanceledEventHandler',

View File

@@ -3,6 +3,46 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.17.15](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.14...@standardnotes/home-server@1.17.15) (2023-10-17)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.14](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.13...@standardnotes/home-server@1.17.14) (2023-10-16)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.13](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.12...@standardnotes/home-server@1.17.13) (2023-10-13)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.12](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.11...@standardnotes/home-server@1.17.12) (2023-10-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.11](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.10...@standardnotes/home-server@1.17.11) (2023-10-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.10](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.9...@standardnotes/home-server@1.17.10) (2023-10-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.9](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.8...@standardnotes/home-server@1.17.9) (2023-10-12)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.8](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.7...@standardnotes/home-server@1.17.8) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.7](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.6...@standardnotes/home-server@1.17.7) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.6](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.5...@standardnotes/home-server@1.17.6) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server
## [1.17.5](https://github.com/standardnotes/server/compare/@standardnotes/home-server@1.17.4...@standardnotes/home-server@1.17.5) (2023-10-11)
**Note:** Version bump only for package @standardnotes/home-server

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/home-server",
"version": "1.17.5",
"version": "1.17.15",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.46.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.7...@standardnotes/revisions-server@1.46.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.45.7](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.6...@standardnotes/revisions-server@1.45.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.45.6](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.5...@standardnotes/revisions-server@1.45.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.45.5](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.4...@standardnotes/revisions-server@1.45.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.45.4](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.3...@standardnotes/revisions-server@1.45.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/server/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.45.3](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.2...@standardnotes/revisions-server@1.45.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.45.2](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.1...@standardnotes/revisions-server@1.45.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/revisions-server
## [1.45.1](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.45.0...@standardnotes/revisions-server@1.45.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/revisions-server
# [1.45.0](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.44.4...@standardnotes/revisions-server@1.45.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.44.4](https://github.com/standardnotes/server/compare/@standardnotes/revisions-server@1.44.3...@standardnotes/revisions-server@1.44.4) (2023-10-11)
**Note:** Version bump only for package @standardnotes/revisions-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Revisions)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.Revisions })
sdk.start()
import * as cors from 'cors'

View File

@@ -3,14 +3,14 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.RevisionsWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.RevisionsWorker })
sdk.start()
import { Logger } from 'winston'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
const container = new ContainerConfigLoader('worker')
@@ -22,8 +22,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
TYPES.Revisions_DomainEventSubscriberFactory,
)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.Revisions_DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/revisions-server",
"version": "1.44.4",
"version": "1.46.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -31,16 +31,15 @@ import { SQSClient, SQSClientConfig } from '@aws-sdk/client-sqs'
import {
DomainEventMessageHandlerInterface,
DomainEventHandlerInterface,
DomainEventSubscriberFactoryInterface,
DomainEventPublisherInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import {
SQSEventMessageHandler,
SQSDomainEventSubscriberFactory,
DirectCallEventMessageHandler,
DirectCallDomainEventPublisher,
SNSDomainEventPublisher,
SQSOpenTelemetryEventMessageHandler,
SNSOpenTelemetryDomainEventPublisher,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { DumpRepositoryInterface } from '../Domain/Dump/DumpRepositoryInterface'
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
@@ -180,7 +179,7 @@ export class ContainerConfigLoader {
container
.bind<DomainEventPublisherInterface>(TYPES.Revisions_DomainEventPublisher)
.toDynamicValue((context: interfaces.Context) => {
return new SNSDomainEventPublisher(
return new SNSOpenTelemetryDomainEventPublisher(
context.container.get(TYPES.Revisions_SNS),
context.container.get(TYPES.Revisions_SNS_TOPIC_ARN),
)
@@ -510,25 +509,19 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Revisions_DomainEventMessageHandler)
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.RevisionsWorker,
eventHandlers,
container.get(TYPES.Revisions_Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Revisions_Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Revisions_DomainEventSubscriberFactory)
.toDynamicValue((context: interfaces.Context) => {
return new SQSDomainEventSubscriberFactory(
context.container.get(TYPES.Revisions_SQS),
context.container.get(TYPES.Revisions_SQS_QUEUE_URL),
context.container.get(TYPES.Revisions_DomainEventMessageHandler),
)
})
.bind<DomainEventSubscriberInterface>(TYPES.Revisions_DomainEventSubscriber)
.toConstantValue(
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.RevisionsWorker,
container.get<SQSClient>(TYPES.Revisions_SQS),
container.get<string>(TYPES.Revisions_SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.Revisions_DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Revisions_Logger),
),
)
}
// Inversify Controllers

View File

@@ -65,7 +65,7 @@ const TYPES = {
Revisions_SharedVaultRemovedEventHandler: Symbol.for('Revisions_SharedVaultRemovedEventHandler'),
// Services
Revisions_CrossServiceTokenDecoder: Symbol.for('Revisions_CrossServiceTokenDecoder'),
Revisions_DomainEventSubscriberFactory: Symbol.for('Revisions_DomainEventSubscriberFactory'),
Revisions_DomainEventSubscriber: Symbol.for('Revisions_DomainEventSubscriber'),
Revisions_DomainEventMessageHandler: Symbol.for('Revisions_DomainEventMessageHandler'),
Revisions_DomainEventPublisher: Symbol.for('Revisions_DomainEventPublisher'),
Revisions_DomainEventFactory: Symbol.for('Revisions_DomainEventFactory'),

View File

@@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.26.0](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.7...@standardnotes/scheduler-server@1.26.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.25.7](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.6...@standardnotes/scheduler-server@1.25.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.25.6](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.5...@standardnotes/scheduler-server@1.25.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.25.5](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.4...@standardnotes/scheduler-server@1.25.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.25.4](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.3...@standardnotes/scheduler-server@1.25.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/server/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.25.3](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.2...@standardnotes/scheduler-server@1.25.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.25.2](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.1...@standardnotes/scheduler-server@1.25.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.25.1](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.25.0...@standardnotes/scheduler-server@1.25.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/scheduler-server
# [1.25.0](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.24.3...@standardnotes/scheduler-server@1.25.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.24.3](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.24.2...@standardnotes/scheduler-server@1.24.3) (2023-10-11)
**Note:** Version bump only for package @standardnotes/scheduler-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK, OpenTelemetryTracer } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.SchedulerScheduledTask)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.SchedulerScheduledTask })
sdk.start()
import { Logger } from 'winston'

View File

@@ -3,11 +3,11 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.SchedulerWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.SchedulerWorker })
sdk.start()
import { Logger } from 'winston'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import * as dayjs from 'dayjs'
import * as utc from 'dayjs/plugin/utc'
@@ -26,6 +26,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(TYPES.DomainEventSubscriberFactory)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.24.3",
"version": "1.26.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -6,7 +6,8 @@ import { Container } from 'inversify'
import {
DomainEventHandlerInterface,
DomainEventMessageHandlerInterface,
DomainEventSubscriberFactoryInterface,
DomainEventPublisherInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import { Env } from './Env'
@@ -14,9 +15,9 @@ import TYPES from './Types'
import { AppDataSource } from './DataSource'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
import {
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SQSOpenTelemetryEventMessageHandler,
SNSOpenTelemetryDomainEventPublisher,
SQSEventMessageHandler,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { Timer, TimerInterface } from '@standardnotes/time'
import { PredicateRepositoryInterface } from '../Domain/Predicate/PredicateRepositoryInterface'
@@ -134,8 +135,10 @@ export class ContainerConfigLoader {
container.bind<JobDoneInterpreterInterface>(TYPES.JobDoneInterpreter).to(JobDoneInterpreter)
container
.bind<SNSDomainEventPublisher>(TYPES.DomainEventPublisher)
.toConstantValue(new SNSDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)))
.bind<DomainEventPublisherInterface>(TYPES.DomainEventPublisher)
.toConstantValue(
new SNSOpenTelemetryDomainEventPublisher(container.get(TYPES.SNS), container.get(TYPES.SNS_TOPIC_ARN)),
)
const eventHandlers: Map<string, DomainEventHandlerInterface> = new Map([
['PREDICATE_VERIFIED', container.get(TYPES.PredicateVerifiedEventHandler)],
@@ -146,20 +149,16 @@ export class ContainerConfigLoader {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.SchedulerWorker,
eventHandlers,
container.get(TYPES.Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.bind<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.SchedulerWorker,
container.get<SQSClient>(TYPES.SQS),
container.get<string>(TYPES.SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Logger),
),
)

View File

@@ -25,7 +25,7 @@ const TYPES = {
ExitDiscountAppliedEventHandler: Symbol.for('ExitDiscountAppliedEventHandler'),
// Services
DomainEventPublisher: Symbol.for('DomainEventPublisher'),
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
DomainEventSubscriber: Symbol.for('DomainEventSubscriber'),
DomainEventFactory: Symbol.for('DomainEventFactory'),
DomainEventMessageHandler: Symbol.for('DomainEventMessageHandler'),
Timer: Symbol.for('Timer'),

View File

@@ -3,6 +3,57 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.118.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.7...@standardnotes/syncing-server@1.118.0) (2023-10-17)
### Bug Fixes
* **syncing-server:** binding ([5b06ea9](https://github.com/standardnotes/syncing-server-js/commit/5b06ea94f9734c1a82549235058b7f63c7665fb7))
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/syncing-server-js/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.117.7](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.6...@standardnotes/syncing-server@1.117.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/syncing-server-js/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.117.6](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.5...@standardnotes/syncing-server@1.117.6) (2023-10-12)
### Bug Fixes
* passing key params for backup requests ([#867](https://github.com/standardnotes/syncing-server-js/issues/867)) ([0739816](https://github.com/standardnotes/syncing-server-js/commit/07398169c80e7871cd04d889f471c3eef70e1aae))
## [1.117.5](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.4...@standardnotes/syncing-server@1.117.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.117.4](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.3...@standardnotes/syncing-server@1.117.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/syncing-server-js/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/syncing-server-js/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.117.3](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.2...@standardnotes/syncing-server@1.117.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.117.2](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.1...@standardnotes/syncing-server@1.117.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.117.1](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.117.0...@standardnotes/syncing-server@1.117.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/syncing-server
# [1.117.0](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.116.5...@standardnotes/syncing-server@1.117.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/syncing-server-js/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.116.5](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.116.4...@standardnotes/syncing-server@1.116.5) (2023-10-11)
**Note:** Version bump only for package @standardnotes/syncing-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.SyncingServer)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.SyncingServer })
sdk.start()
import '../src/Infra/InversifyExpressUtils/AnnotatedHealthCheckController'

View File

@@ -3,14 +3,14 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.SyncingServerWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.SyncingServerWorker })
sdk.start()
import { Logger } from 'winston'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
const container = new ContainerConfigLoader('worker')
@@ -20,11 +20,9 @@ void container.load().then((container) => {
const logger: Logger = container.get(TYPES.Sync_Logger)
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(
TYPES.Sync_DomainEventSubscriberFactory,
)
logger.info('Starting worker...')
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.Sync_DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.116.5",
"version": "1.118.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -13,10 +13,9 @@ import { Item } from '../Domain/Item/Item'
import {
DirectCallDomainEventPublisher,
DirectCallEventMessageHandler,
SNSDomainEventPublisher,
SQSDomainEventSubscriberFactory,
SNSOpenTelemetryDomainEventPublisher,
SQSEventMessageHandler,
SQSOpenTelemetryEventMessageHandler,
SQSOpenTelemetryDomainEventSubscriber,
} from '@standardnotes/domain-events-infra'
import { DomainEventFactoryInterface } from '../Domain/Event/DomainEventFactoryInterface'
import { DomainEventFactory } from '../Domain/Event/DomainEventFactory'
@@ -44,11 +43,10 @@ import { ContentDecoder, ContentDecoderInterface } from '@standardnotes/common'
import {
DomainEventMessageHandlerInterface,
DomainEventHandlerInterface,
DomainEventSubscriberFactoryInterface,
DomainEventPublisherInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import axios, { AxiosInstance } from 'axios'
import { AuthHttpServiceInterface } from '../Domain/Auth/AuthHttpServiceInterface'
import { ExtensionsHttpService } from '../Domain/Extension/ExtensionsHttpService'
import { ExtensionsHttpServiceInterface } from '../Domain/Extension/ExtensionsHttpServiceInterface'
import { AccountDeletionRequestedEventHandler } from '../Domain/Handler/AccountDeletionRequestedEventHandler'
@@ -57,7 +55,6 @@ import { EmailBackupRequestedEventHandler } from '../Domain/Handler/EmailBackupR
import { ItemRevisionCreationRequestedEventHandler } from '../Domain/Handler/ItemRevisionCreationRequestedEventHandler'
import { ItemBackupServiceInterface } from '../Domain/Item/ItemBackupServiceInterface'
import { FSItemBackupService } from '../Infra/FS/FSItemBackupService'
import { AuthHttpService } from '../Infra/HTTP/AuthHttpService'
import { S3ItemBackupService } from '../Infra/S3/S3ItemBackupService'
import {
ControllerContainer,
@@ -286,30 +283,26 @@ export class ContainerConfigLoader {
container
.bind<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher)
.toDynamicValue((context: interfaces.Context) => {
return new SNSDomainEventPublisher(
return new SNSOpenTelemetryDomainEventPublisher(
context.container.get(TYPES.Sync_SNS),
context.container.get(TYPES.Sync_SNS_TOPIC_ARN),
)
})
container.bind<SQSClient>(TYPES.Sync_SQS).toDynamicValue((context: interfaces.Context) => {
const env: Env = context.container.get(TYPES.Sync_Env)
const sqsConfig: SQSClientConfig = {
region: env.get('SQS_AWS_REGION'),
const sqsConfig: SQSClientConfig = {
region: env.get('SQS_AWS_REGION', true),
}
if (env.get('SQS_ENDPOINT', true)) {
sqsConfig.endpoint = env.get('SQS_ENDPOINT', true)
}
if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) {
sqsConfig.credentials = {
accessKeyId: env.get('SQS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
if (env.get('SQS_ENDPOINT', true)) {
sqsConfig.endpoint = env.get('SQS_ENDPOINT', true)
}
if (env.get('SQS_ACCESS_KEY_ID', true) && env.get('SQS_SECRET_ACCESS_KEY', true)) {
sqsConfig.credentials = {
accessKeyId: env.get('SQS_ACCESS_KEY_ID', true),
secretAccessKey: env.get('SQS_SECRET_ACCESS_KEY', true),
}
}
return new SQSClient(sqsConfig)
})
}
const sqsClient = new SQSClient(sqsConfig)
container.bind<SQSClient>(TYPES.Sync_SQS).toConstantValue(sqsClient)
container.bind<S3Client | undefined>(TYPES.Sync_S3).toDynamicValue((context: interfaces.Context) => {
const env: Env = context.container.get(TYPES.Sync_Env)
@@ -1106,17 +1099,6 @@ export class ContainerConfigLoader {
],
])
if (!isConfiguredForHomeServer) {
container.bind(TYPES.Sync_AUTH_SERVER_URL).toConstantValue(env.get('AUTH_SERVER_URL'))
container
.bind<AuthHttpServiceInterface>(TYPES.Sync_AuthHttpService)
.toDynamicValue((context: interfaces.Context) => {
return new AuthHttpService(
context.container.get(TYPES.Sync_HTTPClient),
context.container.get(TYPES.Sync_AUTH_SERVER_URL),
)
})
container
.bind<EmailBackupRequestedEventHandler>(TYPES.Sync_EmailBackupRequestedEventHandler)
.toConstantValue(
@@ -1125,7 +1107,6 @@ export class ContainerConfigLoader {
isSecondaryDatabaseEnabled
? container.get<ItemRepositoryInterface>(TYPES.Sync_MongoDBItemRepository)
: null,
container.get<AuthHttpServiceInterface>(TYPES.Sync_AuthHttpService),
container.get<ItemBackupServiceInterface>(TYPES.Sync_ItemBackupService),
container.get<DomainEventPublisherInterface>(TYPES.Sync_DomainEventPublisher),
container.get<DomainEventFactoryInterface>(TYPES.Sync_DomainEventFactory),
@@ -1152,27 +1133,21 @@ export class ContainerConfigLoader {
} else {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.Sync_DomainEventMessageHandler)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger)))
container
.bind<DomainEventSubscriberInterface>(TYPES.Sync_DomainEventSubscriber)
.toConstantValue(
isConfiguredForHomeServerOrSelfHosting
? new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Sync_Logger))
: new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.SyncingServerWorker,
eventHandlers,
container.get(TYPES.Sync_Logger),
),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.SyncingServerWorker,
container.get<SQSClient>(TYPES.Sync_SQS),
container.get<string>(TYPES.Sync_SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.Sync_DomainEventMessageHandler),
container.get<Logger>(TYPES.Sync_Logger),
),
)
}
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.Sync_DomainEventSubscriberFactory)
.toDynamicValue((context: interfaces.Context) => {
return new SQSDomainEventSubscriberFactory(
context.container.get(TYPES.Sync_SQS),
context.container.get(TYPES.Sync_SQS_QUEUE_URL),
context.container.get(TYPES.Sync_DomainEventMessageHandler),
)
})
container
.bind<ControllerContainerInterface>(TYPES.Sync_ControllerContainer)
.toConstantValue(configuration?.controllerConatiner ?? new ControllerContainer())

View File

@@ -36,7 +36,6 @@ const TYPES = {
Sync_SQS_AWS_REGION: Symbol.for('Sync_SQS_AWS_REGION'),
Sync_AUTH_JWT_SECRET: Symbol.for('Sync_AUTH_JWT_SECRET'),
Sync_EXTENSIONS_SERVER_URL: Symbol.for('Sync_EXTENSIONS_SERVER_URL'),
Sync_AUTH_SERVER_URL: Symbol.for('Sync_AUTH_SERVER_URL'),
Sync_S3_AWS_REGION: Symbol.for('Sync_S3_AWS_REGION'),
Sync_S3_BACKUP_BUCKET_NAME: Symbol.for('Sync_S3_BACKUP_BUCKET_NAME'),
Sync_EMAIL_ATTACHMENT_MAX_BYTE_SIZE: Symbol.for('Sync_EMAIL_ATTACHMENT_MAX_BYTE_SIZE'),
@@ -106,7 +105,7 @@ const TYPES = {
// Services
Sync_ContentDecoder: Symbol.for('Sync_ContentDecoder'),
Sync_DomainEventPublisher: Symbol.for('Sync_DomainEventPublisher'),
Sync_DomainEventSubscriberFactory: Symbol.for('Sync_DomainEventSubscriberFactory'),
Sync_DomainEventSubscriber: Symbol.for('Sync_DomainEventSubscriber'),
Sync_DomainEventFactory: Symbol.for('Sync_DomainEventFactory'),
Sync_DomainEventMessageHandler: Symbol.for('Sync_DomainEventMessageHandler'),
Sync_HTTPClient: Symbol.for('Sync_HTTPClient'),
@@ -115,7 +114,6 @@ const TYPES = {
Sync_SyncResponseFactory20161215: Symbol.for('Sync_SyncResponseFactory20161215'),
Sync_SyncResponseFactory20200115: Symbol.for('Sync_SyncResponseFactory20200115'),
Sync_SyncResponseFactoryResolver: Symbol.for('Sync_SyncResponseFactoryResolver'),
Sync_AuthHttpService: Symbol.for('Sync_AuthHttpService'),
Sync_ExtensionsHttpService: Symbol.for('Sync_ExtensionsHttpService'),
Sync_ItemBackupService: Symbol.for('Sync_ItemBackupService'),
Sync_ItemSaveValidator: Symbol.for('Sync_ItemSaveValidator'),

View File

@@ -1,5 +0,0 @@
import { KeyParamsData } from '@standardnotes/responses'
export interface AuthHttpServiceInterface {
getUserKeyParams(userUuid: string): Promise<KeyParamsData>
}

View File

@@ -1,4 +1,3 @@
import { KeyParamsData } from '@standardnotes/responses'
import {
DomainEventHandlerInterface,
DomainEventPublisherInterface,
@@ -6,7 +5,6 @@ import {
} from '@standardnotes/domain-events'
import { EmailLevel } from '@standardnotes/domain-core'
import { Logger } from 'winston'
import { AuthHttpServiceInterface } from '../Auth/AuthHttpServiceInterface'
import { DomainEventFactoryInterface } from '../Event/DomainEventFactoryInterface'
import { ItemBackupServiceInterface } from '../Item/ItemBackupServiceInterface'
import { ItemRepositoryInterface } from '../Item/ItemRepositoryInterface'
@@ -18,7 +16,6 @@ export class EmailBackupRequestedEventHandler implements DomainEventHandlerInter
constructor(
private primaryItemRepository: ItemRepositoryInterface,
private secondaryItemRepository: ItemRepositoryInterface | null,
private authHttpService: AuthHttpServiceInterface,
private itemBackupService: ItemBackupServiceInterface,
private domainEventPublisher: DomainEventPublisherInterface,
private domainEventFactory: DomainEventFactoryInterface,
@@ -40,19 +37,6 @@ export class EmailBackupRequestedEventHandler implements DomainEventHandlerInter
event: EmailBackupRequestedEvent,
itemRepository: ItemRepositoryInterface,
): Promise<void> {
let authParams: KeyParamsData
try {
authParams = await this.authHttpService.getUserKeyParams(event.payload.userUuid)
} catch (error) {
this.logger.error(
`Could not get user key params from auth service for user ${event.payload.userUuid}: ${
(error as Error).message
}`,
)
return
}
const itemQuery: ItemQuery = {
userUuid: event.payload.userUuid,
sortBy: 'updated_at_timestamp',
@@ -75,7 +59,7 @@ export class EmailBackupRequestedEventHandler implements DomainEventHandlerInter
const bundleBackupFileNames = await this.itemBackupService.backup(
items,
authParams,
event.payload.keyParams,
this.emailAttachmentMaxByteSize,
)
@@ -88,11 +72,11 @@ export class EmailBackupRequestedEventHandler implements DomainEventHandlerInter
for (const backupFileName of backupFileNames) {
await this.domainEventPublisher.publish(
this.domainEventFactory.createEmailRequestedEvent({
body: getBody(authParams.identifier as string),
body: getBody(event.payload.keyParams.identifier as string),
level: EmailLevel.LEVELS.System,
messageIdentifier: 'DATA_BACKUP',
subject: getSubject(bundleIndex++, backupFileNames.length, dateOnly),
userEmail: authParams.identifier as string,
userEmail: event.payload.keyParams.identifier as string,
sender: 'backups@standardnotes.org',
attachments: [
{

View File

@@ -1,27 +0,0 @@
import { KeyParamsData } from '@standardnotes/responses'
import { AxiosInstance } from 'axios'
import { AuthHttpServiceInterface } from '../../Domain/Auth/AuthHttpServiceInterface'
export class AuthHttpService implements AuthHttpServiceInterface {
constructor(
private httpClient: AxiosInstance,
private authServerUrl: string,
) {}
async getUserKeyParams(userUuid: string): Promise<KeyParamsData> {
const keyParamsResponse = await this.httpClient.request({
method: 'GET',
timeout: 10000,
headers: {
Accept: 'application/json',
},
url: `${this.authServerUrl}/users/params?uuid=${userUuid}`,
validateStatus:
/* istanbul ignore next */
(status: number) => status >= 200 && status < 500,
})
return keyParamsResponse.data
}
}

View File

@@ -3,6 +3,51 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.17.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.7...@standardnotes/websockets-server@1.17.0) (2023-10-17)
### Features
* add wrapping sqs receive message with open telemetry ([aba4f90](https://github.com/standardnotes/server/commit/aba4f90485e1b40baac34561321a5381945aa27e))
## [1.16.7](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.6...@standardnotes/websockets-server@1.16.7) (2023-10-13)
### Bug Fixes
* reduce the amount of metrics gathered in telemetery ([32fe8d0](https://github.com/standardnotes/server/commit/32fe8d0a8523d6e1875cd0814c0cbdf27d8df7b3))
## [1.16.6](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.5...@standardnotes/websockets-server@1.16.6) (2023-10-12)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.16.5](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.4...@standardnotes/websockets-server@1.16.5) (2023-10-12)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.16.4](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.3...@standardnotes/websockets-server@1.16.4) (2023-10-12)
### Bug Fixes
* disable opentelemetry tracing on async worker jobs ([e0b19ef](https://github.com/standardnotes/server/commit/e0b19ef011197c854cb6e833dbaa982f661e8d17))
* disable sqs open telemetry manual tracing in favour of automated instrumentation ([337eae7](https://github.com/standardnotes/server/commit/337eae73c6cb18ae872527b06f6c23e1c48b6dff))
## [1.16.3](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.2...@standardnotes/websockets-server@1.16.3) (2023-10-12)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.16.2](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.1...@standardnotes/websockets-server@1.16.2) (2023-10-11)
**Note:** Version bump only for package @standardnotes/websockets-server
## [1.16.1](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.16.0...@standardnotes/websockets-server@1.16.1) (2023-10-11)
**Note:** Version bump only for package @standardnotes/websockets-server
# [1.16.0](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.15.4...@standardnotes/websockets-server@1.16.0) (2023-10-11)
### Features
* add opentelemetry tracing in distributed system ([72c9b28](https://github.com/standardnotes/server/commit/72c9b28ebe108a2011d1a598fd4682132a533126))
## [1.15.4](https://github.com/standardnotes/server/compare/@standardnotes/websockets-server@1.15.3...@standardnotes/websockets-server@1.15.4) (2023-10-11)
**Note:** Version bump only for package @standardnotes/websockets-server

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.Websockets)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.Websockets })
sdk.start()
import '../src/Infra/InversifyExpressUtils/AnnotatedHealthCheckController'

View File

@@ -3,7 +3,7 @@ import 'reflect-metadata'
import { OpenTelemetrySDK } from '@standardnotes/domain-events-infra'
import { ServiceIdentifier } from '@standardnotes/domain-core'
const sdk = new OpenTelemetrySDK(ServiceIdentifier.NAMES.WebsocketsWorker)
const sdk = new OpenTelemetrySDK({ serviceName: ServiceIdentifier.NAMES.WebsocketsWorker })
sdk.start()
import { Logger } from 'winston'
@@ -11,7 +11,7 @@ import { Logger } from 'winston'
import { ContainerConfigLoader } from '../src/Bootstrap/Container'
import TYPES from '../src/Bootstrap/Types'
import { Env } from '../src/Bootstrap/Env'
import { DomainEventSubscriberFactoryInterface } from '@standardnotes/domain-events'
import { DomainEventSubscriberInterface } from '@standardnotes/domain-events'
const container = new ContainerConfigLoader()
void container.load().then((container) => {
@@ -22,6 +22,7 @@ void container.load().then((container) => {
logger.info('Starting worker...')
const subscriberFactory: DomainEventSubscriberFactoryInterface = container.get(TYPES.DomainEventSubscriberFactory)
subscriberFactory.create().start()
const subscriber = container.get<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
subscriber.start()
})

View File

@@ -1,6 +1,6 @@
{
"name": "@standardnotes/websockets-server",
"version": "1.15.4",
"version": "1.17.0",
"engines": {
"node": ">=18.0.0 <21.0.0"
},

View File

@@ -9,7 +9,7 @@ import { Container } from 'inversify'
import {
DomainEventHandlerInterface,
DomainEventMessageHandlerInterface,
DomainEventSubscriberFactoryInterface,
DomainEventSubscriberInterface,
} from '@standardnotes/domain-events'
import { Env } from './Env'
import TYPES from './Types'
@@ -18,10 +18,7 @@ import { RedisWebSocketsConnectionRepository } from '../Infra/Redis/RedisWebSock
import { AddWebSocketsConnection } from '../Domain/UseCase/AddWebSocketsConnection/AddWebSocketsConnection'
import { RemoveWebSocketsConnection } from '../Domain/UseCase/RemoveWebSocketsConnection/RemoveWebSocketsConnection'
import { WebSocketsClientMessenger } from '../Infra/WebSockets/WebSocketsClientMessenger'
import {
SQSDomainEventSubscriberFactory,
SQSOpenTelemetryEventMessageHandler,
} from '@standardnotes/domain-events-infra'
import { SQSEventMessageHandler, SQSOpenTelemetryDomainEventSubscriber } from '@standardnotes/domain-events-infra'
import { ApiGatewayAuthMiddleware } from '../Controller/ApiGatewayAuthMiddleware'
import {
@@ -144,20 +141,16 @@ export class ContainerConfigLoader {
container
.bind<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler)
.toConstantValue(
new SQSOpenTelemetryEventMessageHandler(
ServiceIdentifier.NAMES.WebsocketsWorker,
eventHandlers,
container.get(TYPES.Logger),
),
)
.toConstantValue(new SQSEventMessageHandler(eventHandlers, container.get(TYPES.Logger)))
container
.bind<DomainEventSubscriberFactoryInterface>(TYPES.DomainEventSubscriberFactory)
.bind<DomainEventSubscriberInterface>(TYPES.DomainEventSubscriber)
.toConstantValue(
new SQSDomainEventSubscriberFactory(
container.get(TYPES.SQS),
container.get(TYPES.SQS_QUEUE_URL),
container.get(TYPES.DomainEventMessageHandler),
new SQSOpenTelemetryDomainEventSubscriber(
ServiceIdentifier.NAMES.WebsocketsWorker,
container.get<SQSClient>(TYPES.SQS),
container.get<string>(TYPES.SQS_QUEUE_URL),
container.get<DomainEventMessageHandlerInterface>(TYPES.DomainEventMessageHandler),
container.get<winston.Logger>(TYPES.Logger),
),
)

View File

@@ -27,7 +27,7 @@ const TYPES = {
// Services
CrossServiceTokenDecoder: Symbol.for('CrossServiceTokenDecoder'),
WebSocketConnectionTokenEncoder: Symbol.for('WebSocketConnectionTokenEncoder'),
DomainEventSubscriberFactory: Symbol.for('DomainEventSubscriberFactory'),
DomainEventSubscriber: Symbol.for('DomainEventSubscriber'),
DomainEventMessageHandler: Symbol.for('DomainEventMessageHandler'),
HTTPClient: Symbol.for('HTTPClient'),
WebSocketsClientMessenger: Symbol.for('WebSocketsClientMessenger'),

View File

@@ -4438,7 +4438,7 @@ __metadata:
opentelemetry-instrumentation-typeorm: "npm:^0.39.1"
prettier: "npm:^3.0.3"
reflect-metadata: "npm:^0.1.13"
sqs-consumer: "npm:^7.3.0"
sqs-consumer: "npm:7.4.0-canary.0"
ts-jest: "npm:^29.1.0"
typescript: "npm:^5.0.4"
winston: "npm:^3.8.1"
@@ -12735,15 +12735,15 @@ __metadata:
languageName: node
linkType: hard
"sqs-consumer@npm:^7.3.0":
version: 7.3.0
resolution: "sqs-consumer@npm:7.3.0"
"sqs-consumer@npm:7.4.0-canary.0":
version: 7.4.0-canary.0
resolution: "sqs-consumer@npm:7.4.0-canary.0"
dependencies:
"@aws-sdk/client-sqs": "npm:^3.363.0"
debug: "npm:^4.3.4"
peerDependencies:
"@aws-sdk/client-sqs": ^3.363.0
checksum: 367ea2a6f3ea5da331efbb7052e643f1657aafa138c8404f336389effbbaba734858bd4daf29c86ab0b4c8a015863ddac6b19482302324f46d45a38fae731f54
checksum: 7ecff41c977775f5e61e9f58f79a86b3939bd9ade9cecd7532d8344c454ec059267645c87544d38dbb4c4403e65c908d51c69aee3776c009310c3ba79c1172c7
languageName: node
linkType: hard