Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make processALl and processChanges private, expose a public process function and let people pass isSync to constructor of imodeltransformer #190

Merged
merged 21 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bda984d
All tests building and passing with private processAll, processChange…
nick4598 Jul 9, 2024
f9950a0
Attempt to comment process. How should it look when the behavior chan…
nick4598 Jul 9, 2024
b96ff25
fix up documentation a bit to reflect that process( is called now.
nick4598 Jul 9, 2024
24e760b
slight documentation change
nick4598 Jul 10, 2024
8d75fc4
just use isSync passed from options, abandon that private var
nick4598 Jul 10, 2024
f5690c8
changes
nick4598 Jul 10, 2024
6f9ad88
Change files
nick4598 Jul 10, 2024
641bd9c
slightly different validation approach
nick4598 Jul 11, 2024
c3584a2
fix comment
nick4598 Jul 11, 2024
e1b8bcb
try v4 of pnpm action setup
nick4598 Jul 11, 2024
e2a48ef
remove isSynchronization and just pass processchangesoptions
nick4598 Jul 11, 2024
ceab270
always call initialize in process because initialize will return earl…
nick4598 Jul 12, 2024
4034553
remove isReverseSynchronization from transformoptions
nick4598 Jul 12, 2024
2fb35af
add comment to accessToken stating its preferred to setup an authoriz…
nick4598 Jul 12, 2024
17e37f1
fix docs
nick4598 Jul 12, 2024
65c5e50
update comment on argsForProcessChanges
nick4598 Aug 5, 2024
5a373e7
move processChanges options, remove accessToken, warn if Auth client …
derbynn Aug 12, 2024
e621a5c
update unsafeFallbackReverseSyncVersion and unsafeFallbackSyncVersion…
derbynn Aug 12, 2024
ab2e701
Merge branch 'main' into nick/private-processallchanges
derbynn Aug 13, 2024
ff23398
fix comments, improve warning message and remove unnecessary commas
derbynn Aug 16, 2024
a25f48a
Merge branch 'nick/private-processallchanges' of https://github.com/i…
derbynn Aug 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Make processAll and processChanges private, expose a public process function and let people pass isSync to constructor of imodeltransformer",
"packageName": "@itwin/imodel-transformer",
"email": "22119573+nick4598@users.noreply.github.com",
"dependentChangeType": "patch"
}
4 changes: 2 additions & 2 deletions packages/performance-tests/test/rawInserts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default async function rawInserts(
});

const [transformWithProvTimer] = await timed(async () => {
await transformerWithProv.processAll();
await transformerWithProv.process();
});

reporter.addEntry(
Expand Down Expand Up @@ -157,7 +157,7 @@ export default async function rawInserts(
});

const [transformNoProvTimer] = await timed(async () => {
await transformerNoProv.processAll();
await transformerNoProv.process();
});

reporter.addEntry(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const nativeTransformerTestModule: TestTransformerModule = {
return {
async run() {
await transformer.processSchemas();
await transformer.processAll();
await transformer.process();
transformer.dispose();
},
};
Expand Down Expand Up @@ -96,7 +96,7 @@ const nativeTransformerTestModule: TestTransformerModule = {
});
return {
async run() {
await transformer.processAll();
await transformer.process();
transformer.dispose();
},
};
Expand Down
1 change: 0 additions & 1 deletion packages/test-app/src/Main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,6 @@ void (async () => {
if (processChanges) {
assert(undefined !== args.sourceStartChangesetId);
await Transformer.transformChanges(
await acquireAccessToken(),
derbynn marked this conversation as resolved.
Show resolved Hide resolved
sourceDb,
targetDb,
args.sourceStartChangesetId,
Expand Down
16 changes: 8 additions & 8 deletions packages/test-app/src/Transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/

import {
AccessToken,
assert,
DbResult,
Id64,
Expand Down Expand Up @@ -70,7 +69,7 @@ export class Transformer extends IModelTransformer {
const transformer = new Transformer(sourceDb, targetDb, options);
await transformer.processSchemas();
await transformer.saveChanges("processSchemas");
await transformer.processAll();
await transformer.process();
await transformer.saveChanges("processAll");
if (options?.deleteUnusedGeometryParts) {
transformer.deleteUnusedGeometryParts();
Expand All @@ -81,7 +80,6 @@ export class Transformer extends IModelTransformer {
}

public static async transformChanges(
accessToken: AccessToken,
sourceDb: IModelDb,
targetDb: IModelDb,
sourceStartChangesetId: string,
Expand All @@ -91,13 +89,15 @@ export class Transformer extends IModelTransformer {
assert("" === sourceStartChangesetId);
return this.transformAll(sourceDb, targetDb, options);
}
const transformer = new Transformer(sourceDb, targetDb, options);
const transformer = new Transformer(sourceDb, targetDb, {
...options,
argsForProcessChanges: {
startChangeset: { id: sourceStartChangesetId },
},
});
await transformer.processSchemas();
await transformer.saveChanges("processSchemas");
await transformer.processChanges({
accessToken,
startChangeset: { id: sourceStartChangesetId },
});
await transformer.process();
await transformer.saveChanges("processChanges");
if (options?.deleteUnusedGeometryParts) {
transformer.deleteUnusedGeometryParts();
Expand Down
52 changes: 23 additions & 29 deletions packages/transformer/src/IModelExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import {
} from "@itwin/ecschema-metadata";
import { TransformerLoggerCategory } from "./TransformerLoggerCategory";
import * as nodeAssert from "assert";
import type { InitOptions } from "./IModelTransformer";
import {
ElementAspectsHandler,
ExportElementAspectsStrategy,
Expand Down Expand Up @@ -83,34 +82,34 @@ export type ExporterInitOptions = ExportChangesOptions;
* Arguments for [[IModelExporter.exportChanges]]
* @public
*/
export type ExportChangesOptions = Omit<InitOptions, "startChangeset"> & {
export type ExportChangesOptions = {
skipPropagateChangesToRootElements?: boolean;
} /**
* an array of ChangesetFileProps which are used to read the changesets and populate the ChangedInstanceIds using [[ChangedInstanceIds.initialize]] in [[IModelExporter.exportChanges]]
* @note mutually exclusive with @see changesetRanges, @see startChangeset and @see changedInstanceIds, so define one of the four, never more
*/ & (
| { csFileProps: ChangesetFileProps[] }
/**
* Class instance that contains modified elements between 2 versions of an iModel.
* If this parameter is not provided, then [[ChangedInstanceIds.initialize]] in [[IModelExporter.exportChanges]]
* will be called to discover changed elements.
* @note mutually exclusive with @see changesetRanges, @see csFileProps and @see startChangeset, so define one of the four, never more
*/
| { changedInstanceIds: ChangedInstanceIds }
/**
* An ordered array of changeset index ranges, e.g. [[2,2], [4,5]] is [2,4,5]
* @note mutually exclusive with @see changedInstanceIds, @see csFileProps and @see startChangeset, so define one of the four, never more
*/
| { changesetRanges: [number, number][] }
/**
* Include changes from this changeset up through and including the current changeset.
* @note To form a range of versions to process, set `startChangeset` for the start (inclusive)
* of the desired range and open the source iModel as of the end (inclusive) of the desired range.
* @default the current changeset of the sourceDb, if undefined
*/
| { startChangeset: { id?: string; index?: number } }
| {}
);
| { csFileProps: ChangesetFileProps[] }
/**
* Class instance that contains modified elements between 2 versions of an iModel.
* If this parameter is not provided, then [[ChangedInstanceIds.initialize]] in [[IModelExporter.exportChanges]]
* will be called to discover changed elements.
* @note mutually exclusive with @see changesetRanges, @see csFileProps and @see startChangeset, so define one of the four, never more
*/
| { changedInstanceIds: ChangedInstanceIds }
/**
* An ordered array of changeset index ranges, e.g. [[2,2], [4,5]] is [2,4,5]
* @note mutually exclusive with @see changedInstanceIds, @see csFileProps and @see startChangeset, so define one of the four, never more
*/
| { changesetRanges: [number, number][] }
/**
* Include changes from this changeset up through and including the current changeset.
* @note To form a range of versions to process, set `startChangeset` for the start (inclusive)
* of the desired range and open the source iModel as of the end (inclusive) of the desired range.
* @default the current changeset of the sourceDb, if undefined
*/
| { startChangeset: { id?: string; index?: number } }
| {}
);

/** Handles the events generated by IModelExporter.
* @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).
Expand Down Expand Up @@ -452,7 +451,6 @@ export class IModelExporter {
typeof accessTokenOrOpts === "object"
? accessTokenOrOpts
: {
accessToken: accessTokenOrOpts,
startChangeset: { id: startChangesetId },
};

Expand Down Expand Up @@ -1190,7 +1188,6 @@ export class ChangedInstanceIds {
if ("changedInstanceIds" in opts) return opts.changedInstanceIds;

const iModelId = opts.iModel.iModelId;
const accessToken = opts.accessToken;

const startChangeset =
"startChangeset" in opts ? opts.startChangeset : undefined;
Expand All @@ -1205,15 +1202,13 @@ export class ChangedInstanceIds {
changeset: {
id: startChangeset.id ?? opts.iModel.changeset.id,
},
accessToken,
})
).index,
opts.iModel.changeset.index ??
(
await IModelHost.hubAccess.queryChangeset({
iModelId,
changeset: { id: opts.iModel.changeset.id },
accessToken,
})
).index,
],
Expand All @@ -1227,7 +1222,6 @@ export class ChangedInstanceIds {
await Promise.all(
changesetRanges.map(async ([first, end]) =>
IModelHost.hubAccess.downloadChangesets({
accessToken,
iModelId,
range: { first, end },
targetDir: BriefcaseManager.getChangeSetsPath(iModelId),
Expand Down
4 changes: 2 additions & 2 deletions packages/transformer/src/IModelImporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ export class IModelImporter {
protected onProgress(): void {}

/** Optionally compute the projectExtents for the target iModel depending on the options for this IModelImporter.
* @note This method is automatically called from [IModelTransformer.processChanges]($transformer) and [IModelTransformer.processAll]($transformer).
* @note This method is automatically called from [IModelTransformer.process]($transformer).
* @see [IModelDb.computeProjectExtents]($backend), [[autoExtendProjectExtents]]
*/
public computeProjectExtents(): void {
Expand Down Expand Up @@ -755,7 +755,7 @@ export class IModelImporter {
}

/** Examine the geometry streams of every [GeometricElement3d]($backend) in the target iModel and apply the specified optimizations.
* @note This method is automatically called from [[IModelTransformer.processChanges]] and [[IModelTransformer.processAll]] if
* @note This method is automatically called from [[IModelTransformer.process]] if
* [[IModelTransformOptions.optimizeGeometry]] is defined.
*/
public optimizeGeometry(options: OptimizeGeometryOptions): void {
Expand Down
Loading
Loading