Skip to main content
Version: v5.1

IafGraphicsSvc

cacheGraphicsFiles#

Request the Graphics Service to cache a graphics file in its file store for streaming later.

ParameterRequiredTypeDescription
filesYesundefined
ctxYesCtxcontext
Returns

Promise<String> - ok: 204 response

Examples
let files = [  {    "_fileId": "da9a12ac-699c-4232-8c06-fc789eb9d6e5"  },  {    "_fileId": "aa51b6b9-8c61-4bea-a5bf-66fd4d423f9e",    "_fileVersionId": "81266d27-7fb6-4c80-bf3c-77038ffdbfd7"  }]await IafGraphicsSvc.cacheGraphicsFiles(files, ctx);

createFileSet#

Creates a GraphicsFileSet with a list of GraphicsFiles. The files in the GraphicsFileSet will be available for streaming in a single Iaf-Viewer session. The _id of the returned GraphicsFileSet should be provided to the Iaf-Viewer to setup the websocket connection for streaming geometry. A GraphicsFileSet can be used only by the user who created it. A GraphicsFileSet will be removed after the websocket connection is terminated.

ParameterRequiredTypeDescription
fileSetYesGraphicsFileSetGraphicsFileSet containing a list of GraphicsFiles that should be made available for an Iaf-Viewer session.
ctxYesCtxContext storage that contains data, such as authorization token requirements, namespaces, or session storage.
Returns

GraphicsFileSet - created: 201 response. The returned GraphicsFileSet contains an _id which should be passed to the Iaf-Viewer for setting up a session. The returned GraphicsFileSet will contain all or a sub-set of the input GraphicsFiles depending on which files exist in the File Service and to which files the user has READ access.

Examples
let fileSet = { files = [   {     _fileId: "da9a12ac-699c-4232-8c06-fc789eb9d6e5"   },   {     _fileId: "aa51b6b9-8c61-4bea-a5bf-66fd4d423f9e",     _fileVersionId: "81266d27-7fb6-4c80-bf3c-77038ffdbfd7"   } ]};
let severFileSet = IafGraphicsSvc.createFileSet(files, ctx);

createGraphicsData#

Creates graphics data object with specified properties for rendering in a 3D viewer.

ParameterRequiredTypeDescription
ctxYesCtxContext containing session or authorization details, with nsfilter as part of the namespace filtering.
dataYesArrayAn array of markup objects, each containing points, type, viewerType, and styleConfig.
Returns

Promise<Object> - Response data from the graphics service.

Examples
let data = [  {"_type": "markup","_properties": {      points: [        { x: -10026.515145147227, y: -8477.090905149831, z: 23920.00041471026 },        { x: -3465.221490438962, y: -26919.918005364816, z: 23920.00041496129 }      ],      type: 'LINE',      viewerType: '3D',      styleConfig: {  }    }  }];
let response = await IafGraphicsSvc.createGraphicsData(data, ctx);

createPermissions#

Creates permissions for a resource in the Graphics Service.

ParameterRequiredTypeDescription
ctxYesCtxContext containing namespace, session, or auth data.
permissionsYesArray<Permission>Array of permission objects to create.
Returns

Promise<Object> - CreatePermissionsResponse with successes and failures.

deleteGraphicsData#

Deletes graphics data object by ID.

ParameterRequiredTypeDescription
ctxYesCtxContext containing session or authorization details.
idsYesundefined
idYesStringThe ID of the markup item to delete.
Returns

Promise<void> - A confirmation of deletion from the graphics service.

deletePermission#

Deletes a permission using its .

ParameterRequiredTypeDescription
ctxYesCtxContext object.
idYesStringThe ID of the permission to delete.
Returns

Promise<String> - Confirmation of deletion.

getLayersList#

Get the desired list of layers for a BIM Model.

ParameterRequiredTypeDescription
ctxYesCtxcontext
Returns

Promise<String> - ok: 204 response

Examples
let layers = await IafGraphicsSvc.getLayersList();

getMapboxToken#

Fetch the Mapbox access token.

ParameterRequiredTypeDescription
ctxYesCtxcontext
Returns

Promise<String> - The Mapbox access token.

Examples
let token = await IafGraphicsSvc.getMapboxToken(ctx);

getPermissions#

Retrieves permissions based on the provided criteria.

ParameterRequiredTypeDescription
ctxYesCtxContext containing auth/session info.
criteriaYesPermissionCriteriaCriteria object to filter permissions (e.g., by namespace or user).
Returns

Promise<Page<Permission>> - Page of matching permissions.

getScriptDownloadUrl#

Gets a presigned temporary URL for a GraphicsService script, valid for short time (15 mins). The presigned URL can be used to download scripts without exposing access tokens in the URL.

ParameterRequiredTypeDescription
pathYesStringScript path relative to /graphicssvc/scripts/ (e.g., "communicator/web_viewer.js")
ctxYesCtxContext containing session or authorization details, with optional nsfilter.
Returns

Promise<String> - Presigned URL that can be used in script tag or dynamic import

Examples
// Get presigned URL for communicator scriptconst presignedUrl = await IafGraphicsSvc.getScriptDownloadUrl('communicator/web_viewer.js', ctx);
// Use presigned URL to load script (no token needed)await IafResourceUtils.loadJs(presignedUrl, { token: false });``````javascript// Get presigned URL with nsfilterconst ctxWithNsFilter = { ...ctx, nsfilter: 'project1' };const presignedUrl = await IafGraphicsSvc.getScriptDownloadUrl('communicator/web_viewer.js', ctxWithNsFilter);

getStatus#

Get the status of graphics service.

ParameterRequiredTypeDescription
ctxYesCtxcontext
Returns

Promise<String> - ok: 204 response

Examples
let status = await IafGraphicsSvc.getStatus();

getWebSocketUrl#

Gets a presigned temporary URL for a GraphicsService WebSocket connection, valid for short time (15 mins). The presigned URL can be used to establish WebSocket connections without exposing access tokens in the URL.

ParameterRequiredTypeDescription
fileSetIdYesStringFileSet ID for the WebSocket connection
ctxYesCtxContext containing session or authorization details, with optional nsfilter, serverVersion, isSingleWsEnabled.
Returns

Promise<String> - Presigned WebSocket URL (ws:// or wss://) that can be used for WebSocket connections

Examples
// Get presigned WebSocket URLconst wsUrl = await IafGraphicsSvc.getWebSocketUrl(fileSet._id, ctx);
// Use presigned URL for WebSocket connectionviewer.createRemoteViewer(containerId, model, fileSet, null, wsUrl, ...);

keepAlive#

Sends a keep-alive ping to prevent spawn termination for a given FileSet. This should be called periodically (e.g., every 60 seconds) while a model is active.

ParameterRequiredTypeDescription
fileSetIdYesStringThe ID of the FileSet to keep alive
ctxYesCtxContext containing session or authorization details
Returns

Promise<Object> - Response from the keep-alive endpoint

Examples
// Keep spawn alive for active FileSetawait IafGraphicsSvc.keepAlive(fileSet._id, ctx);

logMapbox#

Logs a message to the Mapbox logging service.

ParameterRequiredTypeDescription
levelYesstringThe log level (e.g., 'error', 'warning', 'info').
messageYesstringThe message to log.
ctxYesObjectThe context that contains session or authorization details.
Returns

Promise<Object> - The response from the Mapbox logging service.

readGraphicsDataById#

Reads graphics data object by ID.

ParameterRequiredTypeDescription
ctxYesCtxContext containing session or authorization details.
idYesStringThe ID of the markup item to retrieve.
Returns

Promise<Object> - The markup item data from the graphics service.

readGraphicsDataByType#

Retrieves a list of markups filtered by from the Graphics Service.

ParameterRequiredTypeDescription
ctxYesCtxContext containing session or authorization details, with nsfilter as part of the namespace filtering.
typeYesStringGraphics data to query, for example .
optionsYesGraphicsDataReadOptionsPagination controls for iterating through the dataset. .
Returns

Promise<Object> - Response data from the graphics service.

Examples
let response = await IafGraphicsSvc.readGraphicsDataByIds(ctx , 'markup', {pageSize: 20, fetchAllPages: false});

updateGraphicsDataById#

Updates graphics data object by ID with new properties.

ParameterRequiredTypeDescription
ctxYesCtxContext containing session or authorization details.
idYesStringThe ID of the markup item to update.
dataYesObjectThe updated data for the markup item.
Returns

Promise<Object> - The updated markup item data from the graphics service.

updatePermissions#

Updates existing permissions in the Graphics Service.

ParameterRequiredTypeDescription
ctxYesCtxContext object.
permissionsYesArray<Permission>Updated array of permission objects.
Returns

Promise<Object> - UpdatePermissionsResponse.