Skip to content

Commit

Permalink
extract-api
Browse files Browse the repository at this point in the history
  • Loading branch information
nick4598 committed Jan 3, 2025
1 parent a0834ec commit 6ad00d9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
33 changes: 33 additions & 0 deletions common/api/imodel-transformer.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { EntityReference } from '@itwin/core-common';
import { ExternalSourceAspect } from '@itwin/core-backend';
import { ExternalSourceAspectProps } from '@itwin/core-common';
import { FontProps } from '@itwin/core-common';
import { Id64Arg } from '@itwin/core-bentley';
import { Id64Array } from '@itwin/core-bentley';
import { Id64Set } from '@itwin/core-bentley';
import { Id64String } from '@itwin/core-bentley';
Expand All @@ -36,11 +37,34 @@ import { Relationship } from '@itwin/core-backend';
import { RelationshipProps } from '@itwin/core-backend';
import { Schema } from '@itwin/ecschema-metadata';
import { SchemaKey } from '@itwin/ecschema-metadata';
import { SqliteChangeOp } from '@itwin/core-backend';

// @beta
export interface ChangedInstanceCustomRelationshipData {
// (undocumented)
classFullName: string;
// (undocumented)
ecClassId: Id64String;
// (undocumented)
sourceIdOfRelationship: Id64String;
// (undocumented)
targetIdOfRelationship: Id64String;
}

// @public
export class ChangedInstanceIds {
constructor(db: IModelDb);
addChange(change: ChangedECInstance): Promise<void>;
// @beta
addCustomAspectChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
// @beta
addCustomCodeSpecChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
// @beta
addCustomElementChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
// @beta
addCustomModelChange(changeType: SqliteChangeOp, ids: Id64Arg): void;
// @beta
addCustomRelationshipChange(ecClassId: string, changeType: SqliteChangeOp, id: Id64String, sourceECInstanceId: Id64String, targetECInstanceId: Id64String): Promise<void>;
// (undocumented)
aspect: ChangedInstanceOps;
// (undocumented)
Expand All @@ -49,8 +73,14 @@ export class ChangedInstanceIds {
element: ChangedInstanceOps;
// (undocumented)
font: ChangedInstanceOps;
// @beta
getCustomRelationshipDataFromId(id: Id64String): ChangedInstanceCustomRelationshipData | undefined;
// (undocumented)
get hasCustomChanges(): boolean;
static initialize(opts: ChangedInstanceIdsInitOptions): Promise<ChangedInstanceIds | undefined>;
// (undocumented)
get isEmpty(): boolean;
// (undocumented)
model: ChangedInstanceOps;
// (undocumented)
relationship: ChangedInstanceOps;
Expand All @@ -69,6 +99,8 @@ export class ChangedInstanceOps {
// (undocumented)
insertIds: Set<string>;
// (undocumented)
get isEmpty(): boolean;
// (undocumented)
updateIds: Set<string>;
}

Expand Down Expand Up @@ -124,6 +156,7 @@ export function hasEntityChanged(entity: Entity, entityProps: EntityProps, names
// @beta
export class IModelExporter {
constructor(sourceDb: IModelDb, elementAspectsStrategy?: new (source: IModelDb, handler: ElementAspectsHandler) => ExportElementAspectsStrategy);
addCustomChanges(): void;
excludeCodeSpec(codeSpecName: string): void;
excludeElement(elementId: Id64String): void;
excludeElementAspectClass(classFullName: string): void;
Expand Down
1 change: 1 addition & 0 deletions common/api/summary/imodel-transformer.exports.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
sep=;
Release Tag;API Item
beta;ChangedInstanceCustomRelationshipData
public;ChangedInstanceIds
public;ChangedInstanceIdsInitOptions = ExportChangesOptions &
public;ChangedInstanceOps
Expand Down
16 changes: 9 additions & 7 deletions packages/transformer/src/IModelExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1065,6 +1065,7 @@ export class ChangedInstanceOps {
/**
* Interface to describe a 'custom' change. A custom change is one which isn't found by reading changesets, but instead added by a user calling the 'addCustomChange' API on the ChangedInstanceIds instance.
* The purpose a custom change would serve is to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
* @beta
*/
export interface ChangedInstanceCustomRelationshipData {
sourceIdOfRelationship: Id64String;
Expand Down Expand Up @@ -1237,6 +1238,7 @@ export class ChangedInstanceIds {
* @note element changes will also cause the element's model to be marked as updated in [[ChangedInstanceIds.model]], so that the element does not get skipped by the transformer.
* @note It is the responsibility of the caller to ensure that the provided id is, in fact an element.
* @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
* @beta
*/
public addCustomElementChange(
changeType: SqliteChangeOp,
Expand All @@ -1255,6 +1257,7 @@ export class ChangedInstanceIds {
* from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
* @note It is the responsibility of the caller to ensure that the provided id is, in fact a codespec.
* @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
* @beta
*/
public addCustomCodeSpecChange(
changeType: SqliteChangeOp,
Expand All @@ -1272,6 +1275,7 @@ export class ChangedInstanceIds {
* from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
* @note It is the responsibility of the caller to ensure that the provided id is, in fact a model.
* @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
* @beta
*/
public addCustomModelChange(changeType: SqliteChangeOp, ids: Id64Arg): void {
for (const id of Id64.iterable(ids)) {
Expand All @@ -1287,6 +1291,7 @@ export class ChangedInstanceIds {
* from the set of updatedIds and add it to the set of deletedIds for the appropriate class type.
* @note It is the responsibility of the caller to ensure that the provided id is, in fact an aspect.
* @note In most cases, this method does not need to be called. Its only for consumers to mimic changes as if they were found in a changeset, which should only be useful in certain cases such as the changing of filter criteria for a preexisting master branch relationship.
* @beta
*/
public addCustomAspectChange(changeType: SqliteChangeOp, ids: Id64Arg): void {
for (const id of Id64.iterable(ids)) {
Expand All @@ -1309,7 +1314,9 @@ export class ChangedInstanceIds {
this.handleChange(this.model, "Updated", modelId);
}

/** TODO: Maybe relationships only? maybe not. */
/** TODO: Maybe relationships only? maybe not.
* @beta
*/
public getCustomRelationshipDataFromId(
id: Id64String
): ChangedInstanceCustomRelationshipData | undefined {
Expand All @@ -1329,6 +1336,7 @@ export class ChangedInstanceIds {
* @param id ECInstanceID of the custom change
* @param sourceECInstanceId source ECInstanceId of the relationship
* @param targetECInstanceId target ECInstanceId of the relationship
* @beta
*/
public async addCustomRelationshipChange(
ecClassId: string,
Expand Down Expand Up @@ -1359,12 +1367,6 @@ export class ChangedInstanceIds {
this.handleChange(this.relationship, changeType, id);
}

private getClassFullNameFromECClassId(
ecClassid: Id64String
): string | undefined {
return this._ecClassIdsToClassFullNames?.get(ecClassid);
}

private handleChange(
changedInstanceOps: ChangedInstanceOps,
changeType: SqliteChangeOp,
Expand Down

0 comments on commit 6ad00d9

Please sign in to comment.