@itwin/imodel-transformer 0.1.9 → 0.1.11

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.
package/CHANGELOG.md CHANGED
@@ -1,9 +1,17 @@
1
1
  # Change Log - @itwin/imodel-transformer
2
2
 
3
- This log was last generated on Tue, 02 May 2023 18:28:36 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 30 May 2023 13:03:51 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## 0.1.10
8
+
9
+ Tue, 30 May 2023 13:03:51 GMT
10
+
11
+ ### Patches
12
+
13
+ - fix detectElementDeletes since importer.deleteElement change ([commit](https://github.com/iTwin/transformer/commit/b248d238de2da7dae5ebc5b2609d0d79890811d6))
14
+
7
15
  ## 0.1.8
8
16
 
9
17
  Tue, 02 May 2023 18:28:36 GMT
@@ -1 +1 @@
1
- {"version":3,"file":"EntityUnifier.d.ts","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAA4C,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAE5I,gBAAgB;AAChB,yBAAiB,aAAa,CAAC;IAC7B,MAAM,UAAU,eAAe,CAAC,MAAM,EAAE,cAAc,yEASrD;IAED,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhE,2GAA2G;IAC3G,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,iBAS9D;IAED,MAAM,UAAU,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG;QAAE,eAAe,EAAE,eAAe,CAAA;KAAE,WA0B1G;;CACF"}
1
+ {"version":3,"file":"EntityUnifier.d.ts","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,eAAe,EAAe,MAAM,oBAAoB,CAAC;AAClG,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAA4C,QAAQ,EAAgB,MAAM,qBAAqB,CAAC;AAG5I,gBAAgB;AAChB,yBAAiB,aAAa,CAAC;IAC7B,MAAM,UAAU,eAAe,CAAC,MAAM,EAAE,cAAc,yEASrD;IAED,KAAK,aAAa,GAAG,CAAC,WAAW,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAEhE,2GAA2G;IAC3G,MAAM,UAAU,UAAU,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,iBAS9D;IAED,MAAM,UAAU,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE;QAAE,MAAM,EAAE,cAAc,CAAA;KAAE,GAAG;QAAE,eAAe,EAAE,eAAe,CAAA;KAAE,WA+B1G;;CACF"}
@@ -13,6 +13,7 @@ exports.EntityUnifier = void 0;
13
13
  const assert = require("assert");
14
14
  const core_common_1 = require("@itwin/core-common");
15
15
  const core_backend_1 = require("@itwin/core-backend");
16
+ const core_bentley_1 = require("@itwin/core-bentley");
16
17
  /** @internal */
17
18
  var EntityUnifier;
18
19
  (function (EntityUnifier) {
@@ -42,6 +43,9 @@ var EntityUnifier;
42
43
  function exists(db, arg) {
43
44
  if ("entityReference" in arg) {
44
45
  const [type, id] = core_backend_1.EntityReferences.split(arg.entityReference);
46
+ // FIXME: add a test with a deleted reference that triggers this
47
+ if (id === undefined || core_bentley_1.Id64.isInvalid(id))
48
+ return false;
45
49
  const bisCoreRootClassName = core_common_1.ConcreteEntityTypes.toBisCoreRootClassFullName(type);
46
50
  return db.withPreparedStatement(`SELECT 1 FROM ${bisCoreRootClassName} WHERE ECInstanceId=?`, (stmt) => {
47
51
  stmt.bindId(1, id);
@@ -55,6 +59,8 @@ var EntityUnifier;
55
59
  });
56
60
  }
57
61
  else {
62
+ if (arg.entity.id === undefined || core_bentley_1.Id64.isInvalid(arg.entity.id))
63
+ return false;
58
64
  return db.withPreparedStatement(`SELECT 1 FROM [${arg.entity.schemaName}].[${arg.entity.className}] WHERE ECInstanceId=?`, (stmt) => {
59
65
  stmt.bindId(1, arg.entity.id);
60
66
  const matchesResult = stmt.step();
@@ -1 +1 @@
1
- {"version":3,"file":"EntityUnifier.js","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;;;GAIG;AACH,iCAAiC;AACjC,oDAAkG;AAClG,sDAA4I;AAE5I,gBAAgB;AAChB,IAAiB,aAAa,CAqD7B;AArDD,WAAiB,aAAa;IAC5B,SAAgB,eAAe,CAAC,MAAsB;QACpD,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,SAAS,CAAC;aACd,IAAI,MAAM,YAAY,4BAAa;YACtC,OAAO,gBAAgB,CAAC;aACrB,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,cAAc,CAAC;;YAEtB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IATe,6BAAe,kBAS9B,CAAA;IAID,2GAA2G;IAC3G,SAAgB,UAAU,CAAC,EAAY,EAAE,MAAsB;QAC7D,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,CAAC;aACjE,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAkB,CAAC;aAC5E,IAAI,MAAM,YAAY,4BAAa;YACtC,OAAO,EAAE,CAAC,QAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,CAAC;;YAEnE,MAAM,CAAC,KAAK,EAAE,4BAA4B,MAAM,CAAC,WAAW,CAAC,IAAI,kDAAkD,CAAC,CA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AAE,cAAc,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IA1Be,oBAAM,SA0BrB,CAAA;AACH,CAAC,EArDgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAqD7B","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 Utils\n * utilities that unify operations, especially CRUD operations, on entities\n * for entity-generic operations in the transformer\n */\nimport * as assert from \"assert\";\nimport { ConcreteEntityTypes, DbResult, EntityReference, IModelError } from \"@itwin/core-common\";\nimport { ConcreteEntity, ConcreteEntityProps, Element, ElementAspect, EntityReferences, IModelDb, Relationship } from \"@itwin/core-backend\";\n\n/** @internal */\nexport namespace EntityUnifier {\n export function getReadableType(entity: ConcreteEntity) {\n if (entity instanceof Element)\n return \"element\";\n else if (entity instanceof ElementAspect)\n return \"element aspect\";\n else if (entity instanceof Relationship)\n return \"relationship\";\n else\n return \"unknown entity type\";\n }\n\n type EntityUpdater = (entityProps: ConcreteEntityProps) => void;\n\n /** needs to return a widened type otherwise typescript complains when result is used with a narrow type */\n export function updaterFor(db: IModelDb, entity: ConcreteEntity) {\n if (entity instanceof Element)\n return db.elements.updateElement.bind(db.elements) as EntityUpdater;\n else if (entity instanceof Relationship)\n return db.relationships.updateInstance.bind(db.relationships) as EntityUpdater;\n else if (entity instanceof ElementAspect)\n return db.elements.updateAspect.bind(db.elements) as EntityUpdater;\n else\n assert(false, `unreachable; entity was '${entity.constructor.name}' not an Element, Relationship, or ElementAspect`);\n }\n\n export function exists(db: IModelDb, arg: { entity: ConcreteEntity } | { entityReference: EntityReference }) {\n if (\"entityReference\" in arg) {\n const [type, id] = EntityReferences.split(arg.entityReference);\n const bisCoreRootClassName = ConcreteEntityTypes.toBisCoreRootClassFullName(type);\n return db.withPreparedStatement(`SELECT 1 FROM ${bisCoreRootClassName} WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n } else {\n return db.withPreparedStatement(`SELECT 1 FROM [${arg.entity.schemaName}].[${arg.entity.className}] WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, arg.entity.id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"EntityUnifier.js","sourceRoot":"","sources":["../../src/EntityUnifier.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;;;GAIG;AACH,iCAAiC;AACjC,oDAAkG;AAClG,sDAA4I;AAC5I,sDAA2C;AAE3C,gBAAgB;AAChB,IAAiB,aAAa,CA0D7B;AA1DD,WAAiB,aAAa;IAC5B,SAAgB,eAAe,CAAC,MAAsB;QACpD,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,SAAS,CAAC;aACd,IAAI,MAAM,YAAY,4BAAa;YACtC,OAAO,gBAAgB,CAAC;aACrB,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,cAAc,CAAC;;YAEtB,OAAO,qBAAqB,CAAC;IACjC,CAAC;IATe,6BAAe,kBAS9B,CAAA;IAID,2GAA2G;IAC3G,SAAgB,UAAU,CAAC,EAAY,EAAE,MAAsB;QAC7D,IAAI,MAAM,YAAY,sBAAO;YAC3B,OAAO,EAAE,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,CAAC;aACjE,IAAI,MAAM,YAAY,2BAAY;YACrC,OAAO,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,CAAC,EA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BAC9D,OAAO,KAAK,CAAC;YACf,OAAO,EAAE,CAAC,qBAAqB,CAAC,kBAAkB,GAAG,CAAC,MAAM,CAAC,UAAU,MAAM,GAAG,CAAC,MAAM,CAAC,SAAS,wBAAwB,EAAE,CAAC,IAAI,EAAE,EAAE;gBAClI,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;gBAC9B,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClC,IAAI,aAAa,KAAK,sBAAQ,CAAC,aAAa;oBAC1C,OAAO,IAAI,CAAC;gBACd,IAAI,aAAa,KAAK,sBAAQ,CAAC,cAAc;oBAC3C,OAAO,KAAK,CAAC;;oBAEb,MAAM,IAAI,yBAAW,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;SACJ;IACH,CAAC;IA/Be,oBAAM,SA+BrB,CAAA;AACH,CAAC,EA1DgB,aAAa,GAAb,qBAAa,KAAb,qBAAa,QA0D7B","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 Utils\n * utilities that unify operations, especially CRUD operations, on entities\n * for entity-generic operations in the transformer\n */\nimport * as assert from \"assert\";\nimport { ConcreteEntityTypes, DbResult, EntityReference, IModelError } from \"@itwin/core-common\";\nimport { ConcreteEntity, ConcreteEntityProps, Element, ElementAspect, EntityReferences, IModelDb, Relationship } from \"@itwin/core-backend\";\nimport { Id64 } from \"@itwin/core-bentley\";\n\n/** @internal */\nexport namespace EntityUnifier {\n export function getReadableType(entity: ConcreteEntity) {\n if (entity instanceof Element)\n return \"element\";\n else if (entity instanceof ElementAspect)\n return \"element aspect\";\n else if (entity instanceof Relationship)\n return \"relationship\";\n else\n return \"unknown entity type\";\n }\n\n type EntityUpdater = (entityProps: ConcreteEntityProps) => void;\n\n /** needs to return a widened type otherwise typescript complains when result is used with a narrow type */\n export function updaterFor(db: IModelDb, entity: ConcreteEntity) {\n if (entity instanceof Element)\n return db.elements.updateElement.bind(db.elements) as EntityUpdater;\n else if (entity instanceof Relationship)\n return db.relationships.updateInstance.bind(db.relationships) as EntityUpdater;\n else if (entity instanceof ElementAspect)\n return db.elements.updateAspect.bind(db.elements) as EntityUpdater;\n else\n assert(false, `unreachable; entity was '${entity.constructor.name}' not an Element, Relationship, or ElementAspect`);\n }\n\n export function exists(db: IModelDb, arg: { entity: ConcreteEntity } | { entityReference: EntityReference }) {\n if (\"entityReference\" in arg) {\n const [type, id] = EntityReferences.split(arg.entityReference);\n // FIXME: add a test with a deleted reference that triggers this\n if (id === undefined || Id64.isInvalid(id))\n return false;\n const bisCoreRootClassName = ConcreteEntityTypes.toBisCoreRootClassFullName(type);\n return db.withPreparedStatement(`SELECT 1 FROM ${bisCoreRootClassName} WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n } else {\n if (arg.entity.id === undefined || Id64.isInvalid(arg.entity.id))\n return false;\n return db.withPreparedStatement(`SELECT 1 FROM [${arg.entity.schemaName}].[${arg.entity.className}] WHERE ECInstanceId=?`, (stmt) => {\n stmt.bindId(1, arg.entity.id);\n const matchesResult = stmt.step();\n if (matchesResult === DbResult.BE_SQLITE_ROW)\n return true;\n if (matchesResult === DbResult.BE_SQLITE_DONE)\n return false;\n else\n throw new IModelError(matchesResult, \"query failed\");\n });\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/imodel-transformer",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "API for exporting an iModel's parts and also importing them into another iModel",
5
5
  "main": "lib/cjs/transformer.js",
6
6
  "typings": "lib/cjs/transformer",