Skip to content

Commit

Permalink
Disable deprecation lint rule for all calls to nativeDb (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick4598 authored Aug 8, 2024
1 parent 0f8e8a5 commit 683d764
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 54 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.27.0

Expand All @@ -44,7 +44,7 @@ jobs:
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.27.0

Expand Down Expand Up @@ -100,7 +100,7 @@ jobs:
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.27.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
token: ${{ secrets.IMJS_ADMIN_GH_TOKEN }}

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.27.0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
token: ${{ secrets.IMJS_ADMIN_GH_TOKEN }}

- name: Install pnpm
uses: pnpm/action-setup@v2.2.4
uses: pnpm/action-setup@v4
with:
version: 7.33.2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "",
"packageName": "@itwin/imodel-transformer",
"email": "22119573+nick4598@users.noreply.github.com",
"dependentChangeType": "patch"
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,10 @@
"pnpm": ">=6",
"npm": "<0",
"node": ">=16"
},
"pnpm": {
"overrides": {
"semver": "^7.5.2"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default async function identityTransformer(context: TestCaseContext) {
const schemaDumpDir = fs.mkdtempSync(
path.join(os.tmpdir(), "identity-test-schemas-dump-")
);
// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
sourceDb.nativeDb.exportSchemas(schemaDumpDir);
Logger.logInfo(loggerCategory, `dumped schemas to: ${schemaDumpDir}`);
throw err;
Expand Down
2 changes: 1 addition & 1 deletion packages/performance-tests/test/cases/prepare-fork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default async function prepareFork(context: TestCaseContext) {
const schemaDumpDir = fs.mkdtempSync(
path.join(os.tmpdir(), "fork-test-schemas-dump-")
);
// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
sourceDb.nativeDb.exportSchemas(schemaDumpDir);
Logger.logInfo(loggerCategory, `dumped schemas to: ${schemaDumpDir}`);
throw err;
Expand Down
2 changes: 1 addition & 1 deletion packages/performance-tests/test/iModelUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface IModelParams {
// TODO: dedup with other packages
// for testing purposes only, based on SetToStandalone.ts, force a snapshot to mimic a standalone iModel
export function setToStandalone(iModelPath: string) {
// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
const nativeDb = new IModelHost.platform.DgnDb();
nativeDb.openIModel(iModelPath, OpenMode.ReadWrite);
nativeDb.setITwinId(Guid.empty); // empty iTwinId means "standalone"
Expand Down
6 changes: 3 additions & 3 deletions packages/performance-tests/test/rawInserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default async function rawInserts(
});

const [applyChangeSetTimer] = timed(() => {
// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
changesetDb.nativeDb.applyChangeset(changeset1);
});

Expand Down Expand Up @@ -186,7 +186,7 @@ export default async function rawInserts(

// stolen from itwinjs-core: core/backend/src/test/changesets/ChangeMerging.test.ts
function createChangeset(imodel: IModelDb): ChangesetFileProps {
// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
const changeset = imodel.nativeDb.startCreateChangeset();

// completeCreateChangeset deletes the file that startCreateChangeSet created.
Expand All @@ -195,7 +195,7 @@ function createChangeset(imodel: IModelDb): ChangesetFileProps {
fs.copyFileSync(changeset.pathname, csFileName);
changeset.pathname = csFileName;

// eslint-disable-next-line @itwin/no-internal
// eslint-disable-next-line @itwin/no-internal, deprecation/deprecation
imodel.nativeDb.completeCreateChangeset({ index: 0 });
return changeset as any; // FIXME: bad peer deps
}
2 changes: 2 additions & 0 deletions packages/test-app/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ void (async () => {
if (args.targetStandaloneDestination) {
fs.copyFileSync(fileName, args.targetStandaloneDestination);
function setToStandalone(iModelPath: string) {
/* eslint-disable deprecation/deprecation */
const nativeDb = new IModelHost.platform.DgnDb();
nativeDb.openIModel(iModelPath, OpenMode.ReadWrite);
nativeDb.setITwinId(Guid.empty); // empty iTwinId means "standalone"
Expand All @@ -510,6 +511,7 @@ void (async () => {
nativeDb.saveChanges(); // save change to briefcaseId
nativeDb.closeFile();
}
/* eslint-enable deprecation/deprecation */
targetDb.close();
setToStandalone(args.targetStandaloneDestination);
await StandaloneDb.upgradeSchemas({ fileName });
Expand Down
3 changes: 3 additions & 0 deletions packages/transformer/src/BranchProvenanceInitializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export async function initializeBranchProvenance(
if (args.createFedGuidsForMaster) {
// FIXME<LOW>: Consider enforcing that the master and branch dbs passed as part of ProvenanceInitArgs to this function
// are identical. https://github.com/iTwin/imodel-transformer/issues/138
/* eslint-disable deprecation/deprecation */
args.master.withSqliteStatement(
`
UPDATE bis_Element
Expand Down Expand Up @@ -96,6 +97,7 @@ export async function initializeBranchProvenance(
FROM master.bis_Element m
WHERE m.Id=main.bis_Element.Id
)`,

// eslint-disable-next-line @itwin/no-internal
(s) =>
assert(
Expand All @@ -119,6 +121,7 @@ export async function initializeBranchProvenance(
args.branch.nativeDb.getLastError()
);
});
/* eslint-enable deprecation/deprecation */
args.branch.performCheckpoint();

const reopenBranch = makeDbReopener(args.branch);
Expand Down
4 changes: 4 additions & 0 deletions packages/transformer/src/IModelImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class IModelImporter {
* @note A subclass may override this method to customize insert behavior but should call `super.onInsertElement`.
*/
protected onInsertElement(elementProps: ElementProps): Id64String {
/* eslint-disable deprecation/deprecation */
try {
const elementId = this.targetDb.nativeDb.insertElement(elementProps, {
forceUseId: this.options.preserveElementIdsForFiltering,
Expand Down Expand Up @@ -324,6 +325,7 @@ export class IModelImporter {
}
throw error; // throw original error
}
/* eslint-enable deprecation/deprecation */
}

/** Update an existing Element in the target iModel from the specified ElementProps.
Expand All @@ -340,6 +342,7 @@ export class IModelImporter {
);
this.trackProgress();
if (this.options.simplifyElementGeometry) {
/* eslint-disable-next-line deprecation/deprecation */
this.targetDb.nativeDb.simplifyElementGeometry({
id: elementProps.id,
convertBReps: true,
Expand Down Expand Up @@ -757,6 +760,7 @@ export class IModelImporter {
*/
public optimizeGeometry(options: OptimizeGeometryOptions): void {
if (options.inlineUniqueGeometryParts) {
/* eslint-disable-next-line deprecation/deprecation */
const result = this.targetDb.nativeDb.inlineGeometryPartReferences();
Logger.logInfo(
loggerCategory,
Expand Down
1 change: 1 addition & 0 deletions packages/transformer/src/IModelTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2745,6 +2745,7 @@ 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,
Expand Down
3 changes: 2 additions & 1 deletion packages/transformer/src/test/IModelTransformerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,9 @@ 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>();
Expand Down
1 change: 1 addition & 0 deletions packages/transformer/src/test/TestUtils/IModelTestUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,7 @@ export class IModelTestUtils {

/** Flushes the Txns in the TxnTable - this allows importing of schemas */
public static flushTxns(iModelDb: IModelDb): boolean {
/* eslint-disable-next-line deprecation/deprecation */
iModelDb.nativeDb.deleteAllTxns();
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/transformer/src/test/TestUtils/RevisionUtility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface ChangesetSizeInfo {
prefixSize?: number;
}

/* eslint-disable deprecation/deprecation */
export class RevisionUtility {
public static readonly DEFAULT: LzmaParams = {
algo: 1,
Expand All @@ -55,6 +56,7 @@ export class RevisionUtility {
): BentleyStatus {
if (!IModelJsFs.existsSync(sourceFile))
throw new Error("SourceFile does not exists");

return IModelHost.platform.RevisionUtility.recompressRevision(
sourceFile,
targetFile,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ 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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2163,6 +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"
Expand Down Expand Up @@ -3579,6 +3580,7 @@ describe("IModelTransformer", () => {
assert(biscoreVersion !== undefined);
const fakeSchemaVersion = "1.0.99";
expect(Semver.lt(biscoreVersion, fakeSchemaVersion)).to.be.true;
// eslint-disable-next-line deprecation/deprecation
const biscoreText = sourceDb.nativeDb.schemaToXmlString("BisCore");
assert(biscoreText !== undefined);
const fakeBisCoreUpdateText = biscoreText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ describe("IModelTransformerHub", () => {
"Second import should not add relationships"
);
targetDb.saveChanges();
// eslint-disable-next-line deprecation/deprecation
assert.isFalse(targetDb.nativeDb.hasPendingTxns());
await targetDb.pushChanges({
accessToken,
Expand Down Expand Up @@ -780,6 +781,7 @@ describe("IModelTransformerHub", () => {
seedBisCoreVersion !== updatedBisCoreVersion;

// push sourceDb schema changes
/* eslint-disable deprecation/deprecation */
assert.equal(
sourceDb.nativeDb.hasPendingTxns(),
expectedHasPendingTxns,
Expand Down Expand Up @@ -807,6 +809,7 @@ describe("IModelTransformerHub", () => {
sourceDb.nativeDb.hasUnsavedChanges(),
"Expect importSchemas to be a no-op"
);
/* eslint-enable deprecation/deprecation */
sourceDb.saveChanges(); // will be no changes to save in this case
await sourceDb.pushChanges({
accessToken,
Expand Down Expand Up @@ -893,6 +896,7 @@ describe("IModelTransformerHub", () => {
const masterSeedDb = SnapshotDb.createEmpty(masterSeedFileName, {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

Expand Down Expand Up @@ -988,6 +992,7 @@ describe("IModelTransformerHub", () => {
const masterSeedDb = SnapshotDb.createEmpty(masterSeedFileName, {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);
const noFedGuidElemIds = masterSeedDb.queryEntityIds({
Expand Down Expand Up @@ -1104,6 +1109,7 @@ describe("IModelTransformerHub", () => {
const masterSeedDb = SnapshotDb.createEmpty(masterSeedFileName, {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);
const noFedGuidElemIds = masterSeedDb.queryEntityIds({
Expand Down Expand Up @@ -1255,6 +1261,7 @@ describe("IModelTransformerHub", () => {
const masterSeedDb = SnapshotDb.createEmpty(masterSeedFileName, {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

Expand Down Expand Up @@ -1547,10 +1554,12 @@ describe("IModelTransformerHub", () => {
const changesetPath = masterDbChangeset.pathname;
assert.isTrue(IModelJsFs.existsSync(changesetPath));
// below is one way of determining the set of elements that were deleted in a specific changeset
/* eslint-disable deprecation/deprecation */
const statusOrResult =
master.db.nativeDb.extractChangedInstanceIdsFromChangeSets([
changesetPath,
]);
/* eslint-enable deprecation/deprecation */
assert.isUndefined(statusOrResult.error);
const result = statusOrResult.result;
if (result === undefined) throw Error("expected to be defined");
Expand Down Expand Up @@ -1624,10 +1633,12 @@ describe("IModelTransformerHub", () => {
const changesetPath = replayedDbChangeset.pathname;
assert.isTrue(IModelJsFs.existsSync(changesetPath));
// below is one way of determining the set of elements that were deleted in a specific changeset
/* eslint-disable deprecation/deprecation */
const statusOrResult =
replayedDb.nativeDb.extractChangedInstanceIdsFromChangeSets([
changesetPath,
]);
/* eslint-enable deprecation/deprecation */
const result = statusOrResult.result;
if (result === undefined) throw Error("expected to be defined");

Expand Down Expand Up @@ -1756,10 +1767,12 @@ describe("IModelTransformerHub", () => {
});
expect(sourceDbChangesets).to.have.length(2);
const latestChangeset = sourceDbChangesets[1];
/* eslint-disable deprecation/deprecation */
const extractedChangedIds =
sourceDb.nativeDb.extractChangedInstanceIdsFromChangeSets([
latestChangeset.pathname,
]);
/* eslint-enable deprecation/deprecation */
const expectedChangedIds: IModelJsNative.ChangedInstanceIdsProps = {
element: { update: [modelSelectorId] },
model: { update: [IModel.dictionaryId] }, // containing model will also get last modification time updated
Expand Down Expand Up @@ -2449,10 +2462,12 @@ describe("IModelTransformerHub", () => {
});
expect(branchDbChangesets).to.have.length(2);
const latestChangeset = branchDbChangesets[1];
/* eslint-disable deprecation/deprecation */
const extractedChangedIds =
branchDb.nativeDb.extractChangedInstanceIdsFromChangeSets([
latestChangeset.pathname,
]);
/* eslint-enable deprecation/deprecation */
const aspectDeletions = [
...modelToDeleteWithElem.aspects,
...childSubject.aspects,
Expand Down Expand Up @@ -3257,6 +3272,7 @@ describe("IModelTransformerHub", () => {
const masterSeedDb = SnapshotDb.createEmpty(masterSeedFileName, {
rootSubject: { name: masterIModelName },
});
// eslint-disable-next-line deprecation/deprecation
masterSeedDb.nativeDb.setITwinId(iTwinId); // workaround for "ContextId was not properly setup in the checkpoint" issue
populateTimelineSeed(masterSeedDb, masterSeedState);

Expand Down
Loading

0 comments on commit 683d764

Please sign in to comment.