FIX - TASKER BIM ROUTING: production endpoint и CAD-форматы Ops
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import {
|
||||
DEFAULT_BEAM_VIEWER_BASE_URL,
|
||||
getBeamDirectModelTypeFromFileName,
|
||||
getBeamModelTypeFromFileName,
|
||||
// @ts-expect-error Node's strip-types test runner requires the explicit TypeScript extension.
|
||||
} from "./beam-viewer-config.ts";
|
||||
|
||||
test("routes STEP and IGES variants through the converter", () => {
|
||||
assert.equal(getBeamModelTypeFromFileName("model.step"), "step");
|
||||
assert.equal(getBeamModelTypeFromFileName("model.STP"), "step");
|
||||
assert.equal(getBeamModelTypeFromFileName("model.iges"), "iges");
|
||||
assert.equal(getBeamModelTypeFromFileName("model.IGS"), "iges");
|
||||
assert.equal(getBeamDirectModelTypeFromFileName("model.igs"), null);
|
||||
});
|
||||
|
||||
test("uses the production BIM service when build args are absent", () => {
|
||||
assert.equal(DEFAULT_BEAM_VIEWER_BASE_URL, "https://bim.nodedc.tech");
|
||||
});
|
||||
@@ -0,0 +1,35 @@
|
||||
export const DEFAULT_BEAM_VIEWER_BASE_URL = "https://bim.nodedc.tech";
|
||||
|
||||
const BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
bim: "bim",
|
||||
glb: "gltf",
|
||||
gltf: "gltf",
|
||||
las: "las",
|
||||
laz: "las",
|
||||
obj: "obj",
|
||||
stl: "stl",
|
||||
xkt: "xkt",
|
||||
};
|
||||
|
||||
const BEAM_CONVERTIBLE_MODEL_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
iges: "iges",
|
||||
igs: "iges",
|
||||
step: "step",
|
||||
stp: "step",
|
||||
};
|
||||
|
||||
export const getBeamFileExtension = (name: string): string => {
|
||||
const parts = name.split(".");
|
||||
return parts.length > 1 ? parts[parts.length - 1].toLowerCase() : "";
|
||||
};
|
||||
|
||||
export const getBeamModelTypeFromFileName = (name: string | undefined): string | null => {
|
||||
if (!name) return null;
|
||||
const extension = getBeamFileExtension(name);
|
||||
return BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION[extension] ?? BEAM_CONVERTIBLE_MODEL_TYPE_BY_EXTENSION[extension] ?? null;
|
||||
};
|
||||
|
||||
export const getBeamDirectModelTypeFromFileName = (name: string | undefined): string | null => {
|
||||
if (!name) return null;
|
||||
return BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION[getBeamFileExtension(name)] ?? null;
|
||||
};
|
||||
@@ -1,5 +1,11 @@
|
||||
import type { AxiosProgressEvent } from "axios";
|
||||
import type { TIssueAttachment } from "@plane/types";
|
||||
import {
|
||||
DEFAULT_BEAM_VIEWER_BASE_URL,
|
||||
getBeamDirectModelTypeFromFileName,
|
||||
getBeamFileExtension,
|
||||
getBeamModelTypeFromFileName,
|
||||
} from "./beam-viewer-config";
|
||||
|
||||
export type TBeamViewerConversion = {
|
||||
artifactSrc?: string;
|
||||
@@ -101,24 +107,6 @@ export const dispatchBeamViewerOpenEvent = (detail: TBeamViewerOpenEventDetail)
|
||||
window.dispatchEvent(new CustomEvent<TBeamViewerOpenEventDetail>(BEAM_VIEWER_OPEN_EVENT, { detail }));
|
||||
};
|
||||
|
||||
const DEFAULT_BEAM_VIEWER_BASE_URL = "http://localhost:8080";
|
||||
|
||||
const BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
bim: "bim",
|
||||
glb: "gltf",
|
||||
gltf: "gltf",
|
||||
las: "las",
|
||||
laz: "las",
|
||||
obj: "obj",
|
||||
stl: "stl",
|
||||
xkt: "xkt",
|
||||
};
|
||||
|
||||
const BEAM_CONVERTIBLE_MODEL_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
step: "step",
|
||||
stp: "step",
|
||||
};
|
||||
|
||||
const MIME_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
glb: "model/gltf-binary",
|
||||
gltf: "model/gltf+json",
|
||||
@@ -127,11 +115,6 @@ const MIME_TYPE_BY_EXTENSION: Record<string, string> = {
|
||||
const normalizeBaseUrl = (url: string | undefined): string =>
|
||||
(url && url.trim() ? url.trim() : DEFAULT_BEAM_VIEWER_BASE_URL).replace(/\/+$/, "");
|
||||
|
||||
const getFileExtension = (name: string): string => {
|
||||
const parts = name.split(".");
|
||||
return parts.length > 1 ? parts[parts.length - 1].toLowerCase() : "";
|
||||
};
|
||||
|
||||
const getUploadGroupId = (parts: Array<string | undefined>): string => {
|
||||
const value = parts
|
||||
.filter(Boolean)
|
||||
@@ -167,18 +150,15 @@ export const getBeamApiBaseUrl = (): string =>
|
||||
normalizeBaseUrl(process.env.VITE_BEAM_API_BASE_URL || process.env.VITE_BEAM_VIEWER_BASE_URL);
|
||||
|
||||
export const getBeamModelTypeFromName = (name: string | undefined): string | null => {
|
||||
if (!name) return null;
|
||||
const extension = getFileExtension(name);
|
||||
return BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION[extension] ?? BEAM_CONVERTIBLE_MODEL_TYPE_BY_EXTENSION[extension] ?? null;
|
||||
return getBeamModelTypeFromFileName(name);
|
||||
};
|
||||
|
||||
export const getBeamDirectModelTypeFromName = (name: string | undefined): string | null => {
|
||||
if (!name) return null;
|
||||
return BEAM_DIRECT_MODEL_TYPE_BY_EXTENSION[getFileExtension(name)] ?? null;
|
||||
return getBeamDirectModelTypeFromFileName(name);
|
||||
};
|
||||
|
||||
export const getBeamModelMimeType = (file: File): string =>
|
||||
MIME_TYPE_BY_EXTENSION[getFileExtension(file.name)] || "application/octet-stream";
|
||||
MIME_TYPE_BY_EXTENSION[getBeamFileExtension(file.name)] || "application/octet-stream";
|
||||
|
||||
export const isBeamModelFile = (name: string | undefined): boolean => !!getBeamModelTypeFromName(name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user