-
Notifications
You must be signed in to change notification settings - Fork 242
docs: Rewrite Settings and Workspaces documentation #9065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
de4596b
docs: fill Workspace.md documentation gaps (#1927)
hl662 f1848fa
Merge branch 'master' into nam/settings-workspace-docs
hl662 5d3fd02
Merge remote-tracking branch 'origin/master' into nam/settings-worksp…
hl662 735f169
Split Workspace.md into 3 focused docs: overview, Settings, and Works…
hl662 c6d9106
Merge remote-tracking branch 'origin/master' into nam/settings-worksp…
hl662 097cb41
docs: fix invalid Workspace resources link in WorkspacesAndSettings.md
hl662 f4e8a30
docs: fix Mermaid diagram syntax in workspace/settings learning docs
hl662 a017997
docs: fix Mermaid subgraph title clipping in WorkspacesAndSettings di…
hl662 07cea38
docs: shorten CloudSqlite subgraph title to fix header clipping
hl662 d2c3604
Merge remote-tracking branch 'origin/master' into nam/settings-worksp…
hl662 21fe6c9
restructure: separate settings and workspace docs into focused files
hl662 32a9f15
polish: address doc review feedback for clarity and consistency
hl662 751fd56
Merge remote-tracking branch 'origin' into nam/settings-workspace-docs
hl662 31d7e2a
Add missing SettingsDb extract snippets for Settings.md docs
hl662 6c64046
Fix invalid API hyperlinks in Settings.md
hl662 6956964
Merge origin/master into nam/settings-workspace-docs
hl662 10544e2
Replace SettingsDb with 'settings container' across learning docs
hl662 f06bada
Rename snippet IDs from SettingsDb.* to SettingsContainer.*
hl662 d37a5f2
Fix three inaccurate claims in Settings.md
hl662 73d6b15
Merge remote-tracking branch 'origin' into nam/settings-workspace-docs
hl662 af02b59
Address PR review comments and improve doc coherence
hl662 d542ac4
Fix doc-review findings: deprecated API refs, extract close(), scope …
hl662 d5702d8
Remove plan.md
hl662 1630f5e
changes
hl662 eed3a1c
Fix scope layering wording and add rush change file
hl662 fe910db
Merge origin/master into nam/settings-workspace-docs
hl662 f895423
Fix broken SettingsDb link in 5.8.0 changehistory
hl662 9caf7f4
Merge branch 'master' into nam/settings-workspace-docs
hl662 bd75208
Fix no-console lint error in WorkspaceExamples extract
hl662 8ac9e0d
Merge branch 'nam/settings-workspace-docs' of https://github.com/iTwi…
hl662 2a341d9
Merge remote-tracking branch 'origin/master' into nam/settings-worksp…
hl662 37247d0
Trim WorkspacesAndSettings.md per reviewer feedback
hl662 7b3e690
Add end-to-end tutorial for Settings and Workspaces
hl662 c0b91fb
Merge remote-tracking branch 'origin/master' into nam/settings-worksp…
hl662 93a235c
differentiate version pinning from floating settings reference
hl662 9b82690
Address PR review feedback: remove redundant sections, extract inline…
hl662 0da070a
Clarify settings container docs
hl662 d92fc82
Refine settings docs from review
hl662 6b17077
Apply final settings doc suggestion
hl662 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
common/changes/@itwin/core-backend/nam-settings-workspace-docs_2026-04-15-20-20.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "changes": [ | ||
| { | ||
| "comment": "Updated TSDoc for Settings and IModelDb to reference current EditTxn APIs instead of deprecated methods.", | ||
| "type": "none", | ||
| "packageName": "@itwin/core-backend" | ||
| } | ||
| ], | ||
| "packageName": "@itwin/core-backend", | ||
| "email": "50554904+hl662@users.noreply.github.com" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| # Workspaces and Settings | ||
|
|
||
| Every non-trivial iTwin.js application needs two things at run-time: **configuration** (which tools are available, what units to use, which data sources are active) and **resources** (binary assets like fonts, textures, and templates). iTwin.js provides two complementary systems to address these needs: | ||
|
ben-polinsky marked this conversation as resolved.
Outdated
|
||
|
|
||
| - **[Settings]($backend)** — a priority-ordered stack of key-value configuration pairs. Configuration flows from cloud-hosted settings containers into the active [Settings]($backend) runtime, where values can be read by name. | ||
| - **[Workspace resources](./Workspace.md)** — versioned binary assets stored in [WorkspaceDb]($backend) containers. Settings tell the application *which* `WorkspaceDb`s to load; the application then retrieves resources from them. | ||
|
|
||
| These two systems are deliberately separate. Settings containers are discoverable without opening an iModel. `WorkspaceDb` containers are referenced *by* settings. This separation eliminates the circular dependency that would arise if settings had to be loaded from a `WorkspaceDb` just to discover which `WorkspaceDb` to open. | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
|
|
||
| At runtime, settings and resources are accessed through one of three workspace scopes: | ||
|
|
||
| | Workspace | Scope | Access | | ||
| |---|---|---| | ||
| | [IModelHost.appWorkspace]($backend) | Application-wide defaults and configuration | Available immediately after [IModelHost.startup]($backend) | | ||
| | [IModelHost.getITwinWorkspace]($backend) | iTwin-scoped settings shared across all iModels in an iTwin | Requires an iTwinId; no iModel needed | | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
| | [IModelDb.workspace]($backend) | iModel-specific overrides; falls back to `appWorkspace` for unresolved settings. Does **not** automatically include iTwin-scoped settings | Available when an iModel is open | | ||
|
|
||
| `appWorkspace` and `IModelDb.workspace` share the same priority stack, so iModel-level settings automatically override application defaults. `getITwinWorkspace` is independent — its settings are only available to an iModel if explicitly referenced (see [Referencing iTwin settings from an iModel](./Settings.md#referencing-itwin-settings-from-an-imodel)). See [Choosing the right workspace](./Workspace.md#choosing-the-right-workspace) for guidance on when to use each scope. | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
|
|
||
| ## The two container types | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
|
|
||
| Both container types are built on [CloudSqlite]($backend) with [WorkspaceDb]($backend) as the underlying database, but they serve different roles and are discovered differently. | ||
|
|
||
| ```mermaid | ||
| graph LR | ||
| subgraph CloudSqlite["CloudSqlite"] | ||
| direction TB | ||
| note["Versioned · Immutable once published<br/>Semver-based · Container-scoped"] | ||
| end | ||
|
|
||
| subgraph SettingsContainer["Settings container (containerType: "settings")"] | ||
| SDB["<b>Settings</b><br/>Key-value config<br/>JSON dictionaries<br/>Priority-based merge"] | ||
| end | ||
|
|
||
| subgraph WorkspaceContainer["Workspace container (containerType: "workspace")"] | ||
| WDB["<b>Resources</b><br/>Named resources<br/>Strings, blobs, files<br/>On-demand lookup"] | ||
| end | ||
|
|
||
| CloudSqlite --- SettingsContainer | ||
| CloudSqlite --- WorkspaceContainer | ||
| SDB -->|"settings point to"| WDB | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| | | **Settings container** | **Workspace container** | | ||
| |---|---|---| | ||
| | **Purpose** | Application configuration | Data resources | | ||
| | **Content** | JSON key-value dictionaries | Strings, blobs, embedded files | | ||
| | **Container type** | `"settings"` | `"workspace"` | | ||
| | **Discovery** | Automatic via [IModelHost.getITwinWorkspace]($backend) — no iModel needed | Referenced from settings values | | ||
| | **Resolution order** | Loaded first | Loaded second, via settings pointers | | ||
| | **Write API** | [WorkspaceEditor]($backend) with `containerType: "settings"` | [WorkspaceEditor]($backend) | | ||
| | **Versioning** | Semver — immutable once published | Semver — immutable once published | | ||
|
|
||
| ## How settings and resources connect | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
johnnyd710 marked this conversation as resolved.
Outdated
|
||
|
|
||
| At runtime the flow always starts from settings: | ||
|
|
||
| 1. **Discover and load** — call [IModelHost.getITwinWorkspace]($backend) with an iTwinId. This automatically discovers settings containers for the iTwin, loads their dictionaries into the [Settings priority stack](./Settings.md#settings-priorities), and returns a [Workspace]($backend) ready to use. No iModel is required. | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
| 2. **Resolve resources** — read settings values that point to [WorkspaceDb]($backend) containers, then open those containers to access resources. | ||
|
|
||
| > For advanced scenarios (admin tooling, custom discovery logic), [WorkspaceEditor.queryContainers]($backend) provides lower-level access to enumerate containers by iTwinId and `containerType`. | ||
|
|
||
| ## Scope and priority | ||
|
|
||
| Settings from multiple sources are merged using a priority stack. A higher-priority dictionary overrides a lower-priority one for any given setting name. | ||
|
|
||
| ```mermaid | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
| graph TD | ||
| subgraph AppWorkspace["IModelHost.appWorkspace"] | ||
| D["defaults (100)"] | ||
|
hl662 marked this conversation as resolved.
Outdated
|
||
| A["application (200)"] | ||
| O["organization/iTwin (400)"] | ||
| end | ||
|
|
||
| subgraph IModelWorkspace["IModelDb.workspace"] | ||
| B["branch (500)"] | ||
| M["iModel (600)"] | ||
|
hl662 marked this conversation as resolved.
Outdated
|
||
| end | ||
|
|
||
| D -->|"overridden by"| A | ||
| A -->|"overridden by"| O | ||
| O -->|"overridden by"| B | ||
| B -->|"overridden by"| M | ||
|
|
||
| style M fill:#d4edda,stroke:#28a745 | ||
| style D fill:#f8f9fa,stroke:#6c757d | ||
| ``` | ||
|
|
||
| In practice: | ||
| - **Organization-wide defaults** are stored in a settings container and loaded at [SettingsPriority.iTwin]($backend) (400). | ||
| - **iModel-specific overrides** are loaded at [SettingsPriority.iModel]($backend) (600) — iModel wins over iTwin. | ||
| - **Application defaults** are loaded at [SettingsPriority.application]($backend) (200) — overrideable by any cloud-backed settings. | ||
|
|
||
| > **Note:** The diagram above simplifies organization and iTwin into one level. The full priority stack includes a separate [SettingsPriority.organization]($backend) (300) level — see [Settings priorities](./Settings.md#settings-priorities) for details. | ||
|
|
||
| `IModelHost.appWorkspace` holds dictionaries at `application` priority or lower. `IModelDb.workspace` holds higher-priority dictionaries and falls back to `appWorkspace` when a setting is not found. | ||
|
|
||
| ## Container discovery | ||
|
johnnyd710 marked this conversation as resolved.
Outdated
|
||
|
|
||
| [IModelHost.getITwinWorkspace]($backend) handles settings container discovery automatically — it queries for containers tagged with `containerType: "settings"`, loads their dictionaries, and returns a ready-to-use [Workspace]($backend). Most application code does not need to interact with the discovery layer directly. | ||
|
|
||
| [WorkspaceDb]($backend) containers (`containerType: "workspace"`) are discovered *indirectly* — by reading settings values that point to them. See [Workspace resources](./Workspace.md) for details. | ||
|
|
||
| > For admin tooling or custom workflows, [WorkspaceEditor.queryContainers]($backend) provides direct access to enumerate containers by iTwinId and `containerType`. See [Settings containers](./Settings.md#settings-containers) for examples. | ||
|
|
||
| ## Recommended reading order | ||
|
|
||
| 1. **This overview** — understand the two systems and three workspace scopes. | ||
| 2. **[Settings](./Settings.md)** — how to define settings schemas, load dictionaries, read values, and create/manage settings containers in the cloud. | ||
| 3. **[Workspace resources](./Workspace.md)** — how to create, version, and access binary resources stored in [WorkspaceDb]($backend) containers. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.