@selvajs/selva 4.21.0-beta.17 → 4.21.0-beta.18

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 (115) hide show
  1. package/build/adapter-node.js +2 -2
  2. package/build/client/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
  3. package/build/client/_app/immutable/chunks/a5NclWb-.js +2 -0
  4. package/build/client/_app/immutable/chunks/a5NclWb-.js.br +0 -0
  5. package/build/client/_app/immutable/chunks/a5NclWb-.js.gz +0 -0
  6. package/build/client/_app/immutable/entry/{app.CqykPefk.js → app.D3YN7-nC.js} +2 -2
  7. package/build/client/_app/immutable/entry/app.D3YN7-nC.js.br +0 -0
  8. package/build/client/_app/immutable/entry/app.D3YN7-nC.js.gz +0 -0
  9. package/build/client/_app/immutable/nodes/{20.B2EnikH5.js → 20.B8bN-AYw.js} +1 -1
  10. package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.br +0 -0
  11. package/build/client/_app/immutable/nodes/20.B8bN-AYw.js.gz +0 -0
  12. package/build/client/_app/immutable/nodes/{25.C7VDbaM3.js → 25.DbMk0htM.js} +20 -20
  13. package/build/client/_app/immutable/nodes/25.DbMk0htM.js.br +0 -0
  14. package/build/client/_app/immutable/nodes/25.DbMk0htM.js.gz +0 -0
  15. package/build/client/_app/version.json +1 -1
  16. package/build/client/_app/version.json.br +0 -0
  17. package/build/client/_app/version.json.gz +0 -0
  18. package/build/server/.vite/manifest.json +88 -6
  19. package/build/server/_app/immutable/assets/baseHDR.Dkr46J8-.hdr +0 -0
  20. package/build/server/chunks/DefinitionCard.js +1 -1
  21. package/build/server/chunks/DefinitionCard.js.map +1 -1
  22. package/build/server/chunks/api.js +1 -1
  23. package/build/server/chunks/baseHDR.js +5 -0
  24. package/build/server/chunks/baseHDR.js.map +1 -0
  25. package/build/server/chunks/capture.js +5 -0
  26. package/build/server/chunks/capture.js.map +1 -0
  27. package/build/server/chunks/diff.js +1 -8
  28. package/build/server/chunks/diff.js.map +1 -1
  29. package/build/server/chunks/functions.js +1 -1
  30. package/build/server/chunks/handlers.js +71 -25
  31. package/build/server/chunks/handlers.js.map +1 -1
  32. package/build/server/chunks/instance.js +5 -5
  33. package/build/server/chunks/instanceAdmins.server.js +1 -1
  34. package/build/server/chunks/internal.js +3 -3
  35. package/build/server/chunks/inventory.js +59 -16
  36. package/build/server/chunks/inventory.js.map +1 -1
  37. package/build/server/chunks/package.js +2 -1
  38. package/build/server/chunks/package.js.map +1 -1
  39. package/build/server/chunks/path.js +7 -0
  40. package/build/server/chunks/path.js.map +1 -0
  41. package/build/server/chunks/presets.server.js +1 -1
  42. package/build/server/chunks/providers.server.js +21 -12
  43. package/build/server/chunks/providers.server.js.map +1 -1
  44. package/build/server/chunks/registry.js +18 -3
  45. package/build/server/chunks/registry.js.map +1 -1
  46. package/build/server/chunks/remote.js +1559 -0
  47. package/build/server/chunks/remote.js.map +1 -0
  48. package/build/server/chunks/rhino3dm.js.map +1 -1
  49. package/build/server/chunks/server-errors.js +19 -1
  50. package/build/server/chunks/server-errors.js.map +1 -1
  51. package/build/server/chunks/server5.js +52 -0
  52. package/build/server/chunks/server5.js.map +1 -0
  53. package/build/server/chunks/solve.js +5 -0
  54. package/build/server/chunks/solve.js.map +1 -0
  55. package/build/server/chunks/stash-instance.js +94 -0
  56. package/build/server/chunks/stash-instance.js.map +1 -0
  57. package/build/server/chunks/sveltekit.js +2 -1
  58. package/build/server/chunks/sveltekit.js.map +1 -1
  59. package/build/server/chunks/types4.js +10 -0
  60. package/build/server/chunks/types4.js.map +1 -0
  61. package/build/server/entries/endpoints/api/admin/users/_id_/disable/_server.ts.js +1 -1
  62. package/build/server/entries/endpoints/api/v1/definitions/_guid_/_server.ts.js +1 -1
  63. package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js +3 -2
  64. package/build/server/entries/endpoints/api/v1/definitions/_guid_/image/_server.ts.js.map +1 -1
  65. package/build/server/entries/endpoints/api/v1/definitions/_guid_/publish/_server.ts.js +1 -1
  66. package/build/server/entries/endpoints/api/v1/definitions/_guid_/schema/_server.ts.js +1 -1
  67. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_linkId_/_server.ts.js +1 -1
  68. package/build/server/entries/endpoints/api/v1/definitions/_guid_/share-links/_server.ts.js +1 -1
  69. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_server.ts.js +1 -1
  70. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/_server.ts.js +1 -1
  71. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/changes/_server.ts.js +1 -1
  72. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/inventory/_server.ts.js +1 -1
  73. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/schema/_server.ts.js +1 -1
  74. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/_versionId_/scripts/_scriptId_/_server.ts.js +1 -1
  75. package/build/server/entries/endpoints/api/v1/definitions/_guid_/versions/check/_server.ts.js +1 -1
  76. package/build/server/entries/endpoints/api/v1/definitions/_server.ts.js +1 -1
  77. package/build/server/entries/endpoints/api/v1/me/_server.ts.js +1 -1
  78. package/build/server/entries/endpoints/api/v1/me/starred/_guid_/_server.ts.js +1 -1
  79. package/build/server/entries/endpoints/api/v1/me/token/_server.ts.js +1 -1
  80. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/_server.ts.js +1 -1
  81. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/assets/_kind_/_server.ts.js +1 -1
  82. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_server.ts.js +1 -1
  83. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/members/_userId_/_server.ts.js +1 -1
  84. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_server.ts.js +1 -1
  85. package/build/server/entries/endpoints/api/v1/orgs/_orgId_/tokens/_tokenId_/_server.ts.js +1 -1
  86. package/build/server/entries/endpoints/api/v1/projects/_id_/reclaim/_server.ts.js +1 -1
  87. package/build/server/entries/endpoints/docs/api/openapi.yaml/_server.ts.js +1 -1
  88. package/build/server/entries/endpoints/mcp/_server.ts.js +1085 -91
  89. package/build/server/entries/endpoints/mcp/_server.ts.js.map +1 -1
  90. package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js +18 -0
  91. package/build/server/entries/endpoints/mcp/files/_token_/_name_/_server.ts.js.map +1 -0
  92. package/build/server/entries/hooks.server.js +8 -3
  93. package/build/server/entries/hooks.server.js.map +1 -1
  94. package/build/server/entries/pages/projects/_page.svelte.js +12 -6
  95. package/build/server/entries/pages/projects/_page.svelte.js.map +1 -1
  96. package/build/server/entries/pages/team/tokens/_page.server.ts.js +1 -1
  97. package/build/server/index.js +1 -1
  98. package/build/server/manifest-full.js +8 -1
  99. package/build/server/manifest.js +8 -1
  100. package/build/server/nodes/20.js +1 -1
  101. package/build/server/nodes/25.js +1 -1
  102. package/build/server/remote-entry.js +1 -1559
  103. package/build/server/server.js +8 -1
  104. package/package.json +6 -5
  105. package/templates/.env.example +6 -0
  106. package/build/client/_app/immutable/chunks/Cv7GBWJh.js +0 -2
  107. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.br +0 -0
  108. package/build/client/_app/immutable/chunks/Cv7GBWJh.js.gz +0 -0
  109. package/build/client/_app/immutable/entry/app.CqykPefk.js.br +0 -0
  110. package/build/client/_app/immutable/entry/app.CqykPefk.js.gz +0 -0
  111. package/build/client/_app/immutable/nodes/20.B2EnikH5.js.br +0 -0
  112. package/build/client/_app/immutable/nodes/20.B2EnikH5.js.gz +0 -0
  113. package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.br +0 -0
  114. package/build/client/_app/immutable/nodes/25.C7VDbaM3.js.gz +0 -0
  115. package/build/server/remote-entry.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"solve.js","names":[],"sources":[],"mappings":""}
@@ -0,0 +1,94 @@
1
+ import { x as getStorageProvider } from "./providers.server.js";
2
+ import { randomBytes } from "node:crypto";
3
+ // src/lib/server/mcp/stash.ts
4
+ var STASH_TTL_MS = 36e5;
5
+ var STASH_SWEEP_EVERY_MS = 36e5;
6
+ var HOUR_MS = 36e5;
7
+ var SWEEP_BACK_HOURS = 48;
8
+ var ROOT = "mcp-stash";
9
+ var SWEPT_MARKER = `${ROOT}/swept.bin`;
10
+ var TOKEN = /^(\d+)-([A-Za-z0-9_-]{32})$/;
11
+ function createStash(storage, now = Date.now) {
12
+ let sweptThrough;
13
+ let sweeping;
14
+ const paths = (hour, id) => ({
15
+ data: `${ROOT}/${hour}/${id}.bin`,
16
+ meta: `${ROOT}/${hour}/${id}.meta.bin`
17
+ });
18
+ async function readMarker() {
19
+ const raw = await storage.get(SWEPT_MARKER).catch(() => null);
20
+ const hour = raw ? Number(new TextDecoder().decode(raw)) : NaN;
21
+ return Number.isInteger(hour) ? hour : void 0;
22
+ }
23
+ async function sweepDue() {
24
+ const last = Math.floor(now() / HOUR_MS) - 2;
25
+ sweptThrough ??= await readMarker();
26
+ if (sweptThrough !== void 0 && sweptThrough >= last) return;
27
+ const first = sweptThrough === void 0 ? last - SWEEP_BACK_HOURS : sweptThrough + 1;
28
+ for (let hour = first; hour <= last; hour++) await storage.deletePrefix(`${ROOT}/${hour}/`);
29
+ sweptThrough = last;
30
+ await storage.put(SWEPT_MARKER, new TextEncoder().encode(String(last)), "application/octet-stream");
31
+ }
32
+ function sweep() {
33
+ const run = (sweeping ?? Promise.resolve()).then(sweepDue).catch(() => {});
34
+ sweeping = run;
35
+ return run;
36
+ }
37
+ return {
38
+ sweep,
39
+ async put({ kind, name, contentType, data }) {
40
+ sweep();
41
+ const hour = String(Math.floor(now() / HOUR_MS));
42
+ const id = randomBytes(24).toString("base64url");
43
+ const at = paths(hour, id);
44
+ const meta = {
45
+ kind,
46
+ name,
47
+ contentType,
48
+ expiresAt: now() + STASH_TTL_MS
49
+ };
50
+ await storage.put(at.data, data, "application/octet-stream");
51
+ await storage.put(at.meta, new TextEncoder().encode(JSON.stringify(meta)), "application/octet-stream");
52
+ return `${hour}-${id}`;
53
+ },
54
+ async get(token, kind) {
55
+ sweep();
56
+ const match = TOKEN.exec(token);
57
+ if (!match) return void 0;
58
+ const at = paths(match[1], match[2]);
59
+ const rawMeta = await storage.get(at.meta);
60
+ if (!rawMeta) return void 0;
61
+ const meta = JSON.parse(new TextDecoder().decode(rawMeta));
62
+ if (meta.kind !== kind || meta.expiresAt <= now()) return void 0;
63
+ const data = await storage.get(at.data);
64
+ return data ? {
65
+ ...meta,
66
+ data
67
+ } : void 0;
68
+ }
69
+ };
70
+ }
71
+ /** For a solve's geometry: the stash holds bytes. */
72
+ var jsonBytes = (value) => new TextEncoder().encode(JSON.stringify(value));
73
+ var fromJsonBytes = (bytes) => JSON.parse(new TextDecoder().decode(bytes));
74
+ // src/lib/server/mcp/stash-instance.ts
75
+ var stash;
76
+ var janitor;
77
+ /** The stash on the configured storage provider, made on first use. */
78
+ function mcpStash() {
79
+ stash ??= createStash(getStorageProvider());
80
+ return stash;
81
+ }
82
+ /**
83
+ * Sweeps expired stash entries now and then hourly, so they go on time even when no MCP call
84
+ * comes in. Once per process.
85
+ */
86
+ function startStashJanitor() {
87
+ if (janitor) return;
88
+ mcpStash().sweep();
89
+ janitor = setInterval(() => void mcpStash().sweep(), STASH_SWEEP_EVERY_MS);
90
+ janitor.unref?.();
91
+ }
92
+ export { jsonBytes as i, startStashJanitor as n, fromJsonBytes as r, mcpStash as t };
93
+
94
+ //# sourceMappingURL=stash-instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stash-instance.js","names":[],"sources":["../../../src/lib/server/mcp/stash.ts","../../../src/lib/server/mcp/stash-instance.ts"],"sourcesContent":["import { randomBytes } from 'node:crypto';\nimport type { IStorageProvider } from '@selvajs/platform';\n\n/**\n * What an MCP tool hands out by token instead of inline: a solve's output files (a download\n * link), its geometry (for the 3D view) and a rendered preview (for the cover). Kept in the\n * storage provider for {@link STASH_TTL_MS}, so a link survives a restart and works on every\n * instance that shares the storage.\n *\n * A token is the only credential: whoever holds a file link can download it until it expires.\n */\nexport interface StashEntry {\n\tkind: 'file' | 'solve' | 'preview';\n\t/** File name for a download. */\n\tname: string;\n\tcontentType: string;\n\tdata: Uint8Array;\n\texpiresAt: number;\n}\n\nexport interface Stash {\n\tput(entry: Omit<StashEntry, 'expiresAt'>): Promise<string>;\n\t/** The entry, if it exists, has not expired and is of `kind`. */\n\tget(token: string, kind: StashEntry['kind']): Promise<StashEntry | undefined>;\n\t/** Deletes every hour that holds only expired entries. Cheap when nothing is due. */\n\tsweep(): Promise<void>;\n}\n\nexport const STASH_TTL_MS = 60 * 60_000;\nexport const STASH_SWEEP_EVERY_MS = 60 * 60_000;\n// Entries live under the hour they were made in. Storage can't list, so expired entries go by\n// deleting whole hours: an hour two behind the current one holds nothing still valid. The last\n// hour swept is kept in storage, so a restart, however long, resumes where the last run stopped.\nconst HOUR_MS = 60 * 60_000;\nconst SWEEP_BACK_HOURS = 48;\nconst ROOT = 'mcp-stash';\nconst SWEPT_MARKER = `${ROOT}/swept.bin`;\nconst TOKEN = /^(\\d+)-([A-Za-z0-9_-]{32})$/;\n\ntype Storage = Pick<IStorageProvider, 'get' | 'put' | 'deletePrefix'>;\n\ninterface Meta {\n\tkind: StashEntry['kind'];\n\tname: string;\n\tcontentType: string;\n\texpiresAt: number;\n}\n\nexport function createStash(storage: Storage, now: () => number = Date.now): Stash {\n\tlet sweptThrough: number | undefined;\n\tlet sweeping: Promise<void> | undefined;\n\n\t// `.bin` and an octet-stream type, so no provider takes either for an image to transcode.\n\tconst paths = (hour: string, id: string) => ({\n\t\tdata: `${ROOT}/${hour}/${id}.bin`,\n\t\tmeta: `${ROOT}/${hour}/${id}.meta.bin`\n\t});\n\n\tasync function readMarker(): Promise<number | undefined> {\n\t\tconst raw = await storage.get(SWEPT_MARKER).catch(() => null);\n\t\tconst hour = raw ? Number(new TextDecoder().decode(raw)) : NaN;\n\t\treturn Number.isInteger(hour) ? hour : undefined;\n\t}\n\n\tasync function sweepDue(): Promise<void> {\n\t\tconst last = Math.floor(now() / HOUR_MS) - 2;\n\t\tsweptThrough ??= await readMarker();\n\t\tif (sweptThrough !== undefined && sweptThrough >= last) return;\n\t\tconst first = sweptThrough === undefined ? last - SWEEP_BACK_HOURS : sweptThrough + 1;\n\t\tfor (let hour = first; hour <= last; hour++) {\n\t\t\tawait storage.deletePrefix(`${ROOT}/${hour}/`);\n\t\t}\n\t\tsweptThrough = last;\n\t\tawait storage.put(\n\t\t\tSWEPT_MARKER,\n\t\t\tnew TextEncoder().encode(String(last)),\n\t\t\t'application/octet-stream'\n\t\t);\n\t}\n\n\t// Sweeps run one after another, never side by side. A failed one leaves the marker where it\n\t// was, so the next retries the same hours.\n\tfunction sweep(): Promise<void> {\n\t\tconst run = (sweeping ?? Promise.resolve()).then(sweepDue).catch(() => {});\n\t\tsweeping = run;\n\t\treturn run;\n\t}\n\n\treturn {\n\t\tsweep,\n\n\t\tasync put({ kind, name, contentType, data }) {\n\t\t\tvoid sweep();\n\t\t\tconst hour = String(Math.floor(now() / HOUR_MS));\n\t\t\tconst id = randomBytes(24).toString('base64url');\n\t\t\tconst at = paths(hour, id);\n\t\t\tconst meta: Meta = { kind, name, contentType, expiresAt: now() + STASH_TTL_MS };\n\t\t\tawait storage.put(at.data, data, 'application/octet-stream');\n\t\t\tawait storage.put(\n\t\t\t\tat.meta,\n\t\t\t\tnew TextEncoder().encode(JSON.stringify(meta)),\n\t\t\t\t'application/octet-stream'\n\t\t\t);\n\t\t\treturn `${hour}-${id}`;\n\t\t},\n\n\t\tasync get(token, kind) {\n\t\t\tvoid sweep();\n\t\t\tconst match = TOKEN.exec(token);\n\t\t\tif (!match) return undefined;\n\t\t\tconst at = paths(match[1], match[2]);\n\t\t\tconst rawMeta = await storage.get(at.meta);\n\t\t\tif (!rawMeta) return undefined;\n\t\t\tconst meta = JSON.parse(new TextDecoder().decode(rawMeta)) as Meta;\n\t\t\tif (meta.kind !== kind || meta.expiresAt <= now()) return undefined;\n\t\t\tconst data = await storage.get(at.data);\n\t\t\treturn data ? { ...meta, data } : undefined;\n\t\t}\n\t};\n}\n\n/** For a solve's geometry: the stash holds bytes. */\nexport const jsonBytes = (value: unknown) => new TextEncoder().encode(JSON.stringify(value));\nexport const fromJsonBytes = (bytes: Uint8Array): unknown =>\n\tJSON.parse(new TextDecoder().decode(bytes));\n","import { getStorageProvider } from '#lib/server/providers.server.js';\nimport { createStash, STASH_SWEEP_EVERY_MS, type Stash } from './stash.js';\n\nlet stash: Stash | undefined;\nlet janitor: ReturnType<typeof setInterval> | undefined;\n\n/** The stash on the configured storage provider, made on first use. */\nexport function mcpStash(): Stash {\n\tstash ??= createStash(getStorageProvider());\n\treturn stash;\n}\n\n/**\n * Sweeps expired stash entries now and then hourly, so they go on time even when no MCP call\n * comes in. Once per process.\n */\nexport function startStashJanitor(): void {\n\tif (janitor) return;\n\tvoid mcpStash().sweep();\n\tjanitor = setInterval(() => void mcpStash().sweep(), STASH_SWEEP_EVERY_MS);\n\tjanitor.unref?.();\n}\n"],"mappings":";;;AA4BA,IAAa,eAAe;AAC5B,IAAa,uBAAuB;AAIpC,IAAM,UAAU;AAChB,IAAM,mBAAmB;AACzB,IAAM,OAAO;AACb,IAAM,eAAe,GAAG,KAAK;AAC7B,IAAM,QAAQ;AAWd,SAAgB,YAAY,SAAkB,MAAoB,KAAK,KAAY;CAClF,IAAI;CACJ,IAAI;CAGJ,MAAM,SAAS,MAAc,QAAgB;EAC5C,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,GAAG;EAC5B,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,GAAG;CAC7B;CAEA,eAAe,aAA0C;EACxD,MAAM,MAAM,MAAM,QAAQ,IAAI,YAAY,CAAC,CAAC,YAAY,IAAI;EAC5D,MAAM,OAAO,MAAM,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI;EAC3D,OAAO,OAAO,UAAU,IAAI,IAAI,OAAO,KAAA;CACxC;CAEA,eAAe,WAA0B;EACxC,MAAM,OAAO,KAAK,MAAM,IAAI,IAAI,OAAO,IAAI;EAC3C,iBAAiB,MAAM,WAAW;EAClC,IAAI,iBAAiB,KAAA,KAAa,gBAAgB,MAAM;EACxD,MAAM,QAAQ,iBAAiB,KAAA,IAAY,OAAO,mBAAmB,eAAe;EACpF,KAAK,IAAI,OAAO,OAAO,QAAQ,MAAM,QACpC,MAAM,QAAQ,aAAa,GAAG,KAAK,GAAG,KAAK,EAAE;EAE9C,eAAe;EACf,MAAM,QAAQ,IACb,cACA,IAAI,YAAY,CAAC,CAAC,OAAO,OAAO,IAAI,CAAC,GACrC,0BACD;CACD;CAIA,SAAS,QAAuB;EAC/B,MAAM,OAAO,YAAY,QAAQ,QAAQ,EAAA,CAAG,KAAK,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;EACzE,WAAW;EACX,OAAO;CACR;CAEA,OAAO;EACN;EAEA,MAAM,IAAI,EAAE,MAAM,MAAM,aAAa,QAAQ;GAC5C,MAAW;GACX,MAAM,OAAO,OAAO,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC;GAC/C,MAAM,KAAK,YAAY,EAAE,CAAC,CAAC,SAAS,WAAW;GAC/C,MAAM,KAAK,MAAM,MAAM,EAAE;GACzB,MAAM,OAAa;IAAE;IAAM;IAAM;IAAa,WAAW,IAAI,IAAI;GAAa;GAC9E,MAAM,QAAQ,IAAI,GAAG,MAAM,MAAM,0BAA0B;GAC3D,MAAM,QAAQ,IACb,GAAG,MACH,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,IAAI,CAAC,GAC7C,0BACD;GACA,OAAO,GAAG,KAAK,GAAG;EACnB;EAEA,MAAM,IAAI,OAAO,MAAM;GACtB,MAAW;GACX,MAAM,QAAQ,MAAM,KAAK,KAAK;GAC9B,IAAI,CAAC,OAAO,OAAO,KAAA;GACnB,MAAM,KAAK,MAAM,MAAM,IAAI,MAAM,EAAE;GACnC,MAAM,UAAU,MAAM,QAAQ,IAAI,GAAG,IAAI;GACzC,IAAI,CAAC,SAAS,OAAO,KAAA;GACrB,MAAM,OAAO,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,OAAO,CAAC;GACzD,IAAI,KAAK,SAAS,QAAQ,KAAK,aAAa,IAAI,GAAG,OAAO,KAAA;GAC1D,MAAM,OAAO,MAAM,QAAQ,IAAI,GAAG,IAAI;GACtC,OAAO,OAAO;IAAE,GAAG;IAAM;GAAK,IAAI,KAAA;EACnC;CACD;AACD;;AAGA,IAAa,aAAa,UAAmB,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,UAAU,KAAK,CAAC;AAC3F,IAAa,iBAAiB,UAC7B,KAAK,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK,CAAC;;ACzH3C,IAAI;AACJ,IAAI;;AAGJ,SAAgB,WAAkB;CACjC,UAAU,YAAY,mBAAmB,CAAC;CAC1C,OAAO;AACR;;;;;AAMA,SAAgB,oBAA0B;CACzC,IAAI,SAAS;CACb,SAAc,CAAC,CAAC,MAAM;CACtB,UAAU,kBAAkB,KAAK,SAAS,CAAC,CAAC,MAAM,GAAG,oBAAoB;CACzE,QAAQ,QAAQ;AACjB"}
@@ -35,7 +35,7 @@ import { isHttpError, json } from "@sveltejs/kit";
35
35
  * `tokens` arrives in an options object rather than as a third positional, so
36
36
  * the two composed bags cannot be swapped at a call site.
37
37
  */
38
- function depsFromConfig(config, services = {}, { tokens = {}, uploadLimits, evictComputeClient = () => {}, onComputeConfigSaved = () => {}, notifications, instanceName = "Selva", apiTokenSettingsPath = "/settings/tokens", apiRateLimiter, projectCreateLimiter, idempotency } = {}) {
38
+ function depsFromConfig(config, services = {}, { tokens = {}, uploadLimits, evictComputeClient = () => {}, onComputeConfigSaved = () => {}, notifications, instanceName = "Selva", mailTemplates, apiTokenSettingsPath = "/settings/tokens", apiRateLimiter, projectCreateLimiter, idempotency } = {}) {
39
39
  const { data } = config;
40
40
  return {
41
41
  auth: config.auth,
@@ -61,6 +61,7 @@ function depsFromConfig(config, services = {}, { tokens = {}, uploadLimits, evic
61
61
  onComputeConfigSaved,
62
62
  notifications,
63
63
  instanceName,
64
+ mailTemplates,
64
65
  apiTokenSettingsPath,
65
66
  apiRateLimiter,
66
67
  projectCreateLimiter,
@@ -1 +1 @@
1
- {"version":3,"file":"sveltekit.js","names":[],"sources":["../../../../server/src/api/deps.ts","../../../../server/src/api/map-core-error.ts","../../../src/lib/server/api/sveltekit.ts"],"sourcesContent":["/**\n * Everything an API handler talks to, as one injected value.\n *\n * Handlers used to reach module-global getters (`getProjectProvider()`,\n * `getDefinitionService()`, …) from the Selva app's composition root — 77 call\n * sites across the v1 routes. That welded them to one app's boot: a second app\n * on a different provider set could not call them at all.\n *\n * Most fields are sub-stores of `IDataProvider`, so a host that already built a\n * `SelvaConfig` gets them via `depsFromConfig`. `services` stays host-defined:\n * `DefinitionService` and friends are composed rather than resolved, and a host\n * may supply its own.\n */\n\nimport { isFlagEnabled, NoopEventSink } from '@selvajs/platform';\nimport type { DefinitionService } from '../definitions/definition-service.js';\nimport type { OrgAssetService } from '../organizations/org-asset-service.js';\nimport type { TokenCodec } from '../tokens/token-codec.js';\nimport type { ApiTokenCodec } from '../tokens/api-token-codec.js';\nimport type { ApiTokenHolderPolicy } from '../tokens/api-token-holder.js';\nimport type { ApiTokenResolutionCache } from '../http/api-token.js';\nimport type { ApiRateLimiter } from './rate-limit.js';\nimport type { ApiIdempotencyStore } from './idempotency.js';\nimport type {\n\tIAuthProvider,\n\tIDataProvider,\n\tIEventSink,\n\tINotificationProvider,\n\tIStorageProvider,\n\tSelvaConfig,\n\tSelvaFlags\n} from '@selvajs/platform';\n\nexport interface SelvaDeps {\n\tauth: IAuthProvider;\n\tstorage: IStorageProvider;\n\tdata: IDataProvider;\n\t/** `data.orgs` — hoisted because 18 v1 call sites read it directly. */\n\torgs: IDataProvider['orgs'];\n\t/** `data.projects` — 18 call sites. */\n\tprojects: IDataProvider['projects'];\n\t/** `data.definitions` — the definition metadata store. */\n\tdefinitionMeta: IDataProvider['definitions'];\n\tcomputeServer: IDataProvider['computeServer'];\n\tuserProfile: IDataProvider['userProfile'];\n\tshareLinks: IDataProvider['shareLinks'];\n\tinvites: IDataProvider['invites'];\n\tpermissions: IDataProvider['permissions'];\n\tplatformProjectGrants: IDataProvider['platformProjectGrants'];\n\t/**\n\t * Audit sink. Never optional here even though `SelvaConfig.events` is:\n\t * handlers emit escalation events (`project.reclaimed`,\n\t * `org_member.removed_orphaning_projects`) that the audit trail depends on,\n\t * and a handler deciding for itself what a missing sink means is how one of\n\t * them ends up silently unlogged. `depsFromConfig` substitutes\n\t * `NoopEventSink`, which discards explicitly.\n\t */\n\tevents: IEventSink;\n\t/**\n\t * Feature flags, as a predicate rather than a record: an omitted flag must\n\t * read as false, and keeping that in `isFlagEnabled` stops each caller from\n\t * re-deciding what a missing flag means.\n\t */\n\tflag: (name: keyof SelvaFlags) => boolean;\n\t/**\n\t * Token codecs, one per family, keyed by what they mint.\n\t *\n\t * Injected rather than resolved because the codec is built from an\n\t * instance-wide HMAC secret, and reading that secret is the host's job — a\n\t * package that reached for `process.env.SELVA_HMAC_KEY` itself would pin\n\t * every host to one env var name and one way of loading it. Rotating a\n\t * secret invalidates that family's outstanding tokens, so the two families\n\t * are separate values rather than one shared codec.\n\t *\n\t * Optional: a host with no sharing and no invites wires neither. The\n\t * handlers that need one fail loudly if it is absent rather than minting a\n\t * token nobody can verify.\n\t */\n\ttokens: {\n\t\tshareLinks?: TokenCodec;\n\t\tinvites?: TokenCodec;\n\t\t/** Without it, minting answers 503 `API_TOKENS_UNAVAILABLE`. */\n\t\tapiTokens?: ApiTokenCodec;\n\t\t/** Who may mint and use API tokens. Absent: the platform permission `manage_api_tokens`. */\n\t\tmayHoldApiTokens?: ApiTokenHolderPolicy;\n\t\t/** How long one sign-in lasts before minting needs a new one (`resolveSignInMaxAgeMs`). Absent: no limit. */\n\t\tsignInMaxAgeMs?: number;\n\t\t/**\n\t\t * The cache the host hands `resolveApiToken`, so a revoke through these handlers drops\n\t\t * the key from it at once. Absent: nothing to drop.\n\t\t */\n\t\tresolutionCache?: ApiTokenResolutionCache;\n\t};\n\t/**\n\t * Upload caps, in bytes.\n\t *\n\t * Deployment config, so the host resolves them — a package reading its own\n\t * env would pin every host to one variable name. Defaults apply when the\n\t * host says nothing, because a missing cap must not read as \"unlimited\":\n\t * `requireUpload` compares against this number, and `undefined` would let\n\t * any size through.\n\t */\n\tuploadLimits: {\n\t\tmaxDefinitionFileSize: number;\n\t\tmaxImageFileSize: number;\n\t};\n\t/**\n\t * Outbound mail, and the instance name to fall back to when a record has no\n\t * name of its own.\n\t *\n\t * Optional because mail is best-effort by design: an invite row is committed\n\t * before delivery is attempted, and the caller still holds the accept URL to\n\t * share by hand. A host with no mail configured wires nothing and the\n\t * handlers report `not-configured` rather than failing the write.\n\t */\n\tnotifications?: INotificationProvider;\n\t/**\n\t * Per-token request limit `runHandler` charges. Absent: the process-wide\n\t * default (`DEFAULT_API_RATE_LIMIT`). `null`: no limit. A host's own limiter\n\t * must outlive the request, since deps are rebuilt per request.\n\t */\n\tapiRateLimiter?: ApiRateLimiter | null;\n\t/**\n\t * Projects one owner may create through API keys, across all their keys.\n\t * Absent: the process-wide default (`DEFAULT_PROJECT_CREATE_LIMIT`). `null`:\n\t * no limit.\n\t */\n\tprojectCreateLimiter?: ApiRateLimiter | null;\n\t/** Replay store for routes mounted with `idempotent: true`. Absent: the process-wide default. */\n\tidempotency?: ApiIdempotencyStore;\n\t/** Instance display name, used where a record has none. */\n\tinstanceName: string;\n\t/** Where a person manages their API tokens, linked from the new-key email. Host-relative. */\n\tapiTokenSettingsPath: string;\n\t/**\n\t * Drop the host's warm compute client for one server id.\n\t *\n\t * A warm client caches on server `id`, so a rotated URL or key keeps the\n\t * same cache key with stale connection details and never ages out. The\n\t * config-write handlers evict through this rather than importing a cache:\n\t * which cache holds them is the host's decision, and importing one would\n\t * pull a whole solve engine into every consumer.\n\t *\n\t * Defaults to a no-op — a host with no client cache has nothing to evict,\n\t * and the handler must not have to know which kind of host it is running on.\n\t */\n\tevictComputeClient: (id: string) => void;\n\t/**\n\t * Called after every compute-config save, so a host remembering resolved servers\n\t * (`createServerResolver`) reads the config again. Defaults to a no-op.\n\t */\n\tonComputeConfigSaved: () => void;\n\t/**\n\t * Composed services the host supplies.\n\t *\n\t * The named ones are typed because handlers call them — leaving a service\n\t * `unknown` pushes a cast into every call site, and a cast is exactly where\n\t * a second host's differently-shaped service would slip through unnoticed.\n\t * The index signature keeps host-specific extras possible without naming\n\t * them here.\n\t */\n\tservices: {\n\t\tdefinitions?: DefinitionService;\n\t\torgAssets?: OrgAssetService;\n\t} & Record<string, unknown>;\n}\n\n/**\n * Build deps from a resolved `SelvaConfig`, plus whatever services and token\n * codecs the host composed on top. The hoisted fields are aliases into `data`,\n * not copies.\n *\n * `services` stays positional — every existing caller passes it there — and\n * `tokens` arrives in an options object rather than as a third positional, so\n * the two composed bags cannot be swapped at a call site.\n */\nexport function depsFromConfig(\n\tconfig: SelvaConfig,\n\tservices: SelvaDeps['services'] = {},\n\t{\n\t\ttokens = {},\n\t\tuploadLimits,\n\t\tevictComputeClient = () => {},\n\t\tonComputeConfigSaved = () => {},\n\t\tnotifications,\n\t\tinstanceName = 'Selva',\n\t\tapiTokenSettingsPath = '/settings/tokens',\n\t\tapiRateLimiter,\n\t\tprojectCreateLimiter,\n\t\tidempotency\n\t}: {\n\t\ttokens?: SelvaDeps['tokens'];\n\t\tuploadLimits?: Partial<SelvaDeps['uploadLimits']>;\n\t\tevictComputeClient?: SelvaDeps['evictComputeClient'];\n\t\tonComputeConfigSaved?: SelvaDeps['onComputeConfigSaved'];\n\t\tnotifications?: INotificationProvider;\n\t\tinstanceName?: string;\n\t\tapiTokenSettingsPath?: string;\n\t\tapiRateLimiter?: ApiRateLimiter | null;\n\t\tprojectCreateLimiter?: ApiRateLimiter | null;\n\t\tidempotency?: ApiIdempotencyStore;\n\t} = {}\n): SelvaDeps {\n\tconst { data } = config;\n\treturn {\n\t\tauth: config.auth,\n\t\tstorage: config.storage,\n\t\tdata,\n\t\torgs: data.orgs,\n\t\tprojects: data.projects,\n\t\tdefinitionMeta: data.definitions,\n\t\tcomputeServer: data.computeServer,\n\t\tuserProfile: data.userProfile,\n\t\tshareLinks: data.shareLinks,\n\t\tinvites: data.invites,\n\t\tpermissions: data.permissions,\n\t\tplatformProjectGrants: data.platformProjectGrants,\n\t\tevents: config.events ?? new NoopEventSink(),\n\t\tflag: (name) => isFlagEnabled(config, name),\n\t\ttokens,\n\t\t// Same defaults `resolveComputeLimits` applies, repeated rather than\n\t\t// imported: pulling that in would make every host resolving deps also\n\t\t// resolve compute limits from env, which is the coupling this avoids.\n\t\tuploadLimits: {\n\t\t\tmaxDefinitionFileSize: uploadLimits?.maxDefinitionFileSize ?? 50 * 1024 * 1024,\n\t\t\tmaxImageFileSize: uploadLimits?.maxImageFileSize ?? 10 * 1024 * 1024\n\t\t},\n\t\tevictComputeClient,\n\t\tonComputeConfigSaved,\n\t\tnotifications,\n\t\tinstanceName,\n\t\tapiTokenSettingsPath,\n\t\tapiRateLimiter,\n\t\tprojectCreateLimiter,\n\t\tidempotency,\n\t\tservices\n\t};\n}\n","/**\n * The domain errors this package's own handlers raise, folded into the envelope.\n *\n * A host's `mapError` should call this first and add only its own error types.\n * These rules cannot live solely in a host: the handler that throws them ships\n * from here, so a host that forgot one would serve 500 where every other host\n * serves 503 — the same API answering differently depending on who mounted it.\n *\n * Postgres surfaces a unique-constraint name verbatim, which is useless to an\n * end user, so the constraints this package's handlers can trip are translated\n * here rather than left to each host.\n */\n\nimport { ApiError, ApiErrorCode, codeForStatus } from './errors.js';\nimport { ComputeServerUnconfiguredError } from '../compute/errors.js';\nimport { SchemaExtractionError } from '../definitions/schema-extraction.js';\nimport { ProviderError } from '@selvajs/platform';\n\nconst UNIQUE_CONSTRAINT_MESSAGES: Record<string, string> = {\n\tprojects_org_name_unique: 'A project with that name already exists in this organization.',\n\tprojects_org_id_slug_key: 'A project with that name already exists in this organization.',\n\torgs_slug_key: 'An organization with that slug already exists.',\n\tdefinitions_pkey: 'A definition with that ID already exists.'\n};\n\nfunction friendlyConstraintMessage(raw: string): string | null {\n\tfor (const [name, msg] of Object.entries(UNIQUE_CONSTRAINT_MESSAGES)) {\n\t\tif (raw.includes(name)) return msg;\n\t}\n\treturn null;\n}\n\n/**\n * Compute unreachable or serving an unreadable schema is operator-side (503); a\n * schema the parser cannot read is the caller's file (422).\n */\nexport function mapCoreError(err: unknown): ApiError | undefined {\n\tif (err instanceof SchemaExtractionError) {\n\t\treturn err.kind === 'unreachable' || err.kind === 'malformed'\n\t\t\t? new ApiError(503, ApiErrorCode.COMPUTE_UNAVAILABLE, err.message)\n\t\t\t: new ApiError(422, ApiErrorCode.UNPROCESSABLE, err.message);\n\t}\n\tif (err instanceof ComputeServerUnconfiguredError) {\n\t\treturn new ApiError(503, ApiErrorCode.COMPUTE_UNAVAILABLE, err.message);\n\t}\n\tif (err instanceof ProviderError) {\n\t\tconst friendly = friendlyConstraintMessage(err.message);\n\t\treturn new ApiError(err.statusCode, codeForStatus(err.statusCode), friendly ?? err.message);\n\t}\n\treturn undefined;\n}\n","/**\n * The SvelteKit binding for the transport-free handlers in `@selvajs/server/api`.\n *\n * The only file in the app that knows both worlds: it turns a `RequestEvent`\n * into an `ApiRequest` and folds this app's domain errors into the shared\n * envelope. A handler mounted through here names no framework, so the same\n * handler runs under Next or Hono behind a sibling adapter roughly this size.\n */\n\nimport { isHttpError, json, type RequestEvent } from '@sveltejs/kit';\nimport { publicUrl } from '#lib/server/origin.js';\nimport {\n\tApiError,\n\tApiErrorCode,\n\tchargeApiRateLimit,\n\tcodeForStatus,\n\tdepsFromConfig,\n\tmapCoreError,\n\trateLimitedResponse,\n\trunHandler,\n\twithRateLimitHeaders,\n\ttype ApiHandler,\n\ttype ApiRequest,\n\ttype RunHandlerOptions,\n\ttype SelvaDeps\n} from '@selvajs/server/api';\nimport {\n\tgetBranding,\n\tgetDefinitionService,\n\tgetNotificationProvider,\n\tgetOrgAssetService\n} from '../providers.server';\nimport { shareLinkCodec } from '../shareLinks/token.server';\nimport { inviteCodec } from '../invites/token.server';\nimport { apiTokenCodec, apiTokenResolutions } from '../apiTokens/token.server';\nimport { MAX_DEFINITION_FILE_SIZE, MAX_IMAGE_FILE_SIZE } from '../computeLimits';\nimport { evictComputeClient } from '../compute/engine.server';\nimport { serverResolver } from '../compute/serverResolver.server';\nimport { apiRateLimiter } from '../computeRateLimit.server';\nimport { signInMaxAgeMs } from '../signInMaxAge.server';\n\n/**\n * This app's own errors, folded into the shared envelope.\n *\n * SvelteKit's `HttpError` is the only one left here — everything else the v1\n * handlers throw ships from `@selvajs/server`, so `mapCoreError` owns those\n * rules and a second host gets the same statuses without copying them.\n */\nexport function mapAppError(err: unknown): ApiError | undefined {\n\t// Access guards in `access.server.ts` throw SvelteKit's error() and must\n\t// keep doing so — page loads share them and need SvelteKit to render the\n\t// failure. Without this branch every guard 403 falls through to the 500\n\t// fallback, a downgrade no type check catches.\n\tif (isHttpError(err)) {\n\t\t// Guards throw `error(status, 'string')`; `apiError` throws the object\n\t\t// form with `fields` (Zod's per-field detail) — both are live, so this\n\t\t// reads the body rather than just the status.\n\t\tconst body = err.body as\n\t\t\t| {\n\t\t\t\t\tmessage?: string;\n\t\t\t\t\tcode?: ApiErrorCode;\n\t\t\t\t\tfields?: Record<string, string>;\n\t\t\t\t\tdetails?: Record<string, string>;\n\t\t\t }\n\t\t\t| string;\n\t\tif (typeof body === 'string') {\n\t\t\treturn new ApiError(err.status, codeForStatus(err.status), body);\n\t\t}\n\t\treturn new ApiError(\n\t\t\terr.status,\n\t\t\tbody?.code ?? codeForStatus(err.status),\n\t\t\tbody?.message ?? 'Request failed',\n\t\t\tbody?.fields,\n\t\t\tbody?.details\n\t\t);\n\t}\n\treturn mapCoreError(err);\n}\n\n// Providers resolve lazily and memoize, so building deps per request costs a\n// few property reads — no provider is constructed here.\nfunction buildDeps(event: RequestEvent): SelvaDeps {\n\treturn depsFromConfig(\n\t\tevent.locals.providers,\n\t\t{\n\t\t\tdefinitions: getDefinitionService(),\n\t\t\torgAssets: getOrgAssetService()\n\t\t},\n\t\t{\n\t\t\t// Resolved per request, not captured: both codecs re-key on the secret,\n\t\t\t// so a rotated SELVA_HMAC_KEY takes effect without a restart.\n\t\t\ttokens: {\n\t\t\t\tshareLinks: shareLinkCodec(),\n\t\t\t\tinvites: inviteCodec(),\n\t\t\t\tapiTokens: apiTokenCodec(),\n\t\t\t\tsignInMaxAgeMs,\n\t\t\t\tresolutionCache: apiTokenResolutions\n\t\t\t},\n\t\t\t// Passed explicitly — depsFromConfig's defaults would silently ignore\n\t\t\t// this deployment's MAX_*_FILE_SIZE_BYTES.\n\t\t\tuploadLimits: {\n\t\t\t\tmaxDefinitionFileSize: MAX_DEFINITION_FILE_SIZE,\n\t\t\t\tmaxImageFileSize: MAX_IMAGE_FILE_SIZE\n\t\t\t},\n\t\t\t// Cache is keyed on server id; without this a compute-config write\n\t\t\t// leaves a warm client holding a rotated URL or key.\n\t\t\tevictComputeClient,\n\t\t\tonComputeConfigSaved: () => serverResolver.forget(),\n\t\t\tnotifications: getNotificationProvider(),\n\t\t\tinstanceName: getBranding().name,\n\t\t\tapiTokenSettingsPath: '/team/tokens',\n\t\t\t// Module singleton: the limiter must outlive this per-request deps object.\n\t\t\tapiRateLimiter\n\t\t}\n\t);\n}\n\nexport function toApiRequest(event: RequestEvent): ApiRequest {\n\treturn {\n\t\tctx: event.locals.ctx,\n\t\tuser: event.locals.user,\n\t\tprofile: event.locals.profile,\n\t\tlog: event.locals.log,\n\t\tparams: event.params,\n\t\turl: publicUrl(event.url),\n\t\trequest: event.request,\n\t\tdeps: buildDeps(event)\n\t};\n}\n\n/**\n * Mount a transport-free handler as a SvelteKit `RequestHandler`.\n *\n * Routes addressed by a project or definition pass `scopeTarget`, so a key\n * scoped to that project or definition can reach them; solve routes pass\n * `action: 'solve'`; creates pass `idempotent: true`.\n */\nexport function mount(\n\tfallback: string,\n\thandler: ApiHandler,\n\topts: Pick<RunHandlerOptions, 'action' | 'scopeTarget' | 'anyScope' | 'idempotent'> = {}\n) {\n\treturn (event: RequestEvent): Promise<Response> =>\n\t\trunHandler(handler, toApiRequest(event), { fallback, mapError: mapAppError, ...opts });\n}\n\n/**\n * The per-token rate limit for a route that builds its own `Response` instead\n * of going through `mount`: charged before the handler runs, and `RateLimit-*`\n * on every token response, thrown errors included.\n */\nexport function withApiRateLimit<E extends RequestEvent>(\n\thandler: (event: E) => Promise<Response>\n): (event: E) => Promise<Response> {\n\treturn async (event) => {\n\t\tconst verdict = await chargeApiRateLimit(event.locals.ctx, apiRateLimiter);\n\t\tif (verdict && !verdict.allowed) return rateLimitedResponse(verdict);\n\t\ttry {\n\t\t\treturn withRateLimitHeaders(await handler(event), verdict);\n\t\t} catch (err) {\n\t\t\tif (!verdict || !isHttpError(err)) throw err;\n\t\t\treturn withRateLimitHeaders(json(err.body, { status: err.status }), verdict);\n\t\t}\n\t};\n}\n"],"mappings":"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"}
1
+ {"version":3,"file":"sveltekit.js","names":[],"sources":["../../../../server/src/api/deps.ts","../../../../server/src/api/map-core-error.ts","../../../src/lib/server/api/sveltekit.ts"],"sourcesContent":["/**\n * Everything an API handler talks to, as one injected value.\n *\n * Handlers used to reach module-global getters (`getProjectProvider()`,\n * `getDefinitionService()`, …) from the Selva app's composition root — 77 call\n * sites across the v1 routes. That welded them to one app's boot: a second app\n * on a different provider set could not call them at all.\n *\n * Most fields are sub-stores of `IDataProvider`, so a host that already built a\n * `SelvaConfig` gets them via `depsFromConfig`. `services` stays host-defined:\n * `DefinitionService` and friends are composed rather than resolved, and a host\n * may supply its own.\n */\n\nimport { isFlagEnabled, NoopEventSink } from '@selvajs/platform';\nimport type { DefinitionService } from '../definitions/definition-service.js';\nimport type { OrgAssetService } from '../organizations/org-asset-service.js';\nimport type { TokenCodec } from '../tokens/token-codec.js';\nimport type { ApiTokenCodec } from '../tokens/api-token-codec.js';\nimport type { ApiTokenHolderPolicy } from '../tokens/api-token-holder.js';\nimport type { ApiTokenResolutionCache } from '../http/api-token.js';\nimport type { ApiRateLimiter } from './rate-limit.js';\nimport type { ApiIdempotencyStore } from './idempotency.js';\nimport type { MailTemplates } from '@selvajs/notifications';\nimport type {\n\tIAuthProvider,\n\tIDataProvider,\n\tIEventSink,\n\tINotificationProvider,\n\tIStorageProvider,\n\tSelvaConfig,\n\tSelvaFlags\n} from '@selvajs/platform';\n\nexport interface SelvaDeps {\n\tauth: IAuthProvider;\n\tstorage: IStorageProvider;\n\tdata: IDataProvider;\n\t/** `data.orgs` — hoisted because 18 v1 call sites read it directly. */\n\torgs: IDataProvider['orgs'];\n\t/** `data.projects` — 18 call sites. */\n\tprojects: IDataProvider['projects'];\n\t/** `data.definitions` — the definition metadata store. */\n\tdefinitionMeta: IDataProvider['definitions'];\n\tcomputeServer: IDataProvider['computeServer'];\n\tuserProfile: IDataProvider['userProfile'];\n\tshareLinks: IDataProvider['shareLinks'];\n\tinvites: IDataProvider['invites'];\n\tpermissions: IDataProvider['permissions'];\n\tplatformProjectGrants: IDataProvider['platformProjectGrants'];\n\t/**\n\t * Audit sink. Never optional here even though `SelvaConfig.events` is:\n\t * handlers emit escalation events (`project.reclaimed`,\n\t * `org_member.removed_orphaning_projects`) that the audit trail depends on,\n\t * and a handler deciding for itself what a missing sink means is how one of\n\t * them ends up silently unlogged. `depsFromConfig` substitutes\n\t * `NoopEventSink`, which discards explicitly.\n\t */\n\tevents: IEventSink;\n\t/**\n\t * Feature flags, as a predicate rather than a record: an omitted flag must\n\t * read as false, and keeping that in `isFlagEnabled` stops each caller from\n\t * re-deciding what a missing flag means.\n\t */\n\tflag: (name: keyof SelvaFlags) => boolean;\n\t/**\n\t * Token codecs, one per family, keyed by what they mint.\n\t *\n\t * Injected rather than resolved because the codec is built from an\n\t * instance-wide HMAC secret, and reading that secret is the host's job — a\n\t * package that reached for `process.env.SELVA_HMAC_KEY` itself would pin\n\t * every host to one env var name and one way of loading it. Rotating a\n\t * secret invalidates that family's outstanding tokens, so the two families\n\t * are separate values rather than one shared codec.\n\t *\n\t * Optional: a host with no sharing and no invites wires neither. The\n\t * handlers that need one fail loudly if it is absent rather than minting a\n\t * token nobody can verify.\n\t */\n\ttokens: {\n\t\tshareLinks?: TokenCodec;\n\t\tinvites?: TokenCodec;\n\t\t/** Without it, minting answers 503 `API_TOKENS_UNAVAILABLE`. */\n\t\tapiTokens?: ApiTokenCodec;\n\t\t/** Who may mint and use API tokens. Absent: the platform permission `manage_api_tokens`. */\n\t\tmayHoldApiTokens?: ApiTokenHolderPolicy;\n\t\t/** How long one sign-in lasts before minting needs a new one (`resolveSignInMaxAgeMs`). Absent: no limit. */\n\t\tsignInMaxAgeMs?: number;\n\t\t/**\n\t\t * The cache the host hands `resolveApiToken`, so a revoke through these handlers drops\n\t\t * the key from it at once. Absent: nothing to drop.\n\t\t */\n\t\tresolutionCache?: ApiTokenResolutionCache;\n\t};\n\t/**\n\t * Upload caps, in bytes.\n\t *\n\t * Deployment config, so the host resolves them — a package reading its own\n\t * env would pin every host to one variable name. Defaults apply when the\n\t * host says nothing, because a missing cap must not read as \"unlimited\":\n\t * `requireUpload` compares against this number, and `undefined` would let\n\t * any size through.\n\t */\n\tuploadLimits: {\n\t\tmaxDefinitionFileSize: number;\n\t\tmaxImageFileSize: number;\n\t};\n\t/**\n\t * Outbound mail, and the instance name to fall back to when a record has no\n\t * name of its own.\n\t *\n\t * Optional because mail is best-effort by design: an invite row is committed\n\t * before delivery is attempted, and the caller still holds the accept URL to\n\t * share by hand. A host with no mail configured wires nothing and the\n\t * handlers report `not-configured` rather than failing the write.\n\t */\n\tnotifications?: INotificationProvider;\n\t/**\n\t * Per-token request limit `runHandler` charges. Absent: the process-wide\n\t * default (`DEFAULT_API_RATE_LIMIT`). `null`: no limit. A host's own limiter\n\t * must outlive the request, since deps are rebuilt per request.\n\t */\n\tapiRateLimiter?: ApiRateLimiter | null;\n\t/**\n\t * Projects one owner may create through API keys, across all their keys.\n\t * Absent: the process-wide default (`DEFAULT_PROJECT_CREATE_LIMIT`). `null`:\n\t * no limit.\n\t */\n\tprojectCreateLimiter?: ApiRateLimiter | null;\n\t/** Replay store for routes mounted with `idempotent: true`. Absent: the process-wide default. */\n\tidempotency?: ApiIdempotencyStore;\n\t/** Instance display name: the product name in outbound mail, and used where a record has none. */\n\tinstanceName: string;\n\t/** Host wording for outbound mail, per kind. A kind left out uses the built-in English template. */\n\tmailTemplates?: MailTemplates;\n\t/** Where a person manages their API tokens, linked from the new-key email. Host-relative. */\n\tapiTokenSettingsPath: string;\n\t/**\n\t * Drop the host's warm compute client for one server id.\n\t *\n\t * A warm client caches on server `id`, so a rotated URL or key keeps the\n\t * same cache key with stale connection details and never ages out. The\n\t * config-write handlers evict through this rather than importing a cache:\n\t * which cache holds them is the host's decision, and importing one would\n\t * pull a whole solve engine into every consumer.\n\t *\n\t * Defaults to a no-op — a host with no client cache has nothing to evict,\n\t * and the handler must not have to know which kind of host it is running on.\n\t */\n\tevictComputeClient: (id: string) => void;\n\t/**\n\t * Called after every compute-config save, so a host remembering resolved servers\n\t * (`createServerResolver`) reads the config again. Defaults to a no-op.\n\t */\n\tonComputeConfigSaved: () => void;\n\t/**\n\t * Composed services the host supplies.\n\t *\n\t * The named ones are typed because handlers call them — leaving a service\n\t * `unknown` pushes a cast into every call site, and a cast is exactly where\n\t * a second host's differently-shaped service would slip through unnoticed.\n\t * The index signature keeps host-specific extras possible without naming\n\t * them here.\n\t */\n\tservices: {\n\t\tdefinitions?: DefinitionService;\n\t\torgAssets?: OrgAssetService;\n\t} & Record<string, unknown>;\n}\n\n/**\n * Build deps from a resolved `SelvaConfig`, plus whatever services and token\n * codecs the host composed on top. The hoisted fields are aliases into `data`,\n * not copies.\n *\n * `services` stays positional — every existing caller passes it there — and\n * `tokens` arrives in an options object rather than as a third positional, so\n * the two composed bags cannot be swapped at a call site.\n */\nexport function depsFromConfig(\n\tconfig: SelvaConfig,\n\tservices: SelvaDeps['services'] = {},\n\t{\n\t\ttokens = {},\n\t\tuploadLimits,\n\t\tevictComputeClient = () => {},\n\t\tonComputeConfigSaved = () => {},\n\t\tnotifications,\n\t\tinstanceName = 'Selva',\n\t\tmailTemplates,\n\t\tapiTokenSettingsPath = '/settings/tokens',\n\t\tapiRateLimiter,\n\t\tprojectCreateLimiter,\n\t\tidempotency\n\t}: {\n\t\ttokens?: SelvaDeps['tokens'];\n\t\tuploadLimits?: Partial<SelvaDeps['uploadLimits']>;\n\t\tevictComputeClient?: SelvaDeps['evictComputeClient'];\n\t\tonComputeConfigSaved?: SelvaDeps['onComputeConfigSaved'];\n\t\tnotifications?: INotificationProvider;\n\t\tinstanceName?: string;\n\t\tmailTemplates?: MailTemplates;\n\t\tapiTokenSettingsPath?: string;\n\t\tapiRateLimiter?: ApiRateLimiter | null;\n\t\tprojectCreateLimiter?: ApiRateLimiter | null;\n\t\tidempotency?: ApiIdempotencyStore;\n\t} = {}\n): SelvaDeps {\n\tconst { data } = config;\n\treturn {\n\t\tauth: config.auth,\n\t\tstorage: config.storage,\n\t\tdata,\n\t\torgs: data.orgs,\n\t\tprojects: data.projects,\n\t\tdefinitionMeta: data.definitions,\n\t\tcomputeServer: data.computeServer,\n\t\tuserProfile: data.userProfile,\n\t\tshareLinks: data.shareLinks,\n\t\tinvites: data.invites,\n\t\tpermissions: data.permissions,\n\t\tplatformProjectGrants: data.platformProjectGrants,\n\t\tevents: config.events ?? new NoopEventSink(),\n\t\tflag: (name) => isFlagEnabled(config, name),\n\t\ttokens,\n\t\t// Same defaults `resolveComputeLimits` applies, repeated rather than\n\t\t// imported: pulling that in would make every host resolving deps also\n\t\t// resolve compute limits from env, which is the coupling this avoids.\n\t\tuploadLimits: {\n\t\t\tmaxDefinitionFileSize: uploadLimits?.maxDefinitionFileSize ?? 50 * 1024 * 1024,\n\t\t\tmaxImageFileSize: uploadLimits?.maxImageFileSize ?? 10 * 1024 * 1024\n\t\t},\n\t\tevictComputeClient,\n\t\tonComputeConfigSaved,\n\t\tnotifications,\n\t\tinstanceName,\n\t\tmailTemplates,\n\t\tapiTokenSettingsPath,\n\t\tapiRateLimiter,\n\t\tprojectCreateLimiter,\n\t\tidempotency,\n\t\tservices\n\t};\n}\n","/**\n * The domain errors this package's own handlers raise, folded into the envelope.\n *\n * A host's `mapError` should call this first and add only its own error types.\n * These rules cannot live solely in a host: the handler that throws them ships\n * from here, so a host that forgot one would serve 500 where every other host\n * serves 503 — the same API answering differently depending on who mounted it.\n *\n * Postgres surfaces a unique-constraint name verbatim, which is useless to an\n * end user, so the constraints this package's handlers can trip are translated\n * here rather than left to each host.\n */\n\nimport { ApiError, ApiErrorCode, codeForStatus } from './errors.js';\nimport { ComputeServerUnconfiguredError } from '../compute/errors.js';\nimport { SchemaExtractionError } from '../definitions/schema-extraction.js';\nimport { ProviderError } from '@selvajs/platform';\n\nconst UNIQUE_CONSTRAINT_MESSAGES: Record<string, string> = {\n\tprojects_org_name_unique: 'A project with that name already exists in this organization.',\n\tprojects_org_id_slug_key: 'A project with that name already exists in this organization.',\n\torgs_slug_key: 'An organization with that slug already exists.',\n\tdefinitions_pkey: 'A definition with that ID already exists.'\n};\n\nfunction friendlyConstraintMessage(raw: string): string | null {\n\tfor (const [name, msg] of Object.entries(UNIQUE_CONSTRAINT_MESSAGES)) {\n\t\tif (raw.includes(name)) return msg;\n\t}\n\treturn null;\n}\n\n/**\n * Compute unreachable or serving an unreadable schema is operator-side (503); a\n * schema the parser cannot read is the caller's file (422).\n */\nexport function mapCoreError(err: unknown): ApiError | undefined {\n\tif (err instanceof SchemaExtractionError) {\n\t\treturn err.kind === 'unreachable' || err.kind === 'malformed'\n\t\t\t? new ApiError(503, ApiErrorCode.COMPUTE_UNAVAILABLE, err.message)\n\t\t\t: new ApiError(422, ApiErrorCode.UNPROCESSABLE, err.message);\n\t}\n\tif (err instanceof ComputeServerUnconfiguredError) {\n\t\treturn new ApiError(503, ApiErrorCode.COMPUTE_UNAVAILABLE, err.message);\n\t}\n\tif (err instanceof ProviderError) {\n\t\tconst friendly = friendlyConstraintMessage(err.message);\n\t\treturn new ApiError(err.statusCode, codeForStatus(err.statusCode), friendly ?? err.message);\n\t}\n\treturn undefined;\n}\n","/**\n * The SvelteKit binding for the transport-free handlers in `@selvajs/server/api`.\n *\n * The only file in the app that knows both worlds: it turns a `RequestEvent`\n * into an `ApiRequest` and folds this app's domain errors into the shared\n * envelope. A handler mounted through here names no framework, so the same\n * handler runs under Next or Hono behind a sibling adapter roughly this size.\n */\n\nimport { isHttpError, json, type RequestEvent } from '@sveltejs/kit';\nimport { publicUrl } from '#lib/server/origin.js';\nimport {\n\tApiError,\n\tApiErrorCode,\n\tchargeApiRateLimit,\n\tcodeForStatus,\n\tdepsFromConfig,\n\tmapCoreError,\n\trateLimitedResponse,\n\trunHandler,\n\twithRateLimitHeaders,\n\ttype ApiHandler,\n\ttype ApiRequest,\n\ttype RunHandlerOptions,\n\ttype SelvaDeps\n} from '@selvajs/server/api';\nimport {\n\tgetBranding,\n\tgetDefinitionService,\n\tgetNotificationProvider,\n\tgetOrgAssetService\n} from '../providers.server';\nimport { shareLinkCodec } from '../shareLinks/token.server';\nimport { inviteCodec } from '../invites/token.server';\nimport { apiTokenCodec, apiTokenResolutions } from '../apiTokens/token.server';\nimport { MAX_DEFINITION_FILE_SIZE, MAX_IMAGE_FILE_SIZE } from '../computeLimits';\nimport { evictComputeClient } from '../compute/engine.server';\nimport { serverResolver } from '../compute/serverResolver.server';\nimport { apiRateLimiter } from '../computeRateLimit.server';\nimport { signInMaxAgeMs } from '../signInMaxAge.server';\n\n/**\n * This app's own errors, folded into the shared envelope.\n *\n * SvelteKit's `HttpError` is the only one left here — everything else the v1\n * handlers throw ships from `@selvajs/server`, so `mapCoreError` owns those\n * rules and a second host gets the same statuses without copying them.\n */\nexport function mapAppError(err: unknown): ApiError | undefined {\n\t// Access guards in `access.server.ts` throw SvelteKit's error() and must\n\t// keep doing so — page loads share them and need SvelteKit to render the\n\t// failure. Without this branch every guard 403 falls through to the 500\n\t// fallback, a downgrade no type check catches.\n\tif (isHttpError(err)) {\n\t\t// Guards throw `error(status, 'string')`; `apiError` throws the object\n\t\t// form with `fields` (Zod's per-field detail) — both are live, so this\n\t\t// reads the body rather than just the status.\n\t\tconst body = err.body as\n\t\t\t| {\n\t\t\t\t\tmessage?: string;\n\t\t\t\t\tcode?: ApiErrorCode;\n\t\t\t\t\tfields?: Record<string, string>;\n\t\t\t\t\tdetails?: Record<string, string>;\n\t\t\t }\n\t\t\t| string;\n\t\tif (typeof body === 'string') {\n\t\t\treturn new ApiError(err.status, codeForStatus(err.status), body);\n\t\t}\n\t\treturn new ApiError(\n\t\t\terr.status,\n\t\t\tbody?.code ?? codeForStatus(err.status),\n\t\t\tbody?.message ?? 'Request failed',\n\t\t\tbody?.fields,\n\t\t\tbody?.details\n\t\t);\n\t}\n\treturn mapCoreError(err);\n}\n\n// Providers resolve lazily and memoize, so building deps per request costs a\n// few property reads — no provider is constructed here.\nfunction buildDeps(event: RequestEvent): SelvaDeps {\n\treturn depsFromConfig(\n\t\tevent.locals.providers,\n\t\t{\n\t\t\tdefinitions: getDefinitionService(),\n\t\t\torgAssets: getOrgAssetService()\n\t\t},\n\t\t{\n\t\t\t// Resolved per request, not captured: both codecs re-key on the secret,\n\t\t\t// so a rotated SELVA_HMAC_KEY takes effect without a restart.\n\t\t\ttokens: {\n\t\t\t\tshareLinks: shareLinkCodec(),\n\t\t\t\tinvites: inviteCodec(),\n\t\t\t\tapiTokens: apiTokenCodec(),\n\t\t\t\tsignInMaxAgeMs,\n\t\t\t\tresolutionCache: apiTokenResolutions\n\t\t\t},\n\t\t\t// Passed explicitly — depsFromConfig's defaults would silently ignore\n\t\t\t// this deployment's MAX_*_FILE_SIZE_BYTES.\n\t\t\tuploadLimits: {\n\t\t\t\tmaxDefinitionFileSize: MAX_DEFINITION_FILE_SIZE,\n\t\t\t\tmaxImageFileSize: MAX_IMAGE_FILE_SIZE\n\t\t\t},\n\t\t\t// Cache is keyed on server id; without this a compute-config write\n\t\t\t// leaves a warm client holding a rotated URL or key.\n\t\t\tevictComputeClient,\n\t\t\tonComputeConfigSaved: () => serverResolver.forget(),\n\t\t\tnotifications: getNotificationProvider(),\n\t\t\tinstanceName: getBranding().name,\n\t\t\tapiTokenSettingsPath: '/team/tokens',\n\t\t\t// Module singleton: the limiter must outlive this per-request deps object.\n\t\t\tapiRateLimiter\n\t\t}\n\t);\n}\n\nexport function toApiRequest(event: RequestEvent): ApiRequest {\n\treturn {\n\t\tctx: event.locals.ctx,\n\t\tuser: event.locals.user,\n\t\tprofile: event.locals.profile,\n\t\tlog: event.locals.log,\n\t\tparams: event.params,\n\t\turl: publicUrl(event.url),\n\t\trequest: event.request,\n\t\tdeps: buildDeps(event)\n\t};\n}\n\n/**\n * Mount a transport-free handler as a SvelteKit `RequestHandler`.\n *\n * Routes addressed by a project or definition pass `scopeTarget`, so a key\n * scoped to that project or definition can reach them; solve routes pass\n * `action: 'solve'`; creates pass `idempotent: true`.\n */\nexport function mount(\n\tfallback: string,\n\thandler: ApiHandler,\n\topts: Pick<RunHandlerOptions, 'action' | 'scopeTarget' | 'anyScope' | 'idempotent'> = {}\n) {\n\treturn (event: RequestEvent): Promise<Response> =>\n\t\trunHandler(handler, toApiRequest(event), { fallback, mapError: mapAppError, ...opts });\n}\n\n/**\n * The per-token rate limit for a route that builds its own `Response` instead\n * of going through `mount`: charged before the handler runs, and `RateLimit-*`\n * on every token response, thrown errors included.\n */\nexport function withApiRateLimit<E extends RequestEvent>(\n\thandler: (event: E) => Promise<Response>\n): (event: E) => Promise<Response> {\n\treturn async (event) => {\n\t\tconst verdict = await chargeApiRateLimit(event.locals.ctx, apiRateLimiter);\n\t\tif (verdict && !verdict.allowed) return rateLimitedResponse(verdict);\n\t\ttry {\n\t\t\treturn withRateLimitHeaders(await handler(event), verdict);\n\t\t} catch (err) {\n\t\t\tif (!verdict || !isHttpError(err)) throw err;\n\t\t\treturn withRateLimitHeaders(json(err.body, { status: err.status }), verdict);\n\t\t}\n\t};\n}\n"],"mappings":"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"}
@@ -0,0 +1,10 @@
1
+ // ../platform/src/shareLinks/types.ts
2
+ /**
3
+ * Default cap applied when the minter doesn't specify one. Tokens are
4
+ * leak-prone by design (visible in iframes), so a default bounds the
5
+ * worst-case denial-of-wallet damage.
6
+ */
7
+ var DEFAULT_SHARE_LINK_MAX_SOLVES = 1e3;
8
+ export { DEFAULT_SHARE_LINK_MAX_SOLVES as t };
9
+
10
+ //# sourceMappingURL=types4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types4.js","names":[],"sources":["../../../../platform/src/shareLinks/types.ts"],"sourcesContent":["import type { DefinitionChannel } from '../definitions/types.js';\n\n/**\n * Per-definition token granting access to one (definitionId, channel)\n * without an account. The plaintext token is shown to the minter exactly\n * once; `tokenHash` is the HMAC stored at rest.\n */\nexport interface ShareLink {\n\tid: string;\n\tdefinitionId: string;\n\tchannel: DefinitionChannel;\n\ttokenHash: string;\n\t/** e.g. \"Demo for Acme\". */\n\tname?: string;\n\tcreatedBy: string;\n\tcreatedAt: string;\n\t/** Null = never expires. */\n\texpiresAt?: string | null;\n\t/** Non-null = revoked. */\n\trevokedAt?: string | null;\n\t/** false = view/schema only; true = solve allowed. */\n\tallowSolve: boolean;\n\t/** Null = unlimited. */\n\tmaxSolves?: number | null;\n\tsolveCount: number;\n}\n\n/**\n * A share link plus the definition and project it hangs off.\n *\n * The org-wide roster is the one read where the parent matters: `definitionId`\n * alone identifies nothing a person can recognize, and revoking the wrong link\n * is unrecoverable — the raw token is gone.\n *\n * `tokenHash` is omitted, not merely unused. This is the only share-link shape\n * built for a page, and the roster spans every definition in the org — so a\n * careless `JSON.stringify` here would ship every credential digest in the\n * tenant to the browser at once.\n */\nexport interface OrgShareLink extends Omit<ShareLink, 'tokenHash'> {\n\tdefinitionName: string;\n\tprojectId: string;\n\tprojectName: string;\n}\n\n/**\n * Default cap applied when the minter doesn't specify one. Tokens are\n * leak-prone by design (visible in iframes), so a default bounds the\n * worst-case denial-of-wallet damage.\n */\nexport const DEFAULT_SHARE_LINK_MAX_SOLVES = 1000;\n\n/**\n * Days until a link minted without an expiry stops working. A link that never\n * expires outlives the key it was hashed under and anyone's memory of handing\n * it out; the minter can still pass `expiresAt: null` deliberately.\n */\nexport const DEFAULT_SHARE_LINK_TTL_DAYS = 90;\n"],"mappings":";;;;;;AAkDA,IAAa,gCAAgC"}
@@ -1,7 +1,7 @@
1
1
  import { K as actorFrom, T as providers, g as getPermissionStore, r as getAuthProvider, u as getEventSink } from "../../../../../../../chunks/providers.server.js";
2
2
  import { O as ApiErrorCode, b as requireManageInstanceUsers } from "../../../../../../../chunks/access.js";
3
3
  import { U as requireParams } from "../../../../../../../chunks/api.js";
4
- import { et as revokeUserApiTokens } from "../../../../../../../chunks/handlers.js";
4
+ import { tt as revokeUserApiTokens } from "../../../../../../../chunks/handlers.js";
5
5
  import { t as apiError } from "../../../../../../../chunks/api-errors.js";
6
6
  import "../../../../../../../chunks/access2.server.js";
7
7
  import { r as noContent, t as apiRoute } from "../../../../../../../chunks/http2.js";
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../chunks/api.js";
2
- import { E as updateDefinition, S as getDefinition, x as deleteDefinition } from "../../../../../../chunks/handlers.js";
2
+ import { D as updateDefinition, S as getDefinition, x as deleteDefinition } from "../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,9 +1,10 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { D as uploadDefinitionImage } from "../../../../../../../chunks/handlers.js";
2
+ import { C as getDefinitionImage, O as uploadDefinitionImage } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/image/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
6
+ var GET = mount("Failed to read image", getDefinitionImage, { scopeTarget });
6
7
  var POST = mount("Failed to upload image", uploadDefinitionImage, { scopeTarget });
7
- export { POST };
8
+ export { GET, POST };
8
9
 
9
10
  //# sourceMappingURL=_server.ts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"_server.ts.js","names":[],"sources":["../../../../../../../../../src/routes/api/v1/definitions/[guid]/image/+server.ts"],"sourcesContent":["import type { RequestHandler } from './$types';\nimport { mount } from '#lib/server/api/sveltekit.js';\nimport { definitionScopeTarget } from '@selvajs/server/api';\nimport { uploadDefinitionImage } from '@selvajs/server/handlers';\n\nconst scopeTarget = definitionScopeTarget('guid');\n\nexport const POST: RequestHandler = mount('Failed to upload image', uploadDefinitionImage, {\n\tscopeTarget\n});\n"],"mappings":";;;;AAKA,IAAM,cAAc,sBAAsB,MAAM;AAEhD,IAAa,OAAuB,MAAM,0BAA0B,uBAAuB,EAC1F,YACD,CAAC"}
1
+ {"version":3,"file":"_server.ts.js","names":[],"sources":["../../../../../../../../../src/routes/api/v1/definitions/[guid]/image/+server.ts"],"sourcesContent":["import type { RequestHandler } from './$types';\nimport { mount } from '#lib/server/api/sveltekit.js';\nimport { definitionScopeTarget } from '@selvajs/server/api';\nimport { getDefinitionImage, uploadDefinitionImage } from '@selvajs/server/handlers';\n\nconst scopeTarget = definitionScopeTarget('guid');\n\nexport const GET: RequestHandler = mount('Failed to read image', getDefinitionImage, {\n\tscopeTarget\n});\n\nexport const POST: RequestHandler = mount('Failed to upload image', uploadDefinitionImage, {\n\tscopeTarget\n});\n"],"mappings":";;;;AAKA,IAAM,cAAc,sBAAsB,MAAM;AAEhD,IAAa,MAAsB,MAAM,wBAAwB,oBAAoB,EACpF,YACD,CAAC;AAED,IAAa,OAAuB,MAAM,0BAA0B,uBAAuB,EAC1F,YACD,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { T as publishDefinition } from "../../../../../../../chunks/handlers.js";
2
+ import { E as publishDefinition } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/publish/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { C as getDefinitionSchema } from "../../../../../../../chunks/handlers.js";
2
+ import { w as getDefinitionSchema } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/schema/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../chunks/api.js";
2
- import { z as revokeShareLink } from "../../../../../../../../chunks/handlers.js";
2
+ import { B as revokeShareLink } from "../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/share-links/[linkId]/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { L as createShareLink, R as listShareLinks } from "../../../../../../../chunks/handlers.js";
2
+ import { R as createShareLink, z as listShareLinks } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/share-links/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { I as uploadVersion, P as listVersions } from "../../../../../../../chunks/handlers.js";
2
+ import { F as listVersions, L as uploadVersion } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../chunks/api.js";
2
- import { A as getVersion, k as deleteVersion } from "../../../../../../../../chunks/handlers.js";
2
+ import { A as deleteVersion, j as getVersion } from "../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/[versionId]/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../../chunks/api.js";
2
- import { j as getVersionChanges } from "../../../../../../../../../chunks/handlers.js";
2
+ import { M as getVersionChanges } from "../../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/[versionId]/changes/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../../chunks/api.js";
2
- import { F as refreshVersionInventory } from "../../../../../../../../../chunks/handlers.js";
2
+ import { I as refreshVersionInventory } from "../../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/[versionId]/inventory/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../../chunks/api.js";
2
- import { M as getVersionSchema } from "../../../../../../../../../chunks/handlers.js";
2
+ import { N as getVersionSchema } from "../../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/[versionId]/schema/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../../../chunks/api.js";
2
- import { N as getVersionScriptDiff } from "../../../../../../../../../../chunks/handlers.js";
2
+ import { P as getVersionScriptDiff } from "../../../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/[versionId]/scripts/[scriptId]/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,5 +1,5 @@
1
1
  import { F as definitionScopeTarget } from "../../../../../../../../chunks/api.js";
2
- import { O as checkVersion } from "../../../../../../../../chunks/handlers.js";
2
+ import { k as checkVersion } from "../../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/definitions/[guid]/versions/check/+server.ts
5
5
  var scopeTarget = definitionScopeTarget("guid");
@@ -1,4 +1,4 @@
1
- import { b as createDefinition, w as listDefinitions } from "../../../../../chunks/handlers.js";
1
+ import { T as listDefinitions, b as createDefinition } from "../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/definitions/+server.ts
4
4
  var GET = mount("Failed to list definitions", listDefinitions);
@@ -1,4 +1,4 @@
1
- import { at as getMe } from "../../../../../chunks/handlers.js";
1
+ import { ot as getMe } from "../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/me/+server.ts
4
4
  var GET = mount("Failed to load identity", getMe);
@@ -1,4 +1,4 @@
1
- import { it as unstarDefinition, rt as starDefinition } from "../../../../../../../chunks/handlers.js";
1
+ import { at as unstarDefinition, it as starDefinition } from "../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/me/starred/[guid]/+server.ts
4
4
  var PUT = mount("Failed to star definition", starDefinition);
@@ -1,4 +1,4 @@
1
- import { $ as revokeOwnApiToken } from "../../../../../../chunks/handlers.js";
1
+ import { et as revokeOwnApiToken } from "../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/me/token/+server.ts
4
4
  var DELETE = mount("Failed to revoke API token", revokeOwnApiToken, { anyScope: true });
@@ -1,4 +1,4 @@
1
- import { tt as getOrg } from "../../../../../../chunks/handlers.js";
1
+ import { nt as getOrg } from "../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/+server.ts
4
4
  var GET = mount("Failed to load organization", getOrg);
@@ -1,4 +1,4 @@
1
- import { B as removeOrgAsset, V as uploadOrgAsset } from "../../../../../../../../chunks/handlers.js";
1
+ import { H as uploadOrgAsset, V as removeOrgAsset } from "../../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/assets/[kind]/+server.ts
4
4
  var POST = mount("Failed to upload asset", uploadOrgAsset);
@@ -1,4 +1,4 @@
1
- import { nt as listOrgMembers } from "../../../../../../../chunks/handlers.js";
1
+ import { rt as listOrgMembers } from "../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/members/+server.ts
4
4
  var GET = mount("Failed to list organization members", listOrgMembers);
@@ -1,4 +1,4 @@
1
- import { U as removeOrgMember, W as updateOrgMember } from "../../../../../../../../chunks/handlers.js";
1
+ import { G as updateOrgMember, W as removeOrgMember } from "../../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/members/[userId]/+server.ts
4
4
  var PATCH = mount("Failed to update member", updateOrgMember);
@@ -1,4 +1,4 @@
1
- import { J as createApiToken, Y as listApiTokens } from "../../../../../../../chunks/handlers.js";
1
+ import { X as listApiTokens, Y as createApiToken } from "../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/tokens/+server.ts
4
4
  var GET = mount("Failed to list API tokens", listApiTokens);
@@ -1,4 +1,4 @@
1
- import { Q as revokeApiToken } from "../../../../../../../../chunks/handlers.js";
1
+ import { $ as revokeApiToken } from "../../../../../../../../chunks/handlers.js";
2
2
  import { t as mount } from "../../../../../../../../chunks/sveltekit.js";
3
3
  // src/routes/api/v1/orgs/[orgId]/tokens/[tokenId]/+server.ts
4
4
  var DELETE = mount("Failed to revoke API token", revokeApiToken);
@@ -1,5 +1,5 @@
1
1
  import { I as projectScopeTarget } from "../../../../../../../chunks/api.js";
2
- import { H as reclaimProject } from "../../../../../../../chunks/handlers.js";
2
+ import { U as reclaimProject } from "../../../../../../../chunks/handlers.js";
3
3
  import { t as mount } from "../../../../../../../chunks/sveltekit.js";
4
4
  // src/routes/api/v1/projects/[id]/reclaim/+server.ts
5
5
  var scopeTarget = projectScopeTarget("id");