@itwin/core-backend 5.0.0-dev.106 → 5.0.0-dev.109

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 (99) hide show
  1. package/lib/cjs/CatalogDb.d.ts +103 -0
  2. package/lib/cjs/CatalogDb.d.ts.map +1 -0
  3. package/lib/cjs/CatalogDb.js +271 -0
  4. package/lib/cjs/CatalogDb.js.map +1 -0
  5. package/lib/cjs/CloudSqlite.d.ts +104 -20
  6. package/lib/cjs/CloudSqlite.d.ts.map +1 -1
  7. package/lib/cjs/CloudSqlite.js +157 -46
  8. package/lib/cjs/CloudSqlite.js.map +1 -1
  9. package/lib/cjs/ECSchemaXmlContext.d.ts +1 -1
  10. package/lib/cjs/ECSchemaXmlContext.js +1 -1
  11. package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
  12. package/lib/cjs/Entity.d.ts +8 -4
  13. package/lib/cjs/Entity.d.ts.map +1 -1
  14. package/lib/cjs/Entity.js +3 -3
  15. package/lib/cjs/Entity.js.map +1 -1
  16. package/lib/cjs/IModelDb.d.ts +6 -1
  17. package/lib/cjs/IModelDb.d.ts.map +1 -1
  18. package/lib/cjs/IModelDb.js +14 -7
  19. package/lib/cjs/IModelDb.js.map +1 -1
  20. package/lib/cjs/IModelHost.d.ts +1 -1
  21. package/lib/cjs/IModelHost.js +1 -1
  22. package/lib/cjs/IModelHost.js.map +1 -1
  23. package/lib/cjs/NativeHost.d.ts.map +1 -1
  24. package/lib/cjs/NativeHost.js +4 -1
  25. package/lib/cjs/NativeHost.js.map +1 -1
  26. package/lib/cjs/SQLiteDb.d.ts.map +1 -1
  27. package/lib/cjs/SQLiteDb.js +5 -4
  28. package/lib/cjs/SQLiteDb.js.map +1 -1
  29. package/lib/cjs/ViewStore.d.ts.map +1 -1
  30. package/lib/cjs/ViewStore.js +27 -27
  31. package/lib/cjs/ViewStore.js.map +1 -1
  32. package/lib/cjs/core-backend.d.ts +1 -0
  33. package/lib/cjs/core-backend.d.ts.map +1 -1
  34. package/lib/cjs/core-backend.js +1 -0
  35. package/lib/cjs/core-backend.js.map +1 -1
  36. package/lib/cjs/internal/ChannelAdmin.js +4 -4
  37. package/lib/cjs/internal/ChannelAdmin.js.map +1 -1
  38. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts +2 -16
  39. package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  40. package/lib/cjs/internal/workspace/WorkspaceImpl.js +35 -104
  41. package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
  42. package/lib/cjs/workspace/Workspace.d.ts +6 -13
  43. package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
  44. package/lib/cjs/workspace/Workspace.js.map +1 -1
  45. package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -7
  46. package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
  47. package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
  48. package/lib/esm/CatalogDb.d.ts +103 -0
  49. package/lib/esm/CatalogDb.d.ts.map +1 -0
  50. package/lib/esm/CatalogDb.js +267 -0
  51. package/lib/esm/CatalogDb.js.map +1 -0
  52. package/lib/esm/CloudSqlite.d.ts +104 -20
  53. package/lib/esm/CloudSqlite.d.ts.map +1 -1
  54. package/lib/esm/CloudSqlite.js +157 -46
  55. package/lib/esm/CloudSqlite.js.map +1 -1
  56. package/lib/esm/ECSchemaXmlContext.d.ts +1 -1
  57. package/lib/esm/ECSchemaXmlContext.js +1 -1
  58. package/lib/esm/ECSchemaXmlContext.js.map +1 -1
  59. package/lib/esm/Entity.d.ts +8 -4
  60. package/lib/esm/Entity.d.ts.map +1 -1
  61. package/lib/esm/Entity.js +3 -3
  62. package/lib/esm/Entity.js.map +1 -1
  63. package/lib/esm/IModelDb.d.ts +6 -1
  64. package/lib/esm/IModelDb.d.ts.map +1 -1
  65. package/lib/esm/IModelDb.js +14 -7
  66. package/lib/esm/IModelDb.js.map +1 -1
  67. package/lib/esm/IModelHost.d.ts +1 -1
  68. package/lib/esm/IModelHost.js +1 -1
  69. package/lib/esm/IModelHost.js.map +1 -1
  70. package/lib/esm/NativeHost.d.ts.map +1 -1
  71. package/lib/esm/NativeHost.js +4 -1
  72. package/lib/esm/NativeHost.js.map +1 -1
  73. package/lib/esm/SQLiteDb.d.ts.map +1 -1
  74. package/lib/esm/SQLiteDb.js +5 -4
  75. package/lib/esm/SQLiteDb.js.map +1 -1
  76. package/lib/esm/ViewStore.d.ts.map +1 -1
  77. package/lib/esm/ViewStore.js +28 -28
  78. package/lib/esm/ViewStore.js.map +1 -1
  79. package/lib/esm/core-backend.d.ts +1 -0
  80. package/lib/esm/core-backend.d.ts.map +1 -1
  81. package/lib/esm/core-backend.js +1 -0
  82. package/lib/esm/core-backend.js.map +1 -1
  83. package/lib/esm/internal/ChannelAdmin.js +5 -5
  84. package/lib/esm/internal/ChannelAdmin.js.map +1 -1
  85. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts +2 -16
  86. package/lib/esm/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
  87. package/lib/esm/internal/workspace/WorkspaceImpl.js +36 -100
  88. package/lib/esm/internal/workspace/WorkspaceImpl.js.map +1 -1
  89. package/lib/esm/test/standalone/SnapshotDb.test.js +2 -2
  90. package/lib/esm/test/standalone/SnapshotDb.test.js.map +1 -1
  91. package/lib/esm/test/standalone/Workspace.test.js +4 -3
  92. package/lib/esm/test/standalone/Workspace.test.js.map +1 -1
  93. package/lib/esm/workspace/Workspace.d.ts +6 -13
  94. package/lib/esm/workspace/Workspace.d.ts.map +1 -1
  95. package/lib/esm/workspace/Workspace.js.map +1 -1
  96. package/lib/esm/workspace/WorkspaceEditor.d.ts +2 -7
  97. package/lib/esm/workspace/WorkspaceEditor.d.ts.map +1 -1
  98. package/lib/esm/workspace/WorkspaceEditor.js.map +1 -1
  99. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.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AC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAG7B,MAAM,wBAAwB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AAEzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","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\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./FontFile\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./ImageSourceConversion\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelDbFonts\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./LockControl\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SheetIndex\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./TextAnnotationElement\";\nexport {\n computeGraphemeOffsets,\n computeLayoutTextBlockResult,\n ComputeGraphemeOffsetsArgs,\n LayoutTextBlockArgs,\n} from \"./TextAnnotationLayout\";\nexport * from \"./TextAnnotationGeometry\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description Images\n * APIs for encoding and decoding images\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
1
+ {"version":3,"file":"core-backend.js","sourceRoot":"","sources":["../../src/core-backend.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,iBAAiB,CAAC;AAChC,cAA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CAAC;AAC7B,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,4BAA4B,GAG7B,MAAM,wBAAwB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,0BAA0B,CAAC;AAEzC;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;IAGI;AAEJ;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG;AAEH;;GAEG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG;AAEH;;;GAGG","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\nexport * from \"./BackendHubAccess\";\nexport * from \"./BackendLoggerCategory\";\nexport * from \"./BisCoreSchema\";\nexport * from \"./BlobContainerService\";\nexport * from \"./BriefcaseManager\";\nexport * from \"./CatalogDb\";\nexport * from \"./Category\";\nexport * from \"./ChangedElementsDb\";\nexport * from \"./ChangeSummaryManager\";\nexport * from \"./ChannelControl\";\nexport * from \"./CheckpointManager\";\nexport * from \"./ClassRegistry\";\nexport * from \"./CloudSqlite\";\nexport * from \"./CodeService\";\nexport * from \"./CodeSpecs\";\nexport * from \"./DevTools\";\nexport * from \"./DisplayStyle\";\nexport * from \"./domains/FunctionalElements\";\nexport * from \"./domains/FunctionalSchema\";\nexport * from \"./domains/GenericElements\";\nexport * from \"./domains/GenericSchema\";\nexport * from \"./ECDb\";\nexport * from \"./ECSchemaXmlContext\";\nexport * from \"./ECSqlStatement\";\nexport * from \"./Element\";\nexport * from \"./ElementAspect\";\nexport * from \"./ElementGraphics\";\nexport * from \"./ElementTreeWalker\";\nexport * from \"./Entity\";\nexport * from \"./EntityReferences\";\nexport * from \"./ExportGraphics\";\nexport * from \"./ExternalSource\";\nexport * from \"./FontFile\";\nexport * from \"./GeoCoordConfig\";\nexport * from \"./GeographicCRSServices\";\nexport * from \"./ImageSourceConversion\";\nexport * from \"./IModelDb\";\nexport * from \"./IModelDbFonts\";\nexport * from \"./IModelElementCloneContext\";\nexport * from \"./IModelHost\";\nexport * from \"./IModelJsFs\";\nexport * from \"./SchemaSync\";\nexport * from \"./IpcHost\";\nexport * from \"./LineStyle\";\nexport * from \"./LocalhostIpcHost\";\nexport * from \"./LocalHub\";\nexport * from \"./LockControl\";\nexport * from \"./Material\";\nexport * from \"./Model\";\nexport * from \"./NativeAppStorage\";\nexport * from \"./NativeHost\";\nexport * from \"./NavigationRelationship\";\nexport * from \"./PropertyStore\";\nexport * from \"./Relationship\";\nexport * from \"./rpc/tracing\";\nexport * from \"./Schema\";\nexport * from \"./SchemaUtils\";\nexport * from \"./SheetIndex\";\nexport * from \"./SQLiteDb\";\nexport * from \"./SqliteStatement\";\nexport * from \"./TextAnnotationElement\";\nexport {\n computeGraphemeOffsets,\n computeLayoutTextBlockResult,\n ComputeGraphemeOffsetsArgs,\n LayoutTextBlockArgs,\n} from \"./TextAnnotationLayout\";\nexport * from \"./TextAnnotationGeometry\";\nexport * from \"./Texture\";\nexport * from \"./TileStorage\";\nexport * from \"./TxnManager\";\nexport * from \"./ViewDefinition\";\nexport * from \"./ViewStore\";\nexport * from \"./workspace/Settings\";\nexport * from \"./workspace/SettingsSchemas\";\nexport * from \"./workspace/Workspace\";\nexport * from \"./workspace/WorkspaceEditor\";\nexport * from \"./SqliteChangesetReader\";\nexport * from \"./ChangesetECAdaptor\";\n\nexport * from \"./internal/cross-package\";\n\n/** @docs-package-description\n * The core-backend package always runs on the computer with a local Briefcase.\n *\n * It contains classes that [backend code]($docs/learning/backend/index.md) can use to work with directly with iModels.\n */\n\n/**\n * @docs-group-description BlobContainers\n * Classes for working with cloud-based blob containers.\n */\n\n/**\n * @docs-group-description Codes\n * Classes for working with [Codes]($docs/BIS/guide/fundamentals/codes.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ECDb\n * Classes for working with ECDb.\n */\n\n/**\n * @docs-group-description ECSQL\n * Classes for working with [ECSQL]($docs/learning/ECSQL.md)\n */\n\n/**\n * @docs-group-description ElementAspects\n * Subclasses of [ElementAspects]($docs/bis/guide/fundamentals/elementaspect-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ElementGeometry\n * Classes for defining the symbology and geometry of geometric elements\n */\n\n/**\n * @docs-group-description Elements\n * Subclasses of [Elements]($docs/BIS/guide/fundamentals/element-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description ExportGraphics\n * APIs for producing low-level graphics primitives from element geometry.\n */\n\n/**\n * @docs-group-description HubAccess\n * APIs for working with IModelHub\n */\n\n/**\n * @docs-group-description Images\n * APIs for encoding and decoding images\n */\n\n/**\n * @docs-group-description IModelHost\n * Classes for configuring and administering the backend [host]($docs/learning/backend/IModelHost.md).\n * See [the learning article]($docs/learning/backend/IModelHost.md).\n */\n\n/**\n * @docs-group-description iModels\n * Classes for working with [iModels]($docs/learning/iModels.md).\n * See [the learning article]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description Logging\n * Logger categories used by this package.\n */\n\n/**\n * @docs-group-description Models\n * Subclasses of [Models]($docs/BIS/guide/fundamentals/model-fundamentals.md).\n * See [the learning articles]($docs/learning/backend/index.md).\n */\n\n/**\n * @docs-group-description NativeApp\n * Classes for working with Mobile/Desktop Application.\n */\n\n/**\n * @docs-group-description Portability\n */\n\n/**\n * @docs-group-description Relationships\n * Classes that describe the [relationships]($docs/bis/guide/fundamentals/relationship-fundamentals.md) between elements.\n */\n\n/**\n * @docs-group-description RpcInterface\n * Classes for working with [RpcInterfaces]($docs/learning/RpcInterface.md).\n */\n\n/**\n * @docs-group-description Schema\n * Classes for working with [ECSchemas]($docs/learning/backend/SchemasAndElementsInTypeScript.md)\n */\n\n/**\n * @docs-group-description SQLite\n * Classes for working directly with SQLite\n */\n\n/**\n * @docs-group-description SQLiteDb\n * Classes for working with SQLiteDb.\n */\n\n/**\n * @docs-group-description TileStorage\n * Class for working with cloud storage using iTwin/object-storage cloud providers\n */\n\n/**\n * @docs-group-description ViewDefinitions\n * Classes for working with Elements that define what appears in [Views]($docs/learning/frontend/views.md).\n * See [the learning articles]($docs/learning/backend/createelements/#orthographicviewdefinition).\n */\n\n/**\n * @docs-group-description Workspace\n * APIs for loading and using Settings and Workspace resources\n */\n"]}
@@ -6,7 +6,7 @@
6
6
  * @module Elements
7
7
  */
8
8
  import { DbResult, IModelStatus } from "@itwin/core-bentley";
9
- import { ChannelError, IModel, IModelError } from "@itwin/core-common";
9
+ import { ChannelControlError, IModel, IModelError } from "@itwin/core-common";
10
10
  import { ChannelControl } from "../ChannelControl";
11
11
  import { Subject } from "../Element";
12
12
  import { IModelHost } from "../IModelHost";
@@ -63,7 +63,7 @@ class ChannelAdmin {
63
63
  return;
64
64
  const deniedChannel = this._deniedModels.get(modelId);
65
65
  if (undefined !== deniedChannel)
66
- ChannelError.throwError("not-allowed", `Channel ${deniedChannel} is not allowed`, deniedChannel);
66
+ ChannelControlError.throwError("not-allowed", `Channel ${deniedChannel} is not allowed`, deniedChannel);
67
67
  const channel = this.getChannelKey(modelId);
68
68
  if (this._allowedChannels.has(channel)) {
69
69
  this._allowedModels.add(modelId);
@@ -75,9 +75,9 @@ class ChannelAdmin {
75
75
  makeChannelRoot(args) {
76
76
  const channelKey = this.getChannelKey(args.elementId);
77
77
  if (ChannelControl.sharedChannelName !== channelKey)
78
- ChannelError.throwError("may-not-nest", `Channel ${channelKey} may not nest`, channelKey);
78
+ ChannelControlError.throwError("may-not-nest", `Channel ${channelKey} may not nest`, channelKey);
79
79
  if (this.queryChannelRoot(args.channelKey) !== undefined)
80
- ChannelError.throwError("root-exists", `Channel ${args.channelKey} root already exist`, channelKey);
80
+ ChannelControlError.throwError("root-exists", `Channel ${args.channelKey} root already exist`, channelKey);
81
81
  const props = { classFullName: ChannelAdmin.channelClassName, element: { id: args.elementId }, owner: args.channelKey };
82
82
  this._iModel.elements.insertAspect(props);
83
83
  }
@@ -86,7 +86,7 @@ class ChannelAdmin {
86
86
  // makeChannelRoot will check that again, but at that point the new Subject is already inserted.
87
87
  // Prefer to check twice instead of deleting the Subject in the latter option.
88
88
  if (this.queryChannelRoot(args.channelKey) !== undefined)
89
- ChannelError.throwError("root-exists", `Channel ${args.channelKey} root already exist`, args.channelKey);
89
+ ChannelControlError.throwError("root-exists", `Channel ${args.channelKey} root already exist`, args.channelKey);
90
90
  const elementId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);
91
91
  this.makeChannelRoot({ elementId, channelKey: args.channelKey });
92
92
  return elementId;
@@ -1 +1 @@
1
- {"version":3,"file":"ChannelAdmin.js","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":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C;QAAC,MAAM,CAAC;YACP,8HAA8H;YAC9H,+EAA+E;YAC/E,OAAO,SAAS,CAAC;QACnB,CAAC;IAEH,CAAC;;AAGH,MAAM,UAAU,oBAAoB,CAAC,MAAgB;IACnD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,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 Elements\n */\n\nimport { DbResult, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { ChannelError, ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { ChannelControl, ChannelKey } from \"../ChannelControl\";\nimport { Subject } from \"../Element\";\nimport { IModelDb } from \"../IModelDb\";\nimport { IModelHost } from \"../IModelHost\";\nimport { _implementationProhibited, _nativeDb, _verifyChannel } from \"./Symbols\";\n\nclass ChannelAdmin implements ChannelControl {\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\n\n public readonly [_implementationProhibited] = undefined;\n private _allowedChannels = new Set<ChannelKey>();\n private _allowedModels = new Set<Id64String>();\n private _deniedModels = new Map<Id64String, ChannelKey>();\n\n public constructor(private _iModel: IModelDb) {\n // for backwards compatibility, allow the shared channel unless explicitly turned off in IModelHostOptions.\n if (IModelHost.configuration?.allowSharedChannel !== false)\n this._allowedChannels.add(ChannelControl.sharedChannelName);\n }\n\n public addAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.add(channelKey);\n this._deniedModels.clear();\n }\n\n public removeAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.delete(channelKey);\n this._allowedModels.clear();\n }\n\n public getChannelKey(elementId: Id64String): ChannelKey {\n if (elementId === IModel.rootSubjectId)\n return ChannelControl.sharedChannelName;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\n stmt.bindId(1, elementId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\n });\n\n if (channel !== undefined)\n return channel;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return ChannelControl.sharedChannelName;\n }\n\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, elementId);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\n });\n\n return this.getChannelKey(parentId);\n }\n\n public [_verifyChannel](modelId: Id64String): void {\n // Note: indirect changes are permitted to change any channel\n if (this._allowedModels.has(modelId) || this._iModel[_nativeDb].isIndirectChanges())\n return;\n\n const deniedChannel = this._deniedModels.get(modelId);\n if (undefined !== deniedChannel)\n ChannelError.throwError(\"not-allowed\", `Channel ${deniedChannel} is not allowed`, deniedChannel);\n\n const channel = this.getChannelKey(modelId);\n if (this._allowedChannels.has(channel)) {\n this._allowedModels.add(modelId);\n return;\n }\n\n this._deniedModels.set(modelId, channel);\n return this[_verifyChannel](modelId);\n }\n\n public makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }) {\n const channelKey = this.getChannelKey(args.elementId);\n if (ChannelControl.sharedChannelName !== channelKey)\n ChannelError.throwError(\"may-not-nest\", `Channel ${channelKey} may not nest`, channelKey);\n\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n ChannelError.throwError(\"root-exists\", `Channel ${args.channelKey} root already exist`, channelKey);\n\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: args.elementId }, owner: args.channelKey };\n this._iModel.elements.insertAspect(props);\n }\n\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\n // Check if channelKey already exists before inserting Subject.\n // makeChannelRoot will check that again, but at that point the new Subject is already inserted.\n // Prefer to check twice instead of deleting the Subject in the latter option.\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n ChannelError.throwError(\"root-exists\", `Channel ${args.channelKey} root already exist`, args.channelKey);\n\n const elementId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\n this.makeChannelRoot({ elementId, channelKey: args.channelKey });\n return elementId;\n }\n\n public queryChannelRoot(channelKey: ChannelKey): Id64String | undefined {\n if (channelKey === ChannelControl.sharedChannelName)\n // RootSubject acts as the ChannelRoot element of the shared channel\n return IModel.rootSubjectId;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const channelRoot = this._iModel.withPreparedStatement(`SELECT Element.Id FROM ${ChannelAdmin.channelClassName} WHERE Owner=?`, (stmt) => {\n stmt.bindString(1, channelKey);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getId() : undefined;\n });\n\n return channelRoot;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return undefined;\n }\n\n }\n}\n\nexport function createChannelControl(iModel: IModelDb): ChannelAdmin {\n return new ChannelAdmin(iModel);\n}\n"]}
1
+ {"version":3,"file":"ChannelAdmin.js","sourceRoot":"","sources":["../../../src/internal/ChannelAdmin.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAA0B,MAAM,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtG,OAAO,EAAE,cAAc,EAAc,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,MAAM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AAU,CAAC,aAAa,EAAE,WAAW,IAAI,CAAC,UAAU,qBAAqB,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;QAElH,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,eAAe,IAAI,MAAM,CAAC,aAAa,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QACjI,IAAI,CAAC,eAAe,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IACnB,CAAC;IAEM,gBAAgB,CAAC,UAAsB;QAC5C,IAAI,UAAU,KAAK,cAAc,CAAC,iBAAiB;YACjD,oEAAoE;YACpE,OAAO,MAAM,CAAC,aAAa,CAAC;QAE9B,IAAI,CAAC;YACH,4DAA4D;YAC5D,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,0BAA0B,YAAY,CAAC,gBAAgB,gBAAgB,EAAE,CAAC,IAAI,EAAE,EAAE;gBACvI,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;gBAC/B,OAAO,QAAQ,CAAC,aAAa,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;YACvF,CAAC,CAAC,CAAC;YAEH,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,8HAA8H;YAC9H,+EAA+E;YAC/E,OAAO,SAAS,CAAC;QACnB,CAAC;IAEH,CAAC;;AAGH,MAAM,UAAU,oBAAoB,CAAC,MAAgB;IACnD,OAAO,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;AAClC,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 Elements\n */\n\nimport { DbResult, Id64String, IModelStatus } from \"@itwin/core-bentley\";\nimport { ChannelControlError, ChannelRootAspectProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { ChannelControl, ChannelKey } from \"../ChannelControl\";\nimport { Subject } from \"../Element\";\nimport { IModelDb } from \"../IModelDb\";\nimport { IModelHost } from \"../IModelHost\";\nimport { _implementationProhibited, _nativeDb, _verifyChannel } from \"./Symbols\";\n\nclass ChannelAdmin implements ChannelControl {\n public static readonly channelClassName = \"bis:ChannelRootAspect\";\n\n public readonly [_implementationProhibited] = undefined;\n private _allowedChannels = new Set<ChannelKey>();\n private _allowedModels = new Set<Id64String>();\n private _deniedModels = new Map<Id64String, ChannelKey>();\n\n public constructor(private _iModel: IModelDb) {\n // for backwards compatibility, allow the shared channel unless explicitly turned off in IModelHostOptions.\n if (IModelHost.configuration?.allowSharedChannel !== false)\n this._allowedChannels.add(ChannelControl.sharedChannelName);\n }\n\n public addAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.add(channelKey);\n this._deniedModels.clear();\n }\n\n public removeAllowedChannel(channelKey: ChannelKey) {\n this._allowedChannels.delete(channelKey);\n this._allowedModels.clear();\n }\n\n public getChannelKey(elementId: Id64String): ChannelKey {\n if (elementId === IModel.rootSubjectId)\n return ChannelControl.sharedChannelName;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const channel = this._iModel.withPreparedStatement(`SELECT Owner FROM ${ChannelAdmin.channelClassName} WHERE Element.Id=?`, (stmt) => {\n stmt.bindId(1, elementId);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getString() : undefined;\n });\n\n if (channel !== undefined)\n return channel;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return ChannelControl.sharedChannelName;\n }\n\n const parentId = this._iModel.withPreparedSqliteStatement(\"SELECT ParentId,ModelId FROM bis_Element WHERE id=?\", (stmt) => {\n stmt.bindId(1, elementId);\n if (DbResult.BE_SQLITE_ROW !== stmt.step())\n throw new IModelError(IModelStatus.NotFound, \"Element does not exist\");\n return stmt.getValueId(0) ?? stmt.getValueId(1); // if parent is undefined, use modelId\n });\n\n return this.getChannelKey(parentId);\n }\n\n public [_verifyChannel](modelId: Id64String): void {\n // Note: indirect changes are permitted to change any channel\n if (this._allowedModels.has(modelId) || this._iModel[_nativeDb].isIndirectChanges())\n return;\n\n const deniedChannel = this._deniedModels.get(modelId);\n if (undefined !== deniedChannel)\n ChannelControlError.throwError(\"not-allowed\", `Channel ${deniedChannel} is not allowed`, deniedChannel);\n\n const channel = this.getChannelKey(modelId);\n if (this._allowedChannels.has(channel)) {\n this._allowedModels.add(modelId);\n return;\n }\n\n this._deniedModels.set(modelId, channel);\n return this[_verifyChannel](modelId);\n }\n\n public makeChannelRoot(args: { elementId: Id64String, channelKey: ChannelKey }) {\n const channelKey = this.getChannelKey(args.elementId);\n if (ChannelControl.sharedChannelName !== channelKey)\n ChannelControlError.throwError(\"may-not-nest\", `Channel ${channelKey} may not nest`, channelKey);\n\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n ChannelControlError.throwError(\"root-exists\", `Channel ${args.channelKey} root already exist`, channelKey);\n\n const props: ChannelRootAspectProps = { classFullName: ChannelAdmin.channelClassName, element: { id: args.elementId }, owner: args.channelKey };\n this._iModel.elements.insertAspect(props);\n }\n\n public insertChannelSubject(args: { subjectName: string, channelKey: ChannelKey, parentSubjectId?: Id64String, description?: string }): Id64String {\n // Check if channelKey already exists before inserting Subject.\n // makeChannelRoot will check that again, but at that point the new Subject is already inserted.\n // Prefer to check twice instead of deleting the Subject in the latter option.\n if (this.queryChannelRoot(args.channelKey) !== undefined)\n ChannelControlError.throwError(\"root-exists\", `Channel ${args.channelKey} root already exist`, args.channelKey);\n\n const elementId = Subject.insert(this._iModel, args.parentSubjectId ?? IModel.rootSubjectId, args.subjectName, args.description);\n this.makeChannelRoot({ elementId, channelKey: args.channelKey });\n return elementId;\n }\n\n public queryChannelRoot(channelKey: ChannelKey): Id64String | undefined {\n if (channelKey === ChannelControl.sharedChannelName)\n // RootSubject acts as the ChannelRoot element of the shared channel\n return IModel.rootSubjectId;\n\n try {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n const channelRoot = this._iModel.withPreparedStatement(`SELECT Element.Id FROM ${ChannelAdmin.channelClassName} WHERE Owner=?`, (stmt) => {\n stmt.bindString(1, channelKey);\n return DbResult.BE_SQLITE_ROW === stmt.step() ? stmt.getValue(0).getId() : undefined;\n });\n\n return channelRoot;\n } catch {\n // Exception happens if the iModel is too old: ChannelRootAspect class not present in the BisCore schema (older than v1.0.10).\n // In that case all data in such iModel is assumed to be in the shared channel.\n return undefined;\n }\n\n }\n}\n\nexport function createChannelControl(iModel: IModelDb): ChannelAdmin {\n return new ChannelAdmin(iModel);\n}\n"]}
@@ -3,15 +3,13 @@
3
3
  */
4
4
  import { FilePropertyProps } from "@itwin/core-common";
5
5
  import { Settings } from "../../workspace/Settings";
6
- import { Workspace, WorkspaceContainer, WorkspaceContainerId, WorkspaceDb, WorkspaceDbFullName, WorkspaceDbLoadError, WorkspaceDbName, WorkspaceDbProps, WorkspaceDbVersion, WorkspaceOpts } from "../../workspace/Workspace";
6
+ import { Workspace, WorkspaceContainer, WorkspaceContainerId, WorkspaceDb, WorkspaceDbLoadError, WorkspaceDbProps, WorkspaceOpts } from "../../workspace/Workspace";
7
7
  import { WorkspaceEditor } from "../../workspace/WorkspaceEditor";
8
8
  /** file extension for local WorkspaceDbs */
9
9
  export declare const workspaceDbFileExt = "itwin-workspace";
10
10
  export declare function constructWorkspaceDb(props: WorkspaceDbProps, container: WorkspaceContainer): WorkspaceDb;
11
11
  export declare function constructWorkspace(settings: Settings, opts?: WorkspaceOpts): OwnedWorkspace;
12
12
  export declare function constructWorkspaceEditor(): WorkspaceEditor;
13
- export declare function noLeadingOrTrailingSpaces(name: string, msg: string): void;
14
- export declare function validateWorkspaceDbName(dbName: WorkspaceDbName): void;
15
13
  /**
16
14
  * Validate that a WorkspaceContainer.Id is valid.
17
15
  * The rules for ContainerIds (from Azure, see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata):
@@ -20,20 +18,8 @@ export declare function validateWorkspaceDbName(dbName: WorkspaceDbName): void;
20
18
  * - may not be shorter than 3 or longer than 63 characters
21
19
  */
22
20
  export declare function validateWorkspaceContainerId(id: WorkspaceContainerId): void;
23
- export declare function validateWorkspaceDbVersion(version?: WorkspaceDbVersion): string;
24
- /**
25
- * Parse the name stored in a WorkspaceContainer into the dbName and version number. A single WorkspaceContainer may hold
26
- * many versions of the same WorkspaceDb. The name of the Db in the WorkspaceContainer is in the format "name:version". This
27
- * function splits them into separate strings.
28
- */
29
- export declare function parseWorkspaceDbFileName(dbFileName: WorkspaceDbFullName): {
30
- dbName: WorkspaceDbName;
31
- version: WorkspaceDbVersion;
32
- };
33
- /** Create a dbName for a WorkspaceDb from its base name and version. This will be in the format "name:version" */
34
- export declare function makeWorkspaceDbFileName(dbName: WorkspaceDbName, version?: WorkspaceDbVersion): WorkspaceDbName;
35
21
  export declare const workspaceManifestProperty: FilePropertyProps;
36
- export declare function throwWorkspaceDbLoadErrors(msg: string, errors: WorkspaceDbLoadError[]): never;
22
+ export declare function throwWorkspaceDbLoadErrors(message: string, wsLoadErrors: WorkspaceDbLoadError[]): never;
37
23
  export interface OwnedWorkspace extends Workspace {
38
24
  /** Only the owner of a Workspace may close it. */
39
25
  close(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"WorkspaceImpl.d.ts","sourceRoot":"","sources":["../../../../src/internal/workspace/WorkspaceImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAOH,OAAO,EAAE,iBAAiB,EAA4C,MAAM,oBAAoB,CAAC;AAMjG,OAAO,EAAe,QAA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AW,cAAe,SAAQ,SAAS;IAC/C,kDAAkD;IAClD,KAAK,IAAI,IAAI,CAAC;CACf"}
1
+ {"version":3,"file":"WorkspaceImpl.d.ts","sourceRoot":"","sources":["../../../../src/internal/workspace/WorkspaceImpl.ts"],"names":[],"mappings":"AAIA;;GAEG;AAMH,OAAO,EAAoB,iBAAiB,EAA+C,MAAM,oBAAoB,CAAC;AAMtH,OAAO,EAAe,QAAQ,EAAgE,MAAM,0BAA0B,CAAC;AAE/H,OAAO,EACsB,SAAS,EAAE,kBAAkB,EAAE,oBAAoB,EAA2B,WAAW,EAC/F,oBAAoB,EAA0F,gBAAgB,EAC1F,aAAa,EACvE,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAqH,eAAe,EAAE,MAAM,iCAAiC,CAAC;AASrL,4CAA4C;AAC5C,eAAO,MAAM,kBAAkB,oBAAoB,CAAC;AAgqBpD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,GAAG,WAAW,CAExG;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,cAAc,CAE3F;AAED,wBAAgB,wBAAwB,IAAI,eAAe,CAE1D;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,oBAAoB,QAGpE;AAED,eAAO,MAAM,yBAAyB,EAAE,iBAAgE,CAAC;AAOzG,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,oBAAoB,EAAE,GAAG,KAAK,CAEvG;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,kDAAkD;IAClD,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -8,9 +8,8 @@
8
8
  import { createHash } from "crypto";
9
9
  import * as fs from "fs-extra";
10
10
  import { dirname, extname, join } from "path";
11
- import * as semver from "semver";
12
11
  import { assert, BeEvent, DbResult, OpenMode } from "@itwin/core-bentley";
13
- import { IModelError } from "@itwin/core-common";
12
+ import { CloudSqliteError, WorkspaceError } from "@itwin/core-common";
14
13
  import { CloudSqlite } from "../../CloudSqlite";
15
14
  import { IModelHost, KnownLocations } from "../../IModelHost";
16
15
  import { IModelJsFs } from "../../IModelJsFs";
@@ -29,7 +28,7 @@ export const workspaceDbFileExt = "itwin-workspace";
29
28
  function makeWorkspaceCloudCache(arg) {
30
29
  const cache = CloudSqlite.CloudCaches.getCache(arg);
31
30
  if (undefined === cache.workspaceContainers) // if we just created this container, add the map.
32
- cache.workspaceContainers = new Map();
31
+ CloudSqlite.addHiddenProperty(cache, "workspaceContainers", new Map());
33
32
  return cache;
34
33
  }
35
34
  function getContainerFullId(props) {
@@ -43,20 +42,20 @@ function getWorkspaceCloudContainer(props, cache) {
43
42
  cloudContainer = CloudSqlite.createCloudContainer(props);
44
43
  cache.workspaceContainers.set(id, cloudContainer);
45
44
  cloudContainer.connectCount = 0;
46
- cloudContainer.sharedConnect = function () {
45
+ CloudSqlite.addHiddenProperty(cloudContainer, "sharedConnect", function () {
47
46
  if (this.connectCount++ === 0) {
48
47
  this.connect(cache);
49
48
  return true;
50
49
  }
51
50
  return false;
52
- };
53
- cloudContainer.sharedDisconnect = function () {
51
+ });
52
+ CloudSqlite.addHiddenProperty(cloudContainer, "sharedDisconnect", function () {
54
53
  if (--this.connectCount <= 0) {
55
54
  this.disconnect();
56
55
  cache.workspaceContainers.delete(id);
57
56
  this.connectCount = 0;
58
57
  }
59
- };
58
+ });
60
59
  return cloudContainer;
61
60
  }
62
61
  class WorkspaceContainerImpl {
@@ -94,31 +93,14 @@ class WorkspaceContainerImpl {
94
93
  }
95
94
  }
96
95
  resolveDbFileName(props) {
97
- const cloudContainer = this.cloudContainer;
98
- if (undefined === cloudContainer)
96
+ const container = this.cloudContainer;
97
+ if (undefined === container)
99
98
  return join(this.dirName, `${props.dbName}.${workspaceDbFileExt}`); // local file, versions not allowed
100
- const dbName = workspaceDbNameWithDefault(props.dbName);
101
- const dbs = cloudContainer.queryDatabases(`${dbName}*`); // get all databases that start with dbName
102
- const versions = [];
103
- for (const db of dbs) {
104
- const thisDb = parseWorkspaceDbFileName(db);
105
- if (thisDb.dbName === dbName && "string" === typeof thisDb.version && thisDb.version.length > 0)
106
- versions.push(thisDb.version);
107
- }
108
- if (versions.length === 0)
109
- versions[0] = "0.0.0";
110
- const range = props.version ?? "*";
111
- try {
112
- const version = semver.maxSatisfying(versions, range, { loose: true, includePrerelease: props.includePrerelease });
113
- if (version)
114
- return `${dbName}:${version}`;
115
- }
116
- catch { }
117
- throwWorkspaceDbLoadError(`No version of '${dbName}' available for "${range}"`, props);
99
+ return CloudSqlite.querySemverMatch({ ...props, container, dbName: workspaceDbNameWithDefault(props.dbName) });
118
100
  }
119
101
  addWorkspaceDb(toAdd) {
120
102
  if (undefined !== this._wsDbs.get(toAdd.dbName))
121
- throw new Error(`workspaceDb '${toAdd.dbName}' already exists in workspace`);
103
+ WorkspaceError.throwError("already-exists", { message: `workspaceDb '${toAdd.dbName}' already exists in workspace` });
122
104
  this._wsDbs.set(toAdd.dbName, toAdd);
123
105
  }
124
106
  getWorkspaceDb(props) {
@@ -163,7 +145,7 @@ class WorkspaceDbImpl {
163
145
  }
164
146
  constructor(props, container) {
165
147
  this.dbName = workspaceDbNameWithDefault(props.dbName);
166
- validateWorkspaceDbName(this.dbName);
148
+ CloudSqlite.validateDbName(this.dbName);
167
149
  this._container = container;
168
150
  this.dbFileName = container.resolveDbFileName(props);
169
151
  container.addWorkspaceDb(this);
@@ -184,7 +166,7 @@ class WorkspaceDbImpl {
184
166
  const cloudContainer = this.container.cloudContainer;
185
167
  if (undefined === cloudContainer)
186
168
  return "1.0.0"; // local file, no versioning. return default
187
- return parseWorkspaceDbFileName(this.dbFileName).version;
169
+ return CloudSqlite.parseDbFileName(this.dbFileName).version;
188
170
  }
189
171
  get manifest() {
190
172
  return this._manifest ??= this.withOpenDb((db) => {
@@ -251,7 +233,7 @@ class WorkspaceDbImpl {
251
233
  prefetch(opts) {
252
234
  const cloudContainer = this._container.cloudContainer;
253
235
  if (cloudContainer === undefined)
254
- throw new Error("no cloud container to prefetch");
236
+ WorkspaceError.throwError("no-cloud-container", { message: "no cloud container to prefetch" });
255
237
  return CloudSqlite.startCloudPrefetch(cloudContainer, this.dbFileName, opts);
256
238
  }
257
239
  queryResources(args) {
@@ -294,7 +276,7 @@ class WorkspaceImpl {
294
276
  }
295
277
  addContainer(toAdd) {
296
278
  if (undefined !== this._containers.get(toAdd.id))
297
- throw new Error("container already exists in workspace");
279
+ WorkspaceError.throwError("container-exists", { message: `container ${toAdd.id} already exists in workspace` });
298
280
  this._containers.set(toAdd.id, toAdd);
299
281
  }
300
282
  findContainer(containerId) {
@@ -411,7 +393,7 @@ class EditorImpl {
411
393
  static _cacheName = workspaceEditorName;
412
394
  static async initializeWorkspace(args) {
413
395
  const props = await this.createBlobContainer({ scope: args.scope, metadata: { ...args.metadata, containerType: "workspace" } });
414
- const dbFullName = makeWorkspaceDbFileName(workspaceDbNameWithDefault(args.dbName), "0.0.0");
396
+ const dbFullName = CloudSqlite.makeSemverName(workspaceDbNameWithDefault(args.dbName), "0.0.0");
415
397
  await super._initializeDb({ ...args, props, dbName: dbFullName, dbType: WorkspaceSqliteDb, blockSize: "4M" });
416
398
  return props;
417
399
  }
@@ -451,28 +433,20 @@ class EditorContainerImpl extends WorkspaceContainerImpl {
451
433
  };
452
434
  }
453
435
  async createNewWorkspaceDbVersion(args) {
454
- const cloudContainer = this.cloudContainer;
455
- if (undefined === cloudContainer)
456
- throw new Error("versions require cloud containers");
457
- const oldName = this.resolveDbFileName(args.fromProps ?? {});
458
- const oldDb = parseWorkspaceDbFileName(oldName);
459
- const newVersion = semver.inc(oldDb.version, args.versionType, args.identifier);
460
- if (!newVersion)
461
- throwWorkspaceDbLoadError("invalid version", args.fromProps ?? {});
462
- const newName = makeWorkspaceDbFileName(oldDb.dbName, newVersion);
463
- await cloudContainer.copyDatabase(oldName, newName);
464
- // return the old and new db names and versions
465
- return { oldDb, newDb: { dbName: oldDb.dbName, version: newVersion } };
436
+ const container = this.cloudContainer;
437
+ if (undefined === container)
438
+ WorkspaceError.throwError("no-cloud-container", { message: "versions require cloud containers" });
439
+ const fromDb = { ...args.fromProps, dbName: workspaceDbNameWithDefault(args.fromProps?.dbName) };
440
+ return CloudSqlite.createNewDbVersion(container, { ...args, fromDb });
466
441
  }
467
442
  getWorkspaceDb(props) {
468
443
  return this.getEditableDb(props);
469
444
  }
470
445
  getEditableDb(props) {
471
446
  const db = this._wsDbs.get(workspaceDbNameWithDefault(props.dbName)) ?? new EditableDbImpl(props, this);
472
- const isPrerelease = semver.major(db.version) === 0 || semver.prerelease(db.version);
473
- if (!isPrerelease && this.cloudContainer && this.cloudContainer.queryDatabase(db.dbFileName)?.state !== "copied") {
447
+ if (this.cloudContainer && !CloudSqlite.isSemverEditable(db.dbFileName, this.cloudContainer)) {
474
448
  this._wsDbs.delete(workspaceDbNameWithDefault(props.dbName));
475
- throw new Error(`${db.dbFileName} has been published and is not editable. Make a new version first.`);
449
+ CloudSqliteError.throwError("already-published", { message: `${db.dbFileName} has been published and is not editable. Make a new version first.` });
476
450
  }
477
451
  return db;
478
452
  }
@@ -504,7 +478,7 @@ class EditorContainerImpl extends WorkspaceContainerImpl {
504
478
  if (fs.existsSync(tempDbFile))
505
479
  IModelJsFs.removeSync(tempDbFile);
506
480
  WorkspaceEditor.createEmptyDb({ localFileName: tempDbFile, manifest: args.manifest });
507
- await CloudSqlite.uploadDb(this.cloudContainer, { localFileName: tempDbFile, dbName: makeWorkspaceDbFileName(workspaceDbNameWithDefault(args.dbName)) });
481
+ await CloudSqlite.uploadDb(this.cloudContainer, { localFileName: tempDbFile, dbName: CloudSqlite.makeSemverName(workspaceDbNameWithDefault(args.dbName)) });
508
482
  IModelJsFs.removeSync(tempDbFile);
509
483
  }
510
484
  return this.getWorkspaceDb(args);
@@ -516,23 +490,22 @@ class EditableDbImpl extends WorkspaceDbImpl {
516
490
  return this._container;
517
491
  }
518
492
  static validateResourceName(name) {
519
- if (name.trim() !== name) {
520
- throw new Error("resource name may not have leading or trailing spaces");
521
- }
493
+ if (name.trim() !== name)
494
+ WorkspaceError.throwError("invalid-name", { message: "resource name may not have leading or trailing spaces" });
522
495
  if (name.length > 1024) {
523
- throw new Error("resource name too long");
496
+ WorkspaceError.throwError("invalid-name", { message: "resource name too long" });
524
497
  }
525
498
  }
526
499
  validateResourceSize(val) {
527
500
  const len = typeof val === "string" ? val.length : val.byteLength;
528
501
  if (len > (1024 * 1024 * 1024)) // one gigabyte
529
- throw new Error("value is too large");
502
+ WorkspaceError.throwError("too-large", { message: "value is too large" });
530
503
  }
531
504
  get cloudProps() {
532
505
  const props = this._container.cloudProps;
533
506
  if (props === undefined)
534
507
  return undefined;
535
- const parsed = parseWorkspaceDbFileName(this.dbFileName);
508
+ const parsed = CloudSqlite.parseDbFileName(this.dbFileName);
536
509
  return { ...props, dbName: parsed.dbName, version: parsed.version };
537
510
  }
538
511
  open() {
@@ -559,8 +532,8 @@ class EditableDbImpl extends WorkspaceDbImpl {
559
532
  const rc = stmt.step();
560
533
  if (DbResult.BE_SQLITE_DONE !== rc) {
561
534
  if (DbResult.BE_SQLITE_CONSTRAINT_PRIMARYKEY === rc)
562
- throw new IModelError(rc, `resource "${rscName}" already exists`);
563
- throw new IModelError(rc, `workspace [${sql}]`);
535
+ WorkspaceError.throwError("resource-exists", { message: `resource "${rscName}" already exists` });
536
+ WorkspaceError.throwError("write-error", { message: `workspace [${sql}], rc=${rc}` });
564
537
  }
565
538
  });
566
539
  this.sqliteDb.saveChanges();
@@ -618,7 +591,7 @@ class EditableDbImpl extends WorkspaceDbImpl {
618
591
  removeFile(rscName) {
619
592
  const file = this.queryFileResource(rscName);
620
593
  if (undefined === file)
621
- throw new Error(`file resource "${rscName}" does not exist`);
594
+ WorkspaceError.throwError("does-not-exist", { message: `file resource "${rscName}" does not exist` });
622
595
  if (file && fs.existsSync(file.localFileName))
623
596
  fs.unlinkSync(file.localFileName);
624
597
  this.sqliteDb[_nativeDb].removeEmbeddedFile(rscName);
@@ -633,15 +606,6 @@ export function constructWorkspace(settings, opts) {
633
606
  export function constructWorkspaceEditor() {
634
607
  return new EditorImpl();
635
608
  }
636
- export function noLeadingOrTrailingSpaces(name, msg) {
637
- if (name.trim() !== name)
638
- throw new Error(`${msg} [${name}] may not have leading or trailing spaces`);
639
- }
640
- export function validateWorkspaceDbName(dbName) {
641
- if (dbName === "" || dbName.length > 255 || /[#\.<>:"/\\"`'|?*\u0000-\u001F]/g.test(dbName) || /^(con|prn|aux|nul|com\d|lpt\d)$/i.test(dbName))
642
- throw new Error(`invalid dbName: [${dbName}]`);
643
- noLeadingOrTrailingSpaces(dbName, "dbName");
644
- }
645
609
  /**
646
610
  * Validate that a WorkspaceContainer.Id is valid.
647
611
  * The rules for ContainerIds (from Azure, see https://docs.microsoft.com/en-us/rest/api/storageservices/naming-and-referencing-containers--blobs--and-metadata):
@@ -651,41 +615,13 @@ export function validateWorkspaceDbName(dbName) {
651
615
  */
652
616
  export function validateWorkspaceContainerId(id) {
653
617
  if (!/^(?=.{3,63}$)[a-z0-9]+(-[a-z0-9]+)*$/g.test(id))
654
- throw new Error(`invalid containerId: [${id}]`);
655
- }
656
- export function validateWorkspaceDbVersion(version) {
657
- version = version ?? "0.0.0";
658
- const opts = { loose: true, includePrerelease: true };
659
- // clean allows prerelease, so try it first. If that fails attempt to coerce it (coerce strips prerelease even if you say not to.)
660
- const semVersion = semver.clean(version, opts) ?? semver.coerce(version, opts)?.version;
661
- if (!semVersion)
662
- throw new Error("invalid version specification");
663
- version = semVersion;
664
- return version;
665
- }
666
- /**
667
- * Parse the name stored in a WorkspaceContainer into the dbName and version number. A single WorkspaceContainer may hold
668
- * many versions of the same WorkspaceDb. The name of the Db in the WorkspaceContainer is in the format "name:version". This
669
- * function splits them into separate strings.
670
- */
671
- export function parseWorkspaceDbFileName(dbFileName) {
672
- const parts = dbFileName.split(":");
673
- return { dbName: parts[0], version: parts[1] };
674
- }
675
- /** Create a dbName for a WorkspaceDb from its base name and version. This will be in the format "name:version" */
676
- export function makeWorkspaceDbFileName(dbName, version) {
677
- return `${dbName}:${validateWorkspaceDbVersion(version)}`;
618
+ WorkspaceError.throwError("invalid-name", { message: `invalid containerId: [${id}]` });
678
619
  }
679
620
  export const workspaceManifestProperty = { namespace: "workspace", name: "manifest" };
680
- function throwWorkspaceDbLoadError(msg, wsDbProps, db) {
681
- const error = new Error(msg);
682
- error.wsDbProps = wsDbProps;
683
- error.wsDb = db;
684
- throw error;
621
+ function throwWorkspaceDbLoadError(message, wsDbProps, wsDb) {
622
+ WorkspaceError.throwError("load-error", { message, wsDb, wsDbProps });
685
623
  }
686
- export function throwWorkspaceDbLoadErrors(msg, errors) {
687
- const error = new Error(msg);
688
- error.wsLoadErrors = errors;
689
- throw error;
624
+ export function throwWorkspaceDbLoadErrors(message, wsLoadErrors) {
625
+ WorkspaceError.throwError("load-errors", { message, wsLoadErrors });
690
626
  }
691
627
  //# sourceMappingURL=WorkspaceImpl.js.map