mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-06 08:50:50 +08:00
Merge remote-tracking branch 'origin/canary' into beta
This commit is contained in:
Generated
+3
-3
@@ -823,7 +823,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
checksum = "0c2a198fb6b0eada2a8df47933734e6d35d350665a33a3593d7164fa52c75c19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"windows-targets 0.52.5",
|
"windows-targets 0.48.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1393,9 +1393,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.21.10"
|
version = "0.21.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f9d5a6813c0759e4609cd494e8e725babae6a2ca7b62a5536a13daaec6fcb7ba"
|
checksum = "7fecbfb7b1444f477b345853b1fce097a2c6fb637b2bfb87e6bc5db0f043fae4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ring",
|
"ring",
|
||||||
"rustls-webpki",
|
"rustls-webpki",
|
||||||
|
|||||||
@@ -118,7 +118,7 @@
|
|||||||
"c8": "^9.1.0",
|
"c8": "^9.1.0",
|
||||||
"nodemon": "^3.1.0",
|
"nodemon": "^3.1.0",
|
||||||
"sinon": "^17.0.1",
|
"sinon": "^17.0.1",
|
||||||
"supertest": "^6.3.4"
|
"supertest": "^7.0.0"
|
||||||
},
|
},
|
||||||
"ava": {
|
"ava": {
|
||||||
"timeout": "1m",
|
"timeout": "1m",
|
||||||
|
|||||||
@@ -593,37 +593,35 @@ export const prompts: Prompt[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export async function refreshPrompts(db: PrismaClient) {
|
export async function refreshPrompts(db: PrismaClient) {
|
||||||
await db.$transaction(async tx => {
|
for (const prompt of prompts) {
|
||||||
for (const prompt of prompts) {
|
await db.aiPrompt.upsert({
|
||||||
await tx.aiPrompt.upsert({
|
create: {
|
||||||
create: {
|
name: prompt.name,
|
||||||
name: prompt.name,
|
action: prompt.action,
|
||||||
action: prompt.action,
|
model: prompt.model,
|
||||||
model: prompt.model,
|
messages: {
|
||||||
messages: {
|
create: prompt.messages.map((message, idx) => ({
|
||||||
create: prompt.messages.map((message, idx) => ({
|
idx,
|
||||||
idx,
|
role: message.role,
|
||||||
role: message.role,
|
content: message.content,
|
||||||
content: message.content,
|
params: message.params,
|
||||||
params: message.params,
|
})),
|
||||||
})),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
where: { name: prompt.name },
|
},
|
||||||
update: {
|
where: { name: prompt.name },
|
||||||
action: prompt.action,
|
update: {
|
||||||
model: prompt.model,
|
action: prompt.action,
|
||||||
messages: {
|
model: prompt.model,
|
||||||
deleteMany: {},
|
messages: {
|
||||||
create: prompt.messages.map((message, idx) => ({
|
deleteMany: {},
|
||||||
idx,
|
create: prompt.messages.map((message, idx) => ({
|
||||||
role: message.role,
|
idx,
|
||||||
content: message.content,
|
role: message.role,
|
||||||
params: message.params,
|
content: message.content,
|
||||||
})),
|
params: message.params,
|
||||||
},
|
})),
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,56 +13,62 @@ export async function upgradeQuotaVersion(
|
|||||||
// add new quota
|
// add new quota
|
||||||
await upsertFeature(db, quota);
|
await upsertFeature(db, quota);
|
||||||
// migrate all users that using old quota to new quota
|
// migrate all users that using old quota to new quota
|
||||||
await db.$transaction(async tx => {
|
await db.$transaction(
|
||||||
const latestQuotaVersion = await tx.features.findFirstOrThrow({
|
async tx => {
|
||||||
where: { feature: quota.feature },
|
const latestQuotaVersion = await tx.features.findFirstOrThrow({
|
||||||
orderBy: { version: 'desc' },
|
where: { feature: quota.feature },
|
||||||
select: { id: true },
|
orderBy: { version: 'desc' },
|
||||||
});
|
select: { id: true },
|
||||||
|
});
|
||||||
|
|
||||||
// find all users that have old free plan
|
// find all users that have old free plan
|
||||||
const userIds = await tx.user.findMany({
|
const userIds = await tx.user.findMany({
|
||||||
where: {
|
where: {
|
||||||
features: {
|
features: {
|
||||||
some: {
|
some: {
|
||||||
feature: {
|
feature: {
|
||||||
type: FeatureKind.Quota,
|
type: FeatureKind.Quota,
|
||||||
feature: quota.feature,
|
feature: quota.feature,
|
||||||
version: { lt: quota.version },
|
version: { lt: quota.version },
|
||||||
|
},
|
||||||
|
activated: true,
|
||||||
},
|
},
|
||||||
activated: true,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
select: { id: true },
|
||||||
select: { id: true },
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// deactivate all old quota for the user
|
// deactivate all old quota for the user
|
||||||
await tx.userFeatures.updateMany({
|
await tx.userFeatures.updateMany({
|
||||||
where: {
|
where: {
|
||||||
id: undefined,
|
id: undefined,
|
||||||
userId: {
|
userId: {
|
||||||
in: userIds.map(({ id }) => id),
|
in: userIds.map(({ id }) => id),
|
||||||
|
},
|
||||||
|
feature: {
|
||||||
|
type: FeatureKind.Quota,
|
||||||
|
},
|
||||||
|
activated: true,
|
||||||
},
|
},
|
||||||
feature: {
|
data: {
|
||||||
type: FeatureKind.Quota,
|
activated: false,
|
||||||
},
|
},
|
||||||
activated: true,
|
});
|
||||||
},
|
|
||||||
data: {
|
|
||||||
activated: false,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
await tx.userFeatures.createMany({
|
await tx.userFeatures.createMany({
|
||||||
data: userIds.map(({ id: userId }) => ({
|
data: userIds.map(({ id: userId }) => ({
|
||||||
userId,
|
userId,
|
||||||
featureId: latestQuotaVersion.id,
|
featureId: latestQuotaVersion.id,
|
||||||
reason,
|
reason,
|
||||||
activated: true,
|
activated: true,
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
maxWait: 10000,
|
||||||
|
timeout: 20000,
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function upsertLatestQuotaVersion(
|
export async function upsertLatestQuotaVersion(
|
||||||
|
|||||||
@@ -740,7 +740,7 @@ __metadata:
|
|||||||
sinon: "npm:^17.0.1"
|
sinon: "npm:^17.0.1"
|
||||||
socket.io: "npm:^4.7.5"
|
socket.io: "npm:^4.7.5"
|
||||||
stripe: "npm:^15.0.0"
|
stripe: "npm:^15.0.0"
|
||||||
supertest: "npm:^6.3.4"
|
supertest: "npm:^7.0.0"
|
||||||
tiktoken: "npm:^1.0.13"
|
tiktoken: "npm:^1.0.13"
|
||||||
ts-node: "npm:^10.9.2"
|
ts-node: "npm:^10.9.2"
|
||||||
typescript: "npm:^5.4.5"
|
typescript: "npm:^5.4.5"
|
||||||
@@ -22847,15 +22847,14 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"formidable@npm:^2.1.2":
|
"formidable@npm:^3.5.1":
|
||||||
version: 2.1.2
|
version: 3.5.1
|
||||||
resolution: "formidable@npm:2.1.2"
|
resolution: "formidable@npm:3.5.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
dezalgo: "npm:^1.0.4"
|
dezalgo: "npm:^1.0.4"
|
||||||
hexoid: "npm:^1.0.0"
|
hexoid: "npm:^1.0.0"
|
||||||
once: "npm:^1.4.0"
|
once: "npm:^1.4.0"
|
||||||
qs: "npm:^6.11.0"
|
checksum: 10/c9a7bbbd4ca8142893da88b51cf7797adee022344ea180cf157a108bf999bed5ad8bc07a10a28d8a39fcbfaa02e8cba07f4ba336fbeb330deb23907336ba1fc2
|
||||||
checksum: 10/d385180e0461f65e6f7b70452859fe1c32aa97a290c2ca33f00cdc33145ef44fa68bbc9b93af2c3af73ae726e42c3477c6619c49f3c34b49934e9481275b7b4c
|
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -34751,21 +34750,21 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"superagent@npm:^8.1.2":
|
"superagent@npm:^9.0.1":
|
||||||
version: 8.1.2
|
version: 9.0.1
|
||||||
resolution: "superagent@npm:8.1.2"
|
resolution: "superagent@npm:9.0.1"
|
||||||
dependencies:
|
dependencies:
|
||||||
component-emitter: "npm:^1.3.0"
|
component-emitter: "npm:^1.3.0"
|
||||||
cookiejar: "npm:^2.1.4"
|
cookiejar: "npm:^2.1.4"
|
||||||
debug: "npm:^4.3.4"
|
debug: "npm:^4.3.4"
|
||||||
fast-safe-stringify: "npm:^2.1.1"
|
fast-safe-stringify: "npm:^2.1.1"
|
||||||
form-data: "npm:^4.0.0"
|
form-data: "npm:^4.0.0"
|
||||||
formidable: "npm:^2.1.2"
|
formidable: "npm:^3.5.1"
|
||||||
methods: "npm:^1.1.2"
|
methods: "npm:^1.1.2"
|
||||||
mime: "npm:2.6.0"
|
mime: "npm:2.6.0"
|
||||||
qs: "npm:^6.11.0"
|
qs: "npm:^6.11.0"
|
||||||
semver: "npm:^7.3.8"
|
semver: "npm:^7.3.8"
|
||||||
checksum: 10/33d0072e051baf91c7d68131c70682a0650dd1bd0b8dfb6f88e5bdfcb02e18cc2b42a66e44b32fd405ac6bcf5fd57c6e267bf80e2a8ce57a18166a9d3a78f57d
|
checksum: 10/a6e7cd5b93aa51b297cc66ede2f08c5143d4645d3ec424f9ee45dd890e6ba33637e63ce0d724c2a9536f83a8d913c0e0a52575fd9c02e0043a5a7d61708a0a45
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
@@ -34781,13 +34780,13 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"supertest@npm:^6.3.4":
|
"supertest@npm:^7.0.0":
|
||||||
version: 6.3.4
|
version: 7.0.0
|
||||||
resolution: "supertest@npm:6.3.4"
|
resolution: "supertest@npm:7.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
methods: "npm:^1.1.2"
|
methods: "npm:^1.1.2"
|
||||||
superagent: "npm:^8.1.2"
|
superagent: "npm:^9.0.1"
|
||||||
checksum: 10/93015318f5a90398915a032747973d9eacf9aebec3f07b413eba9d8b3db83ff48fbf6f5a92f9526578cae50153b0f76a37de197141030d856db4371a711b86ee
|
checksum: 10/73bf2a37e13856a1b3e6a37b9df5cec8e506aa0360a5f5ecd989d1f4b0edf168883e306012e81e371d5252c17d4c7bef4ba30633dbf3877cbf52fc7af51cca9b
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user