IafGraphicsSvc
cacheGraphicsFiles
Request the Graphics Service to cache a graphics file in its file store for streaming later.
| Parameter | Required | Type | Description |
|---|---|---|---|
| files | Yes | undefined | |
| ctx | Yes | Ctx | context |
Promise<String> - ok: 204 response
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| fileSet | Yes | GraphicsFileSet | GraphicsFileSet containing a list of GraphicsFiles that should be made available for an Iaf-Viewer session. |
| ctx | Yes | Ctx | Context storage that contains data, such as authorization token requirements, namespaces, or session storage. |
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.
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing session or authorization details, with nsfilter as part of the namespace filtering. |
| data | Yes | Array | An array of markup objects, each containing points, type, viewerType, and styleConfig. |
Promise<Object> - Response data from the graphics service.
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing namespace, session, or auth data. |
| permissions | Yes | Array<Permission> | Array of permission objects to create. |
Promise<Object> - CreatePermissionsResponse with successes and failures.
deleteGraphicsData
Deletes graphics data object by ID.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing session or authorization details. |
| ids | Yes | undefined | |
| id | Yes | String | The ID of the markup item to delete. |
Promise<void> - A confirmation of deletion from the graphics service.
deletePermission
Deletes a permission using its .
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context object. |
| id | Yes | String | The ID of the permission to delete. |
Promise<String> - Confirmation of deletion.
getLayersList
Get the desired list of layers for a BIM Model.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | context |
Promise<String> - ok: 204 response
let layers = await IafGraphicsSvc.getLayersList();
getMapboxToken
Fetch the Mapbox access token.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | context |
Promise<String> - The Mapbox access token.
let token = await IafGraphicsSvc.getMapboxToken(ctx);
getPermissions
Retrieves permissions based on the provided criteria.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing auth/session info. |
| criteria | Yes | PermissionCriteria | Criteria object to filter permissions (e.g., by namespace or user). |
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| path | Yes | String | Script path relative to /graphicssvc/scripts/ (e.g., "communicator/web_viewer.js") |
| ctx | Yes | Ctx | Context containing session or authorization details, with optional nsfilter. |
Promise<String> - Presigned URL that can be used in script tag or dynamic import
// Get presigned URL for communicator script
const 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 nsfilter
const ctxWithNsFilter = { ...ctx, nsfilter: 'project1' };
const presignedUrl = await IafGraphicsSvc.getScriptDownloadUrl('communicator/web_viewer.js', ctxWithNsFilter);
getStatus
Get the status of graphics service.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | context |
Promise<String> - ok: 204 response
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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| fileSetId | Yes | String | FileSet ID for the WebSocket connection |
| ctx | Yes | Ctx | Context containing session or authorization details, with optional nsfilter, serverVersion, isSingleWsEnabled. |
Promise<String> - Presigned WebSocket URL (ws:// or wss://) that can be used for WebSocket connections
// Get presigned WebSocket URL
const wsUrl = await IafGraphicsSvc.getWebSocketUrl(fileSet._id, ctx);
// Use presigned URL for WebSocket connection
viewer.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.
| Parameter | Required | Type | Description |
|---|---|---|---|
| fileSetId | Yes | String | The ID of the FileSet to keep alive |
| ctx | Yes | Ctx | Context containing session or authorization details |
Promise<Object> - Response from the keep-alive endpoint
// Keep spawn alive for active FileSet
await IafGraphicsSvc.keepAlive(fileSet._id, ctx);
logMapbox
Logs a message to the Mapbox logging service.
| Parameter | Required | Type | Description |
|---|---|---|---|
| level | Yes | string | The log level (e.g., 'error', 'warning', 'info'). |
| message | Yes | string | The message to log. |
| ctx | Yes | Object | The context that contains session or authorization details. |
Promise<Object> - The response from the Mapbox logging service.
readGraphicsDataById
Reads graphics data object by ID.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing session or authorization details. |
| id | Yes | String | The ID of the markup item to retrieve. |
Promise<Object> - The markup item data from the graphics service.
readGraphicsDataByType
Retrieves a list of markups filtered by from the Graphics Service.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing session or authorization details, with nsfilter as part of the namespace filtering. |
| type | Yes | String | Graphics data to query, for example . |
| options | Yes | GraphicsDataReadOptions | Pagination controls for iterating through the dataset. . |
Promise<Object> - Response data from the graphics service.
let response = await IafGraphicsSvc.readGraphicsDataByIds(ctx , 'markup', {pageSize: 20, fetchAllPages: false});
updateGraphicsDataById
Updates graphics data object by ID with new properties.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context containing session or authorization details. |
| id | Yes | String | The ID of the markup item to update. |
| data | Yes | Object | The updated data for the markup item. |
Promise<Object> - The updated markup item data from the graphics service.
updatePermissions
Updates existing permissions in the Graphics Service.
| Parameter | Required | Type | Description |
|---|---|---|---|
| ctx | Yes | Ctx | Context object. |
| permissions | Yes | Array<Permission> | Updated array of permission objects. |