refactor(server): payment service (#8906)

This commit is contained in:
forehalo
2024-12-05 08:31:00 +00:00
parent 4fe1b5ba93
commit 4055e3aa67
26 changed files with 1934 additions and 1537 deletions

View File

@@ -141,7 +141,7 @@ input CreateChatSessionInput {
input CreateCheckoutSessionInput {
coupon: String
idempotencyKey: String!
idempotencyKey: String
plan: SubscriptionPlan = Pro
recurring: SubscriptionRecurring = Yearly
successCallbackLink: String!
@@ -392,6 +392,20 @@ enum InvoiceStatus {
Void
}
type InvoiceType {
amount: Int!
createdAt: DateTime!
currency: String!
id: String @deprecated(reason: "removed")
lastPaymentError: String
link: String
plan: SubscriptionPlan @deprecated(reason: "removed")
reason: String!
recurring: SubscriptionRecurring @deprecated(reason: "removed")
status: InvoiceStatus!
updatedAt: DateTime!
}
"""
The `JSON` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).
"""
@@ -430,7 +444,7 @@ type MissingOauthQueryParameterDataType {
type Mutation {
acceptInviteById(inviteId: String!, sendAcceptMail: Boolean, workspaceId: String!): Boolean!
addWorkspaceFeature(feature: FeatureType!, workspaceId: String!): Int!
cancelSubscription(idempotencyKey: String!, plan: SubscriptionPlan = Pro): UserSubscription!
cancelSubscription(idempotencyKey: String @deprecated(reason: "use header `Idempotency-Key`"), plan: SubscriptionPlan = Pro): SubscriptionType!
changeEmail(email: String!, token: String!): UserType!
changePassword(newPassword: String!, token: String!, userId: String): Boolean!
@@ -477,7 +491,7 @@ type Mutation {
"""Remove user avatar"""
removeAvatar: RemoveAvatar!
removeWorkspaceFeature(feature: FeatureType!, workspaceId: String!): Int!
resumeSubscription(idempotencyKey: String!, plan: SubscriptionPlan = Pro): UserSubscription!
resumeSubscription(idempotencyKey: String @deprecated(reason: "use header `Idempotency-Key`"), plan: SubscriptionPlan = Pro): SubscriptionType!
revoke(userId: String!, workspaceId: String!): Boolean!
revokePage(pageId: String!, workspaceId: String!): Boolean! @deprecated(reason: "use revokePublicPage")
revokePublicPage(pageId: String!, workspaceId: String!): WorkspacePage!
@@ -499,7 +513,7 @@ type Mutation {
"""update multiple server runtime configurable settings"""
updateRuntimeConfigs(updates: JSONObject!): [ServerRuntimeConfigType!]!
updateSubscriptionRecurring(idempotencyKey: String!, plan: SubscriptionPlan = Pro, recurring: SubscriptionRecurring!): UserSubscription!
updateSubscriptionRecurring(idempotencyKey: String @deprecated(reason: "use header `Idempotency-Key`"), plan: SubscriptionPlan = Pro, recurring: SubscriptionRecurring!): SubscriptionType!
"""Update a user"""
updateUser(id: String!, input: ManageUserInput!): UserType!
@@ -770,6 +784,27 @@ enum SubscriptionStatus {
Unpaid
}
type SubscriptionType {
canceledAt: DateTime
createdAt: DateTime!
end: DateTime
id: String @deprecated(reason: "removed")
nextBillAt: DateTime
"""
The 'Free' plan just exists to be a placeholder and for the type convenience of frontend.
There won't actually be a subscription with plan 'Free'
"""
plan: SubscriptionPlan!
recurring: SubscriptionRecurring!
start: DateTime!
status: SubscriptionStatus!
trialEnd: DateTime
trialStart: DateTime
updatedAt: DateTime!
variant: SubscriptionVariant
}
enum SubscriptionVariant {
EA
Onetime
@@ -796,20 +831,6 @@ input UpdateWorkspaceInput {
"""The `Upload` scalar type represents a file upload."""
scalar Upload
type UserInvoice {
amount: Int!
createdAt: DateTime!
currency: String!
id: String!
lastPaymentError: String
link: String
plan: SubscriptionPlan!
reason: String!
recurring: SubscriptionRecurring!
status: InvoiceStatus!
updatedAt: DateTime!
}
union UserOrLimitedUser = LimitedUserType | UserType
type UserQuota {
@@ -829,27 +850,6 @@ type UserQuotaHumanReadable {
storageQuota: String!
}
type UserSubscription {
canceledAt: DateTime
createdAt: DateTime!
end: DateTime
id: String
nextBillAt: DateTime
"""
The 'Free' plan just exists to be a placeholder and for the type convenience of frontend.
There won't actually be a subscription with plan 'Free'
"""
plan: SubscriptionPlan!
recurring: SubscriptionRecurring!
start: DateTime!
status: SubscriptionStatus!
trialEnd: DateTime
trialStart: DateTime
updatedAt: DateTime!
variant: SubscriptionVariant
}
type UserType {
"""User avatar url"""
avatarUrl: String
@@ -873,13 +873,12 @@ type UserType {
"""Get user invoice count"""
invoiceCount: Int!
invoices(skip: Int, take: Int = 8): [UserInvoice!]!
invoices(skip: Int, take: Int = 8): [InvoiceType!]!
"""User name"""
name: String!
quota: UserQuota
subscription(plan: SubscriptionPlan = Pro): UserSubscription @deprecated(reason: "use `UserType.subscriptions`")
subscriptions: [UserSubscription!]!
subscriptions: [SubscriptionType!]!
token: tokenType! @deprecated(reason: "use [/api/auth/sign-in?native=true] instead")
}