Update billing to EE (#10060)

Doesn't make sense to have billing under GPL since it's only used for
our cloud and not by self-hosters
This commit is contained in:
Félix Malfait
2025-02-06 21:10:30 +01:00
committed by GitHub
parent 005762c240
commit 12cec01d80
97 changed files with 195 additions and 1 deletions

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import {
Controller,
Headers,

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { UseGuards } from '@nestjs/common';
import { Args, Mutation, Query, Resolver } from '@nestjs/graphql';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { InjectRepository } from '@nestjs/typeorm';
import chalk from 'chalk';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { InjectRepository } from '@nestjs/typeorm';
import { Command } from 'nest-commander';

View File

@ -1 +1,3 @@
/* @license Enterprise */
export const BILLING_FEATURE_USED = 'BILLING_FEATURE_USED';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { SubscriptionInterval } from 'src/engine/core-modules/billing/enums/billing-subscription-interval.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { BillingPriceTierDTO } from 'src/engine/core-modules/billing/dtos/billing-price-tier.dto';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { createUnionType } from '@nestjs/graphql';
import { BillingPriceLicensedDTO } from 'src/engine/core-modules/billing/dtos/billing-price-licensed.dto';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { BillingPriceLicensedDTO } from 'src/engine/core-modules/billing/dtos/billing-price-licensed.dto';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { Min } from 'class-validator';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { ArgsType, Field } from '@nestjs/graphql';
import {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { ArgsType, Field } from '@nestjs/graphql';
import { IsNotEmpty, IsString } from 'class-validator';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { ArgsType, Field } from '@nestjs/graphql';
import { IsOptional, IsString } from 'class-validator';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { BillingProductDTO } from 'src/engine/core-modules/billing/dtos/billing-product.dto';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, Int, ObjectType } from '@nestjs/graphql';
import { BillingProductPriceDTO } from 'src/engine/core-modules/billing/dtos/billing-product-price.dto';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
@ObjectType()

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { ObjectType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import {
Column,

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field } from '@nestjs/graphql';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { registerEnumType } from '@nestjs/graphql';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import {
Column,

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Field, ObjectType, registerEnumType } from '@nestjs/graphql';
import { IDField } from '@ptc-org/nestjs-query-graphql';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum AvailableProduct {
BasePlan = 'base-plan',
}

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingEntitlementKey {
SSO = 'SSO',
}

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingMeterEventName {
WORKFLOW_NODE_RUN = 'WORKFLOW_NODE_RUN',
}

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingMeterEventTimeWindow {
DAY = 'DAY',
HOUR = 'HOUR',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingMeterStatus {
ACTIVE = 'ACTIVE',
INACTIVE = 'INACTIVE',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { registerEnumType } from '@nestjs/graphql';
export enum BillingPlanKey {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingPriceBillingScheme {
PER_UNIT = 'PER_UNIT',
TIERED = 'TIERED',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingPriceTaxBehavior {
EXCLUSIVE = 'EXCLUSIVE',
INCLUSIVE = 'INCLUSIVE',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { registerEnumType } from '@nestjs/graphql';
export enum BillingPriceTiersMode {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingPriceType {
ONE_TIME = 'ONE_TIME',
RECURRING = 'RECURRING',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingSubscriptionCollectionMethod {
CHARGE_AUTOMATICALLY = 'CHARGE_AUTOMATICALLY',
SEND_INVOICE = 'SEND_INVOICE',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum SubscriptionInterval {
Day = 'day',
Month = 'month',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum SubscriptionStatus {
Active = 'active',
Canceled = 'canceled',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingUsageType {
METERED = 'METERED',
LICENSED = 'LICENSED',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
export enum BillingWebhookEvent {
CUSTOMER_SUBSCRIPTION_CREATED = 'customer.subscription.created',
CUSTOMER_SUBSCRIPTION_UPDATED = 'customer.subscription.updated',

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { ArgumentsHost, Catch, ExceptionFilter } from '@nestjs/common';
import { Response } from 'express';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Logger, Scope } from '@nestjs/common';
import { BillingSubscriptionService } from 'src/engine/core-modules/billing/services/billing-subscription.service';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable } from '@nestjs/common';
import { OnCustomBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-custom-batch-event.decorator';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable } from '@nestjs/common';
import { OnDatabaseBatchEvent } from 'src/engine/api/graphql/graphql-query-runner/decorators/on-database-batch-event.decorator';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
@ -14,11 +16,11 @@ import { StripeBillingPortalService } from 'src/engine/core-modules/billing/stri
import { StripeCheckoutService } from 'src/engine/core-modules/billing/stripe/services/stripe-checkout.service';
import { BillingGetPricesPerPlanResult } from 'src/engine/core-modules/billing/types/billing-get-prices-per-plan-result.type';
import { BillingPortalCheckoutSessionParameters } from 'src/engine/core-modules/billing/types/billing-portal-checkout-session-parameters.type';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
import { FeatureFlagKey } from 'src/engine/core-modules/feature-flag/enums/feature-flag-key.enum';
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
import { UserWorkspace } from 'src/engine/core-modules/user-workspace/user-workspace.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { DomainManagerService } from 'src/engine/core-modules/domain-manager/services/domain-manager.service';
import { assert } from 'src/utils/assert';
@Injectable()

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
export class StripeSDKMock {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable } from '@nestjs/common';
import Stripe from 'stripe';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Module } from '@nestjs/common';
import { StripeSDKService } from 'src/engine/core-modules/billing/stripe/stripe-sdk/services/stripe-sdk.service';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Module } from '@nestjs/common';
import { StripeBillingMeterEventService } from 'src/engine/core-modules/billing/stripe/services/stripe-billing-meter-event.service';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingProduct } from 'src/engine/core-modules/billing/entities/billing-product.entity';
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPrice } from 'src/engine/core-modules/billing/entities/billing-price.entity';
export type BillingGetPricesPerPlanResult = {

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';
import { BillingGetPricesPerPlanResult } from 'src/engine/core-modules/billing/types/billing-get-prices-per-plan-result.type';
import { User } from 'src/engine/core-modules/user/user.entity';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';
import { BillingUsageType } from 'src/engine/core-modules/billing/enums/billing-usage-type.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { NonNegative } from 'type-fest';
import { BillingMeterEventName } from 'src/engine/core-modules/billing/enums/billing-meter-event-names';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';
import { BillingPriceTiersMode } from 'src/engine/core-modules/billing/enums/billing-price-tiers-mode.enum';
import { SubscriptionInterval } from 'src/engine/core-modules/billing/enums/billing-subscription-interval.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingMeterEventTimeWindow } from 'src/engine/core-modules/billing/enums/billing-meter-event-time-window.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingPriceBillingScheme } from 'src/engine/core-modules/billing/enums/billing-price-billing-scheme.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { transformStripeProductToDatabaseProduct } from 'src/engine/core-modules/billing/utils/transform-stripe-product-to-database-product.util';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPriceLicensedDTO } from 'src/engine/core-modules/billing/dtos/billing-price-licensed.dto';
import { BillingPriceMeteredDTO } from 'src/engine/core-modules/billing/dtos/billing-price-metered.dto';
import { BillingPlanOutput } from 'src/engine/core-modules/billing/dtos/outputs/billing-plan.output';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingPlanKey } from 'src/engine/core-modules/billing/enums/billing-plan-key.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingMeterEventTimeWindow } from 'src/engine/core-modules/billing/enums/billing-meter-event-time-window.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingPriceBillingScheme } from 'src/engine/core-modules/billing/enums/billing-price-billing-scheme.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
export const transformStripeProductToDatabaseProduct = (

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingPriceBillingScheme } from 'src/engine/core-modules/billing/enums/billing-price-billing-scheme.enum';
import { BillingPriceTaxBehavior } from 'src/engine/core-modules/billing/enums/billing-price-tax-behavior.enum';
import { BillingPriceTiersMode } from 'src/engine/core-modules/billing/enums/billing-price-tiers-mode.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { transformStripeProductEventToDatabaseProduct } from 'src/engine/core-modules/billing/webhooks/utils/transform-stripe-product-event-to-database-product.util';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { transformStripeSubscriptionEventToDatabaseCustomer } from 'src/engine/core-modules/billing/webhooks/utils/transform-stripe-subscription-event-to-database-customer.util';
describe('transformStripeSubscriptionEventToDatabaseCustomer', () => {
const mockWorkspaceId = 'workspace_123';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import { BillingSubscriptionCollectionMethod } from 'src/engine/core-modules/billing/enums/billing-subscription-collection-method.enum';
import { SubscriptionStatus } from 'src/engine/core-modules/billing/enums/billing-subscription-status.enum';
import { transformStripeSubscriptionEventToDatabaseSubscription } from 'src/engine/core-modules/billing/webhooks/utils/transform-stripe-subscription-event-to-database-subscription.util';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingEntitlementKey } from 'src/engine/core-modules/billing/enums/billing-entitlement-key.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingPriceBillingScheme } from 'src/engine/core-modules/billing/enums/billing-price-billing-scheme.enum';

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
export const transformStripeProductEventToDatabaseProduct = (

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
export const transformStripeSubscriptionEventToDatabaseCustomer = (

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
export const transformStripeSubscriptionEventToDatabaseSubscriptionItem = (

View File

@ -1,3 +1,5 @@
/* @license Enterprise */
import Stripe from 'stripe';
import { BillingSubscriptionCollectionMethod } from 'src/engine/core-modules/billing/enums/billing-subscription-collection-method.enum';