@lacrous/omnicloud 0.2.14 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/server/index.js +18 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lacrous/omnicloud",
3
- "version": "0.2.14",
3
+ "version": "0.2.16",
4
4
  "description": "SDK and core building blocks for OmniCloud — self-hosted cloud storage powered by your Telegram account.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -48,9 +48,9 @@
48
48
  "prisma": "^6.2.0"
49
49
  },
50
50
  "devDependencies": {
51
- "@omnicloud/core": "0.2.14",
52
- "@omnicloud/shared": "0.2.14",
53
- "@omnicloud/telegram": "0.2.14",
51
+ "@omnicloud/core": "0.2.16",
52
+ "@omnicloud/shared": "0.2.16",
53
+ "@omnicloud/telegram": "0.2.16",
54
54
  "@types/node": "^22.10.0",
55
55
  "esbuild": "0.25.12",
56
56
  "tsup": "^8.3.0",
package/server/index.js CHANGED
@@ -3899,17 +3899,23 @@ function createFileRepo(prisma) {
3899
3899
  },
3900
3900
  // ── Versions ───────────────────────────────────────────────────────────
3901
3901
  async createVersion(input) {
3902
- const count = await prisma.fileVersion.count({ where: { fileId: input.fileId } });
3903
- const version = await prisma.fileVersion.create({
3904
- data: {
3905
- fileId: input.fileId,
3906
- userId: input.userId,
3907
- versionNumber: count + 1,
3908
- size: BigInt(input.size),
3909
- mimeType: input.mimeType,
3910
- sha256: input.sha256,
3911
- telegramMessageId: BigInt(input.telegramMessageId)
3912
- }
3902
+ const version = await prisma.$transaction(async (tx) => {
3903
+ const latest = await tx.fileVersion.findFirst({
3904
+ where: { fileId: input.fileId },
3905
+ orderBy: { versionNumber: "desc" },
3906
+ select: { versionNumber: true }
3907
+ });
3908
+ return tx.fileVersion.create({
3909
+ data: {
3910
+ fileId: input.fileId,
3911
+ userId: input.userId,
3912
+ versionNumber: (latest?.versionNumber ?? 0) + 1,
3913
+ size: BigInt(input.size),
3914
+ mimeType: input.mimeType,
3915
+ sha256: input.sha256,
3916
+ telegramMessageId: BigInt(input.telegramMessageId)
3917
+ }
3918
+ });
3913
3919
  });
3914
3920
  return mapVersion(version, null);
3915
3921
  },
@@ -4998,7 +5004,7 @@ function encryptionCheck(configured) {
4998
5004
  }
4999
5005
 
5000
5006
  // ../../apps/api/src/routes/storage.ts
5001
- var VERSION = "0.2.14";
5007
+ var VERSION = "0.2.16";
5002
5008
  function registerStorageRoutes(app2, container2) {
5003
5009
  app2.get("/api/health", async () => {
5004
5010
  const database = await probeDatabase(container2);