@itwin/core-backend 5.9.0-dev.1 → 5.9.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/lib/cjs/IModelHost.d.ts +36 -1
  3. package/lib/cjs/IModelHost.d.ts.map +1 -1
  4. package/lib/cjs/IModelHost.js +80 -0
  5. package/lib/cjs/IModelHost.js.map +1 -1
  6. package/lib/cjs/internal/workspace/SettingsEditorImpl.d.ts +18 -3
  7. package/lib/cjs/internal/workspace/SettingsEditorImpl.d.ts.map +1 -1
  8. package/lib/cjs/internal/workspace/SettingsEditorImpl.js +49 -242
  9. package/lib/cjs/internal/workspace/SettingsEditorImpl.js.map +1 -1
  10. package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
  11. package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
  12. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +0 -1
  13. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  14. package/lib/cjs/internal/workspace/WorkspaceImpl.js +70 -41
  15. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  16. package/lib/cjs/workspace/Settings.d.ts +11 -5
  17. package/lib/cjs/workspace/Settings.d.ts.map +1 -1
  18. package/lib/cjs/workspace/Settings.js.map +1 -1
  19. package/lib/cjs/workspace/SettingsDb.d.ts +20 -99
  20. package/lib/cjs/workspace/SettingsDb.d.ts.map +1 -1
  21. package/lib/cjs/workspace/SettingsDb.js +23 -7
  22. package/lib/cjs/workspace/SettingsDb.js.map +1 -1
  23. package/lib/cjs/workspace/SettingsEditor.d.ts +40 -226
  24. package/lib/cjs/workspace/SettingsEditor.d.ts.map +1 -1
  25. package/lib/cjs/workspace/SettingsEditor.js +86 -25
  26. package/lib/cjs/workspace/SettingsEditor.js.map +1 -1
  27. package/lib/cjs/workspace/Workspace.d.ts +7 -11
  28. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  29. package/lib/cjs/workspace/Workspace.js.map +1 -1
  30. package/lib/cjs/workspace/WorkspaceEditor.d.ts +14 -0
  31. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  32. package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
  33. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  34. package/lib/esm/IModelHost.d.ts +36 -1
  35. package/lib/esm/IModelHost.d.ts.map +1 -1
  36. package/lib/esm/IModelHost.js +82 -2
  37. package/lib/esm/IModelHost.js.map +1 -1
  38. package/lib/esm/internal/workspace/SettingsEditorImpl.d.ts +18 -3
  39. package/lib/esm/internal/workspace/SettingsEditorImpl.d.ts.map +1 -1
  40. package/lib/esm/internal/workspace/SettingsEditorImpl.js +52 -246
  41. package/lib/esm/internal/workspace/SettingsEditorImpl.js.map +1 -1
  42. package/lib/esm/internal/workspace/SettingsImpl.d.ts.map +1 -1
  43. package/lib/esm/internal/workspace/SettingsImpl.js.map +1 -1
  44. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts +0 -1
  45. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  46. package/lib/esm/internal/workspace/WorkspaceImpl.js +71 -41
  47. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  48. package/lib/esm/test/standalone/ITwinWorkspace.test.d.ts +2 -0
  49. package/lib/esm/test/standalone/ITwinWorkspace.test.d.ts.map +1 -0
  50. package/lib/esm/test/standalone/ITwinWorkspace.test.js +236 -0
  51. package/lib/esm/test/standalone/ITwinWorkspace.test.js.map +1 -0
  52. package/lib/esm/test/standalone/Settings.test.js +19 -0
  53. package/lib/esm/test/standalone/Settings.test.js.map +1 -1
  54. package/lib/esm/test/standalone/Workspace.test.js +52 -4
  55. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  56. package/lib/esm/test/workspace/SettingsDb.test.js +28 -456
  57. package/lib/esm/test/workspace/SettingsDb.test.js.map +1 -1
  58. package/lib/esm/workspace/Settings.d.ts +11 -5
  59. package/lib/esm/workspace/Settings.d.ts.map +1 -1
  60. package/lib/esm/workspace/Settings.js.map +1 -1
  61. package/lib/esm/workspace/SettingsDb.d.ts +20 -99
  62. package/lib/esm/workspace/SettingsDb.d.ts.map +1 -1
  63. package/lib/esm/workspace/SettingsDb.js +20 -6
  64. package/lib/esm/workspace/SettingsDb.js.map +1 -1
  65. package/lib/esm/workspace/SettingsEditor.d.ts +40 -226
  66. package/lib/esm/workspace/SettingsEditor.d.ts.map +1 -1
  67. package/lib/esm/workspace/SettingsEditor.js +85 -24
  68. package/lib/esm/workspace/SettingsEditor.js.map +1 -1
  69. package/lib/esm/workspace/Workspace.d.ts +7 -11
  70. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  71. package/lib/esm/workspace/Workspace.js.map +1 -1
  72. package/lib/esm/workspace/WorkspaceEditor.d.ts +14 -0
  73. package/lib/esm/workspace/WorkspaceEditor.d.ts.map +1 -1
  74. package/lib/esm/workspace/WorkspaceEditor.js +1 -1
  75. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  76. package/package.json +14 -14
  77. package/lib/cjs/internal/workspace/SettingsDbImpl.d.ts +0 -38
  78. package/lib/cjs/internal/workspace/SettingsDbImpl.d.ts.map +0 -1
  79. package/lib/cjs/internal/workspace/SettingsDbImpl.js +0 -108
  80. package/lib/cjs/internal/workspace/SettingsDbImpl.js.map +0 -1
  81. package/lib/cjs/internal/workspace/SettingsSqliteDb.d.ts +0 -14
  82. package/lib/cjs/internal/workspace/SettingsSqliteDb.d.ts.map +0 -1
  83. package/lib/cjs/internal/workspace/SettingsSqliteDb.js +0 -40
  84. package/lib/cjs/internal/workspace/SettingsSqliteDb.js.map +0 -1
  85. package/lib/esm/internal/workspace/SettingsDbImpl.d.ts +0 -38
  86. package/lib/esm/internal/workspace/SettingsDbImpl.d.ts.map +0 -1
  87. package/lib/esm/internal/workspace/SettingsDbImpl.js +0 -104
  88. package/lib/esm/internal/workspace/SettingsDbImpl.js.map +0 -1
  89. package/lib/esm/internal/workspace/SettingsSqliteDb.d.ts +0 -14
  90. package/lib/esm/internal/workspace/SettingsSqliteDb.d.ts.map +0 -1
  91. package/lib/esm/internal/workspace/SettingsSqliteDb.js +0 -36
  92. package/lib/esm/internal/workspace/SettingsSqliteDb.js.map +0 -1
@@ -92,7 +92,7 @@ export interface SettingsDictionary {
92
92
  getSetting<T extends Setting>(settingName: SettingName): T | undefined;
93
93
  /** Return a deep copy of all settings in this dictionary as a [[SettingsContainer]].
94
94
  * This is useful for inspecting the full contents of the dictionary or for building a modified copy
95
- * to pass to [[EditableSettingsDb.updateSettingsDictionary]].
95
+ * to pass to [[EditableWorkspaceDb.updateSettingsResource]].
96
96
  * The returned container is cloned using [[Setting.clone]], so callers may freely mutate it without
97
97
  * affecting this dictionary's internal state.
98
98
  * @beta
@@ -103,7 +103,7 @@ export interface SettingsDictionary {
103
103
  * @beta
104
104
  */
105
105
  export interface SettingsDictionarySource {
106
- /** The name of the dictionary, which must be unique within its [[workspaceDb]], or - if [[workspaceDb]] is undefined - unique among all dictionaries not associated with any [[WorkspaceDb]]. */
106
+ /** The name of the dictionary, which must be unique within its [[workspaceDb]], or - if no workspaceDb is defined - unique among all dictionaries not associated with any [[WorkspaceDb]]. */
107
107
  readonly name: string;
108
108
  /** The [[WorkspaceDb]] from which the dictionary originated. */
109
109
  readonly workspaceDb?: WorkspaceDb;
@@ -128,7 +128,9 @@ export interface SettingsDictionaryProps extends SettingsDictionarySource {
128
128
  *
129
129
  * Settings are accessed via [[Workspace.settings]]. They are defined at the application level by [[IModelHost.appWorkspace]], but individual iModels may supply
130
130
  * additional iModel-specific settings or overrides for application-level settings. When working in the context of a specific iModel, use [[IModelDb.workspace]]'s `settings`
131
- * property. Any settings not overridden by the iModel will fall back to the settings defined in [[IModelHost.appWorkspace]].
131
+ * property. Any settings not overridden by the iModel will fall back to the settings defined in [[IModelHost.appWorkspace]]. When working in the context of an iTwin,
132
+ * use [[IModelHost.getITwinWorkspace]] to obtain a [[Workspace]] for the iTwin and access its `settings` property.
133
+ * Like iModel-specific settings, any settings supplied by the iTwin will override those defined at the application level.
132
134
  *
133
135
  * Application settings are loaded into [[IModelHost.appWorkspace]] when the session begins (i.e., when [[IModelHost.startup]] is invoked), and unloaded when it ends (in [[IModelHost.shutdown]]).
134
136
  * They are read from [JSON5](https://json5.org/) files delivered with the application. The application should register any additional [[SettingsDictionary]]'s '(and their corresponding
@@ -137,9 +139,13 @@ export interface SettingsDictionaryProps extends SettingsDictionarySource {
137
139
  * iModel-specific settings are stored in the iModel's property table and loaded into [[IModelDb.workspace]] when the iModel is first opened.
138
140
  * You can add and remove a [[SettingsDictionary]] from the property table using [[IModelDb.saveSettingDictionary]] and [[IModelDb.deleteSettingDictionary]].
139
141
  *
140
- * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.
142
+ * iTwin-specific settings are stored in a [[CloudSqliteContainer]] in the cloud.
143
+ * When [[IModelHost.getITwinWorkspace]] is invoked, the container is accessed using the iTwinId and the settings are loaded into the returned [[Workspace]].
144
+ * You can add and remove a [[SettingsDictionary]] from the container using [[Workspace.saveSettingsDictionary]] and [[Workspace.deleteSettingsDictionary]].
141
145
  *
142
- * @see [[IModelHost.appWorkspace]] application-wide settings, and [[IModelDb.workspace]] for settings specific to a given iModel.
146
+ * See the [learning article]($docs/learning/backend/Workspace) for a detailed overview and examples.
147
+ *
148
+ * @see [[IModelHost.appWorkspace]] application-wide settings, [[IModelDb.workspace]] for settings specific to a given iModel, and [[IModelHost.getITwinWorkspace]] for settings specific to a given iTwin.
143
149
  * @beta
144
150
  */
145
151
  export interface Settings {
@@ -1 +1 @@
1
- {"version":3,"file":"Settings.d.ts","sourceRoot":"","sources":["../../../src/workspace/Settings.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,EAAE,YAAY,EA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,IAAI,KAAK,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,CAAC,IAAI,EAAE,CAAC;QACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACrB,IAAI,GAAG,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBACrB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,IAAI,CAAC,QAAQ,CAAE,CAAuB,CAAC,GAAG,CAAC,EAAG,CAAuB,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;gBAC5E,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IA5Ce,gBAAQ,WA4CvB,CAAA;AACH,CAAC,EA/DgB,OAAO,KAAP,OAAO,QA+DvB;AA0CD,YAAY;AACZ,MAAM,KAAW,gBAAgB,CAahC;AAbD,WAAiB,gBAAgB;IAC/B,yGAAyG;IAC5F,yBAAQ,GAAG,GAAG,CAAC;IAC5B,sDAAsD;IACzC,4BAAW,GAAG,GAAG,CAAC;IAC/B,6DAA6D;IAChD,6BAAY,GAAG,GAAG,CAAC;IAChC,sDAAsD;IACzC,sBAAK,GAAG,GAAG,CAAC;IACzB,wDAAwD;IAC3C,uBAAM,GAAG,GAAG,CAAC;IAC1B,gDAAgD;IACnC,uBAAM,GAAG,GAAG,CAAC;AAC5B,CAAC,EAbgB,gBAAgB,KAAhB,gBAAgB,QAahC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Workspace\n */\n\nimport { BeEvent, JSONSchemaType } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { WorkspaceDb } from \"./Workspace\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** The value of a single named parameter within a [[Workspace.settings]] that configures some aspect of the applications run-time behavior.\n * Settings are stored in a [[SettingsDictionary]]. A setting is described by its [[SettingSchema]].\n * @beta\n */\nexport type Setting = JSONSchemaType;\n\n/** @beta */\nexport namespace Setting { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a deep copy of a [[Setting]]. */\n export function clone<T extends Setting>(setting: T): T {\n if (!setting || typeof setting !== \"object\")\n return setting;\n\n const result = Array.isArray(setting) ? [] : {} as any;\n Object.keys(setting).forEach((key: string) => result[key] = clone((setting as any)[key]));\n return result;\n }\n\n /** Returns true if `a` and `b` are considered equivalent [[Setting]] values.\n * Settings of primitive types like `number` and `string` are compared using `===`.\n * Settings of type \"object\" are compared by comparing each property using `areEqual`; the objects are considered\n * equal if they have the exact same set of property names with equivalent values.\n * Settings of type \"array\" are compared by comparing each element of the arrays use `areEqual`; the arrays are considered\n * equal if they have the same number of elements with equivalent values in the same exact order.\n */\n export function areEqual(a: Setting | undefined, b: Setting | undefined): boolean {\n if (a === b) {\n return true;\n }\n\n // For primitive types, === suffices.\n if (typeof a !== \"object\" || typeof b !== \"object\") {\n return false;\n }\n\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n\n for (let i = 0; i < a.length; i++) {\n if (!areEqual(a[i], b[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n aKeys.sort();\n bKeys.sort();\n for (let i = 0; i < aKeys.length; i++) {\n const key = aKeys[i];\n if (key !== bKeys[i]) {\n return false;\n }\n\n if (!areEqual((a as SettingsContainer)[key], (b as SettingsContainer)[key])) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/**\n * The name of a [[Setting]].\n * Setting names must be [valid JavaScript property names](https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript) containing no spaces or periods.\n * The name of a setting begins with the schema prefix of the [[SettingGroupSchema]] in which its [[SettingSchema]] is defined.\n * A setting name therefore forms a path like file names in a file system.\n * For example, the following are setting names defined in the `energyAnalysis`, `iot-scan-visualization`, and `vibration-map` schemas.\n *\n * ```ts\n * \"energyAnalysis/formats/totalWork\"\n * \"energyAnalysis/formats/totalHours\"\n * \"energyAnalysis/units/power\"\n * \"energyAnalysis/units/temperature\"\n * \"energyAnalysis/startupMode\"\n * \"iot-scan-visualization/ports/cameras\"\n * \"vibration-map/filters/scope\"\n * \"vibration-map/filters/prefabricated\"\n * ```\n *\n * @beta\n */\nexport type SettingName = string;\n\n/** An object that defines the values for any number of [[Setting]]s. Each of its properties' names must conform to the semantics of a [[SettingName]].\n * @beta\n */\nexport interface SettingsContainer {\n /** Accesses settings by their names. */\n [name: SettingName]: Setting | undefined;\n}\n\n/** Defines the precedence of a [[SettingsDictionary]].\n * [[Settings]] may contain multiple dictionaries containing different values for the same [[SettingName]].\n * When resolving the value of a [[Setting]], the value from the highest-priority dictionary is used.\n * Priorities are grouped into coarse categories like [[SettingsPriority.application]] and [[SettingsPriority.iModel]].\n * Settings with priorities less than or equal to [[SettingsPriority.application]] are stored in [[IModelHost.appWorkspace]], while\n * those with priorities higher than [[SettingsPriority.application]] are stored inside [[IModelDb.workspace]].\n * @beta\n */\nexport type SettingsPriority = number;\n\n/** @beta */\nexport namespace SettingsPriority { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Settings that originate from default setting files loaded automatically at the start of a session. */\n export const defaults = 100;\n /** Settings supplied by an application at runtime. */\n export const application = 200;\n /** Settings that apply to all iTwins for an organization. */\n export const organization = 300;\n /** Settings that apply to all iModels in an iTwin. */\n export const iTwin = 400;\n /** Settings that apply to all branches of an iModel. */\n export const branch = 500;\n /** Settings that apply to a specific iModel. */\n export const iModel = 600;\n}\n\n/** A named container that supplies values for [[Setting]]s.\n * @see [[Settings.addDictionary]] to register a new settings dictionary.\n * @beta\n */\nexport interface SettingsDictionary {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** Metadata describing the dictionary. */\n readonly props: SettingsDictionaryProps;\n\n /** Obtain a copy of the value of the setting named `settingName` stored in this dictionary, or `undefined` if no such setting exists.\n * The returned value is always cloned using [[Setting.clone]].\n * @note Generally, applications use methods like [[Settings.getString]] and [[Setting.getArray]] to resolve a setting value from multiple\n * dictionaries. Those methods - unlike this one - also validate that `settingName` is of type `T` as defined by its [[SettingSchema]].\n */\n getSetting<T extends Setting>(settingName: SettingName): T | undefined;\n\n /** Return a deep copy of all settings in this dictionary as a [[SettingsContainer]].\n * This is useful for inspecting the full contents of the dictionary or for building a modified copy\n * to pass to [[EditableSettingsDb.updateSettingsDictionary]].\n * The returned container is cloned using [[Setting.clone]], so callers may freely mutate it without\n * affecting this dictionary's internal state.\n * @beta\n */\n toJSON(): SettingsContainer;\n}\n\n/** Uniquely identifies a [[SettingsDictionary]].\n * @beta\n */\nexport interface SettingsDictionarySource {\n /** The name of the dictionary, which must be unique within its [[workspaceDb]], or - if [[workspaceDb]] is undefined - unique among all dictionaries not associated with any [[WorkspaceDb]]. */\n readonly name: string;\n /** The [[WorkspaceDb]] from which the dictionary originated. */\n readonly workspaceDb?: WorkspaceDb;\n}\n\n/** Properties of a [[SettingsDictionary]], defining its name, the [[WorkspaceDb]] (if any) from which it originated, and its [[priority]] relative to other dictionaries.\n * @beta\n */\nexport interface SettingsDictionaryProps extends SettingsDictionarySource {\n /** Precedence value determining which setting value to use when multiple dictionaries supply values for the same [[SettingName]]. */\n readonly priority: SettingsPriority;\n}\n\n/**\n * The collection of [[Setting]]s that supply the run-time configuration of a [[Workspace]].\n * The `Settings` object comprises a collection of named [[SettingsDictionary]] objects.\n * Methods like [[getSetting]], [[getString]], and [[getArray]] provide access to the value of an individual [[Setting]] by searching\n * the [[dictionaries]] in order by their [[SettingsPriority]] to find the highest-priority setting with the requested [[SettingName]].\n * Most methods that retrieve [[Setting]] values validate them against their [[SettingSchema]]s to ensure that they are of the correct type.\n * A [[SettingsDictionary]] can be added or removed using [[addDictionary]] and [[dropDictionary]].\n * Because [[Setting]]s can change at any time during the session, you should avoid caching their values wherever possible.\n * If you must cache them (for example, to display in a user interface), you should listen for the [[onSettingsChanged]] event to be\n * notified of potential changes.\n *\n * Settings are accessed via [[Workspace.settings]]. They are defined at the application level by [[IModelHost.appWorkspace]], but individual iModels may supply\n * additional iModel-specific settings or overrides for application-level settings. When working in the context of a specific iModel, use [[IModelDb.workspace]]'s `settings`\n * property. Any settings not overridden by the iModel will fall back to the settings defined in [[IModelHost.appWorkspace]].\n *\n * Application settings are loaded into [[IModelHost.appWorkspace]] when the session begins (i.e., when [[IModelHost.startup]] is invoked), and unloaded when it ends (in [[IModelHost.shutdown]]).\n * They are read from [JSON5](https://json5.org/) files delivered with the application. The application should register any additional [[SettingsDictionary]]'s '(and their corresponding\n * [[SettingGroupSchema]]s) at this time.\n *\n * iModel-specific settings are stored in the iModel's property table and loaded into [[IModelDb.workspace]] when the iModel is first opened.\n * You can add and remove a [[SettingsDictionary]] from the property table using [[IModelDb.saveSettingDictionary]] and [[IModelDb.deleteSettingDictionary]].\n *\n * See the [learning article]($docs/learning/backend/Workspace) for a detailed overiew and examples.\n *\n * @see [[IModelHost.appWorkspace]] application-wide settings, and [[IModelDb.workspace]] for settings specific to a given iModel.\n * @beta\n */\nexport interface Settings {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** @internal */\n close(): void;\n\n /** The set of settings dictionaries from which [[Setting]] values are obtained, sorted by [[SettingsPriority]].\n * The set can contain at most one dictionary for each unique combination of name and [[WorkspaceDb]].\n * @see [[addDictionary]], [[addFile]], [[addJson]], and [[addDirectory]] to add a new dictionary.\n * @see [[dropDictionary]] to remove a dictionary.\n * @see [[getDictionary]] to look up a dictionary.\n */\n readonly dictionaries: readonly SettingsDictionary[];\n\n /** Event raised whenever a [[SettingsDictionary]] is added or removed. */\n readonly onSettingsChanged: BeEvent<() => void>;\n\n /** Parses the contents of a local [JSON5](https://json5.org/) file as a [[SettingsContainer]] and invokes [[addDictionary]] to\n * add a [[SettingsDictionary]] named `fileName` with the specified priority.\n * @param fileName the name of a local settings file containing the dictionary.\n * @param priority the priority for the dictionary.\n */\n addFile(fileName: LocalFileName, priority: SettingsPriority): void;\n\n /** Invokes [[addFile]] for all files in `directory` with the extension \".json\" or \".json5\". */\n addDirectory(directory: LocalDirName, priority: SettingsPriority): void;\n\n /** Parses `settingsJson` as a [[SettingsContainer]] and invokes [[addDictionary]] to add a [[SettingsDictionary]] with the specified `props`.\n * This is typically used when reading dictionaries out of a [[WorkspaceDb]], where they are stored as stringified JSON.\n */\n addJson(props: SettingsDictionaryProps, settingsJson: string): void;\n\n /** Find a [[SettingsDictionary]] with the same name and [[WorkspaceDb]] as `source`. */\n getDictionary(source: SettingsDictionarySource): SettingsDictionary | undefined;\n\n /** Add a new [[SettingsDictionary]] with the priority, name, and [[WorkspaceDb]] specified by `props` and setting values supplied by `settings`.\n * @note If a dictionary with the same name and [[WorkspaceDb]] already exists, it will be replaced.\n * @see [[addFile]], [[addJson]], and [[addDirectory]] for convenient ways to add dictionaries from various sources.\n */\n addDictionary(props: SettingsDictionaryProps, settings: SettingsContainer): void;\n\n /** Removes a previously-added [[SettingsDictionary]]. */\n dropDictionary(props: SettingsDictionarySource): void;\n\n /** Looks up the highest priority setting value for a SettingName, falling back to a default value if no value for the setting is found.\n * The [[dictionaries]] are searched in order by [[SettingsPriority]]; the first one that provides a value for `settingName` wins.\n * @param settingName The name of the setting.\n * @param defaultValue value returned if settingName is not present in any [[SettingsDictionary]].\n * @note This method is generic on [[Setting]] type, but no type checking is actually performed at run time. So, if you\n * use this method to get a setting with an expected type, but its value is a different type, the return type of this method will be wrong.\n * You must always type check the result. Use the non-generic \"get\" methods like [[getString]] and [[getArray]] if you only want the value\n * if its type is correct.\n * @note Unlike [[getArray]], this method does not combine arrays - it ignores [[SettingsSchema.combineArrays]].\n */\n getSetting<T extends Setting>(settingName: SettingName, defaultValue?: T): T | undefined;\n\n /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */\n getSettingEntries<T extends Setting>(settingName: SettingName): Iterable<{ value: T, dictionary: SettingsDictionary}>;\n\n /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */\n getSettingValues<T extends Setting>(settingName: SettingName): Iterable<T>;\n\n /** Look up the value of a string [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a string.\n */\n getString(settingName: SettingName, defaultValue: string): string;\n getString(settingName: SettingName, defaultValue?: string): string | undefined;\n\n /** Look up the value of a boolean [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a boolean.\n */\n getBoolean(settingName: SettingName, defaultValue: boolean): boolean;\n getBoolean(settingName: SettingName, defaultValue?: boolean): boolean | undefined;\n\n /** Look up the value of a numeric [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a number.\n */\n getNumber(settingName: SettingName, defaultValue: number): number;\n getNumber(settingName: SettingName): number | undefined;\n\n /** Look up the value of an object [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not an object.\n */\n getObject<T extends object>(settingName: SettingName, defaultValue: T): T;\n getObject<T extends object>(settingName: SettingName): T | undefined;\n\n /** Look up the value of an array [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not an array.\n */\n getArray<T extends Setting>(settingName: SettingName, defaultValue: Array<T>): Array<T>;\n getArray<T extends Setting>(settingName: SettingName): Array<T> | undefined;\n}\n"]}
1
+ {"version":3,"file":"Settings.js","sourceRoot":"","sources":["../../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AAsD;IACzC,4BAAW,GAAG,GAAG,CAAC;IAC/B,6DAA6D;IAChD,6BAAY,GAAG,GAAG,CAAC;IAChC,sDAAsD;IACzC,sBAAK,GAAG,GAAG,CAAC;IACzB,wDAAwD;IAC3C,uBAAM,GAAG,GAAG,CAAC;IAC1B,gDAAgD;IACnC,uBAAM,GAAG,GAAG,CAAC;AAC5B,CAAC,EAbgB,gBAAgB,KAAhB,gBAAgB,QAahC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Workspace\n */\n\nimport { BeEvent, JSONSchemaType } from \"@itwin/core-bentley\";\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\nimport { WorkspaceDb } from \"./Workspace\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** The value of a single named parameter within a [[Workspace.settings]] that configures some aspect of the applications run-time behavior.\n * Settings are stored in a [[SettingsDictionary]]. A setting is described by its [[SettingSchema]].\n * @beta\n */\nexport type Setting = JSONSchemaType;\n\n/** @beta */\nexport namespace Setting { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Create a deep copy of a [[Setting]]. */\n export function clone<T extends Setting>(setting: T): T {\n if (!setting || typeof setting !== \"object\")\n return setting;\n\n const result = Array.isArray(setting) ? [] : {} as any;\n Object.keys(setting).forEach((key: string) => result[key] = clone((setting as any)[key]));\n return result;\n }\n\n /** Returns true if `a` and `b` are considered equivalent [[Setting]] values.\n * Settings of primitive types like `number` and `string` are compared using `===`.\n * Settings of type \"object\" are compared by comparing each property using `areEqual`; the objects are considered\n * equal if they have the exact same set of property names with equivalent values.\n * Settings of type \"array\" are compared by comparing each element of the arrays use `areEqual`; the arrays are considered\n * equal if they have the same number of elements with equivalent values in the same exact order.\n */\n export function areEqual(a: Setting | undefined, b: Setting | undefined): boolean {\n if (a === b) {\n return true;\n }\n\n // For primitive types, === suffices.\n if (typeof a !== \"object\" || typeof b !== \"object\") {\n return false;\n }\n\n if (Array.isArray(a) || Array.isArray(b)) {\n if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {\n return false;\n }\n\n for (let i = 0; i < a.length; i++) {\n if (!areEqual(a[i], b[i])) {\n return false;\n }\n }\n\n return true;\n }\n\n const aKeys = Object.keys(a);\n const bKeys = Object.keys(b);\n if (aKeys.length !== bKeys.length) {\n return false;\n }\n\n aKeys.sort();\n bKeys.sort();\n for (let i = 0; i < aKeys.length; i++) {\n const key = aKeys[i];\n if (key !== bKeys[i]) {\n return false;\n }\n\n if (!areEqual((a as SettingsContainer)[key], (b as SettingsContainer)[key])) {\n return false;\n }\n }\n\n return true;\n }\n}\n\n/**\n * The name of a [[Setting]].\n * Setting names must be [valid JavaScript property names](https://developer.mozilla.org/en-US/docs/Glossary/property/JavaScript) containing no spaces or periods.\n * The name of a setting begins with the schema prefix of the [[SettingGroupSchema]] in which its [[SettingSchema]] is defined.\n * A setting name therefore forms a path like file names in a file system.\n * For example, the following are setting names defined in the `energyAnalysis`, `iot-scan-visualization`, and `vibration-map` schemas.\n *\n * ```ts\n * \"energyAnalysis/formats/totalWork\"\n * \"energyAnalysis/formats/totalHours\"\n * \"energyAnalysis/units/power\"\n * \"energyAnalysis/units/temperature\"\n * \"energyAnalysis/startupMode\"\n * \"iot-scan-visualization/ports/cameras\"\n * \"vibration-map/filters/scope\"\n * \"vibration-map/filters/prefabricated\"\n * ```\n *\n * @beta\n */\nexport type SettingName = string;\n\n/** An object that defines the values for any number of [[Setting]]s. Each of its properties' names must conform to the semantics of a [[SettingName]].\n * @beta\n */\nexport interface SettingsContainer {\n /** Accesses settings by their names. */\n [name: SettingName]: Setting | undefined;\n}\n\n/** Defines the precedence of a [[SettingsDictionary]].\n * [[Settings]] may contain multiple dictionaries containing different values for the same [[SettingName]].\n * When resolving the value of a [[Setting]], the value from the highest-priority dictionary is used.\n * Priorities are grouped into coarse categories like [[SettingsPriority.application]] and [[SettingsPriority.iModel]].\n * Settings with priorities less than or equal to [[SettingsPriority.application]] are stored in [[IModelHost.appWorkspace]], while\n * those with priorities higher than [[SettingsPriority.application]] are stored inside [[IModelDb.workspace]].\n * @beta\n */\nexport type SettingsPriority = number;\n\n/** @beta */\nexport namespace SettingsPriority { // eslint-disable-line @typescript-eslint/no-redeclare\n /** Settings that originate from default setting files loaded automatically at the start of a session. */\n export const defaults = 100;\n /** Settings supplied by an application at runtime. */\n export const application = 200;\n /** Settings that apply to all iTwins for an organization. */\n export const organization = 300;\n /** Settings that apply to all iModels in an iTwin. */\n export const iTwin = 400;\n /** Settings that apply to all branches of an iModel. */\n export const branch = 500;\n /** Settings that apply to a specific iModel. */\n export const iModel = 600;\n}\n\n/** A named container that supplies values for [[Setting]]s.\n * @see [[Settings.addDictionary]] to register a new settings dictionary.\n * @beta\n */\nexport interface SettingsDictionary {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** Metadata describing the dictionary. */\n readonly props: SettingsDictionaryProps;\n\n /** Obtain a copy of the value of the setting named `settingName` stored in this dictionary, or `undefined` if no such setting exists.\n * The returned value is always cloned using [[Setting.clone]].\n * @note Generally, applications use methods like [[Settings.getString]] and [[Setting.getArray]] to resolve a setting value from multiple\n * dictionaries. Those methods - unlike this one - also validate that `settingName` is of type `T` as defined by its [[SettingSchema]].\n */\n getSetting<T extends Setting>(settingName: SettingName): T | undefined;\n\n /** Return a deep copy of all settings in this dictionary as a [[SettingsContainer]].\n * This is useful for inspecting the full contents of the dictionary or for building a modified copy\n * to pass to [[EditableWorkspaceDb.updateSettingsResource]].\n * The returned container is cloned using [[Setting.clone]], so callers may freely mutate it without\n * affecting this dictionary's internal state.\n * @beta\n */\n toJSON(): SettingsContainer;\n}\n\n/** Uniquely identifies a [[SettingsDictionary]].\n * @beta\n */\nexport interface SettingsDictionarySource {\n /** The name of the dictionary, which must be unique within its [[workspaceDb]], or - if no workspaceDb is defined - unique among all dictionaries not associated with any [[WorkspaceDb]]. */\n readonly name: string;\n /** The [[WorkspaceDb]] from which the dictionary originated. */\n readonly workspaceDb?: WorkspaceDb;\n}\n\n/** Properties of a [[SettingsDictionary]], defining its name, the [[WorkspaceDb]] (if any) from which it originated, and its [[priority]] relative to other dictionaries.\n * @beta\n */\nexport interface SettingsDictionaryProps extends SettingsDictionarySource {\n /** Precedence value determining which setting value to use when multiple dictionaries supply values for the same [[SettingName]]. */\n readonly priority: SettingsPriority;\n}\n\n/**\n * The collection of [[Setting]]s that supply the run-time configuration of a [[Workspace]].\n * The `Settings` object comprises a collection of named [[SettingsDictionary]] objects.\n * Methods like [[getSetting]], [[getString]], and [[getArray]] provide access to the value of an individual [[Setting]] by searching\n * the [[dictionaries]] in order by their [[SettingsPriority]] to find the highest-priority setting with the requested [[SettingName]].\n * Most methods that retrieve [[Setting]] values validate them against their [[SettingSchema]]s to ensure that they are of the correct type.\n * A [[SettingsDictionary]] can be added or removed using [[addDictionary]] and [[dropDictionary]].\n * Because [[Setting]]s can change at any time during the session, you should avoid caching their values wherever possible.\n * If you must cache them (for example, to display in a user interface), you should listen for the [[onSettingsChanged]] event to be\n * notified of potential changes.\n *\n * Settings are accessed via [[Workspace.settings]]. They are defined at the application level by [[IModelHost.appWorkspace]], but individual iModels may supply\n * additional iModel-specific settings or overrides for application-level settings. When working in the context of a specific iModel, use [[IModelDb.workspace]]'s `settings`\n * property. Any settings not overridden by the iModel will fall back to the settings defined in [[IModelHost.appWorkspace]]. When working in the context of an iTwin,\n * use [[IModelHost.getITwinWorkspace]] to obtain a [[Workspace]] for the iTwin and access its `settings` property.\n * Like iModel-specific settings, any settings supplied by the iTwin will override those defined at the application level.\n *\n * Application settings are loaded into [[IModelHost.appWorkspace]] when the session begins (i.e., when [[IModelHost.startup]] is invoked), and unloaded when it ends (in [[IModelHost.shutdown]]).\n * They are read from [JSON5](https://json5.org/) files delivered with the application. The application should register any additional [[SettingsDictionary]]'s '(and their corresponding\n * [[SettingGroupSchema]]s) at this time.\n *\n * iModel-specific settings are stored in the iModel's property table and loaded into [[IModelDb.workspace]] when the iModel is first opened.\n * You can add and remove a [[SettingsDictionary]] from the property table using [[IModelDb.saveSettingDictionary]] and [[IModelDb.deleteSettingDictionary]].\n *\n * iTwin-specific settings are stored in a [[CloudSqliteContainer]] in the cloud.\n * When [[IModelHost.getITwinWorkspace]] is invoked, the container is accessed using the iTwinId and the settings are loaded into the returned [[Workspace]].\n * You can add and remove a [[SettingsDictionary]] from the container using [[Workspace.saveSettingsDictionary]] and [[Workspace.deleteSettingsDictionary]].\n *\n * See the [learning article]($docs/learning/backend/Workspace) for a detailed overview and examples.\n *\n * @see [[IModelHost.appWorkspace]] application-wide settings, [[IModelDb.workspace]] for settings specific to a given iModel, and [[IModelHost.getITwinWorkspace]] for settings specific to a given iTwin.\n * @beta\n */\nexport interface Settings {\n /** @internal */\n [_implementationProhibited]: unknown;\n\n /** @internal */\n close(): void;\n\n /** The set of settings dictionaries from which [[Setting]] values are obtained, sorted by [[SettingsPriority]].\n * The set can contain at most one dictionary for each unique combination of name and [[WorkspaceDb]].\n * @see [[addDictionary]], [[addFile]], [[addJson]], and [[addDirectory]] to add a new dictionary.\n * @see [[dropDictionary]] to remove a dictionary.\n * @see [[getDictionary]] to look up a dictionary.\n */\n readonly dictionaries: readonly SettingsDictionary[];\n\n /** Event raised whenever a [[SettingsDictionary]] is added or removed. */\n readonly onSettingsChanged: BeEvent<() => void>;\n\n /** Parses the contents of a local [JSON5](https://json5.org/) file as a [[SettingsContainer]] and invokes [[addDictionary]] to\n * add a [[SettingsDictionary]] named `fileName` with the specified priority.\n * @param fileName the name of a local settings file containing the dictionary.\n * @param priority the priority for the dictionary.\n */\n addFile(fileName: LocalFileName, priority: SettingsPriority): void;\n\n /** Invokes [[addFile]] for all files in `directory` with the extension \".json\" or \".json5\". */\n addDirectory(directory: LocalDirName, priority: SettingsPriority): void;\n\n /** Parses `settingsJson` as a [[SettingsContainer]] and invokes [[addDictionary]] to add a [[SettingsDictionary]] with the specified `props`.\n * This is typically used when reading dictionaries out of a [[WorkspaceDb]], where they are stored as stringified JSON.\n */\n addJson(props: SettingsDictionaryProps, settingsJson: string): void;\n\n /** Find a [[SettingsDictionary]] with the same name and [[WorkspaceDb]] as `source`. */\n getDictionary(source: SettingsDictionarySource): SettingsDictionary | undefined;\n\n /** Add a new [[SettingsDictionary]] with the priority, name, and [[WorkspaceDb]] specified by `props` and setting values supplied by `settings`.\n * @note If a dictionary with the same name and [[WorkspaceDb]] already exists, it will be replaced.\n * @see [[addFile]], [[addJson]], and [[addDirectory]] for convenient ways to add dictionaries from various sources.\n */\n addDictionary(props: SettingsDictionaryProps, settings: SettingsContainer): void;\n\n /** Removes a previously-added [[SettingsDictionary]]. */\n dropDictionary(props: SettingsDictionarySource): void;\n\n /** Looks up the highest priority setting value for a SettingName, falling back to a default value if no value for the setting is found.\n * The [[dictionaries]] are searched in order by [[SettingsPriority]]; the first one that provides a value for `settingName` wins.\n * @param settingName The name of the setting.\n * @param defaultValue value returned if settingName is not present in any [[SettingsDictionary]].\n * @note This method is generic on [[Setting]] type, but no type checking is actually performed at run time. So, if you\n * use this method to get a setting with an expected type, but its value is a different type, the return type of this method will be wrong.\n * You must always type check the result. Use the non-generic \"get\" methods like [[getString]] and [[getArray]] if you only want the value\n * if its type is correct.\n * @note Unlike [[getArray]], this method does not combine arrays - it ignores [[SettingsSchema.combineArrays]].\n */\n getSetting<T extends Setting>(settingName: SettingName, defaultValue?: T): T | undefined;\n\n /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */\n getSettingEntries<T extends Setting>(settingName: SettingName): Iterable<{ value: T, dictionary: SettingsDictionary }>;\n\n /** Obtain an iterator over all of the values in the [[dictionaries]] for the [[Setting]] identified by `settingName`, ordered by [[SettingsPriority]]. */\n getSettingValues<T extends Setting>(settingName: SettingName): Iterable<T>;\n\n /** Look up the value of a string [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a string.\n */\n getString(settingName: SettingName, defaultValue: string): string;\n getString(settingName: SettingName, defaultValue?: string): string | undefined;\n\n /** Look up the value of a boolean [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a boolean.\n */\n getBoolean(settingName: SettingName, defaultValue: boolean): boolean;\n getBoolean(settingName: SettingName, defaultValue?: boolean): boolean | undefined;\n\n /** Look up the value of a numeric [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not a number.\n */\n getNumber(settingName: SettingName, defaultValue: number): number;\n getNumber(settingName: SettingName): number | undefined;\n\n /** Look up the value of an object [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not an object.\n */\n getObject<T extends object>(settingName: SettingName, defaultValue: T): T;\n getObject<T extends object>(settingName: SettingName): T | undefined;\n\n /** Look up the value of an array [[Setting]] named `settingName`, returning `defaultValue` if no such value is defined.\n * @throws Error if the setting exists but is not an array.\n */\n getArray<T extends Setting>(settingName: SettingName, defaultValue: Array<T>): Array<T>;\n getArray<T extends Setting>(settingName: SettingName): Array<T> | undefined;\n}\n"]}
@@ -1,109 +1,30 @@
1
1
  /** @packageDocumentation
2
2
  * @module Workspace
3
3
  */
4
- import { Setting, SettingName, SettingsContainer, SettingsPriority } from "./Settings";
5
- import { CloudSqliteContainer, WorkspaceContainerId, WorkspaceDbName } from "./Workspace";
6
- import { _implementationProhibited } from "../internal/Symbols";
7
- /** Metadata stored inside a [[SettingsDb]] describing the database's contents, to help users understand
8
- * the purpose of the [[SettingsDb]] and who to contact with questions about it.
9
- * @note Only the `settingsName` field is required, and users may add additional fields for their own purposes.
10
- * @note Since the information is stored inside the [[SettingsDb]], it is versioned along with the rest of the contents.
11
- * @beta
4
+ import type { WorkspaceDb, WorkspaceDbName } from "./Workspace";
5
+ /**
6
+ * The fixed db name used by [[WorkspaceDb]]'s meant to hold settings.
7
+ * [[Workspace.loadSettingsDictionary]] will treat rows in the 'strings' table as setting dictionary entries when [[WorkspaceDbSettingsProps.dbName]] matches this value.
8
+ * @see [[Workspace.loadSettingsDictionary]]
9
+ * @internal
12
10
  */
13
- export interface SettingsDbManifest {
14
- /** The name of the [[SettingsDb]] to be shown in user interfaces. Organizations should attempt to make this name
15
- * informative enough so that users may refer to it in conversations.
16
- */
17
- readonly settingsName: string;
18
- /** A description of the contents of this [[SettingsDb]] to help users understand its purpose and appropriate usage. */
19
- readonly description?: string;
20
- /** The name of the person to contact with questions about this [[SettingsDb]]. */
21
- readonly contactName?: string;
22
- /** The name of the person who last modified this [[SettingsDb]]. */
23
- readonly lastEditedBy?: string;
24
- }
25
- /** Properties that specify how to load a [[SettingsDb]] within a [[CloudSqliteContainer]].
26
- * @beta
11
+ export declare const settingsWorkspaceDbName: WorkspaceDbName;
12
+ /** The db name type for the iTwin settings [[WorkspaceDb]].
13
+ * @internal
27
14
  */
28
- export interface SettingsDbProps {
29
- /** The base name of the [[SettingsDb]], without any version information. Default: `"settings-db"`. */
30
- readonly dbName?: WorkspaceDbName;
31
- /** The [semver](https://github.com/npm/node-semver) version string or range for the desired [[SettingsDb]].
32
- * If not specified, the latest available version is used.
33
- */
34
- readonly version?: string;
35
- }
36
- /** Arguments for obtaining a [[SettingsDb]] from a previously-loaded container.
37
- * @beta
15
+ export type SettingsDbName = typeof settingsWorkspaceDbName;
16
+ /** A [[WorkspaceDb]] whose name is the fixed iTwin settings db name.
17
+ * @internal
38
18
  */
39
- export interface GetSettingsDbArgs {
40
- /** The [[WorkspaceContainerId]] of the cloud container that holds the [[SettingsDb]].
41
- * This is an opaque GUID assigned by the BlobContainer service when the container is created — it is
42
- * **not** the same as an iTwinId or iModelId.
43
- */
44
- readonly containerId: WorkspaceContainerId;
45
- /** The priority to assign to dictionaries loaded from this [[SettingsDb]]. */
46
- readonly priority: SettingsPriority;
47
- /** The name of the [[SettingsDb]] to retrieve. Default: `"settings-db"`. */
48
- readonly dbName?: WorkspaceDbName;
49
- /** The semantic version string or range for the desired [[SettingsDb]].
50
- * If not specified, the latest available version is used.
51
- */
52
- readonly version?: string;
53
- }
54
- /** A CloudSQLite database dedicated to storing settings as key-value pairs. Unlike a general-purpose [[WorkspaceDb]],
55
- * a `SettingsDb` restricts its API surface to settings-only operations, providing a focused interface
56
- * for reading settings by name.
57
- *
58
- * Internally, all settings are stored in a single JSON blob. Each setting is a named entry in a [[SettingsContainer]].
59
- *
60
- * A `SettingsDb` resides in a [[CloudSqliteContainer]] and can be published to the cloud. Once published,
61
- * the `SettingsDb` becomes immutable; however, multiple versions may be created to allow settings to evolve over time.
62
- * @beta
19
+ export type SettingsDb = WorkspaceDb & {
20
+ readonly dbName: SettingsDbName;
21
+ };
22
+ /** Return true if a [[WorkspaceDb]] is a [[SettingsDb]].
23
+ * @internal
63
24
  */
64
- export interface SettingsDb {
65
- /** @internal */
66
- [_implementationProhibited]: unknown;
67
- /** The [[CloudSqliteContainer]] in which this database resides. */
68
- readonly container: CloudSqliteContainer;
69
- /** The base name of this SettingsDb, without version. */
70
- readonly dbName: string;
71
- /** The resolved [semver](https://github.com/npm/node-semver) version of this SettingsDb.
72
- * @note For local (non-cloud) containers, this property returns `"0.0.0"`.
73
- */
74
- readonly version: string;
75
- /** The priority assigned to dictionaries loaded from this SettingsDb. */
76
- readonly priority: SettingsPriority;
77
- /** Whether the underlying database is currently open. */
78
- readonly isOpen: boolean;
79
- /** The manifest describing the contents of this SettingsDb. */
80
- readonly manifest: SettingsDbManifest;
81
- /** Open the underlying database for querying. When performing significant activity against a SettingsDb,
82
- * open it before the operations and [[close]] it afterwards.
83
- * @note Explicit open/close is a performance optimization for batches of operations. Individual methods like
84
- * [[getSetting]] and [[getSettings]] will auto-open and auto-close the database if it is not already open.
85
- */
86
- open(): void;
87
- /** Close the underlying database. You should call this after [[open]]ing the database and completing your queries.
88
- * @note For [[EditableSettingsDb]] instances, if the container's write lock is currently held, closing persists
89
- * any pending changes and updates the manifest's `lastEditedBy` field with the current write lock holder.
90
- */
91
- close(): void;
92
- /** Return a copy of the value of the setting named `settingName`, or `undefined` if not found.
93
- * The returned value is always cloned using [[Setting.clone]].
94
- * @param settingName The name of the setting to retrieve.
95
- */
96
- getSetting<T extends Setting>(settingName: SettingName): T | undefined;
97
- /** Return a deep copy of all settings stored in this SettingsDb as a [[SettingsContainer]].
98
- * @note The returned object is a fresh copy — mutating it will not affect the stored settings.
99
- */
100
- getSettings(): SettingsContainer;
101
- }
102
- /** The default resource name used to store settings in a [[SettingsDb]].
103
- * This is the key under which all settings are stored in the SQLite `strings` table.
104
- * When loading settings at runtime via [[Workspace.loadSettingsDictionary]], the `resourceName` defaults
105
- * to this value, ensuring the read and write paths always agree on which key to use.
25
+ export declare function isSettingsDb(db: WorkspaceDb): db is SettingsDb;
26
+ /** Query all string resource names from a [[SettingsDb]].
106
27
  * @internal
107
28
  */
108
- export declare const settingsResourceName = "settings";
29
+ export declare function queryStringResourceNames(db: SettingsDb): WorkspaceDbName[];
109
30
  //# sourceMappingURL=SettingsDb.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsDb.d.ts","sourceRoot":"","sources":["../../../src/workspace/SettingsDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,uHAAuH;IACvH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,kFAAkF;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,QA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AO,MAAM,oBAAoB,aAAa,CAAC"}
1
+ {"version":3,"file":"SettingsDb.d.ts","sourceRoot":"","sources":["../../../src/workspace/SettingsDb.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,EAAE,eAA+B,CAAC;AAEtE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,uBAAuB,CAAC;AAE5D;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC;AAE3E;;GAEG;AACH,wBAAgB,YAAY,CAAC,EAAE,EAAE,WAAW,GAAG,EAAE,IAAI,UAAU,CAE9D;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,UAAU,GAAG,eAAe,EAAE,CAI1E"}
@@ -5,12 +5,26 @@
5
5
  /** @packageDocumentation
6
6
  * @module Workspace
7
7
  */
8
- import { _implementationProhibited } from "../internal/Symbols";
9
- /** The default resource name used to store settings in a [[SettingsDb]].
10
- * This is the key under which all settings are stored in the SQLite `strings` table.
11
- * When loading settings at runtime via [[Workspace.loadSettingsDictionary]], the `resourceName` defaults
12
- * to this value, ensuring the read and write paths always agree on which key to use.
8
+ /**
9
+ * The fixed db name used by [[WorkspaceDb]]'s meant to hold settings.
10
+ * [[Workspace.loadSettingsDictionary]] will treat rows in the 'strings' table as setting dictionary entries when [[WorkspaceDbSettingsProps.dbName]] matches this value.
11
+ * @see [[Workspace.loadSettingsDictionary]]
13
12
  * @internal
14
13
  */
15
- export const settingsResourceName = "settings";
14
+ export const settingsWorkspaceDbName = "settings-db";
15
+ /** Return true if a [[WorkspaceDb]] is a [[SettingsDb]].
16
+ * @internal
17
+ */
18
+ export function isSettingsDb(db) {
19
+ return db.dbName === settingsWorkspaceDbName;
20
+ }
21
+ /** Query all string resource names from a [[SettingsDb]].
22
+ * @internal
23
+ */
24
+ export function queryStringResourceNames(db) {
25
+ const resourceNames = [];
26
+ db.queryResources({ type: "string", callback: (names) => { for (const n of names)
27
+ resourceNames.push(n); } });
28
+ return resourceNames;
29
+ }
16
30
  //# sourceMappingURL=SettingsDb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsDb.js","sourceRoot":"","sources":["../../../src/workspace/SettingsDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AAyGhE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Workspace\n */\n\nimport { Setting, SettingName, SettingsContainer, SettingsPriority } from \"./Settings\";\nimport { CloudSqliteContainer, WorkspaceContainerId, WorkspaceDbName } from \"./Workspace\";\nimport { _implementationProhibited } from \"../internal/Symbols\";\n\n/** Metadata stored inside a [[SettingsDb]] describing the database's contents, to help users understand\n * the purpose of the [[SettingsDb]] and who to contact with questions about it.\n * @note Only the `settingsName` field is required, and users may add additional fields for their own purposes.\n * @note Since the information is stored inside the [[SettingsDb]], it is versioned along with the rest of the contents.\n * @beta\n */\nexport interface SettingsDbManifest {\n /** The name of the [[SettingsDb]] to be shown in user interfaces. Organizations should attempt to make this name\n * informative enough so that users may refer to it in conversations.\n */\n readonly settingsName: string;\n /** A description of the contents of this [[SettingsDb]] to help users understand its purpose and appropriate usage. */\n readonly description?: string;\n /** The name of the person to contact with questions about this [[SettingsDb]]. */\n readonly contactName?: string;\n /** The name of the person who last modified this [[SettingsDb]]. */\n readonly lastEditedBy?: string;\n}\n\n/** Properties that specify how to load a [[SettingsDb]] within a [[CloudSqliteContainer]].\n * @beta\n */\nexport interface SettingsDbProps {\n /** The base name of the [[SettingsDb]], without any version information. Default: `\"settings-db\"`. */\n readonly dbName?: WorkspaceDbName;\n /** The [semver](https://github.com/npm/node-semver) version string or range for the desired [[SettingsDb]].\n * If not specified, the latest available version is used.\n */\n readonly version?: string;\n}\n\n/** Arguments for obtaining a [[SettingsDb]] from a previously-loaded container.\n * @beta\n */\nexport interface GetSettingsDbArgs {\n /** The [[WorkspaceContainerId]] of the cloud container that holds the [[SettingsDb]].\n * This is an opaque GUID assigned by the BlobContainer service when the container is created — it is\n * **not** the same as an iTwinId or iModelId.\n */\n readonly containerId: WorkspaceContainerId;\n /** The priority to assign to dictionaries loaded from this [[SettingsDb]]. */\n readonly priority: SettingsPriority;\n /** The name of the [[SettingsDb]] to retrieve. Default: `\"settings-db\"`. */\n readonly dbName?: WorkspaceDbName;\n /** The semantic version string or range for the desired [[SettingsDb]].\n * If not specified, the latest available version is used.\n */\n readonly version?: string;\n}\n\n/** A CloudSQLite database dedicated to storing settings as key-value pairs. Unlike a general-purpose [[WorkspaceDb]],\n * a `SettingsDb` restricts its API surface to settings-only operations, providing a focused interface\n * for reading settings by name.\n *\n * Internally, all settings are stored in a single JSON blob. Each setting is a named entry in a [[SettingsContainer]].\n *\n * A `SettingsDb` resides in a [[CloudSqliteContainer]] and can be published to the cloud. Once published,\n * the `SettingsDb` becomes immutable; however, multiple versions may be created to allow settings to evolve over time.\n * @beta\n */\nexport interface SettingsDb {\n /** @internal */\n [_implementationProhibited]: unknown;\n /** The [[CloudSqliteContainer]] in which this database resides. */\n readonly container: CloudSqliteContainer;\n /** The base name of this SettingsDb, without version. */\n readonly dbName: string;\n /** The resolved [semver](https://github.com/npm/node-semver) version of this SettingsDb.\n * @note For local (non-cloud) containers, this property returns `\"0.0.0\"`.\n */\n readonly version: string;\n /** The priority assigned to dictionaries loaded from this SettingsDb. */\n readonly priority: SettingsPriority;\n /** Whether the underlying database is currently open. */\n readonly isOpen: boolean;\n /** The manifest describing the contents of this SettingsDb. */\n readonly manifest: SettingsDbManifest;\n\n /** Open the underlying database for querying. When performing significant activity against a SettingsDb,\n * open it before the operations and [[close]] it afterwards.\n * @note Explicit open/close is a performance optimization for batches of operations. Individual methods like\n * [[getSetting]] and [[getSettings]] will auto-open and auto-close the database if it is not already open.\n */\n open(): void;\n\n /** Close the underlying database. You should call this after [[open]]ing the database and completing your queries.\n * @note For [[EditableSettingsDb]] instances, if the container's write lock is currently held, closing persists\n * any pending changes and updates the manifest's `lastEditedBy` field with the current write lock holder.\n */\n close(): void;\n\n /** Return a copy of the value of the setting named `settingName`, or `undefined` if not found.\n * The returned value is always cloned using [[Setting.clone]].\n * @param settingName The name of the setting to retrieve.\n */\n getSetting<T extends Setting>(settingName: SettingName): T | undefined;\n\n /** Return a deep copy of all settings stored in this SettingsDb as a [[SettingsContainer]].\n * @note The returned object is a fresh copy — mutating it will not affect the stored settings.\n */\n getSettings(): SettingsContainer;\n}\n\n/** The default resource name used to store settings in a [[SettingsDb]].\n * This is the key under which all settings are stored in the SQLite `strings` table.\n * When loading settings at runtime via [[Workspace.loadSettingsDictionary]], the `resourceName` defaults\n * to this value, ensuring the read and write paths always agree on which key to use.\n * @internal\n */\nexport const settingsResourceName = \"settings\";\n"]}
1
+ {"version":3,"file":"SettingsDb.js","sourceRoot":"","sources":["../../../src/workspace/SettingsDb.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAoB,aAAa,CAAC;AAYtE;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,EAAe;IAC1C,OAAO,EAAE,CAAC,MAAM,KAAK,uBAAuB,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAC,EAAc;IACrD,MAAM,aAAa,GAAa,EAAE,CAAC;IACnC,EAAE,CAAC,cAAc,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,GAAG,KAAK,MAAM,CAAC,IAAI,KAAK;YAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC9G,OAAO,aAAa,CAAC;AACvB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Workspace\n */\n\nimport type { WorkspaceDb, WorkspaceDbName } from \"./Workspace\";\n\n/**\n * The fixed db name used by [[WorkspaceDb]]'s meant to hold settings.\n * [[Workspace.loadSettingsDictionary]] will treat rows in the 'strings' table as setting dictionary entries when [[WorkspaceDbSettingsProps.dbName]] matches this value.\n * @see [[Workspace.loadSettingsDictionary]]\n * @internal\n */\nexport const settingsWorkspaceDbName: WorkspaceDbName = \"settings-db\";\n\n/** The db name type for the iTwin settings [[WorkspaceDb]].\n * @internal\n */\nexport type SettingsDbName = typeof settingsWorkspaceDbName;\n\n/** A [[WorkspaceDb]] whose name is the fixed iTwin settings db name.\n * @internal\n */\nexport type SettingsDb = WorkspaceDb & { readonly dbName: SettingsDbName };\n\n/** Return true if a [[WorkspaceDb]] is a [[SettingsDb]].\n * @internal\n */\nexport function isSettingsDb(db: WorkspaceDb): db is SettingsDb {\n return db.dbName === settingsWorkspaceDbName;\n}\n\n/** Query all string resource names from a [[SettingsDb]].\n * @internal\n */\nexport function queryStringResourceNames(db: SettingsDb): WorkspaceDbName[] {\n const resourceNames: string[] = [];\n db.queryResources({ type: \"string\", callback: (names) => { for (const n of names) resourceNames.push(n); } });\n return resourceNames;\n}\n"]}