@itwin/core-backend 4.6.0-dev.16 → 4.6.0-dev.18

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.
@@ -46,11 +46,6 @@ export declare class SettingsSchemas {
46
46
  static readonly allSchemas: Map<string, SettingSchema>;
47
47
  /** event that signals that the values in [[allSchemas]] have changed in some way. */
48
48
  static readonly onSchemaChanged: BeEvent<() => void>;
49
- /** Clear the contents of the registry and remove all event listeners.
50
- * @note This is really only necessary for tests of the Settings system.
51
- * @internal
52
- */
53
- static reset(): void;
54
49
  /** @internal */
55
50
  static validateArrayObject<T>(val: T, schemaName: string, msg: string): T;
56
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsSchemas.d.ts","sourceRoot":"","sources":["../../../src/workspace/SettingsSchemas.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAkB,kBAAkB,EAAW,MAAM,qBAAqB,CAAC;AACvG,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGjE;;;;;;GAMG;AACH,MAAM,WAAW,aAAc,SAAQ,QAAQ,CAAC,UAAU,CAAC;IACzD,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;IAClC,QAAQ,CAAC,UAAU,CAAC,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAC;IAExD,oGAAoG;IACpG,QAAQ,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAAA;KAAE,CAAC;IACvD,QAAQ,CAAC,KAAK,CAAC,EAA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AG,IAAI;IAQtF,2DAA2D;WAC7C,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAIlD,sDAAsD;WACxC,OAAO,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI;IAQpD,2FAA2F;WAC7E,YAAY,CAAC,OAAO,EAAE,YAAY;IAQhD,oEAAoE;WACtD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAKlD,OAAO,CAAC,MAAM,CAAC,KAAK;IAWpB,OAAO,CAAC,MAAM,CAAC,QAAQ;IASvB,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IA+C/B,OAAO,CAAC,MAAM,CAAC,cAAc;IAc7B,OAAO,CAAC,MAAM,CAAC,eAAe;CAkB/B"}
@@ -20,15 +20,6 @@ const IModelJsFs_1 = require("../IModelJsFs");
20
20
  */
21
21
  class SettingsSchemas {
22
22
  constructor() { } // singleton
23
- /** Clear the contents of the registry and remove all event listeners.
24
- * @note This is really only necessary for tests of the Settings system.
25
- * @internal
26
- */
27
- static reset() {
28
- this._allGroups.clear();
29
- this.allSchemas.clear();
30
- this.onSchemaChanged.clear();
31
- }
32
23
  /** @internal */
33
24
  static validateArrayObject(val, schemaName, msg) {
34
25
  const schema = this.allSchemas.get(schemaName);
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsSchemas.js","sourceRoot":"","sources":["../../../src/workspace/SettingsSchemas.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAAuG;AAEvG,8CAA2C;AAgC3C;;;;GAIG;AACH,MAAa,eAAe;IAC1B,gBAAwB,CAAC,CAAC,YAAY;IAOtC;;;OAGG;IACI,MAAM,CAAC,KAAK;QACjB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QACxB,I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AAC,UAAU,CAAC,EAAE;YACzC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;YACvB,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5C,MAAM,QAAQ,GAA2B,UAAU,CAAC,GAAG,CAAC,CAAC;YACzD,QAAQ,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,IAAI,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;YAC3E,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;SACpC;IACH,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,IAA+C;QAC5E,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5C,QAAQ,IAAI,EAAE;YACZ,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO;gBACV,OAAO,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,SAAS,CAAC;SACpB;IACH,CAAC;;AAxLuB,0BAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC3E,iDAAiD;AAC1B,0BAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;AACrE,qFAAqF;AAC9D,+BAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AANxD,0CAAe","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Workspace\r\n */\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport { parse } from \"json5\";\r\nimport { extname, join } from \"path\";\r\nimport { BeEvent, JSONSchema, JSONSchemaType, JSONSchemaTypeName, Mutable } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsFs } from \"../IModelJsFs\";\r\n\r\n/**\r\n * The properties of a single Setting, used by the settings editor. This interface also includes the\r\n * default value if it is not specified in any Settings file.\r\n * This interface includes all members of [JSONSchema]($bentley) with the extensions added by VSCode.\r\n * @note the `type` member is marked optional in JSONSchema but is required for Settings.\r\n * @beta\r\n */\r\nexport interface SettingSchema extends Readonly<JSONSchema> {\r\n readonly items?: SettingSchema; // must be single object, not array\r\n readonly type: JSONSchemaTypeName; // type is required for settings\r\n readonly properties?: { [name: string]: SettingSchema };\r\n\r\n /** whether the setting replaces lower priority entries with the same name or combines with them. */\r\n readonly cumulative?: true;\r\n}\r\n\r\n/**\r\n * The properties of a group of [[SettingSchema]]s for an application. Groups can be added and removed from [[SettingsSchemas]]\r\n * and are identified by their (required) `groupName` member\r\n * @beta\r\n */\r\nexport interface SettingSchemaGroup {\r\n readonly groupName: string;\r\n readonly properties: { [name: string]: SettingSchema };\r\n readonly order?: number;\r\n readonly title?: string;\r\n readonly description?: string;\r\n readonly extensionId?: string;\r\n}\r\n\r\n/**\r\n * The registry of available [[SettingSchemaGroup]]s.\r\n * The registry is used for editing Settings files and for finding default values for settings.\r\n * @beta\r\n */\r\nexport class SettingsSchemas {\r\n private constructor() { } // singleton\r\n private static readonly _allGroups = new Map<string, SettingSchemaGroup>();\r\n /** a map of all registered [[SettingSchema]]s */\r\n public static readonly allSchemas = new Map<string, SettingSchema>();\r\n /** event that signals that the values in [[allSchemas]] have changed in some way. */\r\n public static readonly onSchemaChanged = new BeEvent<() => void>();\r\n\r\n /** Clear the contents of the registry and remove all event listeners.\r\n * @note This is really only necessary for tests of the Settings system.\r\n * @internal\r\n */\r\n public static reset() {\r\n this._allGroups.clear();\r\n this.allSchemas.clear();\r\n this.onSchemaChanged.clear();\r\n }\r\n\r\n /** @internal */\r\n public static validateArrayObject<T>(val: T, schemaName: string, msg: string): T {\r\n const schema = this.allSchemas.get(schemaName);\r\n const items = schema?.items;\r\n if (undefined === items)\r\n return val;\r\n const required = items.required;\r\n const properties = items.properties;\r\n if (undefined === required || undefined === properties)\r\n return val;\r\n\r\n for (const entry of required) {\r\n const entryType = properties[entry].type;\r\n const value = (val as any)[entry];\r\n if (entryType === \"array\" && Array.isArray(value))\r\n continue;\r\n if (typeof value !== entryType)\r\n throw new Error(`invalid \"${schemaName}\" setting entry for \"${msg}\": ${entry} is ${value}`);\r\n }\r\n return val;\r\n }\r\n\r\n /**\r\n * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `groupName` member that is used\r\n * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.\r\n */\r\n public static addGroup(settingsGroup: SettingSchemaGroup | SettingSchemaGroup[]): void {\r\n if (!Array.isArray(settingsGroup))\r\n settingsGroup = [settingsGroup];\r\n\r\n this.doAdd(settingsGroup);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from stringified json5. */\r\n public static addJson(settingSchema: string): void {\r\n this.addGroup(parse(settingSchema));\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from a json5 file. */\r\n public static addFile(fileName: LocalFileName): void {\r\n try {\r\n this.addJson(fs.readFileSync(fileName, \"utf-8\"));\r\n } catch (e: any) {\r\n throw new Error(`parsing SettingSchema file \"${fileName}\": ${e.message}\"`);\r\n }\r\n }\r\n\r\n /** Add all files with a either \".json\" or \".json5\" extension from a supplied directory. */\r\n public static addDirectory(dirName: LocalDirName) {\r\n for (const fileName of IModelJsFs.readdirSync(dirName)) {\r\n const ext = extname(fileName);\r\n if (ext === \".json5\" || ext === \".json\")\r\n this.addFile(join(dirName, fileName));\r\n }\r\n }\r\n\r\n /** Remove a previously added [[SettingSchemaGroup]] by groupName */\r\n public static removeGroup(groupName: string): void {\r\n this.doRemove(groupName);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n private static doAdd(settingsGroup: SettingSchemaGroup[]) {\r\n settingsGroup.forEach((group) => {\r\n if (undefined === group.groupName)\r\n throw new Error(`settings group has no \"groupName\" member`);\r\n\r\n this.doRemove(group.groupName);\r\n this.validateAndAdd(group);\r\n this._allGroups.set(group.groupName, group);\r\n });\r\n }\r\n\r\n private static doRemove(groupName: string) {\r\n const group = this._allGroups.get(groupName);\r\n if (undefined !== group?.properties) {\r\n for (const key of Object.keys(group.properties))\r\n this.allSchemas.delete(key);\r\n }\r\n this._allGroups.delete(groupName);\r\n }\r\n\r\n private static validateName(name: string) {\r\n if (!name.trim())\r\n throw new Error(`empty property name`);\r\n if (this.allSchemas.has(name))\r\n throw new Error(`property \"${name}\" is already defined`);\r\n }\r\n\r\n private static validateProperty(name: string, property: SettingSchema | undefined) {\r\n if (!property)\r\n throw new Error(`missing required property ${name}`);\r\n\r\n if (!property.type)\r\n throw new Error(`property ${name} has no type`);\r\n\r\n switch (property.type) {\r\n case \"boolean\":\r\n case \"integer\":\r\n case \"null\":\r\n case \"number\":\r\n case \"string\":\r\n return;\r\n\r\n case \"object\":\r\n const required = property.required;\r\n const props = property.properties;\r\n if (required && props) {\r\n for (const entry of required)\r\n this.validateProperty(entry, props[entry]);\r\n }\r\n if (props) {\r\n for (const key of Object.keys(props))\r\n try {\r\n this.validateProperty(key, props[key]);\r\n } catch (e: any) {\r\n throw new Error(`property ${key} of ${name}: ${e.message}`);\r\n }\r\n }\r\n return;\r\n\r\n case \"array\":\r\n if (typeof property.items !== \"object\")\r\n throw new Error(`array property ${name} has no items member`);\r\n try {\r\n this.validateProperty(\"items\", property.items);\r\n } catch (e: any) {\r\n throw new Error(`array property ${name}: ${e.message}`);\r\n }\r\n return;\r\n\r\n default:\r\n throw new Error(`property ${name} has illegal type \"${property.type}\"`);\r\n }\r\n }\r\n\r\n private static validateAndAdd(group: SettingSchemaGroup) {\r\n const properties = group.properties;\r\n if (undefined === properties)\r\n throw new Error(`group ${group.groupName} has no properties`);\r\n\r\n for (const key of Object.keys(properties)) {\r\n this.validateName(key);\r\n this.validateProperty(key, properties[key]);\r\n const property: Mutable<SettingSchema> = properties[key];\r\n property.default = property.default ?? this.getDefaultValue(property.type);\r\n this.allSchemas.set(key, property);\r\n }\r\n }\r\n\r\n private static getDefaultValue(type: JSONSchemaTypeName | JSONSchemaTypeName[]): JSONSchemaType | undefined {\r\n type = Array.isArray(type) ? type[0] : type;\r\n switch (type) {\r\n case \"boolean\":\r\n return false;\r\n case \"integer\":\r\n case \"number\":\r\n return 0;\r\n case \"string\":\r\n return \"\";\r\n case \"array\":\r\n return [];\r\n case \"object\":\r\n return {};\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SettingsSchemas.js","sourceRoot":"","sources":["../../../src/workspace/SettingsSchemas.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,iCAA8B;AAC9B,+BAAqC;AACrC,sDAAuG;AAEvG,8CAA2C;AAgC3C;;;;GAIG;AACH,MAAa,eAAe;IAC1B,gBAAwB,CAAC,CAAC,YAAY;IAOtC,gBAAgB;IACT,MAAM,CAAC,mBAAmB,CAAI,GAAM,EAAE,UAAkB,EAAE,GAAW;QAC1E,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;QAC5B,IAAI,SAAS,KAAK,KAAK;YACrB,OAAO,GAAG,CAAC;QACb,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAChC,MAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC;QACpC,IAAI,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,UAAU;YAC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KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QAC5C,QAAQ,IAAI,EAAE;YACZ,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC;YACf,KAAK,SAAS,CAAC;YACf,KAAK,QAAQ;gBACX,OAAO,CAAC,CAAC;YACX,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ,KAAK,OAAO;gBACV,OAAO,EAAE,CAAC;YACZ,KAAK,QAAQ;gBACX,OAAO,EAAE,CAAC;YACZ;gBACE,OAAO,SAAS,CAAC;SACpB;IACH,CAAC;;AA9KuB,0BAAU,GAAG,IAAI,GAAG,EAA8B,CAAC;AAC3E,iDAAiD;AAC1B,0BAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;AACrE,qFAAqF;AAC9D,+BAAe,GAAG,IAAI,sBAAO,EAAc,CAAC;AANxD,0CAAe","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Workspace\r\n */\r\n\r\nimport * as fs from \"fs-extra\";\r\nimport { parse } from \"json5\";\r\nimport { extname, join } from \"path\";\r\nimport { BeEvent, JSONSchema, JSONSchemaType, JSONSchemaTypeName, Mutable } from \"@itwin/core-bentley\";\r\nimport { LocalDirName, LocalFileName } from \"@itwin/core-common\";\r\nimport { IModelJsFs } from \"../IModelJsFs\";\r\n\r\n/**\r\n * The properties of a single Setting, used by the settings editor. This interface also includes the\r\n * default value if it is not specified in any Settings file.\r\n * This interface includes all members of [JSONSchema]($bentley) with the extensions added by VSCode.\r\n * @note the `type` member is marked optional in JSONSchema but is required for Settings.\r\n * @beta\r\n */\r\nexport interface SettingSchema extends Readonly<JSONSchema> {\r\n readonly items?: SettingSchema; // must be single object, not array\r\n readonly type: JSONSchemaTypeName; // type is required for settings\r\n readonly properties?: { [name: string]: SettingSchema };\r\n\r\n /** whether the setting replaces lower priority entries with the same name or combines with them. */\r\n readonly cumulative?: true;\r\n}\r\n\r\n/**\r\n * The properties of a group of [[SettingSchema]]s for an application. Groups can be added and removed from [[SettingsSchemas]]\r\n * and are identified by their (required) `groupName` member\r\n * @beta\r\n */\r\nexport interface SettingSchemaGroup {\r\n readonly groupName: string;\r\n readonly properties: { [name: string]: SettingSchema };\r\n readonly order?: number;\r\n readonly title?: string;\r\n readonly description?: string;\r\n readonly extensionId?: string;\r\n}\r\n\r\n/**\r\n * The registry of available [[SettingSchemaGroup]]s.\r\n * The registry is used for editing Settings files and for finding default values for settings.\r\n * @beta\r\n */\r\nexport class SettingsSchemas {\r\n private constructor() { } // singleton\r\n private static readonly _allGroups = new Map<string, SettingSchemaGroup>();\r\n /** a map of all registered [[SettingSchema]]s */\r\n public static readonly allSchemas = new Map<string, SettingSchema>();\r\n /** event that signals that the values in [[allSchemas]] have changed in some way. */\r\n public static readonly onSchemaChanged = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static validateArrayObject<T>(val: T, schemaName: string, msg: string): T {\r\n const schema = this.allSchemas.get(schemaName);\r\n const items = schema?.items;\r\n if (undefined === items)\r\n return val;\r\n const required = items.required;\r\n const properties = items.properties;\r\n if (undefined === required || undefined === properties)\r\n return val;\r\n\r\n for (const entry of required) {\r\n const entryType = properties[entry].type;\r\n const value = (val as any)[entry];\r\n if (entryType === \"array\" && Array.isArray(value))\r\n continue;\r\n if (typeof value !== entryType)\r\n throw new Error(`invalid \"${schemaName}\" setting entry for \"${msg}\": ${entry} is ${value}`);\r\n }\r\n return val;\r\n }\r\n\r\n /**\r\n * Add one or more [[SettingSchemaGroup]]s. `SettingSchemaGroup`s must include a `groupName` member that is used\r\n * to identify the group. If a group with the same name is already registered, the old values are first removed and then the new group is added.\r\n */\r\n public static addGroup(settingsGroup: SettingSchemaGroup | SettingSchemaGroup[]): void {\r\n if (!Array.isArray(settingsGroup))\r\n settingsGroup = [settingsGroup];\r\n\r\n this.doAdd(settingsGroup);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from stringified json5. */\r\n public static addJson(settingSchema: string): void {\r\n this.addGroup(parse(settingSchema));\r\n }\r\n\r\n /** Add a [[SettingSchemaGroup]] from a json5 file. */\r\n public static addFile(fileName: LocalFileName): void {\r\n try {\r\n this.addJson(fs.readFileSync(fileName, \"utf-8\"));\r\n } catch (e: any) {\r\n throw new Error(`parsing SettingSchema file \"${fileName}\": ${e.message}\"`);\r\n }\r\n }\r\n\r\n /** Add all files with a either \".json\" or \".json5\" extension from a supplied directory. */\r\n public static addDirectory(dirName: LocalDirName) {\r\n for (const fileName of IModelJsFs.readdirSync(dirName)) {\r\n const ext = extname(fileName);\r\n if (ext === \".json5\" || ext === \".json\")\r\n this.addFile(join(dirName, fileName));\r\n }\r\n }\r\n\r\n /** Remove a previously added [[SettingSchemaGroup]] by groupName */\r\n public static removeGroup(groupName: string): void {\r\n this.doRemove(groupName);\r\n this.onSchemaChanged.raiseEvent();\r\n }\r\n\r\n private static doAdd(settingsGroup: SettingSchemaGroup[]) {\r\n settingsGroup.forEach((group) => {\r\n if (undefined === group.groupName)\r\n throw new Error(`settings group has no \"groupName\" member`);\r\n\r\n this.doRemove(group.groupName);\r\n this.validateAndAdd(group);\r\n this._allGroups.set(group.groupName, group);\r\n });\r\n }\r\n\r\n private static doRemove(groupName: string) {\r\n const group = this._allGroups.get(groupName);\r\n if (undefined !== group?.properties) {\r\n for (const key of Object.keys(group.properties))\r\n this.allSchemas.delete(key);\r\n }\r\n this._allGroups.delete(groupName);\r\n }\r\n\r\n private static validateName(name: string) {\r\n if (!name.trim())\r\n throw new Error(`empty property name`);\r\n if (this.allSchemas.has(name))\r\n throw new Error(`property \"${name}\" is already defined`);\r\n }\r\n\r\n private static validateProperty(name: string, property: SettingSchema | undefined) {\r\n if (!property)\r\n throw new Error(`missing required property ${name}`);\r\n\r\n if (!property.type)\r\n throw new Error(`property ${name} has no type`);\r\n\r\n switch (property.type) {\r\n case \"boolean\":\r\n case \"integer\":\r\n case \"null\":\r\n case \"number\":\r\n case \"string\":\r\n return;\r\n\r\n case \"object\":\r\n const required = property.required;\r\n const props = property.properties;\r\n if (required && props) {\r\n for (const entry of required)\r\n this.validateProperty(entry, props[entry]);\r\n }\r\n if (props) {\r\n for (const key of Object.keys(props))\r\n try {\r\n this.validateProperty(key, props[key]);\r\n } catch (e: any) {\r\n throw new Error(`property ${key} of ${name}: ${e.message}`);\r\n }\r\n }\r\n return;\r\n\r\n case \"array\":\r\n if (typeof property.items !== \"object\")\r\n throw new Error(`array property ${name} has no items member`);\r\n try {\r\n this.validateProperty(\"items\", property.items);\r\n } catch (e: any) {\r\n throw new Error(`array property ${name}: ${e.message}`);\r\n }\r\n return;\r\n\r\n default:\r\n throw new Error(`property ${name} has illegal type \"${property.type}\"`);\r\n }\r\n }\r\n\r\n private static validateAndAdd(group: SettingSchemaGroup) {\r\n const properties = group.properties;\r\n if (undefined === properties)\r\n throw new Error(`group ${group.groupName} has no properties`);\r\n\r\n for (const key of Object.keys(properties)) {\r\n this.validateName(key);\r\n this.validateProperty(key, properties[key]);\r\n const property: Mutable<SettingSchema> = properties[key];\r\n property.default = property.default ?? this.getDefaultValue(property.type);\r\n this.allSchemas.set(key, property);\r\n }\r\n }\r\n\r\n private static getDefaultValue(type: JSONSchemaTypeName | JSONSchemaTypeName[]): JSONSchemaType | undefined {\r\n type = Array.isArray(type) ? type[0] : type;\r\n switch (type) {\r\n case \"boolean\":\r\n return false;\r\n case \"integer\":\r\n case \"number\":\r\n return 0;\r\n case \"string\":\r\n return \"\";\r\n case \"array\":\r\n return [];\r\n case \"object\":\r\n return {};\r\n default:\r\n return undefined;\r\n }\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-backend",
3
- "version": "4.6.0-dev.16",
3
+ "version": "4.6.0-dev.18",
4
4
  "description": "iTwin.js backend components",
5
5
  "main": "lib/cjs/core-backend.js",
6
6
  "typings": "lib/cjs/core-backend",
@@ -25,9 +25,9 @@
25
25
  "url": "http://www.bentley.com"
26
26
  },
27
27
  "peerDependencies": {
28
- "@itwin/core-bentley": "^4.6.0-dev.16",
29
- "@itwin/core-common": "^4.6.0-dev.16",
30
- "@itwin/core-geometry": "^4.6.0-dev.16",
28
+ "@itwin/core-bentley": "^4.6.0-dev.18",
29
+ "@itwin/core-common": "^4.6.0-dev.18",
30
+ "@itwin/core-geometry": "^4.6.0-dev.18",
31
31
  "@opentelemetry/api": "^1.0.4"
32
32
  },
33
33
  "peerDependenciesMeta": {
@@ -69,16 +69,16 @@
69
69
  "ts-node": "^10.8.2",
70
70
  "typescript": "~5.0.2",
71
71
  "webpack": "^5.76.0",
72
- "@itwin/build-tools": "4.6.0-dev.16",
73
- "@itwin/core-bentley": "4.6.0-dev.16",
74
- "@itwin/core-geometry": "4.6.0-dev.16",
75
- "@itwin/core-common": "4.6.0-dev.16",
76
- "@itwin/ecsql-common": "4.6.0-dev.16",
77
- "@itwin/core-webpack-tools": "4.6.0-dev.16",
78
- "internal-tools": "3.0.0-dev.69"
72
+ "@itwin/build-tools": "4.6.0-dev.18",
73
+ "@itwin/core-bentley": "4.6.0-dev.18",
74
+ "@itwin/core-common": "4.6.0-dev.18",
75
+ "@itwin/core-geometry": "4.6.0-dev.18",
76
+ "internal-tools": "3.0.0-dev.69",
77
+ "@itwin/ecsql-common": "4.6.0-dev.18",
78
+ "@itwin/core-webpack-tools": "4.6.0-dev.18"
79
79
  },
80
80
  "dependencies": {
81
- "@bentley/imodeljs-native": "4.6.15",
81
+ "@bentley/imodeljs-native": "4.6.21",
82
82
  "@itwin/cloud-agnostic-core": "^2.1.0",
83
83
  "@itwin/object-storage-azure": "^2.2.2",
84
84
  "@itwin/object-storage-core": "^2.2.2",
@@ -91,7 +91,7 @@
91
91
  "semver": "^7.3.5",
92
92
  "touch": "^3.1.0",
93
93
  "ws": "^7.5.3",
94
- "@itwin/core-telemetry": "4.6.0-dev.16"
94
+ "@itwin/core-telemetry": "4.6.0-dev.18"
95
95
  },
96
96
  "nyc": {
97
97
  "extends": "./node_modules/@itwin/build-tools/.nycrc"