@bitbybit-dev/create-app 1.3.2 → 1.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.
Files changed (190) hide show
  1. package/README.md +47 -124
  2. package/dist/index.js +253 -21
  3. package/dist/index.js.map +1 -1
  4. package/dist/scaffold.d.ts +30 -0
  5. package/dist/scaffold.d.ts.map +1 -0
  6. package/dist/scaffold.js +107 -0
  7. package/dist/scaffold.js.map +1 -0
  8. package/package.json +4 -3
  9. package/src/index.test.ts +309 -8
  10. package/src/index.ts +285 -24
  11. package/src/scaffold.test.ts +177 -0
  12. package/src/scaffold.ts +99 -0
  13. package/templates/_agent/AGENTS.md +39 -0
  14. package/templates/_agent/CLAUDE.md +1 -0
  15. package/templates/_agent/_dot-cursor/mcp.json +5 -0
  16. package/templates/_agent/_dot-gitignore +7 -0
  17. package/templates/_agent/_dot-mcp.json +5 -0
  18. package/templates/_agent/_dot-vscode/mcp.json +5 -0
  19. package/templates/apps/drone-assembly/AGENTS.section.md +20 -0
  20. package/templates/apps/drone-assembly/README.md +35 -0
  21. package/templates/apps/drone-assembly/eslint.config.js +47 -0
  22. package/templates/apps/drone-assembly/index.html +17 -0
  23. package/templates/apps/drone-assembly/package.json +31 -0
  24. package/templates/apps/drone-assembly/public/favicon.ico +0 -0
  25. package/templates/apps/drone-assembly/public/logo.png +0 -0
  26. package/templates/apps/drone-assembly/scripts/smoke.ts +172 -0
  27. package/templates/apps/drone-assembly/src/assembly.ts +99 -0
  28. package/templates/apps/drone-assembly/src/exports.ts +10 -0
  29. package/templates/apps/drone-assembly/src/kernel.ts +14 -0
  30. package/templates/apps/drone-assembly/src/main.ts +298 -0
  31. package/templates/apps/drone-assembly/src/materials.ts +58 -0
  32. package/templates/apps/drone-assembly/src/model.ts +280 -0
  33. package/templates/apps/drone-assembly/src/parts.ts +343 -0
  34. package/templates/apps/drone-assembly/src/style.css +219 -0
  35. package/templates/apps/drone-assembly/src/ui.ts +180 -0
  36. package/templates/apps/drone-assembly/src/vite-env.d.ts +1 -0
  37. package/templates/apps/drone-assembly/tsconfig.json +29 -0
  38. package/templates/apps/laser-cut-box/AGENTS.section.md +17 -0
  39. package/templates/apps/laser-cut-box/README.md +34 -0
  40. package/templates/apps/laser-cut-box/eslint.config.js +47 -0
  41. package/templates/apps/laser-cut-box/index.html +17 -0
  42. package/templates/apps/laser-cut-box/package.json +30 -0
  43. package/templates/apps/laser-cut-box/public/favicon.ico +0 -0
  44. package/templates/apps/laser-cut-box/public/logo.png +0 -0
  45. package/templates/apps/laser-cut-box/scripts/smoke.ts +106 -0
  46. package/templates/apps/laser-cut-box/src/exports.ts +28 -0
  47. package/templates/apps/laser-cut-box/src/main.ts +176 -0
  48. package/templates/apps/laser-cut-box/src/model.ts +92 -0
  49. package/templates/apps/laser-cut-box/src/panels.ts +229 -0
  50. package/templates/apps/laser-cut-box/src/style.css +223 -0
  51. package/templates/apps/laser-cut-box/src/ui.ts +136 -0
  52. package/templates/apps/laser-cut-box/src/vite-env.d.ts +1 -0
  53. package/templates/apps/laser-cut-box/tsconfig.json +29 -0
  54. package/templates/apps/product-configurator/AGENTS.section.md +19 -0
  55. package/templates/apps/product-configurator/README.md +33 -0
  56. package/templates/apps/product-configurator/eslint.config.js +47 -0
  57. package/templates/apps/product-configurator/index.html +17 -0
  58. package/templates/apps/product-configurator/package.json +30 -0
  59. package/templates/apps/product-configurator/public/favicon.ico +0 -0
  60. package/templates/apps/product-configurator/public/logo.png +0 -0
  61. package/templates/apps/product-configurator/scripts/smoke.ts +69 -0
  62. package/templates/apps/product-configurator/src/catalog.ts +56 -0
  63. package/templates/apps/product-configurator/src/exports.ts +19 -0
  64. package/templates/apps/product-configurator/src/main.ts +134 -0
  65. package/templates/apps/product-configurator/src/model.ts +153 -0
  66. package/templates/apps/product-configurator/src/style.css +177 -0
  67. package/templates/apps/product-configurator/src/ui.ts +150 -0
  68. package/templates/apps/product-configurator/src/vite-env.d.ts +1 -0
  69. package/templates/apps/product-configurator/tsconfig.json +29 -0
  70. package/templates/apps/sheet-metal-unfold/AGENTS.section.md +26 -0
  71. package/templates/apps/sheet-metal-unfold/README.md +41 -0
  72. package/templates/apps/sheet-metal-unfold/backend/_dot-env.example +5 -0
  73. package/templates/apps/sheet-metal-unfold/backend/eslint.config.js +47 -0
  74. package/templates/apps/sheet-metal-unfold/backend/package.json +28 -0
  75. package/templates/apps/sheet-metal-unfold/backend/scripts/smoke.ts +52 -0
  76. package/templates/apps/sheet-metal-unfold/backend/src/app.ts +65 -0
  77. package/templates/apps/sheet-metal-unfold/backend/src/cloud.ts +42 -0
  78. package/templates/apps/sheet-metal-unfold/backend/src/index.ts +13 -0
  79. package/templates/apps/sheet-metal-unfold/backend/tsconfig.build.json +9 -0
  80. package/templates/apps/sheet-metal-unfold/backend/tsconfig.json +27 -0
  81. package/templates/apps/sheet-metal-unfold/frontend/eslint.config.js +47 -0
  82. package/templates/apps/sheet-metal-unfold/frontend/index.html +17 -0
  83. package/templates/apps/sheet-metal-unfold/frontend/package.json +30 -0
  84. package/templates/apps/sheet-metal-unfold/frontend/public/favicon.ico +0 -0
  85. package/templates/apps/sheet-metal-unfold/frontend/public/logo.png +0 -0
  86. package/templates/apps/sheet-metal-unfold/frontend/scripts/smoke.ts +84 -0
  87. package/templates/apps/sheet-metal-unfold/frontend/src/cloud-access.ts +37 -0
  88. package/templates/apps/sheet-metal-unfold/frontend/src/exports.ts +10 -0
  89. package/templates/apps/sheet-metal-unfold/frontend/src/flat.ts +71 -0
  90. package/templates/apps/sheet-metal-unfold/frontend/src/main.ts +193 -0
  91. package/templates/apps/sheet-metal-unfold/frontend/src/model.ts +166 -0
  92. package/templates/apps/sheet-metal-unfold/frontend/src/style.css +291 -0
  93. package/templates/apps/sheet-metal-unfold/frontend/src/ui.ts +150 -0
  94. package/templates/apps/sheet-metal-unfold/frontend/src/vite-env.d.ts +1 -0
  95. package/templates/apps/sheet-metal-unfold/frontend/tsconfig.json +29 -0
  96. package/templates/apps/sheet-metal-unfold/frontend/vite.config.ts +9 -0
  97. package/templates/apps/sheet-metal-unfold/package.json +18 -0
  98. package/templates/apps/step-to-gltf-cli/AGENTS.section.md +20 -0
  99. package/templates/apps/step-to-gltf-cli/README.md +34 -0
  100. package/templates/apps/step-to-gltf-cli/eslint.config.js +47 -0
  101. package/templates/apps/step-to-gltf-cli/package.json +26 -0
  102. package/templates/apps/step-to-gltf-cli/samples/bracket.step +2545 -0
  103. package/templates/apps/step-to-gltf-cli/scripts/smoke.ts +49 -0
  104. package/templates/apps/step-to-gltf-cli/src/cli.ts +106 -0
  105. package/templates/apps/step-to-gltf-cli/src/cloud.ts +34 -0
  106. package/templates/apps/step-to-gltf-cli/src/convert.ts +65 -0
  107. package/templates/apps/step-to-gltf-cli/src/kernel.ts +14 -0
  108. package/templates/apps/step-to-gltf-cli/tsconfig.json +27 -0
  109. package/templates/cloud/AGENTS.section.md +22 -0
  110. package/templates/cloud/backends/dotnet-rest/BitbybitClient.cs +22 -50
  111. package/templates/cloud/backends/dotnet-rest/Program.cs +1 -11
  112. package/templates/cloud/backends/dotnet-rest/dotnet-rest.csproj +4 -1
  113. package/templates/cloud/backends/hono-rest/eslint.config.js +47 -0
  114. package/templates/cloud/backends/hono-rest/package.json +11 -4
  115. package/templates/cloud/backends/hono-rest/src/bitbybit-client.ts +34 -45
  116. package/templates/cloud/backends/hono-rest/src/index.ts +1 -11
  117. package/templates/cloud/backends/hono-rest/tsconfig.json +19 -8
  118. package/templates/cloud/backends/hono-sdk/eslint.config.js +47 -0
  119. package/templates/cloud/backends/hono-sdk/package.json +12 -5
  120. package/templates/cloud/backends/hono-sdk/src/bitbybit-client.ts +6 -37
  121. package/templates/cloud/backends/hono-sdk/src/index.ts +1 -12
  122. package/templates/cloud/backends/hono-sdk/tsconfig.json +19 -8
  123. package/templates/cloud/backends/nodejs-rest/eslint.config.js +47 -0
  124. package/templates/cloud/backends/nodejs-rest/package.json +12 -5
  125. package/templates/cloud/backends/nodejs-rest/src/bitbybit-client.ts +6 -35
  126. package/templates/cloud/backends/nodejs-rest/src/index.ts +6 -16
  127. package/templates/cloud/backends/nodejs-rest/tsconfig.build.json +9 -0
  128. package/templates/cloud/backends/nodejs-rest/tsconfig.json +17 -7
  129. package/templates/cloud/backends/nodejs-sdk/eslint.config.js +47 -0
  130. package/templates/cloud/backends/nodejs-sdk/package.json +14 -7
  131. package/templates/cloud/backends/nodejs-sdk/src/bitbybit-client.ts +8 -33
  132. package/templates/cloud/backends/nodejs-sdk/src/index.ts +5 -16
  133. package/templates/cloud/backends/nodejs-sdk/tsconfig.build.json +9 -0
  134. package/templates/cloud/backends/nodejs-sdk/tsconfig.json +19 -9
  135. package/templates/cloud/frontend/eslint.config.js +50 -0
  136. package/templates/cloud/frontend/index.html +3 -1
  137. package/templates/cloud/frontend/package.json +13 -4
  138. package/templates/cloud/frontend/public/favicon.ico +0 -0
  139. package/templates/cloud/frontend/public/logo.png +0 -0
  140. package/templates/cloud/frontend/src/App.tsx +11 -9
  141. package/templates/cloud/frontend/src/api.ts +31 -0
  142. package/templates/cloud/frontend/src/components/ApiKeyWarning.tsx +28 -25
  143. package/templates/cloud/frontend/src/components/Header.tsx +4 -2
  144. package/templates/cloud/frontend/src/components/Tabs.tsx +4 -3
  145. package/templates/cloud/frontend/src/components/Viewer.tsx +57 -77
  146. package/templates/cloud/frontend/src/main.tsx +6 -1
  147. package/templates/cloud/frontend/src/panels/ModelsPanel.tsx +65 -73
  148. package/templates/cloud/frontend/src/panels/PipelinesPanel.tsx +82 -83
  149. package/templates/cloud/frontend/src/vite-env.d.ts +1 -0
  150. package/templates/cloud/frontend/tsconfig.json +19 -7
  151. package/templates/vite/babylonjs/typescript/AGENTS.section.md +13 -0
  152. package/templates/vite/babylonjs/typescript/eslint.config.js +47 -0
  153. package/templates/vite/babylonjs/typescript/index.html +4 -2
  154. package/templates/vite/babylonjs/typescript/package.json +14 -4
  155. package/templates/vite/babylonjs/typescript/public/favicon.ico +0 -0
  156. package/templates/vite/babylonjs/typescript/public/logo.png +0 -0
  157. package/templates/vite/babylonjs/typescript/scripts/smoke.ts +41 -0
  158. package/templates/vite/babylonjs/typescript/src/main.ts +8 -17
  159. package/templates/vite/babylonjs/typescript/src/model.ts +24 -0
  160. package/templates/vite/babylonjs/typescript/tsconfig.json +16 -12
  161. package/templates/vite/playcanvas/typescript/AGENTS.section.md +13 -0
  162. package/templates/vite/playcanvas/typescript/eslint.config.js +47 -0
  163. package/templates/vite/playcanvas/typescript/index.html +4 -2
  164. package/templates/vite/playcanvas/typescript/package.json +14 -4
  165. package/templates/vite/playcanvas/typescript/public/favicon.ico +0 -0
  166. package/templates/vite/playcanvas/typescript/public/logo.png +0 -0
  167. package/templates/vite/playcanvas/typescript/scripts/smoke.ts +41 -0
  168. package/templates/vite/playcanvas/typescript/src/main.ts +11 -22
  169. package/templates/vite/playcanvas/typescript/src/model.ts +24 -0
  170. package/templates/vite/playcanvas/typescript/tsconfig.json +16 -12
  171. package/templates/vite/threejs/typescript/AGENTS.section.md +13 -0
  172. package/templates/vite/threejs/typescript/eslint.config.js +47 -0
  173. package/templates/vite/threejs/typescript/index.html +4 -2
  174. package/templates/vite/threejs/typescript/package.json +16 -6
  175. package/templates/vite/threejs/typescript/public/favicon.ico +0 -0
  176. package/templates/vite/threejs/typescript/public/logo.png +0 -0
  177. package/templates/vite/threejs/typescript/scripts/smoke.ts +41 -0
  178. package/templates/vite/threejs/typescript/src/main.ts +11 -22
  179. package/templates/vite/threejs/typescript/src/model.ts +24 -0
  180. package/templates/vite/threejs/typescript/tsconfig.json +16 -12
  181. package/templates/vite/babylonjs/typescript/public/vite.svg +0 -1
  182. package/templates/vite/playcanvas/typescript/public/vite.svg +0 -1
  183. package/templates/vite/threejs/typescript/public/vite.svg +0 -1
  184. /package/templates/cloud/backends/dotnet-rest/{_gitignore → _dot-gitignore} +0 -0
  185. /package/templates/cloud/backends/hono-rest/{_gitignore → _dot-gitignore} +0 -0
  186. /package/templates/cloud/backends/hono-sdk/{_gitignore → _dot-gitignore} +0 -0
  187. /package/templates/cloud/backends/nodejs-rest/{.env.example → _dot-env.example} +0 -0
  188. /package/templates/cloud/backends/nodejs-rest/{_gitignore → _dot-gitignore} +0 -0
  189. /package/templates/cloud/backends/nodejs-sdk/{.env.example → _dot-env.example} +0 -0
  190. /package/templates/cloud/backends/nodejs-sdk/{_gitignore → _dot-gitignore} +0 -0
@@ -0,0 +1,49 @@
1
+ import { spawnSync, type SpawnSyncReturns } from "node:child_process";
2
+ import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { convertFile, isGlb } from "../src/convert.js";
6
+ import { CAD_CLOUD_URL, NO_KEY_EXIT, STUDIO_KEYS_URL } from "../src/cloud.js";
7
+ import { expandInputs, parseArgs } from "../src/cli.js";
8
+ import { loadKernel } from "../src/kernel.js";
9
+
10
+ const SAMPLE = "samples/bracket.step";
11
+ const EXPECTED: { solids: number; faces: number; edges: number; volume: number; bbox: { min: [number, number, number]; max: [number, number, number] } } = { solids: 1, faces: 39, edges: 84, volume: 11837.245, bbox: { min: [-30, 0, -20], max: [30, 12, 20] } };
12
+ const problems: string[] = [];
13
+ const close = (a: number, b: number): boolean => Math.abs(a - b) <= Math.max(1e-3, Math.abs(b) * 1e-6);
14
+ const matches = (actual: number[], expected: [number, number, number]): boolean => expected.every((value, i) => close(actual[i] ?? Number.NaN, value));
15
+
16
+ const occt = await loadKernel();
17
+ const converted = convertFile(occt, "bracket.step", readFileSync(SAMPLE, "utf8"));
18
+ const s = converted.stats;
19
+ if (!isGlb(converted.glb) || converted.glb.byteLength < 1000) problems.push(`the GLB is not a glTF binary (${converted.glb.byteLength} bytes)`);
20
+ if (!converted.stl?.startsWith("solid")) problems.push("the STL does not start with an ASCII solid record");
21
+ if (s.solids !== EXPECTED.solids || s.faces !== EXPECTED.faces || s.edges !== EXPECTED.edges) problems.push(`counts ${s.solids}/${s.faces}/${s.edges} (solids/faces/edges), expected ${EXPECTED.solids}/${EXPECTED.faces}/${EXPECTED.edges}`);
22
+ if (!close(s.volume, EXPECTED.volume)) problems.push(`volume ${s.volume}, expected ${EXPECTED.volume}`);
23
+ if (!matches(s.bbox.min, EXPECTED.bbox.min) || !matches(s.bbox.max, EXPECTED.bbox.max)) problems.push(`bounding box ${JSON.stringify(s.bbox)}, expected ${JSON.stringify(EXPECTED.bbox)}`);
24
+
25
+ const parsed = parseArgs(["samples", "--out", "x", "--precision", "0.01", "--no-stl"]);
26
+ if (parsed.out !== "x" || parsed.options.meshPrecision !== 0.01 || parsed.options.stl || parsed.cloud) problems.push(`arguments parsed as ${JSON.stringify(parsed)}`);
27
+ if (expandInputs(["samples"]).length !== 1) problems.push("a directory does not expand to its CAD files");
28
+
29
+ const out = mkdtempSync(join(tmpdir(), "step-to-gltf-"));
30
+ const run = (args: string[], env: NodeJS.ProcessEnv): SpawnSyncReturns<string> => spawnSync("npx", ["tsx", "src/cli.ts", ...args], { encoding: "utf8", env: { ...process.env, ...env } });
31
+ const local = run([SAMPLE, "--out", out], {});
32
+ if (local.status !== 0) problems.push(`the CLI failed on the sample: ${local.stderr}`);
33
+ for (const file of ["bracket.glb", "bracket.stl", "bracket.json"]) if (!existsSync(join(out, file))) problems.push(`the CLI did not write ${file}`);
34
+ const written = existsSync(join(out, "bracket.json")) ? (JSON.parse(readFileSync(join(out, "bracket.json"), "utf8")) as { faces: number; source: string }) : null;
35
+ if (written?.faces !== EXPECTED.faces || written.source !== "in-process") problems.push(`the stats file says ${JSON.stringify(written)}`);
36
+
37
+ const cloudEnv: NodeJS.ProcessEnv = { ...process.env };
38
+ delete cloudEnv["BITBYBIT_API_KEY"];
39
+ const cloud = spawnSync("npx", ["tsx", "src/cli.ts", SAMPLE, "--cloud", "--out", out], { encoding: "utf8", env: cloudEnv });
40
+ if (cloud.status !== NO_KEY_EXIT) problems.push(`--cloud without a key exited ${String(cloud.status)}, expected ${NO_KEY_EXIT}`);
41
+ if (!cloud.stderr.includes(CAD_CLOUD_URL) || !cloud.stderr.includes(STUDIO_KEYS_URL)) problems.push("--cloud without a key does not say where to get one");
42
+ if (!cloud.stderr.includes("in-process")) problems.push("--cloud without a key does not say that the local conversion is the free answer");
43
+ rmSync(out, { recursive: true, force: true });
44
+
45
+ console.log(JSON.stringify({ template: "step-to-gltf-cli", sample: s, cli: { exit: local.status, files: 3 }, cloudWithoutKey: { exit: cloud.status } }));
46
+ if (problems.length) {
47
+ console.error(`smoke: ${problems.join("; ")}`);
48
+ process.exit(1);
49
+ }
@@ -0,0 +1,106 @@
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2
+ import { basename, extname, join, resolve } from "node:path";
3
+ import { convertFile, defaultOptions, type ConvertOptions, type Stats } from "./convert.js";
4
+ import { convertViaCloud, NO_KEY_EXIT, NO_KEY_MESSAGE, KEY_VARIABLE } from "./cloud.js";
5
+ import { loadKernel } from "./kernel.js";
6
+
7
+ const CAD_EXTENSIONS = new Set([".step", ".stp", ".iges", ".igs"]);
8
+ const USAGE = `usage: npm run convert -- <file or directory>... [--out <dir>] [--precision <n>] [--stl-precision <n>] [--no-stl] [--cloud]
9
+
10
+ Converts STEP and IGES files to GLB (and STL) in this process, on the open-source OpenCascade
11
+ kernel, and writes a JSON of facts beside each result. Nothing leaves this machine.
12
+
13
+ --out <dir> where to write (default: out)
14
+ --precision <n> glTF mesh precision as a fraction of each edge (default: ${defaultOptions.meshPrecision})
15
+ --stl-precision <n> STL mesh precision in model units (default: ${defaultOptions.stlPrecision})
16
+ --no-stl write only GLB and the stats
17
+ --cloud convert on CAD Cloud instead, one task per file; needs ${KEY_VARIABLE} in the environment.
18
+ For a serverless function or a volume of files, not for a machine that can run the kernel.
19
+ `;
20
+
21
+ interface Args {
22
+ inputs: string[];
23
+ out: string;
24
+ cloud: boolean;
25
+ options: ConvertOptions;
26
+ }
27
+
28
+ export function parseArgs(argv: string[]): Args {
29
+ const args: Args = { inputs: [], out: "out", cloud: false, options: { ...defaultOptions } };
30
+ const rest = [...argv];
31
+ for (let arg = rest.shift(); arg !== undefined; arg = rest.shift()) {
32
+ if (arg === "--out") args.out = rest.shift() ?? args.out;
33
+ else if (arg === "--precision") args.options.meshPrecision = Number(rest.shift() ?? args.options.meshPrecision);
34
+ else if (arg === "--stl-precision") args.options.stlPrecision = Number(rest.shift() ?? args.options.stlPrecision);
35
+ else if (arg === "--no-stl") args.options.stl = false;
36
+ else if (arg === "--cloud") args.cloud = true;
37
+ else if (arg === "--help" || arg === "-h") { console.log(USAGE); process.exit(0); }
38
+ else if (arg.startsWith("--")) throw new Error(`unknown option ${arg}\n${USAGE}`);
39
+ else args.inputs.push(arg);
40
+ }
41
+ if (args.inputs.length === 0) throw new Error(`nothing to convert\n${USAGE}`);
42
+ if (!(args.options.meshPrecision > 0) || !(args.options.stlPrecision > 0)) throw new Error("--precision and --stl-precision must be positive numbers");
43
+ return args;
44
+ }
45
+
46
+ export function expandInputs(inputs: string[]): string[] {
47
+ const files: string[] = [];
48
+ for (const input of inputs) {
49
+ const path = resolve(input);
50
+ if (!existsSync(path)) throw new Error(`${input}: no such file or directory`);
51
+ if (statSync(path).isDirectory()) {
52
+ for (const entry of readdirSync(path).sort()) {
53
+ if (CAD_EXTENSIONS.has(extname(entry).toLowerCase())) files.push(join(path, entry));
54
+ }
55
+ } else {
56
+ files.push(path);
57
+ }
58
+ }
59
+ if (files.length === 0) throw new Error("no .step, .stp, .iges or .igs files among the inputs");
60
+ return files;
61
+ }
62
+
63
+ async function main(): Promise<void> {
64
+ const args = parseArgs(process.argv.slice(2));
65
+ const files = expandInputs(args.inputs);
66
+ mkdirSync(args.out, { recursive: true });
67
+ if (args.cloud && !process.env[KEY_VARIABLE]) {
68
+ console.error(NO_KEY_MESSAGE);
69
+ process.exit(NO_KEY_EXIT);
70
+ }
71
+ const occt = await loadKernel();
72
+ const results: Stats[] = [];
73
+ let failures = 0;
74
+ for (const file of files) {
75
+ const name = basename(file, extname(file));
76
+ const text = readFileSync(file, "utf8");
77
+ try {
78
+ const converted = convertFile(occt, basename(file), text, args.options);
79
+ let source = "in-process";
80
+ if (args.cloud) {
81
+ const cloud = await convertViaCloud(basename(file), text, args.options);
82
+ converted.glb = cloud.glb;
83
+ converted.stats.glbBytes = cloud.glb.byteLength;
84
+ source = `CAD Cloud task ${cloud.taskId}`;
85
+ }
86
+ writeFileSync(join(args.out, `${name}.glb`), converted.glb);
87
+ if (converted.stl !== null) writeFileSync(join(args.out, `${name}.stl`), converted.stl);
88
+ writeFileSync(join(args.out, `${name}.json`), `${JSON.stringify({ ...converted.stats, source }, null, 2)}\n`);
89
+ results.push(converted.stats);
90
+ console.log(`ok ${basename(file)} ${converted.stats.solids} solid(s), ${converted.stats.faces} faces, ${converted.stats.edges} edges, ${converted.stats.glbBytes} bytes of GLB (${source}, ${converted.stats.ms} ms)`);
91
+ } catch (error) {
92
+ failures++;
93
+ console.error(`FAIL ${basename(file)}: ${error instanceof Error ? error.message : String(error)}`);
94
+ }
95
+ }
96
+ console.log(JSON.stringify({ converted: results.length, failed: failures, out: resolve(args.out) }));
97
+ process.exit(failures > 0 ? 1 : 0);
98
+ }
99
+
100
+ const invokedDirectly = process.argv[1] !== undefined && resolve(process.argv[1]).endsWith(join("src", "cli.ts"));
101
+ if (invokedDirectly) {
102
+ main().catch((error: unknown) => {
103
+ console.error(error instanceof Error ? error.message : String(error));
104
+ process.exit(1);
105
+ });
106
+ }
@@ -0,0 +1,34 @@
1
+ import { BitbybitClient } from "@bitbybit-dev/cad-cloud-sdk";
2
+ import type { ConvertOptions } from "./convert.js";
3
+
4
+ export const CAD_CLOUD_URL = "https://bitbybit.dev/cad-cloud";
5
+ export const STUDIO_KEYS_URL = "https://studio.bitbybit.dev/keys/billing";
6
+ export const KEY_VARIABLE = "BITBYBIT_API_KEY";
7
+ export const URL_VARIABLE = "BITBYBIT_API_URL";
8
+ export const DEFAULT_API_URL = "https://api.bitbybit.dev";
9
+ export const NO_KEY_EXIT = 2;
10
+
11
+ export const NO_KEY_MESSAGE = [
12
+ `--cloud converts on CAD Cloud, and ${KEY_VARIABLE} is not set.`,
13
+ "Without --cloud this tool converts in-process on the open-source kernel, free, with the same result for any file this machine can hold;",
14
+ "--cloud is for the cases a local kernel cannot serve: a serverless or edge function without the memory for it, or a volume of files worth handing to a queue.",
15
+ `Any CAD Cloud plan includes conversion (${CAD_CLOUD_URL}); create a key in Bitbybit Studio (${STUDIO_KEYS_URL}) and export ${KEY_VARIABLE} before running with --cloud.`,
16
+ ].join("\n");
17
+
18
+ export interface CloudResult {
19
+ glb: Uint8Array;
20
+ taskId: string;
21
+ }
22
+
23
+ export async function convertViaCloud(file: string, text: string, options: ConvertOptions, env: NodeJS.ProcessEnv = process.env): Promise<CloudResult> {
24
+ const apiKey = env[KEY_VARIABLE];
25
+ if (!apiKey) throw new Error(NO_KEY_MESSAGE);
26
+ const client = new BitbybitClient({ apiKey, baseUrl: env[URL_VARIABLE] ?? DEFAULT_API_URL });
27
+ const uploaded = await client.files.uploadBytes(file, new TextEncoder().encode(text), "application/step");
28
+ const { taskId, downloads } = await client.convert.stepToGltfAndPoll({ stepFileId: uploaded.fileId, meshPrecision: options.meshPrecision, meshRelative: true }, { intervalMs: 1500, maxAttempts: 200 });
29
+ const glb = downloads.find((download) => download.format === "glb" || download.format === "gltf");
30
+ if (!glb) throw new Error(`${file}: CAD Cloud task ${taskId} returned no glTF download`);
31
+ const response = await fetch(glb.downloadUrl);
32
+ if (!response.ok) throw new Error(`${file}: downloading the glTF failed with HTTP ${response.status}`);
33
+ return { glb: new Uint8Array(await response.arrayBuffer()), taskId };
34
+ }
@@ -0,0 +1,65 @@
1
+ import type { OCCTService } from "@bitbybit-dev/occt";
2
+
3
+ export interface ConvertOptions {
4
+ meshPrecision: number;
5
+ stlPrecision: number;
6
+ stl: boolean;
7
+ }
8
+
9
+ export interface Stats {
10
+ file: string;
11
+ solids: number;
12
+ faces: number;
13
+ edges: number;
14
+ volume: number;
15
+ bbox: { min: number[]; max: number[] };
16
+ glbBytes: number;
17
+ stlBytes: number;
18
+ ms: number;
19
+ }
20
+
21
+ export interface Converted {
22
+ glb: Uint8Array;
23
+ stl: string | null;
24
+ stats: Stats;
25
+ }
26
+
27
+ export const defaultOptions: ConvertOptions = { meshPrecision: 0.005, stlPrecision: 0.1, stl: true };
28
+
29
+ export const GLB_MAGIC = "glTF";
30
+
31
+ export function convertFile(occt: OCCTService, file: string, text: string, options: ConvertOptions = defaultOptions): Converted {
32
+ const started = Date.now();
33
+ const shape = occt.io.loadSTEPorIGES({ filetext: text, fileName: file, adjustZtoY: true });
34
+ if (!shape) throw new Error(`${file}: the kernel could not read this file as STEP or IGES`);
35
+ const solids = occt.shapes.solid.getSolids({ shape });
36
+ const faces = occt.shapes.face.getFaces({ shape }).length;
37
+ const edges = occt.shapes.edge.getEdges({ shape }).length;
38
+ const volume = occt.shapes.solid.getSolidsVolumes({ shapes: solids }).reduce((sum, v) => sum + v, 0);
39
+ const bbox = occt.operations.boundingBoxOfShape({ shape });
40
+ const glb = occt.io.convertStepToGltf({ stepData: text, meshPrecision: options.meshPrecision, meshAngle: 0.5, meshRelative: true, internalVerticesMode: false, controlSurfaceDeflection: false });
41
+ const stl = options.stl ? occt.io.saveShapeStl({ shape, fileName: file, precision: options.stlPrecision, adjustYtoZ: true, tryDownload: false, binary: false }) : null;
42
+ return {
43
+ glb,
44
+ stl,
45
+ stats: {
46
+ file,
47
+ solids: solids.length,
48
+ faces,
49
+ edges,
50
+ volume: round(volume),
51
+ bbox: { min: bbox.min.map(round), max: bbox.max.map(round) },
52
+ glbBytes: glb.byteLength,
53
+ stlBytes: stl ? Buffer.byteLength(stl) : 0,
54
+ ms: Date.now() - started,
55
+ },
56
+ };
57
+ }
58
+
59
+ export function isGlb(bytes: Uint8Array): boolean {
60
+ return bytes.byteLength > 12 && String.fromCharCode(...bytes.subarray(0, 4)) === GLB_MAGIC;
61
+ }
62
+
63
+ function round(value: number): number {
64
+ return Math.round(value * 1000) / 1000;
65
+ }
@@ -0,0 +1,14 @@
1
+ import { createRequire } from "node:module";
2
+ import { readdirSync } from "node:fs";
3
+ import { dirname, join } from "node:path";
4
+ import initOpenCascade from "@bitbybit-dev/occt/bitbybit-dev-occt/index.js";
5
+ import { OCCTService, OccHelper, VectorHelperService, ShapesHelperService } from "@bitbybit-dev/occt";
6
+
7
+ export async function loadKernel(): Promise<OCCTService> {
8
+ const require = createRequire(import.meta.url);
9
+ const kernelDir = dirname(require.resolve("@bitbybit-dev/occt/bitbybit-dev-occt/index.js"));
10
+ const wasmFile = readdirSync(kernelDir).find((file) => file.endsWith(".wasm"));
11
+ if (!wasmFile) throw new Error(`no OCCT kernel (.wasm) found in ${kernelDir}`);
12
+ const occ = await initOpenCascade({ locateFile: (file: string) => (file.endsWith(".wasm") ? join(kernelDir, wasmFile) : file) });
13
+ return new OCCTService(occ, new OccHelper(new VectorHelperService(), new ShapesHelperService(), occ));
14
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022"],
7
+ "types": ["node"],
8
+ "noEmit": true,
9
+ "strict": true,
10
+ "noUncheckedIndexedAccess": true,
11
+ "exactOptionalPropertyTypes": true,
12
+ "noImplicitReturns": true,
13
+ "noImplicitOverride": true,
14
+ "noPropertyAccessFromIndexSignature": true,
15
+ "noFallthroughCasesInSwitch": true,
16
+ "noUnusedLocals": true,
17
+ "noUnusedParameters": true,
18
+ "useUnknownInCatchVariables": true,
19
+ "forceConsistentCasingInFileNames": true,
20
+ "isolatedModules": true,
21
+ "verbatimModuleSyntax": true,
22
+ "erasableSyntaxOnly": true,
23
+ "noUncheckedSideEffectImports": true,
24
+ "skipLibCheck": true
25
+ },
26
+ "include": ["src", "scripts"]
27
+ }
@@ -0,0 +1,22 @@
1
+ ## This template: CAD Cloud app with {{BACKEND_NAME}}
2
+
3
+ Two packages. `backend/` holds the API key in `backend/{{SECRET_FILE}}`, calls the Bitbybit CAD Cloud REST API and exposes `/api/*`. `frontend/` (React, Vite, Three.js) calls only the backend, through Vite's dev proxy, and loads the glTF results it gets back. The key never reaches the browser; keep it that way, and keep every call to `api.bitbybit.dev` inside `backend/`.
4
+
5
+ Commands:
6
+
7
+ - backend: `{{BACKEND_START}}` serves it on port 3000; `{{BACKEND_SMOKE}}` checks it without a key
8
+ - frontend: `cd frontend && npm install && npm run dev` serves it at http://localhost:5173; `npm run smoke` typechecks and lints it
9
+
10
+ The routes: every `/api/*` route answers 503 with a message when no key is configured; the single and batch dragon-cup routes create tasks, the pipeline routes run the API's pipelines (translate then union then fillet, cylinders mapped over positions, spheres over radii, a choice conditional, a STEP upload then fillet), one route fetches an existing task's result, and `/api/proxy-download` streams a result file through the backend because the browser's glTF loader cannot fetch it cross-origin from the result URL. The REST clients poll a task every two seconds for at most four minutes; the .NET client uploads a file in three steps (a presigned URL, the PUT, a confirmation). The frontend reads both answer shapes: `downloadUrl` from the REST backends and `downloads[]` from the SDK ones, and on load it picks up `?task=` or `?pipeline-task=` from the URL to show an existing result.
11
+
12
+ The backend's smoke compiles it and nothing more: it proves the code still matches the pinned CAD Cloud SDK and types after a change, without a key and without a network. Running the app for real needs the key below.
13
+
14
+ ## What needs CAD Cloud and where to get it
15
+
16
+ Everything this app renders is computed on CAD Cloud, because this template is the hosted-compute case: a backend that cannot or does not host the CAD kernels (a Cloudflare Worker or a .NET server cannot; a small Node server may choose not to) and sends the work to `api.bitbybit.dev`. If the geometry could instead run in the users' browsers, or in a Node server with the memory to hold a kernel, the free packages are the whole answer and a Vite template from `npm init @bitbybit-dev/app` is the better start. Do not move a cloud call into the browser to save the key: the honest fix is to switch template.
17
+
18
+ - The calls that go to the cloud: every route in `backend/` that creates a task, runs a pipeline, uploads a file or fetches a result. They are metered on the key's plan exactly as the REST API documents.
19
+ - The plan needed: any [CAD Cloud plan](https://bitbybit.dev/cad-cloud). The key's scopes decide which routes work; this template needs `cad`, `files` and `tasks`.
20
+ - Where the key comes from: keys are created and managed in [Bitbybit Studio](https://studio.bitbybit.dev/keys/billing), which also shows the tasks this app ran and the usage they cost.
21
+ - Where the key goes: `backend/{{SECRET_FILE}}`, which `backend/.gitignore` already ignores. Never write it anywhere else, never paste it into a prompt, and never log it.
22
+ - Without a key: every `/api/*` route answers 503 with a message that says so, and the frontend shows the same explanation with the links above. That state is part of the app; keep it working, and keep the links current.
@@ -3,12 +3,15 @@ using System.Text;
3
3
  using System.Text.Json;
4
4
  using System.Text.Json.Nodes;
5
5
 
6
- namespace dotnet_rest;
6
+ namespace DotnetRest;
7
7
 
8
8
  public class BitbybitClient
9
9
  {
10
10
  private const int PollIntervalMs = 2_000;
11
- private const int MaxPollAttempts = 120; // 4 minutes max
11
+ private const int PollTimeoutMs = 4 * 60 * 1000;
12
+ private const int MaxPollAttempts = PollTimeoutMs / PollIntervalMs;
13
+
14
+ private static readonly JsonSerializerOptions SerializerOptions = new() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase };
12
15
 
13
16
  private readonly HttpClient _http;
14
17
  private readonly string _apiKey;
@@ -26,10 +29,6 @@ public class BitbybitClient
26
29
  _apiUrl = config["Bitbybit:ApiUrl"] ?? "https://api.bitbybit.dev";
27
30
  }
28
31
 
29
- // -----------------------------------------------------------------------
30
- // Dragon cup — single model
31
- // -----------------------------------------------------------------------
32
-
33
32
  public async Task<DownloadResult> CreateDragonCupAsync()
34
33
  {
35
34
  var body = new
@@ -58,10 +57,6 @@ public class BitbybitClient
58
57
  return new DownloadResult(taskId, downloads);
59
58
  }
60
59
 
61
- // -----------------------------------------------------------------------
62
- // Dragon cup — batch
63
- // -----------------------------------------------------------------------
64
-
65
60
  public async Task<BatchResult> CreateDragonCupBatchAsync()
66
61
  {
67
62
  var body = new
@@ -112,36 +107,32 @@ public class BitbybitClient
112
107
  };
113
108
 
114
109
  var json = await ApiPostAsync("/api/v1/models/dragon-cup/batch", body);
115
- var taskId = json["data"]?["taskId"]?.GetValue<string>() ?? throw new Exception("No taskId in response");
116
- var subTasks = json["data"]?["subTasks"]?.AsArray() ?? throw new Exception("No subTasks in response");
110
+ var taskId = json["data"]?["taskId"]?.GetValue<string>() ?? throw new InvalidOperationException("No taskId in response");
111
+ var subTasks = json["data"]?["subTasks"]?.AsArray() ?? throw new InvalidOperationException("No subTasks in response");
117
112
 
118
113
  await PollUntilDoneAsync(taskId);
119
114
 
120
115
  var downloadUrls = new List<string>();
121
116
  foreach (var sub in subTasks)
122
117
  {
123
- var subId = sub?["taskId"]?.GetValue<string>() ?? throw new Exception("No sub taskId");
118
+ var subId = sub?["taskId"]?.GetValue<string>() ?? throw new InvalidOperationException("No sub taskId");
124
119
  var resultJson = await ApiGetAsync($"/api/v1/tasks/{subId}/result/glb");
125
- var url = resultJson["data"]?["downloadUrl"]?.GetValue<string>() ?? throw new Exception("No downloadUrl");
120
+ var url = resultJson["data"]?["downloadUrl"]?.GetValue<string>() ?? throw new InvalidOperationException("No downloadUrl");
126
121
  downloadUrls.Add(url);
127
122
  }
128
123
 
129
124
  return new BatchResult(taskId, downloadUrls);
130
125
  }
131
126
 
132
- // -----------------------------------------------------------------------
133
- // Get task result
134
- // -----------------------------------------------------------------------
135
-
136
127
  public async Task<TaskStatusResult> GetTaskResultAsync(string taskId)
137
128
  {
138
129
  var json = await ApiGetAsync($"/api/v1/tasks/{taskId}");
139
- var status = json["data"]?["status"]?.GetValue<string>() ?? throw new Exception("No status");
130
+ var status = json["data"]?["status"]?.GetValue<string>() ?? throw new InvalidOperationException("No status");
140
131
 
141
132
  if (status is "failed" or "cancelled" or "expired")
142
133
  {
143
134
  var error = json["data"]?["error"]?.GetValue<string>() ?? "no details";
144
- throw new Exception($"Task {status}: {error}");
135
+ throw new InvalidOperationException($"Task {status}: {error}");
145
136
  }
146
137
 
147
138
  if (status != "completed")
@@ -152,10 +143,6 @@ public class BitbybitClient
152
143
  return new TaskStatusResult("completed", downloads);
153
144
  }
154
145
 
155
- // -----------------------------------------------------------------------
156
- // Pipelines
157
- // -----------------------------------------------------------------------
158
-
159
146
  public Task<DownloadResult> RunTranslateUnionFilletPipelineAsync()
160
147
  {
161
148
  var body = new
@@ -244,13 +231,8 @@ public class BitbybitClient
244
231
  return SubmitPipelineAsync(body);
245
232
  }
246
233
 
247
- // -----------------------------------------------------------------------
248
- // File upload (3-step presigned URL flow)
249
- // -----------------------------------------------------------------------
250
-
251
234
  public async Task<string> UploadFileAsync(byte[] fileBytes, string filename)
252
235
  {
253
- // 1. Request presigned upload URL
254
236
  var uploadJson = await ApiPostAsync("/api/v1/files/upload", new
255
237
  {
256
238
  filename,
@@ -258,25 +240,19 @@ public class BitbybitClient
258
240
  bytes = fileBytes.Length,
259
241
  });
260
242
 
261
- var fileId = uploadJson["data"]?["fileId"]?.GetValue<string>() ?? throw new Exception("No fileId");
262
- var uploadUrl = uploadJson["data"]?["uploadUrl"]?.GetValue<string>() ?? throw new Exception("No uploadUrl");
243
+ var fileId = uploadJson["data"]?["fileId"]?.GetValue<string>() ?? throw new InvalidOperationException("No fileId");
244
+ var uploadUrl = uploadJson["data"]?["uploadUrl"]?.GetValue<string>() ?? throw new InvalidOperationException("No uploadUrl");
263
245
 
264
- // 2. PUT raw bytes to presigned URL
265
246
  using var putContent = new ByteArrayContent(fileBytes);
266
247
  putContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
267
248
  var putRes = await _http.PutAsync(uploadUrl, putContent);
268
249
  putRes.EnsureSuccessStatusCode();
269
250
 
270
- // 3. Confirm
271
251
  await ApiPostAsync($"/api/v1/files/{Uri.EscapeDataString(fileId)}/confirm", null);
272
252
 
273
253
  return fileId;
274
254
  }
275
255
 
276
- // -----------------------------------------------------------------------
277
- // Internals
278
- // -----------------------------------------------------------------------
279
-
280
256
  private async Task<DownloadResult> SubmitPipelineAsync(object body)
281
257
  {
282
258
  var taskId = await SubmitAndGetTaskIdAsync("/api/v1/cad/pipeline", body);
@@ -287,7 +263,7 @@ public class BitbybitClient
287
263
  private async Task<string> SubmitAndGetTaskIdAsync(string path, object body)
288
264
  {
289
265
  var json = await ApiPostAsync(path, body);
290
- return json["data"]?["taskId"]?.GetValue<string>() ?? throw new Exception("No taskId in response");
266
+ return json["data"]?["taskId"]?.GetValue<string>() ?? throw new InvalidOperationException("No taskId in response");
291
267
  }
292
268
 
293
269
  private async Task<List<FileDownload>> PollAndGetResultAsync(string taskId)
@@ -305,13 +281,13 @@ public class BitbybitClient
305
281
  await Task.Delay(PollIntervalMs);
306
282
 
307
283
  var json = await ApiGetAsync($"/api/v1/tasks/{taskId}");
308
- var status = json["data"]?["status"]?.GetValue<string>() ?? throw new Exception("No status");
284
+ var status = json["data"]?["status"]?.GetValue<string>() ?? throw new InvalidOperationException("No status");
309
285
 
310
286
  if (status == "completed") return;
311
287
  if (status is "failed" or "cancelled" or "expired")
312
288
  {
313
289
  var error = json["data"]?["error"]?.GetValue<string>() ?? "no details";
314
- throw new Exception($"Task {status}: {error}");
290
+ throw new InvalidOperationException($"Task {status}: {error}");
315
291
  }
316
292
  }
317
293
 
@@ -325,8 +301,8 @@ public class BitbybitClient
325
301
  var res = await _http.SendAsync(req);
326
302
  var body = await res.Content.ReadAsStringAsync();
327
303
  if (!res.IsSuccessStatusCode && (int)res.StatusCode != 202)
328
- throw new Exception($"API error {(int)res.StatusCode}: {body}");
329
- return JsonNode.Parse(body) ?? throw new Exception("Empty response");
304
+ throw new HttpRequestException($"API error {(int)res.StatusCode}: {body}", null, res.StatusCode);
305
+ return JsonNode.Parse(body) ?? throw new InvalidOperationException("Empty response");
330
306
  }
331
307
 
332
308
  private async Task<JsonNode> ApiPostAsync(string path, object? body)
@@ -335,19 +311,19 @@ public class BitbybitClient
335
311
  req.Headers.Add("x-api-key", _apiKey);
336
312
  if (body != null)
337
313
  {
338
- var jsonStr = JsonSerializer.Serialize(body, new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
314
+ var jsonStr = JsonSerializer.Serialize(body, SerializerOptions);
339
315
  req.Content = new StringContent(jsonStr, Encoding.UTF8, "application/json");
340
316
  }
341
317
  var res = await _http.SendAsync(req);
342
318
  var responseBody = await res.Content.ReadAsStringAsync();
343
319
  if (!res.IsSuccessStatusCode && (int)res.StatusCode != 202)
344
- throw new Exception($"API error {(int)res.StatusCode}: {responseBody}");
345
- return JsonNode.Parse(responseBody) ?? throw new Exception("Empty response");
320
+ throw new HttpRequestException($"API error {(int)res.StatusCode}: {responseBody}", null, res.StatusCode);
321
+ return JsonNode.Parse(responseBody) ?? throw new InvalidOperationException("Empty response");
346
322
  }
347
323
 
348
324
  private static List<FileDownload> ParseDownloads(JsonNode json)
349
325
  {
350
- var arr = json["data"]?["downloads"]?.AsArray() ?? throw new Exception("No downloads");
326
+ var arr = json["data"]?["downloads"]?.AsArray() ?? throw new InvalidOperationException("No downloads");
351
327
  var downloads = new List<FileDownload>();
352
328
  foreach (var item in arr)
353
329
  {
@@ -361,10 +337,6 @@ public class BitbybitClient
361
337
  }
362
338
  }
363
339
 
364
- // -----------------------------------------------------------------------
365
- // DTOs
366
- // -----------------------------------------------------------------------
367
-
368
340
  public record FileDownload(string Format, string DownloadUrl, string Filename);
369
341
  public record DownloadResult(string TaskId, List<FileDownload> Downloads);
370
342
  public record BatchResult(string TaskId, List<string> DownloadUrls);
@@ -1,13 +1,11 @@
1
- using dotnet_rest;
1
+ using DotnetRest;
2
2
 
3
3
  var builder = WebApplication.CreateBuilder(args);
4
4
 
5
- // Register HttpClient + BitbybitClient for DI
6
5
  builder.Services.AddHttpClient<BitbybitClient>();
7
6
 
8
7
  var app = builder.Build();
9
8
 
10
- // Backend endpoint — calls bitbybit API with server-side API key
11
9
  app.MapPost("/api/generate", async (BitbybitClient client) =>
12
10
  {
13
11
  try
@@ -21,7 +19,6 @@ app.MapPost("/api/generate", async (BitbybitClient client) =>
21
19
  }
22
20
  });
23
21
 
24
- // Batch generation — creates 3 dragon cup variations in parallel
25
22
  app.MapPost("/api/generate-batch", async (BitbybitClient client) =>
26
23
  {
27
24
  try
@@ -35,7 +32,6 @@ app.MapPost("/api/generate-batch", async (BitbybitClient client) =>
35
32
  }
36
33
  });
37
34
 
38
- // Fetch result for an existing task
39
35
  app.MapGet("/api/task/{id}", async (string id, BitbybitClient client) =>
40
36
  {
41
37
  try
@@ -49,7 +45,6 @@ app.MapGet("/api/task/{id}", async (string id, BitbybitClient client) =>
49
45
  }
50
46
  });
51
47
 
52
- // Pipeline: translate → union → fillet
53
48
  app.MapPost("/api/pipeline/translate-union-fillet", async (BitbybitClient client) =>
54
49
  {
55
50
  try
@@ -63,7 +58,6 @@ app.MapPost("/api/pipeline/translate-union-fillet", async (BitbybitClient client
63
58
  }
64
59
  });
65
60
 
66
- // Pipeline: map cylinders at positions
67
61
  app.MapPost("/api/pipeline/map-cylinders", async (BitbybitClient client) =>
68
62
  {
69
63
  try
@@ -77,7 +71,6 @@ app.MapPost("/api/pipeline/map-cylinders", async (BitbybitClient client) =>
77
71
  }
78
72
  });
79
73
 
80
- // Pipeline: map spheres at different radii
81
74
  app.MapPost("/api/pipeline/map-spheres", async (BitbybitClient client) =>
82
75
  {
83
76
  try
@@ -91,7 +84,6 @@ app.MapPost("/api/pipeline/map-spheres", async (BitbybitClient client) =>
91
84
  }
92
85
  });
93
86
 
94
- // Pipeline: choice conditional
95
87
  app.MapPost("/api/pipeline/choice", async (BitbybitClient client) =>
96
88
  {
97
89
  try
@@ -105,7 +97,6 @@ app.MapPost("/api/pipeline/choice", async (BitbybitClient client) =>
105
97
  }
106
98
  });
107
99
 
108
- // Pipeline: file input (upload STEP → fillet)
109
100
  app.MapPost("/api/pipeline/file-input", async (IFormFile file, BitbybitClient client) =>
110
101
  {
111
102
  try
@@ -122,7 +113,6 @@ app.MapPost("/api/pipeline/file-input", async (IFormFile file, BitbybitClient cl
122
113
  }
123
114
  }).DisableAntiforgery();
124
115
 
125
- // Proxy download — fetches a remote file through the backend to avoid CORS issues with GLTFLoader
126
116
  app.MapGet("/api/proxy-download", async (string? url, IHttpClientFactory httpFactory) =>
127
117
  {
128
118
  if (string.IsNullOrEmpty(url))
@@ -4,7 +4,10 @@
4
4
  <TargetFramework>net10.0</TargetFramework>
5
5
  <Nullable>enable</Nullable>
6
6
  <ImplicitUsings>enable</ImplicitUsings>
7
- <RootNamespace>dotnet_rest</RootNamespace>
7
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8
+ <AnalysisLevel>latest-recommended</AnalysisLevel>
9
+ <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
10
+ <RootNamespace>DotnetRest</RootNamespace>
8
11
  </PropertyGroup>
9
12
 
10
13
  </Project>