### Example Configuration JSON Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-performance-test-app/README.md This JSON configuration file allows for detailed setup of performance tests, including output paths, model locations, view settings, and specific test parameters for different iModels and views. ```json { "outputName": "performanceResults.csv", "outputPath": "D:/output/performanceData/", "iModelLocation": "D:/models/TimingTests/", "view": { "width": 1000, "height": 1000 }, "numRendersToSkip": 50, "numRendersToTime": 100, "filenameOptsToIgnore": "+inst +solShd +vsE +cullActVol", "minimize": true, "csvFormat": "original", "useDisjointTimer": true, "testSet": [ { "iModelName": "Wraith.ibim", "outputName": "wraithPerformanceResults.csv", "tests": [ { "testType": "timing", "viewName": "V0", "renderOptions": { "disabledExtensions": ["WEBGL_draw_buffers", "OES_texture_half_float"], "displaySolarShadows": true }, "tileProps": { "disableMagnification": false, "elideEmptyChildContentRequests": false, "enableInstancing": true, "maxActiveRequests": 15, "retryInterval": 5 }, "viewFlags": { "renderMode": "SmoothShade", "dimensions": true, "patterns": true, "weights": true, "styles": true, "transparency": true, "fill": true, "textures": true, "materials": true, "visibleEdges": false, "hiddenEdges": false, "sourceLights": false, "cameraLights": false, "solarLight": false, "shadows": false, "clipVolume": true, "constructions": false, "monochrome": false, "noGeometryMap": false, "backgroundMap": false, "hLineMaterialColors": false, "edgeMask": 0, "ambientOcclusion": false, "forceSurfaceDiscard": false }, "displayStyle": "Filled Hidden Line" }, { "testType": "timing", "viewName": "V0", "viewFlags": { "fill": true }, "displayStyle": "Filled Hidden Line" } ] }, { "iModelName": "Wraith_MultiMulti.ibim", "outputPath": "D:/output/TimingTests/Wrath_MultiMultiPics", "signIn": true, "view": { "width": 500, "height": 500 }, "testType": "image", "tests": [ { "viewName": "V0", "displayStyle": "Smooth" }, { "viewName": "V0", "viewFlags": { "renderMode": "Wireframe" } }, { ``` -------------------------------- ### Install Dependencies Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/tutorials/develop-web-viewer.md After scaffolding the application, navigate to the project directory and install all necessary dependencies using npm. ```bash npm install ``` -------------------------------- ### Start display-test-app in Browser Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-test-app/README.md Use this command to start the application's development servers. You can then access the application by navigating to localhost:3000 in a supported browser. ```cmd npm run start:servers ``` -------------------------------- ### WorkspaceEditor Command Example Source: https://github.com/itwin/itwinjs-core/blob/master/utils/workspace-editor/README.md Example of using WorkspaceEditor with a configuration file to list a database. ```sh > WorkspaceEditor --config myConfig.json listDb db1 ``` -------------------------------- ### Start Webserver for display-test-app Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-test-app/README.md Launches the Vite dev server for hot-module reloading of the frontend. Use `start:mobile` for Android and iOS. ```cmd npm run start:webserver ``` ```cmd npm run start:mobile ``` -------------------------------- ### Start display-test-app in Electron Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-test-app/README.md Use this command to start the application in an Electron environment. Ensure you have navigated to the root of the display-test-app directory. ```cmd npm run start ``` -------------------------------- ### Install Connector Packages Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/WriteAConnector.md Installs the required iTwin connector and development packages using npm. ```Shell $npm install @itwin/ecschema-metadata $npm install @itwin/core-geometry $npm install @itwin/connector-framework $npm install @itwin/core-backend $npm install @itwin/core-common $npm install @itwin/core-bentley $npm install @itwin/imodels-access-backend $npm install @itwin/imodels-client-authoring $npm install --save-dev @itwin/build-tools $npm install --save-dev @itwin/oidc-signin-tool ``` -------------------------------- ### Install Dependencies with Rush Source: https://github.com/itwin/itwinjs-core/blob/master/CONTRIBUTING.md Installs all project dependencies for the monorepo. This should be the first step after cloning the repository. ```bash rush install ``` -------------------------------- ### Start Performance Test Backend for Web Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-performance-test-app/README.md Run this command to start the backend server for web-based performance tests. Access the test in a browser at http://localhost:3000. ```bash npm run start:web ``` -------------------------------- ### Add Trees to WorkspaceDb Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/backend/Workspace.md This example shows how to create a new version of a WorkspaceDb, open it for writing, add resources (tree species), and save the changes. It illustrates versioning starting from 0.0.0 and publishing version 1.1.0. ```typescript async function addTrees(container: WorkspaceContainer): Promise { const treeDb = container.createWorkspaceDb("cornus"); const treeVersion = treeDb.createVersion("1.1.0"); const treeEditor = await treeVersion.openEditor(); await treeEditor.addResource({ name: "Cornus florida", description: "Flowering Dogwood", model: { type: "gltf", uri: "uri/to/cornus_florida.gltf" } }); await treeEditor.addResource({ name: "Cornus kousa", description: "Kousa Dogwood", model: { type: "gltf", uri: "uri/to/cornus_kousa.gltf" } }); await treeEditor.saveChanges(); await treeVersion.publish(); } ``` -------------------------------- ### Complete ChangesetReader Worked Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/backend/ChangesetReader.md A comprehensive example showing how to import a custom schema, insert an element, push an update, and then read changesets individually and as a group. ```typescript [[include:ChangesetReader.WorkedExample]] ``` -------------------------------- ### Install Dependencies with Rush Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-test-app/README.md Performs a clean installation of all dependencies managed by Rush. This is often necessary after pulling the latest repository version to avoid build errors. ```cmd rush install -c ``` -------------------------------- ### WorkspaceEditor Configuration File Example Source: https://github.com/itwin/itwinjs-core/blob/master/utils/workspace-editor/README.md Example JSON configuration file for WorkspaceEditor, specifying container and access details. ```json { "containerId": "5d385232-a2ec-4f31-b74b-8201c027848d", "accessName": "smsblob1", "storageType": "azure?sas=1", "user": "workspace editor example", "accessToken": "" } ``` -------------------------------- ### KaTex Macro Definition Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/guidelines/markdown-intro.md Provides an example of defining a KaTex macro within a JSON configuration. ```json "\\rowXYZ": "{\\begin{bmatrix} #1 & #2 & #3\\end{bmatrix}}" ``` -------------------------------- ### Get Guid Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Retrieves the GUID for a given row ID. ```APIDOC ## getGuid ### Description Retrieves the GUID associated with a row ID. ### Method (Not specified, likely a synchronous method call) ### Parameters - **rowid** (RowId) - Required - The row ID for which to retrieve the GUID. ``` -------------------------------- ### Preview Production Build Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/tutorials/develop-web-viewer.md Start a local server to preview the production build. This is useful for testing the deployed version before actual deployment. ```bash npm run preview ``` -------------------------------- ### Get Guid Map Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Accessor for the GuidMapper associated with the iModel. This is a property getter. ```APIDOC ## guidMap ### Description Accessor for the GuidMapper associated with the iModel. ### Method Getter ### Response #### Success Response - **IModelDb.GuidMapper** - The GuidMapper instance. ``` -------------------------------- ### Example MutableFormatsProvider implementation Source: https://github.com/itwin/itwinjs-core/blob/master/docs/quantity-formatting/usage/Providers.md Provides an example implementation of MutableFormatsProvider. This allows for dynamic management of formats, including adding custom formats or overriding existing ones at runtime. ```typescript class MyMutableFormatsProvider extends MutableFormatsProvider { // Custom implementation details } const myProvider = new MyMutableFormatsProvider(); // Add custom formats or override existing ones here ``` -------------------------------- ### ECSchemaRpcInterface Client Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/ecschema-rpc-interface.api.md Static method to get the client for the ECSchemaRpcInterface. No setup is required. ```typescript static getClient(): ECSchemaRpcInterface; ``` -------------------------------- ### Binding Guid ECProperty with String Representation Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/1.1.0.md When binding a Guid ECProperty to an ECSql parameter, either the Uint8Array or string representation can be supplied. This example shows binding using the string representation. ```typescript for await (const row of conn.query("SELECT FederationGuid FROM bis.Element WHERE FederationGuid = ?", ["xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"])) { // ... } ``` -------------------------------- ### Get Electron App Instance Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-electron.api.md Accesses the Electron App instance. This property is available after the application has started. ```typescript const app = ElectronHost.app; ``` -------------------------------- ### IpcHost.startup Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Starts up the IPC host with optional configuration. ```APIDOC ## IpcHost.startup ### Description Starts up the IPC host with optional configuration. ### Method `static startup(opt?: IpcHostOpts): Promise` ### Parameters - **opt** (IpcHostOpts, optional) - Options for configuring the IPC host. ### Returns - **Promise** - A promise that resolves when the startup is complete. ``` -------------------------------- ### Startup LocalhostIpcHost Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Starts up the LocalhostIpcHost with optional configuration. ```typescript static startup(opts?: { localhostIpcHost?: LocalhostIpcHostOpts; iModelHost?: IModelHostOptions; }): Promise; ``` -------------------------------- ### ViewToggleCameraTool Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-frontend.api.md A tool for toggling camera views. It inherits from ViewTool and provides methods for installation and post-installation setup. ```APIDOC ## ViewToggleCameraTool ### Description A tool for toggling camera views. It inherits from ViewTool and provides methods for installation and post-installation setup. ### Class ViewToggleCameraTool ### Methods - **onInstall()**: Promise - Called when the tool is installed. - **onPostInstall()**: Promise - Called after the tool has been installed. ### Static Properties - **iconSpec**: string - **toolId**: string ``` -------------------------------- ### Get Electron IpcMain Instance Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-electron.api.md Accesses the IpcMain instance for handling inter-process communication. This is available after the host has started. ```typescript const ipcMain = ElectronHost.ipcMain; ``` -------------------------------- ### Get FormatProps Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/quantity-formatting/usage/ParsingAndFormatting.md This TypeScript code demonstrates how to retrieve format properties for a given KindOfQuantity, providing a fallback if none is found. ```typescript [[include:Quantity_Formatting.General_Pattern_Get_FormatProps]] ``` -------------------------------- ### Start Development Server Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/tutorials/develop-web-viewer.md Run the development server to serve the application with live reloading. This command is used during development to see changes instantly. ```bash npm start ``` -------------------------------- ### ECSQL COUNT with GROUP BY Source: https://github.com/itwin/itwinjs-core/blob/master/core/backend/src/test/ecsql/queries/GroupByClause.ecsql.md Use COUNT(*) to get the total number of rows for each group. This example counts elements grouped by the NullProp property. ```sql SELECT NullProp, count(*) as Total_Count FROM aps.TestElement GROUP BY NullProp ``` -------------------------------- ### Run Performance Test with All Options Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-performance-test-app/README.md Example command demonstrating the use of multiple options for a performance test run, including specifying a config file and an output path. ```bash npm run start:web chrome D:\\develop\\testConfig.json D:\\performanceOutput\\ ``` -------------------------------- ### Querying FederationGuid as String Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/1.1.0.md When querying a Guid ECProperty, the result is now returned as a string. This example demonstrates how to iterate over query results and access the FederationGuid property. ```typescript for await (const row of conn.query("SELECT FederationGuid FROM bis.Element WHERE FederationGuid IS NOT NULL")) { // Expect row.federationGuid to be a string of the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" } ``` -------------------------------- ### Certa Configuration File Example Source: https://github.com/itwin/itwinjs-core/blob/master/tools/certa/README.md Configure Certa settings, including test bundle paths, instrumented bundle paths, debugging ports, and Mocha options, using a `certa.json` file. Comments are supported. ```json { // Comments are allowed here! "testBundle": "./lib/bundled-tests.js", "instrumentedTestBundle": "./lib/bundled-tests.instrumented.js", "ports": { "debugging": 5858, "frontendDebugging": 9223 }, "mochaOptions": { "timeout": 2000 } } ``` -------------------------------- ### Execute ECSQL Query and Get Values Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/backend/ECSQLCodeExamples.md This example shows how to execute an ECSQL query and retrieve values from the results. It demonstrates a verbose approach to illustrate API semantics. ```typescript const query = "SELECT ECInstanceId, ClassName, Parent.Id, Parent.RelClassName, LastMod FROM StructuralPhysical.Slab WHERE ECInstanceId = 0x312"; const rows = await iModel.query(query); const row = rows[0]; const id = row.id; const className = row.className; const parentId = row.parentId; const parentRelClassName = row.parentRelClassName; const lastMod = row.lastMod; ``` -------------------------------- ### Convert to Format and Get Persistence Unit Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/quantity-formatting/usage/ParsingAndFormatting.md This TypeScript code shows how to convert retrieved format properties into a Format object and obtain the persistence unit using the UnitsProvider. ```typescript [[include:Quantity_Formatting.General_Pattern_Convert_To_Format]] ``` -------------------------------- ### Opt-out Filtering Strategy Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/common/Logging.md This approach is mainly useful when you are just trying to find out what is happening. It starts by turning all categories on at a certain level by default and then setting the levels of specific categories to other levels. ```typescript Logger.initializeToConsole(); Logger.setLevelDefault(LogLevel.Error); Logger.setLevel("Diagnostics", LogLevel.None); ``` -------------------------------- ### SetupWalkCameraTool Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-frontend.api.md A tool for setting up a walk-through camera in the frontend view. It handles view decoration and user input events. ```APIDOC ## Class: SetupWalkCameraTool ### Description Manages the setup of a walk-through camera, allowing users to navigate through the scene. ### Methods - **decorate(context: DecorateContext): void** Decorates the viewport with camera-related elements. - **decorateSuspended(context: DecorateContext): void** Decorates the viewport when the tool is suspended. - **static drawFigure(context: DecorateContext, vp: Viewport, groundPt: Point3d, eyeHeight: number): void** Draws a figure representing the camera's position and height. - **getAdjustedEyePoint(): Point3d** Retrieves the adjusted eye point for the camera. - **getAdjustedTargetPoint(): Point3d** Retrieves the adjusted target point for the camera. - **isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean** Determines if the current viewport is compatible with this tool. - **isValidLocation(_ev: BeButtonEvent, _isButtonEvent: boolean): boolean** Checks if the current pointer location is valid for interaction. - **onDataButtonDown(ev: BeButtonEvent): Promise** Handles the event when the data button is pressed. - **onMouseMotion(ev: BeButtonEvent): Promise** Handles mouse motion events while the tool is active. - **onPostInstall(): Promise** Executes logic after the tool has been installed. - **onResetButtonUp(_ev: BeButtonEvent): Promise** Handles the event when the reset button is released. - **onRestartTool(): Promise** Restarts the tool's operation. - **onUnsuspend(): Promise** Resumes the tool's operation after suspension. - **provideToolAssistance(): void** Offers assistance and guidance to the user. - **requireWriteableTarget(): boolean** Specifies whether a writeable target is necessary for this tool. - **setupAndPromptForNextAction(): void** Configures the tool and prompts the user for the next step. ### Properties - **viewport (ScreenViewport)**: The current viewport associated with the tool. ### Static Properties - **iconSpec (string)**: The icon specification for the tool. - **toolId (string)**: The unique identifier for the tool. ``` -------------------------------- ### SetupCameraTool Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-frontend.api.md Provides functionality for setting up and manipulating the camera in the frontend view. It includes methods for applying property changes, decorating the view, and handling user input. ```APIDOC ## Class: SetupCameraTool ### Description Manages camera setup and manipulation within the frontend view. Allows users to adjust camera properties and interact with the view. ### Methods - **applyToolSettingPropertyChange(updatedValue: DialogPropertySyncItem): Promise** Applies changes to tool setting properties. - **decorate(context: DecorateContext): void** Decorates the viewport. - **decorateSuspended(context: DecorateContext): void** Decorates the viewport when the tool is suspended. - **static drawCameraFrustum(context: DecorateContext, vp: ScreenViewport, eyePtWorld: Point3d, targetPtWorld: Point3d, eyeSnapPtWorld?: Point3d, targetSnapPtWorld?: Point3d): void** Draws the camera frustum in the specified viewport. - **getAdjustedEyePoint(): Point3d** Gets the adjusted eye point of the camera. - **getAdjustedTargetPoint(): Point3d** Gets the adjusted target point of the camera. - **getToolSettingLockProperty(property: DialogProperty): DialogProperty | undefined** Gets the lock property for a given tool setting. - **isCompatibleViewport(vp: Viewport | undefined, isSelectedViewChange: boolean): boolean** Checks if the current viewport is compatible with the tool. - **isValidLocation(_ev: BeButtonEvent, _isButtonEvent: boolean): boolean** Validates the current pointer location. - **onDataButtonDown(ev: BeButtonEvent): Promise** Handles data button down events. - **onMouseMotion(ev: BeButtonEvent): Promise** Handles mouse motion events. - **onPostInstall(): Promise** Called after the tool is installed. - **onResetButtonUp(_ev: BeButtonEvent): Promise** Handles reset button up events. - **onRestartTool(): Promise** Restarts the tool. - **onUnsuspend(): Promise** Called when the tool is unsuspended. - **provideToolAssistance(): void** Provides tool assistance information. - **requireWriteableTarget(): boolean** Indicates if a writeable target is required. - **setupAndPromptForNextAction(): void** Sets up and prompts for the next action. - **supplyToolSettingsProperties(): DialogItem[] | undefined** Supplies the properties for the tool settings dialog. ### Properties - **cameraHeight (number)**: Gets or sets the camera height. - **cameraHeightProperty (DialogProperty)**: Gets the dialog property for camera height. - **useCameraHeight (boolean)**: Gets or sets whether to use camera height. - **useCameraHeightProperty (DialogProperty)**: Gets the dialog property for using camera height. - **useTargetHeight (boolean)**: Gets or sets whether to use target height. - **useTargetHeightProperty (DialogProperty)**: Gets the dialog property for using target height. - **targetHeight (number)**: Gets or sets the target height. - **targetHeightProperty (DialogProperty)**: Gets the dialog property for target height. - **viewport (ScreenViewport)**: The current viewport. ### Static Properties - **iconSpec (string)**: The icon specification for the tool. - **toolId (string)**: The unique identifier for the tool. ``` -------------------------------- ### Limit Rows with Offset in ECSql Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSqlReference/LIMIT.md Use the LIMIT clause with an OFFSET to retrieve a specific range of rows. This example returns 10 rows starting from the 11th row (offset 10). ```sql -- return only 10 rows from offset 10 SELECT 1 FROM meta.ECClassDef LIMIT 10 OFFSET 10 ``` -------------------------------- ### Format Ratio Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/4.10.0.md Demonstrates how to format a ratio using the FormatProps and Format classes. Ensure a UnitsProvider is registered and initialized before use. ```typescript const ratioFormatProps: FormatProps = { type: "Ratio", ratioType: "OneToN", // Formats the ratio in "1:N" form composite: { includeZero: true, units: [ { name: "Units.HORIZONTAL_PER_VERTICAL" }, ], }, }; const ratioFormat = new Format("Ratio"); ratioFormat.fromJSON(unitsProvider, ratioFormatProps).catch(() => {}); ``` -------------------------------- ### ECSQL LIKE with Underscore Wildcard Source: https://github.com/itwin/itwinjs-core/blob/master/core/backend/src/test/ecsql/queries/Misc.ecsql.md Use the underscore wildcard (_) to match any single character in a string pattern. This example selects elements where DirectStr starts with 'str' followed by any single character. ```sql SELECT ECInstanceId, DirectStr FROM aps.TestElement where DirectStr LIKE 'str_' LIMIT 10 OFFSET 5 ``` -------------------------------- ### Get Related Instance Label with ECExpression Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/4.9.0.md Example of using the new GetRelatedDisplayLabel ECExpression function to retrieve the label of a related instance. This is useful for displaying information about related elements in calculated properties. ```json { "label": "My Calculated Property", "value": "this.GetRelatedDisplayLabel(\"BisCore:ModelContainsElements\", \"Backward\", \"BisCore:Model\")" } ``` -------------------------------- ### create Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-frontend.api.md Asynchronously creates an instance of TileAdmin, initializing its properties and preparing it for use. ```APIDOC ## create ### Description Asynchronously creates and initializes a new TileAdmin instance. This is the primary way to obtain a TileAdmin object. ### Method static create ### Parameters * **props** (TileAdmin.Props | undefined) - Optional properties to configure the TileAdmin instance. ### Returns * **Promise** - A Promise that resolves with the created TileAdmin instance. ``` -------------------------------- ### setupFromFrustum Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-frontend.api.md Configures the view based on a given frustum. This allows for precise control over the camera's viewing volume. ```APIDOC ## setupFromFrustum ### Description Configures the view based on a given frustum. This allows for precise control over the camera's viewing volume. ### Method ViewStatus ### Parameters - **inFrustum**: Frustum - The frustum defining the view volume. - **opts**: OnViewExtentsError - Optional. Options for handling view extent errors. ``` -------------------------------- ### IModelHost Startup and Shutdown Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Handles the initialization and termination of the iModel host. Startup requires optional configuration, while shutdown is a void Promise. ```typescript static startup(options?: IModelHostOptions): Promise; ``` ```typescript static shutdown(this: void): Promise; ``` -------------------------------- ### Prefer Getters for Parameterless Methods Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/guidelines/typescript-coding-guidelines.md Use the 'get' modifier for public methods that take no parameters and start with 'is', 'has', or 'want'. This allows them to be accessed as properties, preventing confusion with function calls and ensuring compile-time errors if parentheses are mistakenly used. ```typescript class Example { get isReady(): boolean { return this._isReady; } } ``` -------------------------------- ### GuidToStr: Convert binary GUID to string Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSqlReference/ECSqlFunctions.md Convert a binary GUID to its string representation for comparison with GUID strings. ```sql SELECT * FROM [BisCore].[Element] WHERE GuidToStr(FederationGuid) = '407bfa18-944d-11ee-b9d1-0242ac120002' ``` -------------------------------- ### Configure Logging and Streams Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/common/Logging.md This example demonstrates how to initialize and configure logging for a service using LoggerLevelsConfig. It should be called during the service's startup logic. ```typescript import { LoggerLevelsConfig } from "@bentley/core-bentley"; async function configureLoggingAndStreams() { const config = await LoggerLevelsConfig.readLoggingConfiguration(); Logger.initialize(config); } configureLoggingAndStreams(); ``` -------------------------------- ### Startup Electron App Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-electron.api.md Initializes the Electron application. Use this to start the application with custom options. ```typescript import { ElectronApp } from "@itwin/core-electron"; await ElectronApp.startup(); ``` -------------------------------- ### StrToGuid: Convert string to binary GUID Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSqlReference/ECSqlFunctions.md Convert a GUID string to its binary representation for comparison with binary GUIDs stored in the database. ```sql SELECT * FROM [BisCore].[Element] WHERE FederationGuid = StrToGuid('407bfa18-944d-11ee-b9d1-0242ac120002') ``` -------------------------------- ### Running the Agent Application Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/tutorials/develop-agent.md Start the agent application. It will listen for changesets pushed to iModelHub. You can also run it against a specific changeset using command-line arguments. ```bash npm start ``` ```bash npm start -- --latest ``` ```bash npm start -- --changeset= ``` -------------------------------- ### Install ecschema2ts Globally Source: https://github.com/itwin/itwinjs-core/blob/master/tools/ecschema2ts/README.md Installs the ecschema2ts command-line tool globally using npm. This command is used for both initial installation and updates. ```sh npm install -g @itwin/ecschema2ts ``` -------------------------------- ### Code GUID State JSON Structure Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Represents the JSON structure for storing the state of a Code GUID, including the GUID itself and optional JSON data or state. ```typescript export interface CodeGuidStateJson { readonly guid: CodeGuid; readonly json?: SettingsContainer; readonly state?: CodeState; } ``` -------------------------------- ### KaTex Macro Usage Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/guidelines/markdown-intro.md Shows how to use a previously defined KaTex macro in Markdown. ```md \\rowXYZ{x}{y}{z} ``` -------------------------------- ### strToGuid() Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSqlReference/ECSqlFunctions.md Converts a string representation of a GUID to its binary GUID format. ```APIDOC ## strToGuid( _guid-string_ ) ### Description Converts a string GUID to a binary GUID. ### Parameters `guid-string`: The string representation of the GUID (e.g., '123e4567-e89b-12d3-a456-426614174000'). ### Returns Binary representation of the GUID. ### Example ```sql SELECT strToGuid('123e4567-e89b-12d3-a456-426614174000') AS BinaryGuid; ``` ``` -------------------------------- ### Initialize TileAdmin with Beta Props Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/2.14.0.md When initializing TileAdmin, pass the props directly to IModelApp.startup as the create method is now async and the property type has changed. ```typescript IModelApp.startup({ tileAdmin: props }); ``` -------------------------------- ### ECSQL Statement Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSQLCodeExamples.md This is an example of an ECSQL statement that can be provided to query an iModel. ```sql SELECT ECInstanceId, ECClassId FROM BisCore.Element ``` -------------------------------- ### Get or Create Continuous Style Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Gets or creates a continuous style. This is a beta feature. ```typescript static getOrCreateContinuousStyle(imodel: IModelDb, scopeModelId: Id64String, width?: number, txn?: EditTxn): Id64String; ``` -------------------------------- ### Build Backend for display-test-app Source: https://github.com/itwin/itwinjs-core/blob/master/test-apps/display-test-app/README.md Builds the backend of the display-test-app. Use the `--watch` flag for continuous compilation during development. ```cmd npm run build:backend ``` ```cmd npm run build:backend -- --watch ``` -------------------------------- ### StrToGuid Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/ECSqlReference/ECSqlFunctions.md Converts a GUID string into a binary format for comparison purposes when GUIDs are stored as binary. ```APIDOC ## StrToGuid( _guid-string_ ) When `GUID` is stored as a binary, it needs to be converted for comparison purposes. ### Example ```sql SELECT * FROM [BisCore].[Element] WHERE FederationGuid = StrToGuid('407bfa18-944d-11ee-b9d1-0242ac120002') ``` ``` -------------------------------- ### Initialize Electron Backend Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/2.12.0.md Initialize the Electron backend for desktop applications using the `ElectronBackend.initialize` method, passing the `rpcInterfaces`. ```typescript import { ElectronBackend } from "@itwin/core-electron/lib/ElectronBackend"; ElectronBackend.initialize({ rpcInterfaces }); ``` -------------------------------- ### KaTex Equation Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/guidelines/markdown-intro.md Demonstrates how to render a mathematical equation using KaTex syntax within a 'equation' code block. ```equation f(x) = \int_{-\infty}^\infty \hat f(\xi)\,e^{2 \pi i \xi x} \,d\xi ``` -------------------------------- ### Initialize Electron Frontend Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/2.12.0.md Initialize the Electron frontend for desktop applications using the `ElectronFrontend.initialize` method, passing the `rpcInterfaces`. ```typescript import { ElectronFrontend } from "@itwin/core-electron/lib/ElectronFrontend"; ElectronFrontend.initialize({ rpcInterfaces }); ``` -------------------------------- ### Iterate Guids Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Iterates over GUIDs associated with row IDs, applying a function to each. This method is marked as internal. ```APIDOC ## iterateGuids ### Description Iterates over GUIDs associated with row IDs, applying a function to each. This method is marked as internal. ### Method (Implicitly a method call, not HTTP) ### Parameters - **rowIds** (Array) - Required - An array of row IDs. - **fn** (function) - Required - A function to apply to each GUID and row ID. It takes `(guid: GuidString, row: RowId)` as arguments. ``` -------------------------------- ### Build for Deployment Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/tutorials/develop-web-viewer.md Generate a production-ready build of the application. The output will be placed in the 'dist' folder. ```bash npm run build ``` -------------------------------- ### Ratio Format Examples Table Source: https://github.com/itwin/itwinjs-core/blob/master/docs/quantity-formatting/definitions/Formats.md Illustrates various ratio format configurations and their resulting formatted outputs, including NToOne, ValueBased, and UseGreatestCommonDivisor types with different precisions and separators. ```text ratioType | ratioFormatType | precision | magnitude | separator | composite.units | Formatted Result ----------|-----------------|-----------|-----------|-----------|-----------------|----------------- NToOne | Decimal | 2 | 1.0 | ":" | - | 1:1 NToOne | Decimal | 2 | 0.5 | ":" | - | 0.5:1 OneToN | Decimal | 0 | 0.01 | ":" | - | 1:100 ValueBased | Decimal | 3 | 2.0 | ":" | - | 2:1 ValueBased | Decimal | 3 | 0.5 | ":" | - | 1:2 UseGreatestCommonDivisor | Decimal | 3 | 0.5 | ":" | - | 1:2 NToOne | Decimal | 2 | 12.0 | "=" | [IN, FT] * | 12"=1' NToOne | Decimal | 2 | 1.0 | "=" | [IN, FT] * | 1"=1' NToOne | Fractional | 16 | 1.5 | "=" | [IN, FT] * | 1 1/2"=1' NToOne | Fractional | 16 | 0.75 | "=" | [IN, FT] * | 3/4"=1' ``` -------------------------------- ### Get or Create Line Pixels Style Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-backend.api.md Gets or creates a line pixels style. This is a beta feature. ```typescript static getOrCreateLinePixelsStyle(imodel: IModelDb, scopeModelId: Id64String, linePixels: LinePixels, txn?: EditTxn): Id64String; ``` -------------------------------- ### Simple Formatting with SchemaFormatsProvider Source: https://github.com/itwin/itwinjs-core/blob/master/docs/quantity-formatting/usage/Providers.md Demonstrates basic formatting using SchemaFormatsProvider. This snippet shows how to initialize and use the provider for simple formatting tasks. ```typescript const schemaContext = new SchemaContext(); const schemaFormatsProvider = new SchemaFormatsProvider(schemaContext); const formatSpec = schemaFormatsProvider.getFormat("MySchema.MyKindOfQuantity"); const formattedValue = formatSpec.format(100); console.log(formattedValue); ``` -------------------------------- ### Guid Namespace Source: https://github.com/itwin/itwinjs-core/blob/master/common/api/core-bentley.api.md Provides utility functions for working with GUIDs (Globally Unique Identifiers), including creating, validating, and normalizing them. ```APIDOC export namespace Guid { const empty: GuidString; export function createValue(): GuidString; export function isGuid(value: string): boolean; export function isV4Guid(value: string): boolean; export function normalize(value: GuidString): GuidString; } ``` -------------------------------- ### Initialize IModelHost Startup Source: https://github.com/itwin/itwinjs-core/blob/master/docs/learning/backend/IModelHost.md This snippet demonstrates the basic initialization of IModelHost.startup, which is a prerequisite for using any backend services in iTwin.js. It should typically be called indirectly via a specialized host. ```typescript await IModelHost.startup(); ``` -------------------------------- ### ECPrimitiveArrayProperty JSON Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/bis/ec/ec-property.md Example of an ECPrimitiveArrayProperty in JSON format. Details name, type, type name, and occurrence constraints. ```json { "name": "PropertyNames", "type": "PrimitiveArrayProperty", "typeName": "string", "minOccurs": 0, "maxOccurs": 2147483647 } ``` -------------------------------- ### Initialize Presentation Backend Source: https://github.com/itwin/itwinjs-core/blob/master/docs/presentation/setup/index.md Initializes the Presentation backend. Ensure all necessary imports and properties are configured. ```typescript [[include:Presentation.Backend.Initialization.Imports]] [[include:Presentation.Backend.Initialization.Props]] [[include:Presentation.Backend.Initialization]] ``` -------------------------------- ### ECPrimitiveArrayProperty XML Example Source: https://github.com/itwin/itwinjs-core/blob/master/docs/bis/ec/ec-property.md Example of an ECPrimitiveArrayProperty defined in XML. Shows property name, type, and occurrence constraints (min/max). ```xml ``` -------------------------------- ### Initialize Cloud Container and Import Local WorkspaceDb Source: https://github.com/itwin/itwinjs-core/blob/master/utils/workspace-editor/README.md These commands initialize a cloud container and import a previously created local WorkspaceDb into it. The `initializeWorkspace` command prepares the cloud environment, and `importDb` transfers the local database. `queryDbs` verifies the import. ```sh > cat createCloud.txt # initialize container and import WorkspaceDb from previous step initializeWorkspace --noPrompt # don't prompt for yes/no importDb project proj112\proj # import WorkspaceDb from local directory into cloud container. queryDbs # so we can tell it worked ``` -------------------------------- ### Initialize Presentation Frontend Source: https://github.com/itwin/itwinjs-core/blob/master/docs/presentation/setup/index.md Initializes the Presentation frontend. Ensure all necessary imports are included. ```typescript [[include:Presentation.Frontend.Imports]] [[include:Presentation.Frontend.Initialization]] ``` -------------------------------- ### Opening BriefcaseDb with Schema Upgrade Options Source: https://github.com/itwin/itwinjs-core/blob/master/docs/changehistory/2.3.0.md Illustrates how to open a BriefcaseDb with specific upgrade options to handle domain schema upgrades. This ensures that the database schema is up-to-date. ```typescript const db = await BriefcaseDb.open({ ...options, upgradeOptions: { ... } }); ```