Skip to content

gi-nx


gi-nx / fetchProjectDetails

ts
function fetchProjectDetails(projectId?: string): Promise<{
  attachments: ProjectAttachment[];
  first_vista: {
     details: {
        _pixelsToMeters?: number;
        _viewBox?: {
           geometry: {
              coordinates: [number, number][][];
              type: "Polygon";
           };
           properties: Record<string, any>;
           type: "Feature";
        };
        activeLayer: string;
        camera: Camera & {
           latitude?: number;
           longitude?: number;
        };
        description?: string;
        dpi?: number;
        layerTree: LayerTree;
        name: string;
        order?: number;
        scenarios?: string[];
        size?: {
           height: number;
           width: number;
        };
        snapShot: string;
        solarDate: string;
        topView: TopView;
     };
     name: string;
     project: number;
  };
} & Permissions>;

Fetches details (including project attachments) for a given project. This is also how you access a project's attachments — pair the returned attachments with getTempUrl to obtain publicly accessible URLs for each one.

Parameters

ParameterTypeDescription
projectId?stringThe project ID. Defaults to the active project if not provided.

Returns

Promise<{ attachments: ProjectAttachment[]; first_vista: { details: { _pixelsToMeters?: number; _viewBox?: { geometry: { coordinates: [number, number][][]; type: "Polygon"; }; properties: Record<string, any>; type: "Feature"; }; activeLayer: string; camera: Camera & { latitude?: number; longitude?: number; }; description?: string; dpi?: number; layerTree: LayerTree; name: string; order?: number; scenarios?: string[]; size?: { height: number; width: number; }; snapShot: string; solarDate: string; topView: TopView; }; name: string; project: number; }; } & Permissions>

A promise that resolves with the project's details data.

Throws

If called from scratchpad or if the user does not have permission to access the project.

Example

tsx
const projectDetailsWithAttachmentPublicUrls = await rpc.invoke("fetchProjectDetails")
  .then((data) =>
    Promise.all(
      (data.attachments ?? []).map(async (file) => {
        const publicTemporaryUrl = await rpc.invoke("getTempUrl", file.url);
        return { ...file, publicTemporaryUrl, storageProxyUrl: file.url };
      })
    )
  )
  .catch((error) => {
    console.error("Error fetching files:", error);
  });