Skip to content

Commit

Permalink
wip clean up compilation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmconne committed Dec 25, 2024
1 parent 5377bab commit 175e5c6
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 56 deletions.
10 changes: 5 additions & 5 deletions packages/transformer/src/BranchProvenanceInitializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function initializeBranchProvenance(
(s) =>
assert(
s.step() === DbResult.BE_SQLITE_DONE,
args.branch.nativeDb.getLastError()
args.branch.getLastError()
)
);
const masterPath = args.master.pathName;
Expand All @@ -86,7 +86,7 @@ export async function initializeBranchProvenance(
(s) =>
assert(
s.step() === DbResult.BE_SQLITE_DONE,
args.branch.nativeDb.getLastError()
args.branch.getLastError()
)
);
args.branch.withSqliteStatement(
Expand All @@ -102,7 +102,7 @@ export async function initializeBranchProvenance(
(s) =>
assert(
s.step() === DbResult.BE_SQLITE_DONE,
args.branch.nativeDb.getLastError()
args.branch.getLastError()
)
);
args.branch.clearCaches(); // statements write lock attached db (clearing statement cache does not fix this)
Expand All @@ -112,13 +112,13 @@ export async function initializeBranchProvenance(
if (res !== DbResult.BE_SQLITE_DONE)
Logger.logTrace(
"initializeBranchProvenance",
`Error detaching db (we will close anyway): ${args.branch.nativeDb.getLastError()}`
`Error detaching db (we will close anyway): ${args.branch.getLastError()}`
);
// this is the case until native side changes
// eslint-disable-next-line @itwin/no-internal
assert(
res === DbResult.BE_SQLITE_ERROR,
args.branch.nativeDb.getLastError()
args.branch.getLastError()
);
});
/* eslint-enable deprecation/deprecation */
Expand Down
8 changes: 4 additions & 4 deletions packages/transformer/src/IModelImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ export class IModelImporter {
protected onInsertElement(elementProps: ElementProps): Id64String {
/* eslint-disable deprecation/deprecation */
try {
const elementId = this.targetDb.nativeDb.insertElement(elementProps, {
const elementId = this.targetDb.elements.insertElement(elementProps, {
forceUseId: this.options.preserveElementIdsForFiltering,
});
// set the id like [IModelDb.insertElement]($backend), does, the raw nativeDb method does not
Expand All @@ -340,7 +340,7 @@ export class IModelImporter {
);
this.trackProgress();
if (this.options.simplifyElementGeometry) {
this.targetDb.nativeDb.simplifyElementGeometry({
this.targetDb.simplifyElementGeometry({
id: elementId,
convertBReps: true,
});
Expand Down Expand Up @@ -378,7 +378,7 @@ export class IModelImporter {
this.trackProgress();
if (this.options.simplifyElementGeometry) {
/* eslint-disable-next-line deprecation/deprecation */
this.targetDb.nativeDb.simplifyElementGeometry({
this.targetDb.simplifyElementGeometry({
id: elementProps.id,
convertBReps: true,
});
Expand Down Expand Up @@ -796,7 +796,7 @@ export class IModelImporter {
public optimizeGeometry(options: OptimizeGeometryOptions): void {
if (options.inlineUniqueGeometryParts) {
/* eslint-disable-next-line deprecation/deprecation */
const result = this.targetDb.nativeDb.inlineGeometryPartReferences();
const result = this.targetDb.inlineGeometryParts();
Logger.logInfo(
loggerCategory,
`Inlined ${result.numRefsInlined} references to ${result.numCandidateParts} geometry parts and deleted ${result.numPartsDeleted} parts.`
Expand Down
10 changes: 5 additions & 5 deletions packages/transformer/src/IModelTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2639,11 +2639,11 @@ export class IModelTransformer extends IModelExportHandler {
this._longNamedSchemasMap.set(schema.name, schemaFileName);
}
/* eslint-disable-next-line deprecation/deprecation */
this.sourceDb.nativeDb.exportSchema(
schema.name,
this._schemaExportDir,
schemaFileName
);
this.sourceDb.exportSchema({
schemaName: schema.name,
outputDirectory: this._schemaExportDir,
outputFileName: schemaFileName,
});
return { schemaPath: path.join(this._schemaExportDir, schemaFileName) };
}

Expand Down
4 changes: 0 additions & 4 deletions packages/transformer/src/test/IModelTransformerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,6 @@ export async function assertIdentityTransformation(
remapper.findTargetCodeSpecId,
remapper.findTargetAspectId,
];
/* eslint-disable-next-line deprecation/deprecation */
expect(sourceDb.nativeDb.hasUnsavedChanges()).to.be.false;
/* eslint-disable-next-line deprecation/deprecation */
expect(targetDb.nativeDb.hasUnsavedChanges()).to.be.false;

const sourceToTargetElemsMap = new Map<Element, Element | undefined>();
const targetToSourceElemsMap = new Map<Element, Element | undefined>();
Expand Down
4 changes: 0 additions & 4 deletions packages/transformer/src/test/TestUtils/IModelTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1382,10 +1382,6 @@ export class ExtensiveTestScenario {
}

public static populateDb(sourceDb: IModelDb): void {
// make sure Arial is in the font table
sourceDb.addNewFont("Arial");
assert.exists(sourceDb.fontMap.getFont("Arial"));

// Initialize project extents
const projectExtents = new Range3d(-1000, -1000, -1000, 1000, 1000, 1000);
sourceDb.updateProjectExtents(projectExtents);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,14 +422,5 @@ async function classicalTransformerBranchInit(
}

function setToStandalone(iModelName: string) {
// eslint-disable-next-line deprecation/deprecation
const nativeDb = new IModelHost.platform.DgnDb();
nativeDb.openIModel(iModelName, OpenMode.ReadWrite);
nativeDb.setITwinId(Guid.empty); // empty iTwinId means "standalone"
nativeDb.saveChanges(); // save change to iTwinId
nativeDb.deleteAllTxns(); // necessary before resetting briefcaseId
nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // standalone iModels should always have BriefcaseId unassigned
nativeDb.saveLocalValue("StandaloneEdit", JSON.stringify({ txns: true }));
nativeDb.saveChanges(); // save change to briefcaseId
nativeDb.closeFile();
StandaloneDb.convertToStandalone(iModelName);
}
4 changes: 2 additions & 2 deletions packages/transformer/src/test/standalone/Catalog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ describe("Catalog", () => {
assert.equal(catalogContainerIds.size, 1); // expected value from createAcmeCatalog
const catalogContainer =
catalogDb.elements.getElement<DefinitionContainer>(
catalogContainerIds.values().next().value,
catalogContainerIds.values().next().value!,
DefinitionContainer
);
const catalogContainerCodeSpec = catalogDb.codeSpecs.getById(
Expand Down Expand Up @@ -1326,7 +1326,7 @@ describe("Catalog", () => {
assert.equal(catalogContainerIds.size, 1); // expected value from createTestCatalog
const catalogContainer =
catalogDb.elements.getElement<DefinitionContainer>(
catalogContainerIds.values().next().value,
catalogContainerIds.values().next().value!,
DefinitionContainer
);
const catalogContainerCodeSpec = catalogDb.codeSpecs.getById(
Expand Down
13 changes: 2 additions & 11 deletions packages/transformer/src/test/standalone/IModelTransformer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2163,16 +2163,7 @@ describe("IModelTransformer", () => {

// for testing purposes only, based on SetToStandalone.ts, force a snapshot to mimic a standalone iModel
function setToStandalone(iModelName: string) {
// eslint-disable-next-line deprecation/deprecation
const nativeDb = new IModelHost.platform.DgnDb();
nativeDb.openIModel(iModelName, OpenMode.ReadWrite);
nativeDb.setITwinId(Guid.empty); // empty iTwinId means "standalone"
nativeDb.saveChanges(); // save change to iTwinId
nativeDb.deleteAllTxns(); // necessary before resetting briefcaseId
nativeDb.resetBriefcaseId(BriefcaseIdValue.Unassigned); // standalone iModels should always have BriefcaseId unassigned
nativeDb.saveLocalValue("StandaloneEdit", JSON.stringify({ txns: true }));
nativeDb.saveChanges(); // save change to briefcaseId
nativeDb.closeFile();
StandaloneDb.convertToStandalone(iModelName);
}

it("biscore update is valid", async () => {
Expand Down Expand Up @@ -2950,7 +2941,7 @@ describe("IModelTransformer", () => {
// insert an unrelated element that uses same id as subject1
// insertElement public api does not support forceUseId option
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
const targetSubjectId3 = targetDb.nativeDb.insertElement(
const targetSubjectId3 = targetDb.elements.insertElement(
newPropsForSubject3,
{ forceUseId: true }
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ describe("IModelTransformerHub", () => {
);
targetDb.saveChanges();
// eslint-disable-next-line deprecation/deprecation
assert.isFalse(targetDb.nativeDb.hasPendingTxns());
assert.isFalse(targetDb.txns.hasPendingTxns);
await targetDb.pushChanges({
accessToken,
description: "Should not actually push because there are no changes",
Expand Down Expand Up @@ -931,12 +931,12 @@ describe("IModelTransformerHub", () => {
// push sourceDb schema changes
/* eslint-disable deprecation/deprecation */
assert.equal(
sourceDb.nativeDb.hasPendingTxns(),
sourceDb.txns.hasPendingTxns,
expectedHasPendingTxns,
"Expect importSchemas to have saved changes"
);
assert.isFalse(
sourceDb.nativeDb.hasUnsavedChanges(),
sourceDb.txns.hasUnsavedChanges,
"Expect no unsaved changes after importSchemas"
);
await sourceDb.pushChanges({
Expand All @@ -950,11 +950,11 @@ describe("IModelTransformerHub", () => {
GenericSchema.schemaFilePath,
]);
assert.isFalse(
sourceDb.nativeDb.hasPendingTxns(),
sourceDb.txns.hasPendingTxns,
"Expect importSchemas to be a no-op"
);
assert.isFalse(
sourceDb.nativeDb.hasUnsavedChanges(),
sourceDb.txns.hasUnsavedChanges,
"Expect importSchemas to be a no-op"
);
/* eslint-enable deprecation/deprecation */
Expand Down Expand Up @@ -1045,7 +1045,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

const masterSeed: TimelineIModelState = {
Expand Down Expand Up @@ -1141,7 +1141,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);
const noFedGuidElemIds = masterSeedDb.queryEntityIds({
from: "Bis.Element",
Expand Down Expand Up @@ -1258,7 +1258,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);
const noFedGuidElemIds = masterSeedDb.queryEntityIds({
from: "Bis.Element",
Expand Down Expand Up @@ -1410,7 +1410,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

// 20 will be deleted, so it's important to know remapping deleted elements still works if there is no fedguid
Expand Down Expand Up @@ -2259,7 +2259,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);
const masterSeed: TimelineIModelState = {
// HACK: we know this will only be used for seeding via its path and performCheckpoint
Expand Down Expand Up @@ -3536,7 +3536,7 @@ describe("IModelTransformerHub", () => {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
// masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

const noFedGuidElemIds = masterSeedDb.queryEntityIds({
Expand Down

0 comments on commit 175e5c6

Please sign in to comment.