V4.14.4 features (#6036)

* feat: add query optimize and bill (#6021)

* add query optimize and bill

* perf: query extension

* fix: embe model

* remove log

* remove log

* fix: test

---------

Co-authored-by: xxyyh <2289112474@qq>
Co-authored-by: archer <545436317@qq.com>

* feat: notice (#6013)

* feat: record user's language

* feat: notice points/dataset indexes; support count limit; update docker-compose.yml

* fix: ts error

* feat: send auth code i18n

* chore: dataset notice limit

* chore: adjust

* fix: ts

* fix: countLimit race condition; i18n en-prefix locale fallback to en

---------

Co-authored-by: archer <545436317@qq.com>

* perf: comment

* perf: send inform code

* fix: type error (#6029)

* feat: add ip region for chat logs (#6010)

* feat: add ip region for chat logs

* refactor: use Geolite2.mmdb

* fix: export chat logs

* fix: return location directly

* test: add unit test

* perf: log show ip data

* adjust commercial plans (#6008)

* plan frontend

* plan limit

* coupon

* discount coupon

* fix

* type

* fix audit

* type

* plan name

* legacy plan

* track

* feat: add discount coupon

* fix

* fix discount coupon

* openapi

* type

* type

* env

* api type

* fix

* fix: simple agent plugin input & agent dashboard card (#6034)

* refactor: remove gridfs (#6031)

* fix: replace gridfs multer operations with s3 compatible ops

* wip: s3 features

* refactor: remove gridfs

* fix

* perf: mock test

* doc

* doc

* doc

* fix: test

* fix: s3

* fix: mock s3

* remove invalid config

* fix: init query extension

* initv4144 (#6037)

* chore: initv4144

* fix

* version

* fix: new plans (#6039)

* fix: new plans

* qr modal tip

* fix: buffer raw text filename (#6040)

* fix: initv4144 (#6041)

* fix: pay refresh (#6042)

* fix: migration shell

* rename collection

* clear timerlock

* clear timerlock

* perf: faq

* perf: bill schema

* fix: openapi

* doc

* fix: share var render

* feat: delete dataset queue

* plan usage display (#6043)

* plan usage display

* text

* fix

* fix: ts

* perf: remove invalid code

* perf: init shell

* doc

* perf: rename field

* perf: avatar presign

* init

* custom plan text (#6045)

* fix plans

* fix

* fixed

* computed

---------

Co-authored-by: archer <545436317@qq.com>

* init shell

* plan text & price page back button (#6046)

* init

* index

* delete dataset

* delete dataset

* perf: delete dataset

* init

---------

Co-authored-by: YeYuheng <57035043+YYH211@users.noreply.github.com>
Co-authored-by: xxyyh <2289112474@qq>
Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
Co-authored-by: Roy <whoeverimf5@gmail.com>
Co-authored-by: heheer <heheer@sealos.io>
This commit is contained in:
Archer
2025-12-08 01:44:15 +08:00
committed by GitHub
parent 9d72f238c0
commit 2ccb5b50c6
247 changed files with 7342 additions and 3819 deletions
-44
View File
@@ -1,44 +0,0 @@
import type { StandardSubLevelEnum, SubModeEnum } from '../sub/constants';
import type { BillTypeEnum, BillPayWayEnum } from './constants';
import { DrawBillQRItem } from './constants';
export type CreateOrderResponse = {
qrCode?: string;
iframeCode?: string;
markdown?: string;
};
export type CreateStandPlanBill = {
type: BillTypeEnum.standSubPlan;
level: `${StandardSubLevelEnum}`;
subMode: `${SubModeEnum}`;
};
type CreateExtractPointsBill = {
type: BillTypeEnum.extraPoints;
extraPoints: number;
};
type CreateExtractDatasetBill = {
type: BillTypeEnum.extraDatasetSub;
extraDatasetSize: number;
month: number;
};
export type CreateBillProps =
| CreateStandPlanBill
| CreateExtractPointsBill
| CreateExtractDatasetBill;
export type CreateBillResponse = {
billId: string;
readPrice: number;
payment: BillPayWayEnum;
} & CreateOrderResponse;
export type UpdatePaymentProps = {
billId: string;
payWay: BillPayWayEnum;
};
export type CheckPayResultResponse = {
status: BillStatusEnum;
description?: string;
};
@@ -1,13 +1,5 @@
import type { PriceOption } from './type';
// 根据积分获取月份
export const getMonthByPoints = (points: number) => {
if (points >= 200) return 12;
if (points >= 100) return 6;
if (points >= 50) return 3;
return 1;
};
// 根据月份获取积分下限
export const getMinPointsByMonth = (month: number): number => {
switch (month) {
-65
View File
@@ -1,65 +0,0 @@
import type { StandardSubLevelEnum, SubModeEnum } from '../sub/constants';
import { SubTypeEnum } from '../sub/constants';
import type { BillPayWayEnum, BillStatusEnum, BillTypeEnum } from './constants';
import type { TeamInvoiceHeaderType } from '../../user/team/type';
export type BillSchemaType = {
_id: string;
userId: string;
teamId: string;
tmbId: string;
createTime: Date;
orderId: string;
status: `${BillStatusEnum}`;
type: BillTypeEnum;
price: number;
hasInvoice: boolean;
metadata: {
payWay: `${BillPayWayEnum}`;
subMode?: `${SubModeEnum}`;
standSubLevel?: `${StandardSubLevelEnum}`;
month?: number;
datasetSize?: number;
extraPoints?: number;
};
refundData?: {
amount: number;
refundId: string;
refundTime: Date;
};
};
export type ChatNodeUsageType = {
inputTokens?: number;
outputTokens?: number;
totalPoints: number;
moduleName: string;
model?: string;
};
export type InvoiceType = {
amount: number;
billIdList: string[];
} & TeamInvoiceHeaderType;
export type InvoiceSchemaType = {
_id: string;
teamId: string;
status: 1 | 2;
createTime: Date;
finishTime?: Date;
file?: Buffer;
} & InvoiceType;
export type AIPointsPriceOption = {
type: 'points';
points: number;
};
export type DatasetPriceOption = {
type: 'dataset';
size: number;
month: number;
};
export type PriceOption = AIPointsPriceOption | DatasetPriceOption;
@@ -0,0 +1,76 @@
import { StandardSubLevelEnum, SubModeEnum } from '../sub/constants';
import { SubTypeEnum } from '../sub/constants';
import { BillPayWayEnum, BillStatusEnum, BillTypeEnum } from './constants';
import type { TeamInvoiceHeaderType } from '../../user/team/type';
import { z } from 'zod';
import { ObjectIdSchema } from '../../../common/type/mongo';
export const BillSchema = z.object({
_id: ObjectIdSchema.meta({ description: '订单 ID' }),
userId: ObjectIdSchema.meta({ description: '用户 ID' }),
teamId: ObjectIdSchema.meta({ description: '团队 ID' }),
tmbId: ObjectIdSchema.meta({ description: '团队成员 ID' }),
createTime: z.coerce.date().meta({ description: '创建时间' }),
orderId: z.string().meta({ description: '订单 ID' }),
status: z.enum(BillStatusEnum).meta({ description: '订单状态' }),
type: z.enum(BillTypeEnum).meta({ description: '订单类型' }),
price: z.number().meta({ description: '价格' }),
couponId: ObjectIdSchema.optional().meta({
description: '优惠券 ID'
}),
hasInvoice: z.boolean().meta({ description: '是否已开发票' }),
metadata: z
.object({
payWay: z.enum(BillPayWayEnum).meta({ description: '支付方式' }),
subMode: z.enum(SubModeEnum).optional().meta({ description: '订阅周期' }),
standSubLevel: z.enum(StandardSubLevelEnum).optional().meta({ description: '订阅等级' }),
month: z.number().optional().meta({ description: '月数' }),
datasetSize: z.number().optional().meta({ description: '数据集大小' }),
extraPoints: z.number().optional().meta({ description: '额外积分' })
})
.meta({ description: '元数据' }),
refundData: z
.object({
amount: z.number().meta({ description: '退款金额' }),
refundId: z.string().meta({ description: '退款 ID' }),
refundTime: z.date().meta({ description: '退款时间' })
})
.optional()
.meta({ description: '退款数据' })
});
export type BillSchemaType = z.infer<typeof BillSchema>;
export type ChatNodeUsageType = {
inputTokens?: number;
outputTokens?: number;
totalPoints: number;
moduleName: string;
model?: string;
};
export type InvoiceType = {
amount: number;
billIdList: string[];
} & TeamInvoiceHeaderType;
export type InvoiceSchemaType = {
_id: string;
teamId: string;
status: 1 | 2;
createTime: Date;
finishTime?: Date;
file?: Buffer;
} & InvoiceType;
export type AIPointsPriceOption = {
type: 'points';
points: number;
};
export type DatasetPriceOption = {
type: 'dataset';
size: number;
month: number;
};
export type PriceOption = AIPointsPriceOption | DatasetPriceOption;
+30 -13
View File
@@ -9,17 +9,17 @@ export enum SubTypeEnum {
export const subTypeMap = {
[SubTypeEnum.standard]: {
label: 'support.wallet.subscription.type.standard',
label: i18nT('common:support.wallet.subscription.type.standard'),
icon: 'support/account/plans',
orderType: BillTypeEnum.standSubPlan
},
[SubTypeEnum.extraDatasetSize]: {
label: 'support.wallet.subscription.type.extraDatasetSize',
label: i18nT('common:support.wallet.subscription.type.extraDatasetSize'),
icon: 'core/dataset/datasetLight',
orderType: BillTypeEnum.extraDatasetSub
},
[SubTypeEnum.extraPoints]: {
label: 'support.wallet.subscription.type.extraPoints',
label: i18nT('common:support.wallet.subscription.type.extraPoints'),
icon: 'core/chat/chatLight',
orderType: BillTypeEnum.extraPoints
}
@@ -31,12 +31,12 @@ export enum SubModeEnum {
}
export const subModeMap = {
[SubModeEnum.month]: {
label: 'support.wallet.subscription.mode.Month',
label: i18nT('common:support.wallet.subscription.mode.Month'),
durationMonth: 1,
payMonth: 1
},
[SubModeEnum.year]: {
label: 'support.wallet.subscription.mode.Year',
label: i18nT('common:support.wallet.subscription.mode.Year'),
durationMonth: 12,
payMonth: 10
}
@@ -44,17 +44,39 @@ export const subModeMap = {
export enum StandardSubLevelEnum {
free = 'free',
basic = 'basic',
advanced = 'advanced',
custom = 'custom',
// @deprecated
experience = 'experience',
team = 'team',
enterprise = 'enterprise',
custom = 'custom'
enterprise = 'enterprise'
}
export const standardSubLevelMap = {
[StandardSubLevelEnum.free]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.free'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.free desc'),
weight: 1
},
[StandardSubLevelEnum.basic]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.basic'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.basic_desc'),
weight: 4
},
[StandardSubLevelEnum.advanced]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.advanced'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.advanced_desc'),
weight: 5
},
[StandardSubLevelEnum.custom]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.custom'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.custom_desc'),
weight: 7
},
// deprecated
[StandardSubLevelEnum.experience]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.experience'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.experience_desc'),
@@ -68,11 +90,6 @@ export const standardSubLevelMap = {
[StandardSubLevelEnum.enterprise]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.enterprise'),
desc: i18nT('common:support.wallet.subscription.standardSubLevel.enterprise_desc'),
weight: 4
},
[StandardSubLevelEnum.custom]: {
label: i18nT('common:support.wallet.subscription.standardSubLevel.custom'),
desc: '',
weight: 5
weight: 6
}
};
+14
View File
@@ -1,12 +1,26 @@
import type { SubTypeEnum, StandardSubLevelEnum } from '../constants';
import type { CouponTypeEnum } from './constants';
export type CustomSubConfig = {
requestsPerMinute: number;
maxTeamMember: number;
maxAppAmount: number;
maxDatasetAmount: number;
chatHistoryStoreDuration: number;
maxDatasetSize: number;
websiteSyncPerDataset: number;
appRegistrationCount: number;
auditLogStoreDuration: number;
ticketResponseTime: number;
};
export type TeamCouponSub = {
type: `${SubTypeEnum}`; // Sub type
durationDay: number; // Duration day
level?: `${StandardSubLevelEnum}`; // Standard sub level
extraDatasetSize?: number; // Extra dataset size
totalPoints?: number; // Total points(Extrapoints or Standard sub)
customConfig?: CustomSubConfig; // Custom config for custom level (only required when level=custom)
};
export type TeamCouponSchema = {
@@ -0,0 +1,33 @@
import { i18nT } from '../../../../../web/i18n/utils';
export enum DiscountCouponTypeEnum {
monthStandardDiscount70 = 'monthStandardDiscount70',
yearStandardDiscount90 = 'yearStandardDiscount90'
}
export enum DiscountCouponStatusEnum {
active = 'active',
used = 'used',
expired = 'expired',
notStart = 'notStart'
}
// Discount coupon type config table, modify to add or update types.
export const discountCouponTypeMap = {
[DiscountCouponTypeEnum.monthStandardDiscount70]: {
type: DiscountCouponTypeEnum.monthStandardDiscount70,
name: i18nT('common:old_user_month_discount_70'),
description: i18nT('common:old_user_month_discount_70_description'),
discount: 0.7,
iconZh: '/imgs/system/discount70CN.svg',
iconEn: '/imgs/system/discount70EN.svg'
},
[DiscountCouponTypeEnum.yearStandardDiscount90]: {
type: DiscountCouponTypeEnum.yearStandardDiscount90,
name: i18nT('common:old_user_year_discount_90'),
description: i18nT('common:old_user_year_discount_90_description'),
discount: 0.9,
iconZh: '/imgs/system/discount90CN.svg',
iconEn: '/imgs/system/discount90EN.svg'
}
};
+34 -8
View File
@@ -3,19 +3,28 @@ import type { StandardSubLevelEnum, SubModeEnum, SubTypeEnum } from './constants
// Content of plan
export type TeamStandardSubPlanItemType = {
name?: string;
desc?: string; // Plan description
price: number; // read price / month
pointPrice: number; // read price/ one thousand
totalPoints: number; // n
maxTeamMember: number;
maxAppAmount: number; // max app or plugin amount
maxDatasetAmount: number;
chatHistoryStoreDuration: number; // n day
maxDatasetSize: number;
trainingWeight: number; // 1~4
permissionCustomApiKey: boolean;
permissionCustomCopyright: boolean; // feature
permissionWebsiteSync: boolean;
permissionTeamOperationLog: boolean;
requestsPerMinute?: number;
appRegistrationCount?: number;
chatHistoryStoreDuration: number; // n day
websiteSyncPerDataset?: number;
auditLogStoreDuration?: number;
ticketResponseTime?: number;
// Custom plan specific fields
priceDescription?: string;
customFormUrl?: string;
customDescriptions?: string[];
};
export type StandSubPlanLevelMapType = Record<
@@ -23,14 +32,21 @@ export type StandSubPlanLevelMapType = Record<
TeamStandardSubPlanItemType
>;
export type PointsPackageItem = {
points: number;
month: number;
price: number;
};
export type SubPlanType = {
[SubTypeEnum.standard]: StandSubPlanLevelMapType;
[SubTypeEnum.standard]?: StandSubPlanLevelMapType;
planDescriptionUrl?: string;
appRegistrationUrl?: string;
[SubTypeEnum.extraDatasetSize]: {
price: number;
};
[SubTypeEnum.extraPoints]: {
price: number;
packages: PointsPackageItem[];
};
};
@@ -49,6 +65,15 @@ export type TeamSubSchema = {
maxApp?: number;
maxDataset?: number;
// custom level configurations
requestsPerMinute?: number;
chatHistoryStoreDuration?: number;
maxDatasetSize?: number;
websiteSyncPerDataset?: number;
appRegistrationCount?: number;
auditLogStoreDuration?: number;
ticketResponseTime?: number;
totalPoints: number;
surplusPoints: number;
@@ -71,4 +96,5 @@ export type ClientTeamPlanStatusType = TeamPlanStatusType & {
usedAppAmount: number;
usedDatasetSize: number;
usedDatasetIndexSize: number;
usedRegistrationCount: number;
};