From 58dff8a1e03aae62951e9c9a4d3a92c919e95710 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 10:40:34 +0100 Subject: [PATCH 1/6] Feature/upgrade prisma to version 4.8.0 (#1547) * Upgrade prisma to version 4.8.0 * Update changelog --- CHANGELOG.md | 1 + package.json | 4 ++-- prisma/schema.prisma | 6 +++--- yarn.lock | 36 ++++++++++++++++++------------------ 4 files changed, 24 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbcd0bf82..05b59e010 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changed the execution time of the asset profile data gathering to every Sunday at lunch time - Upgraded `bull` from version `4.8.5` to `4.10.2` +- Upgraded `prisma` from version `4.7.1` to `4.8.0` ## 1.221.0 - 2022-12-26 diff --git a/package.json b/package.json index ee6592410..25e3c8610 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "@nestjs/schedule": "2.1.0", "@nestjs/serve-static": "3.0.0", "@nrwl/angular": "15.0.13", - "@prisma/client": "4.7.1", + "@prisma/client": "4.8.0", "@simplewebauthn/browser": "5.2.1", "@simplewebauthn/server": "5.2.1", "@stripe/stripe-js": "1.22.0", @@ -120,7 +120,7 @@ "passport": "0.6.0", "passport-google-oauth20": "2.0.0", "passport-jwt": "4.0.0", - "prisma": "4.7.1", + "prisma": "4.8.0", "reflect-metadata": "0.1.13", "rxjs": "7.5.6", "stripe": "8.199.0", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1c210cfb8..b90a78040 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -104,9 +104,9 @@ model Property { model Settings { settings Json? - updatedAt DateTime @updatedAt - userId String @id - User User @relation(fields: [userId], references: [id]) + updatedAt DateTime @updatedAt + userId String @id + User User @relation(fields: [userId], references: [id]) } model SymbolProfile { diff --git a/yarn.lock b/yarn.lock index f76d4725d..8710aa497 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3671,22 +3671,22 @@ dependencies: esquery "^1.0.1" -"@prisma/client@4.7.1": - version "4.7.1" - resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.7.1.tgz#66fe84aca25de17cb3d9141dec003f34714914b9" - integrity sha512-/GbnOwIPtjiveZNUzGXOdp7RxTEkHL4DZP3vBaFNadfr6Sf0RshU5EULFzVaSi9i9PIK9PYd+1Rn7z2B2npb9w== +"@prisma/client@4.8.0": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@prisma/client/-/client-4.8.0.tgz#6ec7adaca6a2e233d7e41dbe7cc6d0fa6143a407" + integrity sha512-Y1riB0p2W52kh3zgssP/YAhln3RjBFcJy3uwEiyjmU+TQYh6QTZDRFBo3JtBWuq2FyMOl1Rye8jxzUP+n0l5Cg== dependencies: - "@prisma/engines-version" "4.7.1-1.272861e07ab64f234d3ffc4094e32bd61775599c" + "@prisma/engines-version" "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe" -"@prisma/engines-version@4.7.1-1.272861e07ab64f234d3ffc4094e32bd61775599c": - version "4.7.1-1.272861e07ab64f234d3ffc4094e32bd61775599c" - resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.7.1-1.272861e07ab64f234d3ffc4094e32bd61775599c.tgz#43ff7d85478e64a1d790e4d53e78768a2acfacfe" - integrity sha512-Bd4LZ+WAnUHOq31e9X/ihi5zPlr4SzTRwUZZYxvWOxlerIZ7HJlVa9zXpuKTKLpI9O1l8Ec4OYCKsivWCs5a3Q== +"@prisma/engines-version@4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe": + version "4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe" + resolved "https://registry.yarnpkg.com/@prisma/engines-version/-/engines-version-4.8.0-61.d6e67a83f971b175a593ccc12e15c4a757f93ffe.tgz#30401aba1029e7d32e3cb717e705a7c92ccc211e" + integrity sha512-MHSOSexomRMom8QN4t7bu87wPPD+pa+hW9+71JnVcF3DqyyO/ycCLhRL1we3EojRpZxKvuyGho2REQsMCvxcJw== -"@prisma/engines@4.7.1": - version "4.7.1" - resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.7.1.tgz#d657d4d05724158140022fa00614e143643090c2" - integrity sha512-zWabHosTdLpXXlMefHmnouhXMoTB1+SCbUU3t4FCmdrtIOZcarPKU3Alto7gm/pZ9vHlGOXHCfVZ1G7OIrSbog== +"@prisma/engines@4.8.0": + version "4.8.0" + resolved "https://registry.yarnpkg.com/@prisma/engines/-/engines-4.8.0.tgz#5123c67dc0d2caa008268fc63081ca2d68b2ed7e" + integrity sha512-A1Asn2rxZMlLAj1HTyfaCv0VQrLUv034jVay05QlqZg1qiHPeA3/pGTfNMijbsMYCsGVxfWEJuaZZuNxXGMCrA== "@samverschueren/stream-to-observable@^0.3.0": version "0.3.1" @@ -16426,12 +16426,12 @@ pretty-hrtime@^1.0.3: resolved "https://registry.npmjs.org/pretty-hrtime/-/pretty-hrtime-1.0.3.tgz" integrity sha512-66hKPCr+72mlfiSjlEB1+45IjXSqvVAIy6mocupoww4tBFE9R9IhwwUGoI4G++Tc9Aq+2rxOt0RFU6gPcrte0A== -prisma@4.7.1: - version "4.7.1" - resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.7.1.tgz#0a1beac26abdc4421e496b75eb50413f3ee3b0ba" - integrity sha512-CCQP+m+1qZOGIZlvnL6T3ZwaU0LAleIHYFPN9tFSzjs/KL6vH9rlYbGOkTuG9Q1s6Ki5D0LJlYlW18Z9EBUpGg== +prisma@4.8.0: + version "4.8.0" + resolved "https://registry.yarnpkg.com/prisma/-/prisma-4.8.0.tgz#634dbbdc9d3f76c61604880251673d08ccb6f02b" + integrity sha512-DWIhxvxt8f4h6MDd35mz7BJff+fu7HItW3WPDIEpCR3RzcOWyiHBbLQW5/DOgmf+pRLTjwXQob7kuTZVYUAw5w== dependencies: - "@prisma/engines" "4.7.1" + "@prisma/engines" "4.8.0" prismjs@^1.27.0, prismjs@^1.28.0: version "1.28.0" From 50160eb9dcd6b4e6628c812554cc9af1e4e2c0a9 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 13:22:19 +0100 Subject: [PATCH 2/6] Feature/upgrade countup.js to version 2.3.2 (#1548) * Upgrade countup.js to version 2.3.2 * Update changelog --- CHANGELOG.md | 1 + package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b59e010..647ec76d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Changed the execution time of the asset profile data gathering to every Sunday at lunch time - Upgraded `bull` from version `4.8.5` to `4.10.2` +- Upgraded `countup.js` from version `2.0.7` to `2.3.2` - Upgraded `prisma` from version `4.7.1` to `4.8.0` ## 1.221.0 - 2022-12-26 diff --git a/package.json b/package.json index 25e3c8610..124f846d3 100644 --- a/package.json +++ b/package.json @@ -103,7 +103,7 @@ "class-validator": "0.13.1", "color": "4.2.3", "countries-list": "2.6.1", - "countup.js": "2.0.7", + "countup.js": "2.3.2", "date-fns": "2.29.3", "envalid": "7.3.1", "google-spreadsheet": "3.2.0", diff --git a/yarn.lock b/yarn.lock index 8710aa497..66017fb6d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7984,10 +7984,10 @@ countries-list@2.6.1: resolved "https://registry.npmjs.org/countries-list/-/countries-list-2.6.1.tgz" integrity sha512-jXM1Nv3U56dPQ1DsUSsEaGmLHburo4fnB7m+1yhWDUVvx5gXCd1ok/y3gXCjXzhqyawG+igcPYcAl4qjkvopaQ== -countup.js@2.0.7: - version "2.0.7" - resolved "https://registry.npmjs.org/countup.js/-/countup.js-2.0.7.tgz" - integrity sha512-FO0nQdvG1iQwHp28wdvkErxnNUSbdkzztqZ6YNHKLHydngD2tdiKEW8dFrqpahF3tj+Ma70h0vyYrCBzxlVWdg== +countup.js@2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/countup.js/-/countup.js-2.3.2.tgz#9a91d95780be1c908d1e6feb548625f353f57988" + integrity sha512-dQ7F/CmKGjaO6cDfhtEXwsKVlXIpJ89dFs8PvkaZH9jBVJ2Z8GU4iwG/qP7MgY8qwr+1skbwR6qecWWQLUzB8Q== cp-file@^7.0.0: version "7.0.0" From 527f7e4faf5b60a70851ed6c776ee288f262bccb Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 13:43:28 +0100 Subject: [PATCH 3/6] Feature/upgrade observable store to version 2.2.15 (#1550) * Upgrade observable-store to version 2.2.15 * Update changelog --- CHANGELOG.md | 1 + package.json | 2 +- yarn.lock | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 647ec76d6..23432350f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Changed the execution time of the asset profile data gathering to every Sunday at lunch time +- Upgraded `@codewithdan/observable-store` from version `2.2.11` to `2.2.15` - Upgraded `bull` from version `4.8.5` to `4.10.2` - Upgraded `countup.js` from version `2.0.7` to `2.3.2` - Upgraded `prisma` from version `4.7.1` to `4.8.0` diff --git a/package.json b/package.json index 124f846d3..911f4677a 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@angular/platform-browser-dynamic": "14.2.0", "@angular/router": "14.2.0", "@angular/service-worker": "14.2.0", - "@codewithdan/observable-store": "2.2.11", + "@codewithdan/observable-store": "2.2.15", "@dfinity/agent": "0.12.1", "@dfinity/auth-client": "0.12.1", "@dfinity/authentication": "0.12.1", diff --git a/yarn.lock b/yarn.lock index 66017fb6d..a2ad6dfad 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2398,10 +2398,10 @@ exec-sh "^0.3.2" minimist "^1.2.0" -"@codewithdan/observable-store@2.2.11": - version "2.2.11" - resolved "https://registry.npmjs.org/@codewithdan/observable-store/-/observable-store-2.2.11.tgz" - integrity sha512-6CfqLJUqV0SwS4yE+9vciqxHUJ6CqIptSXXzFw80MonCDoVJvCJ/xhKfs7VZqJ4jDtEu/7ILvovFtZdLg9fiAg== +"@codewithdan/observable-store@2.2.15": + version "2.2.15" + resolved "https://registry.yarnpkg.com/@codewithdan/observable-store/-/observable-store-2.2.15.tgz#6d27e0988e182853def59a714b712f4389e558d2" + integrity sha512-LVCSMZzTCvoDo5n7YDmtIIEhTmvJ8O21k36Vwu/A4kumdXQ1YVs4sKoSK3vlINZPL4AYY2MRsBVtvre4QIETFw== "@colors/colors@1.5.0": version "1.5.0" From 7c4c047140d94fdbf05e9cf3e1df20085193397d Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 13:45:30 +0100 Subject: [PATCH 4/6] Remove .gitkeep (#1553) --- apps/api/src/app/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 apps/api/src/app/.gitkeep diff --git a/apps/api/src/app/.gitkeep b/apps/api/src/app/.gitkeep deleted file mode 100644 index e69de29bb..000000000 From 1ae8970045d24b2e673ad222a352e1bdce7f7528 Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 13:57:15 +0100 Subject: [PATCH 5/6] Feature/add price to subscription (#1551) * Add price * Update changelog --- CHANGELOG.md | 4 +++ apps/api/src/app/info/info.service.ts | 13 +++++----- .../subscription/subscription.controller.ts | 1 + .../app/subscription/subscription.service.ts | 25 +++++++++++++++++-- .../migration.sql | 2 ++ prisma/schema.prisma | 1 + 6 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 prisma/migrations/20221227203757_added_price_to_subscription/migration.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index 23432350f..205b87bd4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Added the price to the `Subscription` database schema + ### Changed - Changed the execution time of the asset profile data gathering to every Sunday at lunch time diff --git a/apps/api/src/app/info/info.service.ts b/apps/api/src/app/info/info.service.ts index f9eab7018..810611375 100644 --- a/apps/api/src/app/info/info.service.ts +++ b/apps/api/src/app/info/info.service.ts @@ -8,7 +8,6 @@ import { TagService } from '@ghostfolio/api/services/tag/tag.service'; import { DEMO_USER_ID, PROPERTY_IS_READ_ONLY_MODE, - PROPERTY_IS_USER_SIGNUP_ENABLED, PROPERTY_SLACK_COMMUNITY_USERS, PROPERTY_STRIPE_CONFIG, PROPERTY_SYSTEM_MESSAGE, @@ -303,14 +302,14 @@ export class InfoService { return undefined; } - const stripeConfig = await this.prismaService.property.findUnique({ + let subscriptions: Subscription[] = []; + + const stripeConfig = (await this.prismaService.property.findUnique({ where: { key: PROPERTY_STRIPE_CONFIG } - }); + })) ?? { value: '{}' }; - if (stripeConfig) { - return [JSON.parse(stripeConfig.value)]; - } + subscriptions = [JSON.parse(stripeConfig.value)]; - return []; + return subscriptions; } } diff --git a/apps/api/src/app/subscription/subscription.controller.ts b/apps/api/src/app/subscription/subscription.controller.ts index eee815652..4b21482ae 100644 --- a/apps/api/src/app/subscription/subscription.controller.ts +++ b/apps/api/src/app/subscription/subscription.controller.ts @@ -63,6 +63,7 @@ export class SubscriptionController { await this.subscriptionService.createSubscription({ duration: coupon.duration, + price: 0, userId: this.request.user.id }); diff --git a/apps/api/src/app/subscription/subscription.service.ts b/apps/api/src/app/subscription/subscription.service.ts index fa061f369..d3e9dcc7b 100644 --- a/apps/api/src/app/subscription/subscription.service.ts +++ b/apps/api/src/app/subscription/subscription.service.ts @@ -1,6 +1,10 @@ import { ConfigurationService } from '@ghostfolio/api/services/configuration.service'; import { PrismaService } from '@ghostfolio/api/services/prisma.service'; -import { DEFAULT_LANGUAGE_CODE } from '@ghostfolio/common/config'; +import { + DEFAULT_LANGUAGE_CODE, + PROPERTY_STRIPE_CONFIG +} from '@ghostfolio/common/config'; +import { Subscription as SubscriptionInterface } from '@ghostfolio/common/interfaces/subscription.interface'; import { SubscriptionType } from '@ghostfolio/common/types/subscription.type'; import { Injectable, Logger } from '@nestjs/common'; import { Subscription } from '@prisma/client'; @@ -70,13 +74,16 @@ export class SubscriptionService { public async createSubscription({ duration = '1 year', + price, userId }: { duration?: StringValue; + price: number; userId: string; }) { await this.prismaService.subscription.create({ data: { + price, expiresAt: addMilliseconds(new Date(), ms(duration)), User: { connect: { @@ -93,7 +100,21 @@ export class SubscriptionService { aCheckoutSessionId ); - await this.createSubscription({ userId: session.client_reference_id }); + let subscriptions: SubscriptionInterface[] = []; + + const stripeConfig = (await this.prismaService.property.findUnique({ + where: { key: PROPERTY_STRIPE_CONFIG } + })) ?? { value: '{}' }; + + subscriptions = [JSON.parse(stripeConfig.value)]; + + const coupon = subscriptions[0]?.coupon ?? 0; + const price = subscriptions[0]?.price ?? 0; + + await this.createSubscription({ + price: price - coupon, + userId: session.client_reference_id + }); await this.stripe.customers.update(session.customer as string, { description: session.client_reference_id diff --git a/prisma/migrations/20221227203757_added_price_to_subscription/migration.sql b/prisma/migrations/20221227203757_added_price_to_subscription/migration.sql new file mode 100644 index 000000000..cf3f84ee9 --- /dev/null +++ b/prisma/migrations/20221227203757_added_price_to_subscription/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Subscription" ADD COLUMN "price" DOUBLE PRECISION; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index b90a78040..3c252395e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -147,6 +147,7 @@ model Subscription { createdAt DateTime @default(now()) expiresAt DateTime id String @id @default(uuid()) + price Float? updatedAt DateTime @updatedAt userId String User User @relation(fields: [userId], references: [id]) From 52c7adc266bac8cd592d42aa55d6a363ae6e53fa Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Wed, 28 Dec 2022 20:08:30 +0100 Subject: [PATCH 6/6] Feature/upgrade internet identity dependencies to version 0.15.1 (#1549) * Upgrade Internet Identity dependencies to version 0.15.1 * Update changelog --- CHANGELOG.md | 1 + .../login-with-access-token-dialog.html | 7 +- .../src/app/pages/register/register-page.html | 7 +- package.json | 11 +- yarn.lock | 117 +++++++++--------- 5 files changed, 74 insertions(+), 69 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 205b87bd4..c28574d1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Upgraded `@codewithdan/observable-store` from version `2.2.11` to `2.2.15` - Upgraded `bull` from version `4.8.5` to `4.10.2` - Upgraded `countup.js` from version `2.0.7` to `2.3.2` +- Upgraded the _Internet Identity_ dependencies from version `0.12.1` to `0.15.1` - Upgraded `prisma` from version `4.7.1` to `4.8.0` ## 1.221.0 - 2022-12-26 diff --git a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html index 31f48b4d5..982adf896 100644 --- a/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html +++ b/apps/client/src/app/components/login-with-access-token-dialog/login-with-access-token-dialog.html @@ -19,7 +19,7 @@
or
-
or
-