Compare commits

...

8 Commits

Author SHA1 Message Date
standardci 7064bd4c4c chore(release): publish new version
- @standardnotes/auth-server@1.38.1
2022-10-05 12:28:08 +00:00
Karol Sójko a02a26ebdc fix(auth): group typeorm annotations 2022-10-05 14:26:36 +02:00
standardci b92af6cec6 chore(release): publish new version
- @standardnotes/auth-server@1.38.0
2022-10-05 12:16:16 +00:00
Karol Sójko 3091177700 feat(auth): add groups model and database structure 2022-10-05 14:14:22 +02:00
standardci be8838d338 chore(release): publish new version
- @standardnotes/analytics@1.35.0
 - @standardnotes/api-gateway@1.26.0
 - @standardnotes/auth-server@1.37.1
 - @standardnotes/domain-events-infra@1.8.17
 - @standardnotes/domain-events@2.63.0
 - @standardnotes/event-store@1.3.22
 - @standardnotes/files-server@1.6.8
 - @standardnotes/scheduler-server@1.10.36
 - @standardnotes/syncing-server@1.8.20
2022-10-05 08:04:23 +00:00
Karol Sójko 84e8a5cc6e feat(api-gateway): include increments count in statistics measures report 2022-10-05 10:02:55 +02:00
standardci d5db578bfd chore(release): publish new version
- @standardnotes/api-gateway@1.25.0
2022-10-05 07:55:03 +00:00
Karol Sójko 7429f5c8e9 feat(api-gateway): add detailed payments statistics to report 2022-10-05 09:53:25 +02:00
29 changed files with 234 additions and 14 deletions
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.35.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@1.34.0...@standardnotes/analytics@1.35.0) (2022-10-05)
### Features
* **api-gateway:** include increments count in statistics measures report ([84e8a5c](https://github.com/standardnotes/server/commit/84e8a5cc6e6ba216f1c0737a7a93aba581eced0f))
# [1.34.0](https://github.com/standardnotes/server/compare/@standardnotes/analytics@1.33.0...@standardnotes/analytics@1.34.0) (2022-10-04)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/analytics",
"version": "1.34.0",
"version": "1.35.0",
"engines": {
"node": ">=14.0.0 <17.0.0"
},
@@ -12,4 +12,5 @@ export interface StatisticsStoreInterface {
setMeasure(measure: StatisticsMeasure, value: number, periods: Period[]): Promise<void>
getMeasureAverage(measure: StatisticsMeasure, period: Period): Promise<number>
getMeasureTotal(measure: StatisticsMeasure, periodOrPeriodKey: Period | string): Promise<number>
getMeasureIncrementCounts(measure: StatisticsMeasure, period: Period): Promise<number>
}
@@ -8,6 +8,17 @@ import { StatisticsStoreInterface } from '../../Domain/Statistics/StatisticsStor
export class RedisStatisticsStore implements StatisticsStoreInterface {
constructor(private periodKeyGenerator: PeriodKeyGeneratorInterface, private redisClient: IORedis.Redis) {}
async getMeasureIncrementCounts(measure: StatisticsMeasure, period: Period): Promise<number> {
const increments = await this.redisClient.get(
`count:increments:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`,
)
if (increments === null) {
return 0
}
return +increments
}
async setMeasure(measure: StatisticsMeasure, value: number, periods: Period[]): Promise<void> {
const pipeline = this.redisClient.pipeline()
@@ -45,16 +56,15 @@ export class RedisStatisticsStore implements StatisticsStoreInterface {
}
async getMeasureAverage(measure: StatisticsMeasure, period: Period): Promise<number> {
const increments = await this.redisClient.get(
`count:increments:${measure}:timespan:${this.periodKeyGenerator.getPeriodKey(period)}`,
)
if (increments === null) {
const increments = await this.getMeasureIncrementCounts(measure, period)
if (increments === 0) {
return 0
}
const totalValue = await this.getMeasureTotal(measure, period)
return totalValue / +increments
return totalValue / increments
}
async getYesterdayOutOfSyncIncidents(): Promise<number> {
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [1.26.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.25.0...@standardnotes/api-gateway@1.26.0) (2022-10-05)
### Features
* **api-gateway:** include increments count in statistics measures report ([84e8a5c](https://github.com/standardnotes/api-gateway/commit/84e8a5cc6e6ba216f1c0737a7a93aba581eced0f))
# [1.25.0](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.24.5...@standardnotes/api-gateway@1.25.0) (2022-10-05)
### Features
* **api-gateway:** add detailed payments statistics to report ([7429f5c](https://github.com/standardnotes/api-gateway/commit/7429f5c8e9dafdba557cdbfb3d9020513fc7a9ee))
## [1.24.5](https://github.com/standardnotes/api-gateway/compare/@standardnotes/api-gateway@1.24.4...@standardnotes/api-gateway@1.24.5) (2022-10-04)
**Note:** Version bump only for package @standardnotes/api-gateway
+9
View File
@@ -94,6 +94,14 @@ const requestReport = async (
const statisticMeasureNames = [
StatisticsMeasure.Income,
StatisticsMeasure.PlusSubscriptionInitialAnnualPaymentsIncome,
StatisticsMeasure.PlusSubscriptionInitialMonthlyPaymentsIncome,
StatisticsMeasure.PlusSubscriptionRenewingAnnualPaymentsIncome,
StatisticsMeasure.PlusSubscriptionRenewingMonthlyPaymentsIncome,
StatisticsMeasure.ProSubscriptionInitialAnnualPaymentsIncome,
StatisticsMeasure.ProSubscriptionInitialMonthlyPaymentsIncome,
StatisticsMeasure.ProSubscriptionRenewingAnnualPaymentsIncome,
StatisticsMeasure.ProSubscriptionRenewingMonthlyPaymentsIncome,
StatisticsMeasure.Refunds,
StatisticsMeasure.RegistrationLength,
StatisticsMeasure.SubscriptionLength,
@@ -113,6 +121,7 @@ const requestReport = async (
period,
totalValue: await statisticsStore.getMeasureTotal(statisticMeasureName, period),
average: await statisticsStore.getMeasureAverage(statisticMeasureName, period),
increments: await statisticsStore.getMeasureIncrementCounts(statisticMeasureName, period),
})
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/api-gateway",
"version": "1.24.5",
"version": "1.26.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.38.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.38.0...@standardnotes/auth-server@1.38.1) (2022-10-05)
### Bug Fixes
* **auth:** group typeorm annotations ([a02a26e](https://github.com/standardnotes/server/commit/a02a26ebdcc1decda84b265cd75b4932b7131c76))
# [1.38.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.37.1...@standardnotes/auth-server@1.38.0) (2022-10-05)
### Features
* **auth:** add groups model and database structure ([3091177](https://github.com/standardnotes/server/commit/309117770007b8f2d67dcf86fa2c4b9b436e0aef))
## [1.37.1](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.37.0...@standardnotes/auth-server@1.37.1) (2022-10-05)
**Note:** Version bump only for package @standardnotes/auth-server
# [1.37.0](https://github.com/standardnotes/server/compare/@standardnotes/auth-server@1.36.4...@standardnotes/auth-server@1.37.0) (2022-10-04)
### Features
@@ -0,0 +1,28 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
export class groups1664971834974 implements MigrationInterface {
name = 'groups1664971834974'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
'CREATE TABLE `groups` (`uuid` varchar(36) NOT NULL, `type` varchar(64) NOT NULL, PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
)
await queryRunner.query(
'CREATE TABLE `group_users` (`uuid` varchar(36) NOT NULL, `access_level` varchar(64) NOT NULL, `user_uuid` varchar(36) NOT NULL, `group_uuid` varchar(36) NOT NULL, `encrypted_group_key` varchar(255) NOT NULL, UNIQUE INDEX `index_group_users_on_group_and_user` (`user_uuid`, `group_uuid`), PRIMARY KEY (`uuid`)) ENGINE=InnoDB',
)
await queryRunner.query(
'ALTER TABLE `group_users` ADD CONSTRAINT `FK_b97989611efde2c54b074127920` FOREIGN KEY (`user_uuid`) REFERENCES `users`(`uuid`) ON DELETE CASCADE ON UPDATE NO ACTION',
)
await queryRunner.query(
'ALTER TABLE `group_users` ADD CONSTRAINT `FK_9d1bcb8c649eb05d7a2eb62114e` FOREIGN KEY (`group_uuid`) REFERENCES `groups`(`uuid`) ON DELETE CASCADE ON UPDATE NO ACTION',
)
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query('ALTER TABLE `group_users` DROP FOREIGN KEY `FK_9d1bcb8c649eb05d7a2eb62114e`')
await queryRunner.query('ALTER TABLE `group_users` DROP FOREIGN KEY `FK_b97989611efde2c54b074127920`')
await queryRunner.query('DROP INDEX `index_group_users_on_group_and_user` ON `group_users`')
await queryRunner.query('DROP TABLE `group_users`')
await queryRunner.query('DROP TABLE `groups`')
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/auth-server",
"version": "1.37.0",
"version": "1.38.1",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -1,5 +1,7 @@
import { DataSource, LoggerOptions } from 'typeorm'
import { AnalyticsEntity } from '../Domain/Analytics/AnalyticsEntity'
import { Group } from '../Domain/Group/Group'
import { GroupUser } from '../Domain/Group/GroupUser'
import { Permission } from '../Domain/Permission/Permission'
import { Role } from '../Domain/Role/Role'
import { RevokedSession } from '../Domain/Session/RevokedSession'
@@ -57,6 +59,8 @@ export const AppDataSource = new DataSource({
SharedSubscriptionInvitation,
SubscriptionSetting,
AnalyticsEntity,
Group,
GroupUser,
],
migrations: [env.get('DB_MIGRATIONS_PATH', true) ?? 'dist/migrations/*.js'],
migrationsRun: true,
+23
View File
@@ -0,0 +1,23 @@
import { Column, Entity, OneToMany, PrimaryGeneratedColumn } from 'typeorm'
import { User } from '../User/User'
import { GroupType } from './GroupType'
import { GroupUser } from './GroupUser'
@Entity({ name: 'groups' })
export class Group {
@PrimaryGeneratedColumn('uuid')
declare uuid: string
@Column({
length: 64,
})
declare type: GroupType
@OneToMany(
/* istanbul ignore next */
() => GroupUser,
/* istanbul ignore next */
(groupUser) => groupUser.group,
)
declare users: Promise<User[]>
}
@@ -0,0 +1,6 @@
export enum GroupAccessLevel {
Owner = 'owner',
Admin = 'admin',
ReadOnly = 'read-only',
WriteAndRead = 'write-and-read',
}
@@ -0,0 +1,4 @@
export enum GroupType {
Team = 'team',
Private = 'private',
}
@@ -0,0 +1,64 @@
import { Column, Entity, Index, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm'
import { User } from '../User/User'
import { Group } from './Group'
import { GroupAccessLevel } from './GroupAccessLevel'
@Entity({ name: 'group_users' })
@Index('index_group_users_on_group_and_user', ['userUuid', 'groupUuid'], { unique: true })
export class GroupUser {
@PrimaryGeneratedColumn('uuid')
declare uuid: string
@Column({
name: 'access_level',
length: 64,
})
declare accessLevel: GroupAccessLevel
@Column({
name: 'user_uuid',
length: 36,
})
declare userUuid: string
@Column({
name: 'group_uuid',
length: 36,
})
declare groupUuid: string
@Column({
name: 'encrypted_group_key',
length: 255,
type: 'varchar',
})
declare encryptedGroupKey: string
@ManyToOne(
/* istanbul ignore next */
() => User,
/* istanbul ignore next */
(user) => user.groups,
/* istanbul ignore next */
{ onDelete: 'CASCADE' },
)
@JoinColumn(
/* istanbul ignore next */
{ name: 'user_uuid' },
)
declare user: Promise<User>
@ManyToOne(
/* istanbul ignore next */
() => Group,
/* istanbul ignore next */
(group) => group.users,
/* istanbul ignore next */
{ onDelete: 'CASCADE' },
)
@JoinColumn(
/* istanbul ignore next */
{ name: 'group_uuid' },
)
declare group: Promise<Group>
}
+10
View File
@@ -5,6 +5,8 @@ import { Setting } from '../Setting/Setting'
import { UserSubscription } from '../Subscription/UserSubscription'
import { AnalyticsEntity } from '../Analytics/AnalyticsEntity'
import { ProtocolVersion } from '@standardnotes/common'
import { Group } from '../Group/Group'
import { GroupUser } from '../Group/GroupUser'
@Entity({ name: 'users' })
export class User {
@@ -192,6 +194,14 @@ export class User {
)
declare analyticsEntity: Promise<AnalyticsEntity>
@OneToMany(
/* istanbul ignore next */
() => GroupUser,
/* istanbul ignore next */
(groupUser) => groupUser.user,
)
declare groups: Promise<Group[]>
supportsSessions(): boolean {
return parseInt(this.version) >= parseInt(ProtocolVersion.V004)
}
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.8.17](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.8.16...@standardnotes/domain-events-infra@1.8.17) (2022-10-05)
**Note:** Version bump only for package @standardnotes/domain-events-infra
## [1.8.16](https://github.com/standardnotes/server/compare/@standardnotes/domain-events-infra@1.8.15...@standardnotes/domain-events-infra@1.8.16) (2022-10-04)
**Note:** Version bump only for package @standardnotes/domain-events-infra
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events-infra",
"version": "1.8.16",
"version": "1.8.17",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
# [2.63.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.62.0...@standardnotes/domain-events@2.63.0) (2022-10-05)
### Features
* **api-gateway:** include increments count in statistics measures report ([84e8a5c](https://github.com/standardnotes/server/commit/84e8a5cc6e6ba216f1c0737a7a93aba581eced0f))
# [2.62.0](https://github.com/standardnotes/server/compare/@standardnotes/domain-events@2.61.1...@standardnotes/domain-events@2.62.0) (2022-10-04)
### Features
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/domain-events",
"version": "2.62.0",
"version": "2.63.0",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
@@ -16,6 +16,7 @@ export interface DailyAnalyticsReportGeneratedEventPayload {
name: string
totalValue: number
average: number
increments: number
period: number
}>
activityStatisticsOverTime: Array<{
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.3.22](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.3.21...@standardnotes/event-store@1.3.22) (2022-10-05)
**Note:** Version bump only for package @standardnotes/event-store
## [1.3.21](https://github.com/standardnotes/server/compare/@standardnotes/event-store@1.3.20...@standardnotes/event-store@1.3.21) (2022-10-04)
**Note:** Version bump only for package @standardnotes/event-store
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/event-store",
"version": "1.3.21",
"version": "1.3.22",
"description": "Event Store Service",
"private": true,
"main": "dist/src/index.js",
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.6.8](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.6.7...@standardnotes/files-server@1.6.8) (2022-10-05)
**Note:** Version bump only for package @standardnotes/files-server
## [1.6.7](https://github.com/standardnotes/files/compare/@standardnotes/files-server@1.6.6...@standardnotes/files-server@1.6.7) (2022-10-04)
**Note:** Version bump only for package @standardnotes/files-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/files-server",
"version": "1.6.7",
"version": "1.6.8",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.10.36](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.10.35...@standardnotes/scheduler-server@1.10.36) (2022-10-05)
**Note:** Version bump only for package @standardnotes/scheduler-server
## [1.10.35](https://github.com/standardnotes/server/compare/@standardnotes/scheduler-server@1.10.34...@standardnotes/scheduler-server@1.10.35) (2022-10-04)
**Note:** Version bump only for package @standardnotes/scheduler-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/scheduler-server",
"version": "1.10.35",
"version": "1.10.36",
"engines": {
"node": ">=16.0.0 <17.0.0"
},
+4
View File
@@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.8.20](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.8.19...@standardnotes/syncing-server@1.8.20) (2022-10-05)
**Note:** Version bump only for package @standardnotes/syncing-server
## [1.8.19](https://github.com/standardnotes/syncing-server-js/compare/@standardnotes/syncing-server@1.8.18...@standardnotes/syncing-server@1.8.19) (2022-10-04)
**Note:** Version bump only for package @standardnotes/syncing-server
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@standardnotes/syncing-server",
"version": "1.8.19",
"version": "1.8.20",
"engines": {
"node": ">=16.0.0 <17.0.0"
},