@exulu/backend 1.69.3 → 1.70.0

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.
package/dist/index.cjs CHANGED
@@ -22950,6 +22950,48 @@ ${style.markdown}` : params.prompt;
22950
22950
  }
22951
22951
  res.status(204).send();
22952
22952
  });
22953
+ app.get("/shared-artifacts", async (req, res) => {
22954
+ const { db: db2 } = await postgresClient();
22955
+ const auth = await requestValidators.authenticate(req);
22956
+ if (!auth.user?.id) {
22957
+ res.status(401).json({ detail: "Authentication required." });
22958
+ return;
22959
+ }
22960
+ const s3keyRaw = req.query.s3key;
22961
+ if (!s3keyRaw || typeof s3keyRaw !== "string") {
22962
+ res.status(400).json({ detail: "s3key query parameter is required." });
22963
+ return;
22964
+ }
22965
+ const bucket = config.fileUploads?.s3Bucket ?? "";
22966
+ const normalizedKey = normalizeS3Key(s3keyRaw, bucket);
22967
+ const rows = await db2("shared_artifacts").where({ s3key: normalizedKey, created_by: auth.user.id }).orderBy("createdAt", "desc").select("name", "auth_mode", "expires_at", "rights_mode");
22968
+ res.json(rows.map((r) => ({
22969
+ name: r.name,
22970
+ auth_mode: r.auth_mode,
22971
+ expires_at: r.expires_at ?? null,
22972
+ rights_mode: r.rights_mode ?? null
22973
+ })));
22974
+ });
22975
+ app.delete("/shared-artifacts/:name", async (req, res) => {
22976
+ const { db: db2 } = await postgresClient();
22977
+ const auth = await requestValidators.authenticate(req);
22978
+ if (!auth.user?.id) {
22979
+ res.status(401).json({ detail: "Authentication required." });
22980
+ return;
22981
+ }
22982
+ const row = await getSharedArtifactByName(db2, req.params.name ?? "");
22983
+ if (!row) {
22984
+ res.status(404).json({ detail: "Not found." });
22985
+ return;
22986
+ }
22987
+ if (row.created_by !== auth.user.id) {
22988
+ res.status(403).json({ detail: "You can only delete your own share links." });
22989
+ return;
22990
+ }
22991
+ await db2("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).delete();
22992
+ await db2("shared_artifacts").where({ id: row.id }).delete();
22993
+ res.status(204).end();
22994
+ });
22953
22995
  app.post("/shared-artifacts", async (req, res) => {
22954
22996
  const { db: db2 } = await postgresClient();
22955
22997
  const auth = await requestValidators.authenticate(req);
package/dist/index.js CHANGED
@@ -11807,6 +11807,48 @@ ${style.markdown}` : params.prompt;
11807
11807
  }
11808
11808
  res.status(204).send();
11809
11809
  });
11810
+ app.get("/shared-artifacts", async (req, res) => {
11811
+ const { db } = await postgresClient();
11812
+ const auth = await requestValidators.authenticate(req);
11813
+ if (!auth.user?.id) {
11814
+ res.status(401).json({ detail: "Authentication required." });
11815
+ return;
11816
+ }
11817
+ const s3keyRaw = req.query.s3key;
11818
+ if (!s3keyRaw || typeof s3keyRaw !== "string") {
11819
+ res.status(400).json({ detail: "s3key query parameter is required." });
11820
+ return;
11821
+ }
11822
+ const bucket = config.fileUploads?.s3Bucket ?? "";
11823
+ const normalizedKey = normalizeS3Key(s3keyRaw, bucket);
11824
+ const rows = await db("shared_artifacts").where({ s3key: normalizedKey, created_by: auth.user.id }).orderBy("createdAt", "desc").select("name", "auth_mode", "expires_at", "rights_mode");
11825
+ res.json(rows.map((r) => ({
11826
+ name: r.name,
11827
+ auth_mode: r.auth_mode,
11828
+ expires_at: r.expires_at ?? null,
11829
+ rights_mode: r.rights_mode ?? null
11830
+ })));
11831
+ });
11832
+ app.delete("/shared-artifacts/:name", async (req, res) => {
11833
+ const { db } = await postgresClient();
11834
+ const auth = await requestValidators.authenticate(req);
11835
+ if (!auth.user?.id) {
11836
+ res.status(401).json({ detail: "Authentication required." });
11837
+ return;
11838
+ }
11839
+ const row = await getSharedArtifactByName(db, req.params.name ?? "");
11840
+ if (!row) {
11841
+ res.status(404).json({ detail: "Not found." });
11842
+ return;
11843
+ }
11844
+ if (row.created_by !== auth.user.id) {
11845
+ res.status(403).json({ detail: "You can only delete your own share links." });
11846
+ return;
11847
+ }
11848
+ await db("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).delete();
11849
+ await db("shared_artifacts").where({ id: row.id }).delete();
11850
+ res.status(204).end();
11851
+ });
11810
11852
  app.post("/shared-artifacts", async (req, res) => {
11811
11853
  const { db } = await postgresClient();
11812
11854
  const auth = await requestValidators.authenticate(req);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu Bv.",
4
- "version": "1.69.3",
4
+ "version": "1.70.0",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {