How to use @bentley/imodeljs-common - 10 common examples

To help you get started, we’ve selected a few @bentley/imodeljs-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github imodeljs / imodeljs / integration-tests / rpc / src / backend / http.ts View on Github external
async function init() {
  const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "rpc-integration-test", version: "v1.0" } }, rpcInterfaces);

  // create a basic express web server
  const port = Number(process.env.CERTA_PORT || 3021) + 2000;
  const server = new IModelJsExpressServer(rpcConfig.protocol);
  await server.initialize(port);
  // tslint:disable-next-line:no-console
  console.log("Web backend for integration-tests listening on port " + port);
}
github imodeljs / imodeljs / test-apps / perf-test-app / src / backend / backend.ts View on Github external
async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
  } else {
    const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);

    // create a basic express web server
    const port = Number(process.env.CERTA_PORT || 3011) + 2000;
    const server = new IModelJsExpressServer(rpcConfig.protocol);
    await server.initialize(port);
    // tslint:disable-next-line:no-console
    console.log("Web backend for perf-tests listening on port " + port);
  }
}
github imodeljs / imodeljs / integration-tests / core / src / backend / backend.ts View on Github external
async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
  } else {
    const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);

    // create a basic express web server
    const port = Number(process.env.CERTA_PORT || 3011) + 2000;
    const server = new IModelJsExpressServer(rpcConfig.protocol);
    await server.initialize(port);
    // tslint:disable-next-line:no-console
    console.log("Web backend for integration-tests listening on port " + port);
  }
}
github imodeljs / imodeljs / test-apps / perf-test-app / src / backend / backend.ts View on Github external
async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
  } else {
    const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "perf-tests", version: "v1.0" } }, rpcInterfaces);

    // create a basic express web server
    const port = Number(process.env.CERTA_PORT || 3011) + 2000;
    const server = new IModelJsExpressServer(rpcConfig.protocol);
    await server.initialize(port);
    // tslint:disable-next-line:no-console
    console.log("Web backend for perf-tests listening on port " + port);
  }
}
github imodeljs / imodeljs / integration-tests / core / src / backend / backend.ts View on Github external
async function init() {
  if (ElectronRpcConfiguration.isElectron) {
    ElectronRpcManager.initializeImpl({}, rpcInterfaces);
  } else {
    const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "integration-test", version: "v1.0" } }, rpcInterfaces);

    // create a basic express web server
    const port = Number(process.env.CERTA_PORT || 3011) + 2000;
    const server = new IModelJsExpressServer(rpcConfig.protocol);
    await server.initialize(port);
    // tslint:disable-next-line:no-console
    console.log("Web backend for integration-tests listening on port " + port);
  }
}
github imodeljs / imodeljs / test-apps / display-performance-test-app / src / backend / WebMain.ts View on Github external
if (arg.split(".").pop() === "json")
    DisplayPerfRpcInterface.jsonFilePath = arg;
  else if (arg === "chrome" || arg === "edge" || arg === "firefox")
    browser = arg;
});

if (serverConfig === undefined) {
  setupStandaloneConfiguration();

  serverConfig = { port: 3001, baseUrl: "https://localhost" };
} else {

}

// Set up the ability to serve the supported rpcInterfaces via web requests
const cloudConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "display-performance-test-app", version: "v1.0" } }, getRpcInterfaces());

const app = express();
app.use(bodyParser.text({ limit: "50mb" }));

// Enable CORS for all apis
app.all("/*", (_req, res, next) => {
  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Methods", "POST, GET");
  res.header("Access-Control-Allow-Headers", "Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With, X-Correlation-Id, X-Session-Id, X-Application-Id, X-Application-Version, X-User-Id");
  next();
});

// --------------------------------------------
// Routes
// --------------------------------------------
app.use(express.static(path.resolve(__dirname, "public")));
github imodeljs / imodeljs / test-apps / ui-test-app / src / backend / web / BackendServer.ts View on Github external
export default async function initialize(rpcs: RpcInterfaceDefinition[]) {
  // tell BentleyCloudRpcManager which RPC interfaces to handle
  const rpcConfig = BentleyCloudRpcManager.initializeImpl({ info: { title: "ui-test-app", version: "v1.0" } }, rpcs);

  // create a basic express web server
  const port = Number(process.env.PORT || 3001);
  const server = new IModelJsExpressServer(rpcConfig.protocol);
  await server.initialize(port);
  console.log("Web backend for ui-test-app listening on port " + port);
}
github imodeljs / imodeljs / test-apps / synchro-schedule-importer / src / SynchroScheduleImporter.ts View on Github external
iModel.views.iterateViews({ from: "BisCore.SpatialViewDefinition" }, (view: ViewDefinition) => {
    if (!view.isSpatialView())
      return true;

    // Create a new display style.
    const vf = new ViewFlags();
    vf.renderMode = RenderMode.SmoothShade;
    vf.cameraLights = true;
    const bgColor = new ColorDef("rgb(127, 127, 127)");

    const displayStyleId = DisplayStyle3d.insert(iModel, view.model, "Schedule View Style", { viewFlags: vf, backgroundColor: bgColor, scheduleScript: script });
    iModel.views.setDefaultViewId(SpatialViewDefinition.insertWithCamera(iModel, view.model, "Schedule View", view.modelSelectorId, view.categorySelectorId, displayStyleId, iModel.projectExtents, StandardViewIndex.Iso));
    return true;
  });
  return true;
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / imodelindex / ViewsList.tsx View on Github external
public async queryViewProps(imodel: IModelConnection, refresh?: boolean): Promise {
    if (!this._viewDefCache || refresh) {
      const params: ViewQueryParams = {};
      params.from = ViewState.classFullName; // use "BisCore.ViewDefinition" as default class name
      params.where = "";
      const viewProps = await IModelReadRpcInterface.getClient().queryElementProps(imodel.iModelToken.toJSON(), params);
      this._viewDefCache = viewProps as ViewDefinitionProps[];
    }

    return this._viewDefCache;
  }
github imodeljs / imodeljs / test-apps / display-test-app / src / frontend / VersionComparison.ts View on Github external
private initOverrides(): FeatureSymbology.Overrides {
    const ovrs = new FeatureSymbology.Overrides(this.viewport);
    ovrs.neverDrawn.clear();
    ovrs.alwaysDrawn.clear();
    ovrs.setAlwaysDrawnSet(this.changedElems.deleted, true, false); // really "only-drawn" - only draw our deleted elements - unless their subcategory is turned off.

    const red = ColorDef.from(0xff, 0, 0, changedTransparency);
    ovrs.setDefaultOverrides(FeatureSymbology.Appearance.fromRgba(red));

    return ovrs;
  }