@exulu/backend 5.3.0 → 5.4.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.
@@ -1723,7 +1723,7 @@ var ExuluTool = class _ExuluTool {
1723
1723
  if (!agent) {
1724
1724
  throw new Error("Agent not found.");
1725
1725
  }
1726
- const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-77FLVHEA.js");
1726
+ const { convertExuluToolsToAiSdkTools: convertExuluToolsToAiSdkTools2 } = await import("./convert-exulu-tools-to-ai-sdk-tools-437EHCSN.js");
1727
1727
  const tools = await convertExuluToolsToAiSdkTools2(
1728
1728
  [this],
1729
1729
  [],
@@ -10563,6 +10563,14 @@ var usersSchema = {
10563
10563
  name: "favourite_items",
10564
10564
  type: "json"
10565
10565
  },
10566
+ {
10567
+ // Artifacts (2026-10): the shared artifacts a user starred, as a JSON
10568
+ // array of share names — mirrors favourite_projects. Auto-added to
10569
+ // existing DBs by the init-exulu-db column sync; read via userById,
10570
+ // written via usersUpdateOne.
10571
+ name: "favourite_artifacts",
10572
+ type: "json"
10573
+ },
10566
10574
  {
10567
10575
  // Knowledge: per-user "recently viewed" data items. Ordered JSON array
10568
10576
  // of global item ids ("<contextId>/<itemId>"), most-recent first, capped
@@ -11041,6 +11049,10 @@ var sharedArtifactsSchema = {
11041
11049
  // RBAC drives the "regular" auth_mode: rights_mode + the rbac table scope
11042
11050
  // who may view. public/password modes ignore rights_mode.
11043
11051
  RBAC: true,
11052
+ // Generic GraphQL writes are super-admin only: public/password shares carry
11053
+ // rights_mode "public", which the generic write check reads as "anyone may
11054
+ // edit". Creators change their shares through PATCH /shared-artifacts/:name.
11055
+ apiWrites: "super_admin",
11044
11056
  fields: [
11045
11057
  { name: "name", type: "text", index: true, unique: true, required: true },
11046
11058
  { name: "s3key", type: "text", required: true },
@@ -3,7 +3,7 @@ import {
3
3
  OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
4
4
  convertExuluToolsToAiSdkTools,
5
5
  hydrateVariables
6
- } from "./chunk-PU3LGCBR.js";
6
+ } from "./chunk-CWSP2WOQ.js";
7
7
  import "./chunk-4PDWNVNT.js";
8
8
  export {
9
9
  OUTPUT_OFFLOAD_EXEMPT_TOOL_IDS,
package/dist/index.cjs CHANGED
@@ -5206,6 +5206,14 @@ var init_core_schema = __esm({
5206
5206
  name: "favourite_items",
5207
5207
  type: "json"
5208
5208
  },
5209
+ {
5210
+ // Artifacts (2026-10): the shared artifacts a user starred, as a JSON
5211
+ // array of share names — mirrors favourite_projects. Auto-added to
5212
+ // existing DBs by the init-exulu-db column sync; read via userById,
5213
+ // written via usersUpdateOne.
5214
+ name: "favourite_artifacts",
5215
+ type: "json"
5216
+ },
5209
5217
  {
5210
5218
  // Knowledge: per-user "recently viewed" data items. Ordered JSON array
5211
5219
  // of global item ids ("<contextId>/<itemId>"), most-recent first, capped
@@ -5670,6 +5678,10 @@ var init_core_schema = __esm({
5670
5678
  // RBAC drives the "regular" auth_mode: rights_mode + the rbac table scope
5671
5679
  // who may view. public/password modes ignore rights_mode.
5672
5680
  RBAC: true,
5681
+ // Generic GraphQL writes are super-admin only: public/password shares carry
5682
+ // rights_mode "public", which the generic write check reads as "anyone may
5683
+ // edit". Creators change their shares through PATCH /shared-artifacts/:name.
5684
+ apiWrites: "super_admin",
5673
5685
  fields: [
5674
5686
  { name: "name", type: "text", index: true, unique: true, required: true },
5675
5687
  { name: "s3key", type: "text", required: true },
@@ -18427,6 +18439,44 @@ var validateCreateInput = (input, now) => {
18427
18439
  }
18428
18440
  return { ok: true };
18429
18441
  };
18442
+ var RIGHTS_MODES = /* @__PURE__ */ new Set(["private", "users", "roles", "teams", "public"]);
18443
+ var canManageShare = (row, user) => user.super_admin === true || row.created_by != null && String(row.created_by) === String(user.id);
18444
+ var validateUpdateInput = (input, row, now) => {
18445
+ if (input.name !== void 0 && !slugifyShareName(input.name)) {
18446
+ return { ok: false, message: "name must contain url-safe characters." };
18447
+ }
18448
+ const mode = input.auth_mode ?? row.auth_mode;
18449
+ if (mode !== "public" && mode !== "password" && mode !== "regular") {
18450
+ return { ok: false, message: "auth_mode must be public, password, or regular." };
18451
+ }
18452
+ const keepsPassword = row.auth_mode === "password" && !!row.password_hash;
18453
+ if (mode === "password" && !input.password && !keepsPassword) {
18454
+ return { ok: false, message: "A password is required for password mode." };
18455
+ }
18456
+ if (input.expires_at && Number.isNaN(new Date(input.expires_at).getTime())) {
18457
+ return { ok: false, message: "expires_at is not a valid date." };
18458
+ }
18459
+ if (input.expires_at && isExpired(input.expires_at, now)) {
18460
+ return { ok: false, message: "expires_at must be in the future." };
18461
+ }
18462
+ if (input.rights_mode !== void 0 && !RIGHTS_MODES.has(input.rights_mode)) {
18463
+ return { ok: false, message: "rights_mode must be private, users, roles, teams, or public." };
18464
+ }
18465
+ return { ok: true };
18466
+ };
18467
+ var planShareUpdate = (input, row, newPasswordHash, now) => {
18468
+ const mode = input.auth_mode ?? row.auth_mode;
18469
+ const patch = { auth_mode: mode, updatedAt: now };
18470
+ if (input.name !== void 0) patch.name = slugifyShareName(input.name);
18471
+ patch.password_hash = mode === "password" ? newPasswordHash ?? row.password_hash : null;
18472
+ if (input.expires_at !== void 0) patch.expires_at = input.expires_at;
18473
+ if (mode === "regular") {
18474
+ patch.rights_mode = input.rights_mode ?? (row.auth_mode === "regular" ? row.rights_mode ?? "private" : "private");
18475
+ } else {
18476
+ patch.rights_mode = "public";
18477
+ }
18478
+ return patch;
18479
+ };
18430
18480
  var hashSharePassword = (password) => import_bcryptjs3.default.hash(password, 10);
18431
18481
  var verifySharePassword = (password, hash) => import_bcryptjs3.default.compare(password, hash);
18432
18482
  var contentHeadersFor = (key, contentType, filename) => {
@@ -19844,6 +19894,28 @@ function createMutations(table, contexts, tools, config) {
19844
19894
  await saveTranscriptsSettings(parseSettingsInput(args.input));
19845
19895
  return buildTranscriptsSettingsInfo();
19846
19896
  };
19897
+ if (table.apiWrites === "super_admin") {
19898
+ for (const key of [
19899
+ `${tableNamePlural}CreateOne`,
19900
+ `${tableNamePlural}CopyOneById`,
19901
+ `${tableNamePlural}UpdateOne`,
19902
+ `${tableNamePlural}UpdateOneById`,
19903
+ `${tableNamePlural}RemoveOneById`,
19904
+ `${tableNamePlural}RemoveOne`,
19905
+ `${tableNamePlural}BulkUpdateRBAC`
19906
+ ]) {
19907
+ const inner = mutations[key];
19908
+ if (!inner) continue;
19909
+ mutations[key] = async (parent, args, context, info) => {
19910
+ if (context?.user?.super_admin !== true) {
19911
+ throw new Error(
19912
+ `${table.name.plural} rows are changed through their own API; the generic mutation is reserved for super admins.`
19913
+ );
19914
+ }
19915
+ return inner(parent, args, context, info);
19916
+ };
19917
+ }
19918
+ }
19847
19919
  return mutations;
19848
19920
  }
19849
19921
 
@@ -33064,7 +33136,8 @@ var {
33064
33136
  entityTypeSettingsSchema: entityTypeSettingsSchema2,
33065
33137
  promptFavoritesSchema: promptFavoritesSchema2,
33066
33138
  statisticsSchema: statisticsSchema2,
33067
- transcriptionJobsSchema: transcriptionJobsSchema2
33139
+ transcriptionJobsSchema: transcriptionJobsSchema2,
33140
+ sharedArtifactsSchema: sharedArtifactsSchema2
33068
33141
  } = coreSchemas.get();
33069
33142
  var claimCheckLimiter = claimCheckRateLimiter();
33070
33143
  var createExpressRoutes = async (app, tools, contexts, config, evals, tracer) => {
@@ -33135,7 +33208,13 @@ var createExpressRoutes = async (app, tools, contexts, config, evals, tracer) =>
33135
33208
  workflowTemplatesSchema2(),
33136
33209
  statisticsSchema2(),
33137
33210
  rbacSchema2(),
33138
- transcriptionJobsSchema2()
33211
+ transcriptionJobsSchema2(),
33212
+ // Shared artifacts (2026-10): listed and favourited from the IMP's
33213
+ // Artifacts page through the generated operations. The table carries
33214
+ // RBAC, so the generic access control applies (public, own, shared with
33215
+ // me / my role / my team); `password_hash` is hidden and never leaves
33216
+ // the resolvers. The bytes still come from /shared-artifacts/:name/content.
33217
+ sharedArtifactsSchema2()
33139
33218
  ],
33140
33219
  contexts ?? [],
33141
33220
  tools,
@@ -36640,7 +36719,7 @@ ${style.markdown}` : params.prompt;
36640
36719
  res.status(404).json({ detail: "Not found." });
36641
36720
  return;
36642
36721
  }
36643
- if (row.created_by !== auth.user.id) {
36722
+ if (!canManageShare(row, auth.user)) {
36644
36723
  res.status(403).json({ detail: "You can only delete your own share links." });
36645
36724
  return;
36646
36725
  }
@@ -36648,6 +36727,85 @@ ${style.markdown}` : params.prompt;
36648
36727
  await db2("shared_artifacts").where({ id: row.id }).delete();
36649
36728
  res.status(204).end();
36650
36729
  });
36730
+ app.get("/shared-artifacts/:name/settings", async (req, res) => {
36731
+ const { db: db2 } = await postgresClient();
36732
+ const auth = await requestValidators.authenticate(req);
36733
+ if (!auth.user?.id) {
36734
+ res.status(401).json({ detail: "Authentication required." });
36735
+ return;
36736
+ }
36737
+ const row = await getSharedArtifactByName(db2, req.params.name ?? "");
36738
+ if (!row) {
36739
+ res.status(404).json({ detail: "Not found." });
36740
+ return;
36741
+ }
36742
+ if (!canManageShare(row, auth.user)) {
36743
+ res.status(403).json({ detail: "You can only manage your own share links." });
36744
+ return;
36745
+ }
36746
+ const rbac = await db2("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).select("*");
36747
+ res.json({
36748
+ name: row.name,
36749
+ auth_mode: row.auth_mode,
36750
+ expires_at: row.expires_at ?? null,
36751
+ rights_mode: row.rights_mode ?? null,
36752
+ content_type: row.content_type ?? null,
36753
+ created_by: row.created_by ?? null,
36754
+ rbac: {
36755
+ users: rbac.filter((r) => r.access_type === "User").map((r) => ({ id: r.user_id, rights: r.rights })),
36756
+ roles: rbac.filter((r) => r.access_type === "Role").map((r) => ({ id: r.role_id, rights: r.rights })),
36757
+ teams: rbac.filter((r) => r.access_type === "Team").map((r) => ({ id: r.team_id, rights: r.rights }))
36758
+ }
36759
+ });
36760
+ });
36761
+ app.patch("/shared-artifacts/:name", async (req, res) => {
36762
+ const { db: db2 } = await postgresClient();
36763
+ const auth = await requestValidators.authenticate(req);
36764
+ if (!auth.user?.id) {
36765
+ res.status(401).json({ detail: "Authentication required." });
36766
+ return;
36767
+ }
36768
+ const row = await getSharedArtifactByName(db2, req.params.name ?? "");
36769
+ if (!row) {
36770
+ res.status(404).json({ detail: "Not found." });
36771
+ return;
36772
+ }
36773
+ if (!canManageShare(row, auth.user)) {
36774
+ res.status(403).json({ detail: "You can only change your own share links." });
36775
+ return;
36776
+ }
36777
+ const input = req.body ?? {};
36778
+ const now = /* @__PURE__ */ new Date();
36779
+ const valid = validateUpdateInput(input, row, now);
36780
+ if (!valid.ok) {
36781
+ res.status(400).json({ detail: valid.message });
36782
+ return;
36783
+ }
36784
+ const newHash = input.password ? await hashSharePassword(String(input.password)) : null;
36785
+ const patch = planShareUpdate(input, row, newHash, now);
36786
+ if (typeof patch.name === "string" && patch.name !== row.name) {
36787
+ const taken = await getSharedArtifactByName(db2, patch.name);
36788
+ if (taken) {
36789
+ res.status(409).json({ detail: "That share name is already taken." });
36790
+ return;
36791
+ }
36792
+ }
36793
+ const [updated] = await db2("shared_artifacts").where({ id: row.id }).update(patch).returning("*");
36794
+ if (patch.auth_mode === "regular") {
36795
+ if (input.rbac && typeof input.rbac === "object") {
36796
+ const existing = await db2("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).select("*");
36797
+ await handleRBACUpdate(db2, "shared_artifact", row.id, input.rbac, existing);
36798
+ }
36799
+ } else {
36800
+ await db2("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).delete();
36801
+ }
36802
+ res.json({
36803
+ name: updated.name,
36804
+ auth_mode: updated.auth_mode,
36805
+ expires_at: updated.expires_at ?? null,
36806
+ rights_mode: updated.rights_mode ?? null
36807
+ });
36808
+ });
36651
36809
  app.post("/shared-artifacts", async (req, res) => {
36652
36810
  const { db: db2 } = await postgresClient();
36653
36811
  const auth = await requestValidators.authenticate(req);
@@ -39678,7 +39836,7 @@ var {
39678
39836
  memoryConflictScansSchema: memoryConflictScansSchema2,
39679
39837
  transcriptionJobsSchema: transcriptionJobsSchema3,
39680
39838
  imageGenerationsSchema: imageGenerationsSchema2,
39681
- sharedArtifactsSchema: sharedArtifactsSchema2,
39839
+ sharedArtifactsSchema: sharedArtifactsSchema3,
39682
39840
  otpSendAttemptsSchema: otpSendAttemptsSchema2
39683
39841
  } = coreSchemas.get();
39684
39842
  var addMissingFields = async (knex, tableName, fields, skipFields = []) => {
@@ -39741,7 +39899,7 @@ var up = async function(knex) {
39741
39899
  memoryConflictScansSchema2(),
39742
39900
  transcriptionJobsSchema3(),
39743
39901
  imageGenerationsSchema2(),
39744
- sharedArtifactsSchema2(),
39902
+ sharedArtifactsSchema3(),
39745
39903
  rbacSchema3(),
39746
39904
  agentsSchema3(),
39747
39905
  feedbackSchema3(),
package/dist/index.js CHANGED
@@ -193,7 +193,7 @@ import {
193
193
  willEmbedOnQueue,
194
194
  withRetry,
195
195
  workflowTemplatesSchema
196
- } from "./chunk-PU3LGCBR.js";
196
+ } from "./chunk-CWSP2WOQ.js";
197
197
  import {
198
198
  LiteLLMAdminError,
199
199
  findLiteLLMModel,
@@ -1940,6 +1940,44 @@ var validateCreateInput = (input, now) => {
1940
1940
  }
1941
1941
  return { ok: true };
1942
1942
  };
1943
+ var RIGHTS_MODES = /* @__PURE__ */ new Set(["private", "users", "roles", "teams", "public"]);
1944
+ var canManageShare = (row, user) => user.super_admin === true || row.created_by != null && String(row.created_by) === String(user.id);
1945
+ var validateUpdateInput = (input, row, now) => {
1946
+ if (input.name !== void 0 && !slugifyShareName(input.name)) {
1947
+ return { ok: false, message: "name must contain url-safe characters." };
1948
+ }
1949
+ const mode = input.auth_mode ?? row.auth_mode;
1950
+ if (mode !== "public" && mode !== "password" && mode !== "regular") {
1951
+ return { ok: false, message: "auth_mode must be public, password, or regular." };
1952
+ }
1953
+ const keepsPassword = row.auth_mode === "password" && !!row.password_hash;
1954
+ if (mode === "password" && !input.password && !keepsPassword) {
1955
+ return { ok: false, message: "A password is required for password mode." };
1956
+ }
1957
+ if (input.expires_at && Number.isNaN(new Date(input.expires_at).getTime())) {
1958
+ return { ok: false, message: "expires_at is not a valid date." };
1959
+ }
1960
+ if (input.expires_at && isExpired(input.expires_at, now)) {
1961
+ return { ok: false, message: "expires_at must be in the future." };
1962
+ }
1963
+ if (input.rights_mode !== void 0 && !RIGHTS_MODES.has(input.rights_mode)) {
1964
+ return { ok: false, message: "rights_mode must be private, users, roles, teams, or public." };
1965
+ }
1966
+ return { ok: true };
1967
+ };
1968
+ var planShareUpdate = (input, row, newPasswordHash, now) => {
1969
+ const mode = input.auth_mode ?? row.auth_mode;
1970
+ const patch = { auth_mode: mode, updatedAt: now };
1971
+ if (input.name !== void 0) patch.name = slugifyShareName(input.name);
1972
+ patch.password_hash = mode === "password" ? newPasswordHash ?? row.password_hash : null;
1973
+ if (input.expires_at !== void 0) patch.expires_at = input.expires_at;
1974
+ if (mode === "regular") {
1975
+ patch.rights_mode = input.rights_mode ?? (row.auth_mode === "regular" ? row.rights_mode ?? "private" : "private");
1976
+ } else {
1977
+ patch.rights_mode = "public";
1978
+ }
1979
+ return patch;
1980
+ };
1943
1981
  var hashSharePassword = (password) => bcrypt2.hash(password, 10);
1944
1982
  var verifySharePassword = (password, hash) => bcrypt2.compare(password, hash);
1945
1983
  var contentHeadersFor = (key, contentType, filename) => {
@@ -3337,6 +3375,28 @@ function createMutations(table, contexts, tools, config) {
3337
3375
  await saveTranscriptsSettings(parseSettingsInput(args.input));
3338
3376
  return buildTranscriptsSettingsInfo();
3339
3377
  };
3378
+ if (table.apiWrites === "super_admin") {
3379
+ for (const key of [
3380
+ `${tableNamePlural}CreateOne`,
3381
+ `${tableNamePlural}CopyOneById`,
3382
+ `${tableNamePlural}UpdateOne`,
3383
+ `${tableNamePlural}UpdateOneById`,
3384
+ `${tableNamePlural}RemoveOneById`,
3385
+ `${tableNamePlural}RemoveOne`,
3386
+ `${tableNamePlural}BulkUpdateRBAC`
3387
+ ]) {
3388
+ const inner = mutations[key];
3389
+ if (!inner) continue;
3390
+ mutations[key] = async (parent, args, context, info) => {
3391
+ if (context?.user?.super_admin !== true) {
3392
+ throw new Error(
3393
+ `${table.name.plural} rows are changed through their own API; the generic mutation is reserved for super admins.`
3394
+ );
3395
+ }
3396
+ return inner(parent, args, context, info);
3397
+ };
3398
+ }
3399
+ }
3340
3400
  return mutations;
3341
3401
  }
3342
3402
 
@@ -12408,7 +12468,9 @@ import fs2 from "fs";
12408
12468
  import { randomUUID as randomUUID7 } from "crypto";
12409
12469
  import "@opentelemetry/api";
12410
12470
  import JSZip3 from "jszip";
12411
- import { createIdGenerator as createIdGenerator2 } from "ai";
12471
+ import {
12472
+ createIdGenerator as createIdGenerator2
12473
+ } from "ai";
12412
12474
  import cookieParser from "cookie-parser";
12413
12475
 
12414
12476
  // src/exulu/suggestions.ts
@@ -16233,7 +16295,8 @@ var {
16233
16295
  entityTypeSettingsSchema,
16234
16296
  promptFavoritesSchema,
16235
16297
  statisticsSchema,
16236
- transcriptionJobsSchema
16298
+ transcriptionJobsSchema,
16299
+ sharedArtifactsSchema
16237
16300
  } = coreSchemas.get();
16238
16301
  var claimCheckLimiter = claimCheckRateLimiter();
16239
16302
  var createExpressRoutes = async (app, tools, contexts, config, evals, tracer) => {
@@ -16304,7 +16367,13 @@ var createExpressRoutes = async (app, tools, contexts, config, evals, tracer) =>
16304
16367
  workflowTemplatesSchema2(),
16305
16368
  statisticsSchema(),
16306
16369
  rbacSchema(),
16307
- transcriptionJobsSchema()
16370
+ transcriptionJobsSchema(),
16371
+ // Shared artifacts (2026-10): listed and favourited from the IMP's
16372
+ // Artifacts page through the generated operations. The table carries
16373
+ // RBAC, so the generic access control applies (public, own, shared with
16374
+ // me / my role / my team); `password_hash` is hidden and never leaves
16375
+ // the resolvers. The bytes still come from /shared-artifacts/:name/content.
16376
+ sharedArtifactsSchema()
16308
16377
  ],
16309
16378
  contexts ?? [],
16310
16379
  tools,
@@ -19809,7 +19878,7 @@ ${style.markdown}` : params.prompt;
19809
19878
  res.status(404).json({ detail: "Not found." });
19810
19879
  return;
19811
19880
  }
19812
- if (row.created_by !== auth.user.id) {
19881
+ if (!canManageShare(row, auth.user)) {
19813
19882
  res.status(403).json({ detail: "You can only delete your own share links." });
19814
19883
  return;
19815
19884
  }
@@ -19817,6 +19886,85 @@ ${style.markdown}` : params.prompt;
19817
19886
  await db("shared_artifacts").where({ id: row.id }).delete();
19818
19887
  res.status(204).end();
19819
19888
  });
19889
+ app.get("/shared-artifacts/:name/settings", async (req, res) => {
19890
+ const { db } = await postgresClient();
19891
+ const auth = await requestValidators.authenticate(req);
19892
+ if (!auth.user?.id) {
19893
+ res.status(401).json({ detail: "Authentication required." });
19894
+ return;
19895
+ }
19896
+ const row = await getSharedArtifactByName(db, req.params.name ?? "");
19897
+ if (!row) {
19898
+ res.status(404).json({ detail: "Not found." });
19899
+ return;
19900
+ }
19901
+ if (!canManageShare(row, auth.user)) {
19902
+ res.status(403).json({ detail: "You can only manage your own share links." });
19903
+ return;
19904
+ }
19905
+ const rbac = await db("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).select("*");
19906
+ res.json({
19907
+ name: row.name,
19908
+ auth_mode: row.auth_mode,
19909
+ expires_at: row.expires_at ?? null,
19910
+ rights_mode: row.rights_mode ?? null,
19911
+ content_type: row.content_type ?? null,
19912
+ created_by: row.created_by ?? null,
19913
+ rbac: {
19914
+ users: rbac.filter((r) => r.access_type === "User").map((r) => ({ id: r.user_id, rights: r.rights })),
19915
+ roles: rbac.filter((r) => r.access_type === "Role").map((r) => ({ id: r.role_id, rights: r.rights })),
19916
+ teams: rbac.filter((r) => r.access_type === "Team").map((r) => ({ id: r.team_id, rights: r.rights }))
19917
+ }
19918
+ });
19919
+ });
19920
+ app.patch("/shared-artifacts/:name", async (req, res) => {
19921
+ const { db } = await postgresClient();
19922
+ const auth = await requestValidators.authenticate(req);
19923
+ if (!auth.user?.id) {
19924
+ res.status(401).json({ detail: "Authentication required." });
19925
+ return;
19926
+ }
19927
+ const row = await getSharedArtifactByName(db, req.params.name ?? "");
19928
+ if (!row) {
19929
+ res.status(404).json({ detail: "Not found." });
19930
+ return;
19931
+ }
19932
+ if (!canManageShare(row, auth.user)) {
19933
+ res.status(403).json({ detail: "You can only change your own share links." });
19934
+ return;
19935
+ }
19936
+ const input = req.body ?? {};
19937
+ const now = /* @__PURE__ */ new Date();
19938
+ const valid = validateUpdateInput(input, row, now);
19939
+ if (!valid.ok) {
19940
+ res.status(400).json({ detail: valid.message });
19941
+ return;
19942
+ }
19943
+ const newHash = input.password ? await hashSharePassword(String(input.password)) : null;
19944
+ const patch = planShareUpdate(input, row, newHash, now);
19945
+ if (typeof patch.name === "string" && patch.name !== row.name) {
19946
+ const taken = await getSharedArtifactByName(db, patch.name);
19947
+ if (taken) {
19948
+ res.status(409).json({ detail: "That share name is already taken." });
19949
+ return;
19950
+ }
19951
+ }
19952
+ const [updated] = await db("shared_artifacts").where({ id: row.id }).update(patch).returning("*");
19953
+ if (patch.auth_mode === "regular") {
19954
+ if (input.rbac && typeof input.rbac === "object") {
19955
+ const existing = await db("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).select("*");
19956
+ await handleRBACUpdate(db, "shared_artifact", row.id, input.rbac, existing);
19957
+ }
19958
+ } else {
19959
+ await db("rbac").where({ entity: "shared_artifact", target_resource_id: row.id }).delete();
19960
+ }
19961
+ res.json({
19962
+ name: updated.name,
19963
+ auth_mode: updated.auth_mode,
19964
+ expires_at: updated.expires_at ?? null,
19965
+ rights_mode: updated.rights_mode ?? null
19966
+ });
19967
+ });
19820
19968
  app.post("/shared-artifacts", async (req, res) => {
19821
19969
  const { db } = await postgresClient();
19822
19970
  const auth = await requestValidators.authenticate(req);
@@ -22750,7 +22898,7 @@ var {
22750
22898
  memoryConflictScansSchema,
22751
22899
  transcriptionJobsSchema: transcriptionJobsSchema2,
22752
22900
  imageGenerationsSchema,
22753
- sharedArtifactsSchema,
22901
+ sharedArtifactsSchema: sharedArtifactsSchema2,
22754
22902
  otpSendAttemptsSchema
22755
22903
  } = coreSchemas.get();
22756
22904
  var addMissingFields = async (knex, tableName, fields, skipFields = []) => {
@@ -22813,7 +22961,7 @@ var up = async function(knex) {
22813
22961
  memoryConflictScansSchema(),
22814
22962
  transcriptionJobsSchema2(),
22815
22963
  imageGenerationsSchema(),
22816
- sharedArtifactsSchema(),
22964
+ sharedArtifactsSchema2(),
22817
22965
  rbacSchema2(),
22818
22966
  agentsSchema2(),
22819
22967
  feedbackSchema2(),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@exulu/backend",
3
3
  "author": "Qventu B.V.",
4
- "version": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "main": "./dist/index.js",
6
6
  "private": false,
7
7
  "publishConfig": {