@itwin/ecschema-editing 4.5.0-dev.8 → 4.6.0-dev.0

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +62 -1
  2. package/LICENSE.md +1 -1
  3. package/lib/cjs/Differencing/SchemaConflicts.d.ts +76 -0
  4. package/lib/cjs/Differencing/SchemaConflicts.d.ts.map +1 -0
  5. package/lib/cjs/Differencing/SchemaConflicts.js +56 -0
  6. package/lib/cjs/Differencing/SchemaConflicts.js.map +1 -0
  7. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts +43 -0
  8. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.d.ts.map +1 -0
  9. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js +501 -0
  10. package/lib/cjs/Differencing/SchemaDiagnosticVisitor.js.map +1 -0
  11. package/lib/cjs/Differencing/SchemaDifference.d.ts +150 -0
  12. package/lib/cjs/Differencing/SchemaDifference.d.ts.map +1 -0
  13. package/lib/cjs/Differencing/SchemaDifference.js +54 -0
  14. package/lib/cjs/Differencing/SchemaDifference.js.map +1 -0
  15. package/lib/cjs/Editing/ECClasses.d.ts +9 -2
  16. package/lib/cjs/Editing/ECClasses.d.ts.map +1 -1
  17. package/lib/cjs/Editing/ECClasses.js +25 -0
  18. package/lib/cjs/Editing/ECClasses.js.map +1 -1
  19. package/lib/cjs/Editing/Entities.d.ts +8 -2
  20. package/lib/cjs/Editing/Entities.d.ts.map +1 -1
  21. package/lib/cjs/Editing/Entities.js +29 -6
  22. package/lib/cjs/Editing/Entities.js.map +1 -1
  23. package/lib/cjs/Editing/Mixins.d.ts +7 -1
  24. package/lib/cjs/Editing/Mixins.d.ts.map +1 -1
  25. package/lib/cjs/Editing/Mixins.js +15 -0
  26. package/lib/cjs/Editing/Mixins.js.map +1 -1
  27. package/lib/cjs/Editing/RelationshipClasses.d.ts +7 -1
  28. package/lib/cjs/Editing/RelationshipClasses.d.ts.map +1 -1
  29. package/lib/cjs/Editing/RelationshipClasses.js +20 -1
  30. package/lib/cjs/Editing/RelationshipClasses.js.map +1 -1
  31. package/lib/cjs/Merging/CAClassMerger.d.ts.map +1 -1
  32. package/lib/cjs/Merging/CAClassMerger.js +1 -5
  33. package/lib/cjs/Merging/CAClassMerger.js.map +1 -1
  34. package/lib/cjs/Merging/ClassMerger.d.ts +4 -3
  35. package/lib/cjs/Merging/ClassMerger.d.ts.map +1 -1
  36. package/lib/cjs/Merging/ClassMerger.js +57 -49
  37. package/lib/cjs/Merging/ClassMerger.js.map +1 -1
  38. package/lib/cjs/Merging/EntityClassMerger.d.ts +3 -2
  39. package/lib/cjs/Merging/EntityClassMerger.d.ts.map +1 -1
  40. package/lib/cjs/Merging/EntityClassMerger.js +22 -7
  41. package/lib/cjs/Merging/EntityClassMerger.js.map +1 -1
  42. package/lib/cjs/Merging/MixinMerger.d.ts.map +1 -1
  43. package/lib/cjs/Merging/MixinMerger.js +1 -5
  44. package/lib/cjs/Merging/MixinMerger.js.map +1 -1
  45. package/lib/cjs/Merging/PropertyMerger.d.ts +21 -0
  46. package/lib/cjs/Merging/PropertyMerger.d.ts.map +1 -0
  47. package/lib/cjs/Merging/PropertyMerger.js +315 -0
  48. package/lib/cjs/Merging/PropertyMerger.js.map +1 -0
  49. package/lib/cjs/Merging/RelationshipClassMerger.d.ts +15 -0
  50. package/lib/cjs/Merging/RelationshipClassMerger.d.ts.map +1 -0
  51. package/lib/cjs/Merging/RelationshipClassMerger.js +132 -0
  52. package/lib/cjs/Merging/RelationshipClassMerger.js.map +1 -0
  53. package/lib/cjs/Merging/SchemaMerger.d.ts.map +1 -1
  54. package/lib/cjs/Merging/SchemaMerger.js +7 -3
  55. package/lib/cjs/Merging/SchemaMerger.js.map +1 -1
  56. package/lib/cjs/ecschema-editing.d.ts +4 -0
  57. package/lib/cjs/ecschema-editing.d.ts.map +1 -1
  58. package/lib/cjs/ecschema-editing.js +4 -0
  59. package/lib/cjs/ecschema-editing.js.map +1 -1
  60. package/package.json +10 -10
  61. package/lib/cjs/Merging/AnyPropertyMerger.d.ts +0 -15
  62. package/lib/cjs/Merging/AnyPropertyMerger.d.ts.map +0 -1
  63. package/lib/cjs/Merging/AnyPropertyMerger.js +0 -71
  64. package/lib/cjs/Merging/AnyPropertyMerger.js.map +0 -1
  65. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts +0 -32
  66. package/lib/cjs/Merging/ArrayPropertyMerger.d.ts.map +0 -1
  67. package/lib/cjs/Merging/ArrayPropertyMerger.js +0 -143
  68. package/lib/cjs/Merging/ArrayPropertyMerger.js.map +0 -1
  69. package/lib/cjs/Merging/ClassPropertyMerger.d.ts +0 -16
  70. package/lib/cjs/Merging/ClassPropertyMerger.d.ts.map +0 -1
  71. package/lib/cjs/Merging/ClassPropertyMerger.js +0 -90
  72. package/lib/cjs/Merging/ClassPropertyMerger.js.map +0 -1
  73. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts +0 -24
  74. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.d.ts.map +0 -1
  75. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js +0 -106
  76. package/lib/cjs/Merging/PrimitiveOrEnumPropertyMerger.js.map +0 -1
  77. package/lib/cjs/Merging/StructPropertyMerger.d.ts +0 -11
  78. package/lib/cjs/Merging/StructPropertyMerger.d.ts.map +0 -1
  79. package/lib/cjs/Merging/StructPropertyMerger.js +0 -47
  80. package/lib/cjs/Merging/StructPropertyMerger.js.map +0 -1
@@ -0,0 +1,150 @@
1
+ /** @packageDocumentation
2
+ * @module Differencing
3
+ */
4
+ import { SchemaChanges } from "../Validation/SchemaChanges";
5
+ import { SchemaDifferenceConflict } from "./SchemaConflicts";
6
+ import type { AnyEnumerator, AnyPropertyProps, AnySchemaItemProps, CustomAttribute, RelationshipConstraintProps, Schema, SchemaProps, SchemaReferenceProps } from "@itwin/ecschema-metadata";
7
+ /**
8
+ * Defines the type of the difference operation.
9
+ * @internal
10
+ */
11
+ export type DifferenceType = "add" | "modify";
12
+ /**
13
+ * Defines a set of SchemaItem names.
14
+ * @internal
15
+ */
16
+ export type SchemaItemTypeName = "EntityClass" | "Mixin" | "StructClass" | "CustomAttributeClass" | "RelationshipClass" | "Enumeration" | "KindOfQuantity" | "PropertyCategory" | "Unit" | "InvertedUnit" | "Constant" | "Phenomenon" | "UnitSystem" | "Format";
17
+ /**
18
+ * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.
19
+ * @internal
20
+ */
21
+ export type SchemaType = "Schema" | SchemaItemTypeName | "Property" | "RelationshipConstraint";
22
+ /**
23
+ * @internal
24
+ */
25
+ export declare namespace SchemaDifference {
26
+ /**
27
+ * Creates a [[SchemaDifference]] for two given schemas.
28
+ * @param targetSchema The schema the differences gets merged into.
29
+ * @param sourceSchema The schema to get merged in the target.
30
+ * @returns An [[SchemaDifference]] object.
31
+ * @internal
32
+ */
33
+ function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences>;
34
+ /**
35
+ * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.
36
+ * @param targetSchema
37
+ * @param schemaChanges A changes report of two schemas.
38
+ * @returns An [[SchemaDifference]] object.
39
+ * @internal
40
+ */
41
+ function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences>;
42
+ }
43
+ type MutualPartial<T> = {
44
+ -readonly [P in keyof T]?: T[P];
45
+ };
46
+ /**
47
+ * @internal
48
+ */
49
+ export interface SchemaDifferences {
50
+ readonly sourceSchemaName: string;
51
+ readonly targetSchemaName: string;
52
+ readonly changes: AnySchemaDifference[];
53
+ readonly conflicts: SchemaDifferenceConflict[];
54
+ }
55
+ /**
56
+ * @internal
57
+ */
58
+ export type AnySchemaDifference = SchemaDifference | SchemaItemDifference | SchemaPropertyDifference | SchemaReferenceDifference | SchemaEnumeratorDifference | SchemaClassMixinDifference | SchemaRelationshipConstraintDifference | SchemaRelationshipConstraintClassDifference | SchemaCustomAttributeDifference;
59
+ /**
60
+ * @internal
61
+ */
62
+ export interface SchemaDifference {
63
+ changeType: "modify";
64
+ schemaType: "Schema";
65
+ itemName?: undefined;
66
+ path?: undefined;
67
+ json: MutualPartial<SchemaProps>;
68
+ }
69
+ /**
70
+ * @internal
71
+ */
72
+ export interface SchemaItemDifference<T extends AnySchemaItemProps = AnySchemaItemProps> {
73
+ changeType: "add" | "modify" | "remove";
74
+ schemaType: SchemaItemTypeName;
75
+ itemName: string;
76
+ path?: string;
77
+ json: MutualPartial<T>;
78
+ }
79
+ /**
80
+ * @internal
81
+ */
82
+ export interface SchemaPropertyDifference<T extends AnyPropertyProps = AnyPropertyProps> {
83
+ changeType: "add" | "modify" | "remove";
84
+ schemaType: "Property";
85
+ itemName: string;
86
+ path: string;
87
+ json: MutualPartial<T>;
88
+ }
89
+ /**
90
+ * @internal
91
+ */
92
+ export interface SchemaReferenceDifference {
93
+ changeType: "add" | "modify" | "remove";
94
+ schemaType: "Schema";
95
+ itemName?: undefined;
96
+ path: "$references";
97
+ json: MutualPartial<SchemaReferenceProps>;
98
+ }
99
+ /**
100
+ * @internal
101
+ */
102
+ export interface SchemaEnumeratorDifference {
103
+ changeType: "add" | "modify" | "remove";
104
+ schemaType: "Enumeration";
105
+ itemName: string;
106
+ path: string;
107
+ json: MutualPartial<AnyEnumerator>;
108
+ }
109
+ /**
110
+ * @internal
111
+ */
112
+ export interface SchemaClassMixinDifference {
113
+ changeType: "modify";
114
+ schemaType: "EntityClass";
115
+ itemName: string;
116
+ path: "$mixins";
117
+ json: string[];
118
+ }
119
+ /**
120
+ * @internal
121
+ */
122
+ export interface SchemaRelationshipConstraintDifference {
123
+ changeType: "modify";
124
+ schemaType: "RelationshipConstraint";
125
+ itemName: string;
126
+ path: string;
127
+ json: MutualPartial<RelationshipConstraintProps>;
128
+ }
129
+ /**
130
+ * @internal
131
+ */
132
+ export interface SchemaRelationshipConstraintClassDifference {
133
+ changeType: "modify";
134
+ schemaType: "RelationshipClass";
135
+ itemName: string;
136
+ path: string;
137
+ json: string[];
138
+ }
139
+ /**
140
+ * @internal
141
+ */
142
+ export interface SchemaCustomAttributeDifference {
143
+ changeType: "add" | "modify";
144
+ schemaType: "Schema" | "EnitityClass" | "Properties" | "RelationshipConstraint";
145
+ itemName?: string;
146
+ path?: string;
147
+ json: MutualPartial<CustomAttribute>;
148
+ }
149
+ export {};
150
+ //# sourceMappingURL=SchemaDifference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaDifference.d.ts","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EACV,aAAa,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,2BAA2B,EAAE,MAAM,EACzG,WAAW,EAAE,oBAAoB,EAClC,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE9C;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC5B,aAAa,GACb,OAAO,GACP,aAAa,GACb,sBAAsB,GACtB,mBAAmB,GACnB,aAAa,GACb,gBAAgB,GAChB,kBAAkB,GAClB,MAAM,GACN,cAAc,GACd,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,QAAQ,CAAC;AAEX;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,kBAAkB,GAAG,UAAU,GAAG,wBAAwB,CAAC;AAE/F;;GAEG;AACH,yBAAiB,gBAAgB,CAAC;IAChC;;;;;;OAMG;IACH,SAAsB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAMxG;IAED;;;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E,mBAAmB,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC9C,UAAU,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,UAAU,EAAE,QAAQ,GAAG,cAAc,GAAG,YAAY,GAAG,wBAAwB,CAAC;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;CACtC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ /*---------------------------------------------------------------------------------------------
3
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
4
+ * See LICENSE.md in the project root for license terms and full copyright notice.
5
+ *--------------------------------------------------------------------------------------------*/
6
+ /** @packageDocumentation
7
+ * @module Differencing
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SchemaDifference = void 0;
11
+ const SchemaComparer_1 = require("../Validation/SchemaComparer");
12
+ const SchemaDiagnosticVisitor_1 = require("./SchemaDiagnosticVisitor");
13
+ /**
14
+ * @internal
15
+ */
16
+ var SchemaDifference;
17
+ (function (SchemaDifference) {
18
+ /**
19
+ * Creates a [[SchemaDifference]] for two given schemas.
20
+ * @param targetSchema The schema the differences gets merged into.
21
+ * @param sourceSchema The schema to get merged in the target.
22
+ * @returns An [[SchemaDifference]] object.
23
+ * @internal
24
+ */
25
+ async function fromSchemas(targetSchema, sourceSchema) {
26
+ const changesList = [];
27
+ const schemaComparer = new SchemaComparer_1.SchemaComparer({ report: changesList.push.bind(changesList) });
28
+ await schemaComparer.compareSchemas(sourceSchema, targetSchema);
29
+ return fromSchemaChanges(targetSchema, changesList[0]);
30
+ }
31
+ SchemaDifference.fromSchemas = fromSchemas;
32
+ /**
33
+ * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.
34
+ * @param targetSchema
35
+ * @param schemaChanges A changes report of two schemas.
36
+ * @returns An [[SchemaDifference]] object.
37
+ * @internal
38
+ */
39
+ async function fromSchemaChanges(targetSchema, schemaChanges) {
40
+ const schemaDifference = {
41
+ sourceSchemaName: schemaChanges.schema.schemaKey.toString(),
42
+ targetSchemaName: targetSchema.schemaKey.toString(),
43
+ changes: [],
44
+ conflicts: [],
45
+ };
46
+ const visitor = new SchemaDiagnosticVisitor_1.SchemaDiagnosticVisitor(schemaDifference);
47
+ for (const diagnostic of schemaChanges.allDiagnostics) {
48
+ visitor.visit(diagnostic);
49
+ }
50
+ return schemaDifference;
51
+ }
52
+ SchemaDifference.fromSchemaChanges = fromSchemaChanges;
53
+ })(SchemaDifference = exports.SchemaDifference || (exports.SchemaDifference = {}));
54
+ //# sourceMappingURL=SchemaDifference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SchemaDifference.js","sourceRoot":"","sources":["../../../src/Differencing/SchemaDifference.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,iEAA8D;AAE9D,uEAAoE;AAsCpE;;GAEG;AACH,IAAiB,gBAAgB,CAsChC;AAtCD,WAAiB,gBAAgB;IAC/B;;;;;;OAMG;IACI,KAAK,UAAU,WAAW,CAAC,YAAoB,EAAE,YAAoB;QAC1E,MAAM,WAAW,GAAoB,EAAE,CAAC;QACxC,MAAM,cAAc,GAAG,IAAI,+BAAc,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QAC1F,MAAM,cAAc,CAAC,cAAc,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAEhE,OAAO,iBAAiB,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IANqB,4BAAW,cAMhC,CAAA;IAED;;;;;;OAMG;IACI,KAAK,UAAU,iBAAiB,CAAC,YAAoB,EAAE,aAA4B;QACxF,MAAM,gBAAgB,GAAsB;YAC1C,gBAAgB,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC3D,gBAAgB,EAAE,YAAY,CAAC,SAAS,CAAC,QAAQ,EAAE;YACnD,OAAO,EAAE,EAAE;YACX,SAAS,EAAE,EAAE;SACd,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,iDAAuB,CAAC,gBAAgB,CAAC,CAAC;QAC9D,KAAI,MAAM,UAAU,IAAI,aAAa,CAAC,cAAc,EAAE;YACpD,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;SAC3B;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAdqB,kCAAiB,oBActC,CAAA;AACH,CAAC,EAtCgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAsChC","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 Differencing\n */\n\nimport { SchemaChanges } from \"../Validation/SchemaChanges\";\nimport { SchemaComparer } from \"../Validation/SchemaComparer\";\nimport { SchemaDifferenceConflict } from \"./SchemaConflicts\";\nimport { SchemaDiagnosticVisitor } from \"./SchemaDiagnosticVisitor\";\nimport type {\n AnyEnumerator, AnyPropertyProps, AnySchemaItemProps, CustomAttribute, RelationshipConstraintProps, Schema,\n SchemaProps, SchemaReferenceProps,\n} from \"@itwin/ecschema-metadata\";\n\n/**\n * Defines the type of the difference operation.\n * @internal\n */\nexport type DifferenceType = \"add\" | \"modify\";\n\n/**\n * Defines a set of SchemaItem names.\n * @internal\n */\nexport type SchemaItemTypeName =\n \"EntityClass\" |\n \"Mixin\" |\n \"StructClass\" |\n \"CustomAttributeClass\" |\n \"RelationshipClass\" |\n \"Enumeration\" |\n \"KindOfQuantity\" |\n \"PropertyCategory\" |\n \"Unit\" |\n \"InvertedUnit\" |\n \"Constant\" |\n \"Phenomenon\" |\n \"UnitSystem\" |\n \"Format\";\n\n/**\n * Defines the possible values SchemaTypes that can occur in SchemaDifferences or Conflicts.\n * @internal\n */\nexport type SchemaType = \"Schema\" | SchemaItemTypeName | \"Property\" | \"RelationshipConstraint\";\n\n/**\n * @internal\n */\nexport namespace SchemaDifference {\n /**\n * Creates a [[SchemaDifference]] for two given schemas.\n * @param targetSchema The schema the differences gets merged into.\n * @param sourceSchema The schema to get merged in the target.\n * @returns An [[SchemaDifference]] object.\n * @internal\n */\n export async function fromSchemas(targetSchema: Schema, sourceSchema: Schema): Promise<SchemaDifferences> {\n const changesList: SchemaChanges[] = [];\n const schemaComparer = new SchemaComparer({ report: changesList.push.bind(changesList) });\n await schemaComparer.compareSchemas(sourceSchema, targetSchema);\n\n return fromSchemaChanges(targetSchema, changesList[0]);\n }\n\n /**\n * Creates a [[SchemaDifference]] for a given [[SchemaChanges]] report.\n * @param targetSchema\n * @param schemaChanges A changes report of two schemas.\n * @returns An [[SchemaDifference]] object.\n * @internal\n */\n export async function fromSchemaChanges(targetSchema: Schema, schemaChanges: SchemaChanges): Promise<SchemaDifferences> {\n const schemaDifference: SchemaDifferences = {\n sourceSchemaName: schemaChanges.schema.schemaKey.toString(),\n targetSchemaName: targetSchema.schemaKey.toString(),\n changes: [],\n conflicts: [],\n };\n\n const visitor = new SchemaDiagnosticVisitor(schemaDifference);\n for(const diagnostic of schemaChanges.allDiagnostics) {\n visitor.visit(diagnostic);\n }\n\n return schemaDifference;\n }\n}\n\ntype MutualPartial<T> = {\n -readonly [P in keyof T]?: T[P];\n};\n\n/**\n * @internal\n */\nexport interface SchemaDifferences {\n\n readonly sourceSchemaName: string;\n readonly targetSchemaName: string;\n\n readonly changes: AnySchemaDifference[];\n readonly conflicts: SchemaDifferenceConflict[];\n}\n\n/**\n * @internal\n */\nexport type AnySchemaDifference =\n SchemaDifference |\n SchemaItemDifference |\n SchemaPropertyDifference |\n SchemaReferenceDifference |\n SchemaEnumeratorDifference |\n SchemaClassMixinDifference |\n SchemaRelationshipConstraintDifference |\n SchemaRelationshipConstraintClassDifference |\n SchemaCustomAttributeDifference;\n\n/**\n * @internal\n */\nexport interface SchemaDifference {\n changeType: \"modify\";\n schemaType: \"Schema\";\n itemName?: undefined;\n path?: undefined;\n json: MutualPartial<SchemaProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaItemDifference<T extends AnySchemaItemProps = AnySchemaItemProps> {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: SchemaItemTypeName;\n itemName: string;\n path?: string;\n json: MutualPartial<T>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaPropertyDifference<T extends AnyPropertyProps = AnyPropertyProps> {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Property\";\n itemName: string;\n path: string;\n json: MutualPartial<T>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaReferenceDifference {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Schema\";\n itemName?: undefined;\n path: \"$references\";\n json: MutualPartial<SchemaReferenceProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaEnumeratorDifference {\n changeType: \"add\" | \"modify\" | \"remove\";\n schemaType: \"Enumeration\";\n itemName: string;\n path: string;\n json: MutualPartial<AnyEnumerator>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaClassMixinDifference {\n changeType: \"modify\";\n schemaType: \"EntityClass\";\n itemName: string;\n path: \"$mixins\";\n json: string[];\n}\n\n/**\n * @internal\n */\nexport interface SchemaRelationshipConstraintDifference {\n changeType: \"modify\";\n schemaType: \"RelationshipConstraint\";\n itemName: string;\n path: string;\n json: MutualPartial<RelationshipConstraintProps>;\n}\n\n/**\n * @internal\n */\nexport interface SchemaRelationshipConstraintClassDifference {\n changeType: \"modify\";\n schemaType: \"RelationshipClass\";\n itemName: string;\n path: string;\n json: string[];\n}\n\n/**\n * @internal\n */\nexport interface SchemaCustomAttributeDifference {\n changeType: \"add\" | \"modify\";\n schemaType: \"Schema\" | \"EnitityClass\" | \"Properties\" | \"RelationshipConstraint\";\n itemName?: string;\n path?: string;\n json: MutualPartial<CustomAttribute>;\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { CustomAttribute, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
4
+ import { CustomAttribute, CustomAttributeContainerProps, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps, PrimitivePropertyProps, PrimitiveType, SchemaItemKey, StructArrayPropertyProps, StructClass, StructPropertyProps } from "@itwin/ecschema-metadata";
5
5
  import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
6
  /**
7
7
  * @alpha
@@ -67,8 +67,15 @@ export declare class ECClasses {
67
67
  * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name
68
68
  */
69
69
  setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults>;
70
+ /**
71
+ * Sets the Category to the Property.
72
+ * @param classKey The SchemaItemKey of the class.
73
+ * @param propertyName The name of the property.
74
+ * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.
75
+ */
76
+ setPropertyCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey): Promise<PropertyEditResults>;
70
77
  private getClass;
71
- private removeCustomAttribute;
78
+ protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute): void;
72
79
  private findDerivedClasses;
73
80
  }
74
81
  //# sourceMappingURL=ECClasses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.d.ts","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,eAAe,EAEmC,WAAW,EAAE,wBAAwB,EAAE,2B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AO,CAAC,mBAAmB,CAAC;IAYjH,kCAAkC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,wBAAwB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAajK,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAYnF,MAAM,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAc5E;;;;OAIG;IACU,kBAAkB,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAyB1H;;;;;OAKG;IACU,4BAA4B,CAAC,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,eAAe,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA8BxJ;;;;;;;OAOG;IACU,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA0C1I;;;;;OAKG;IACU,OAAO,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAsB3F;;;;;OAKG;IACU,mBAAmB,CAAC,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,aAAa,GAAG,OAAO,CAAC,mBAAmB,CAAC;YAsB3H,QAAQ;IAuBtB,SAAS,CAAC,qBAAqB,CAAC,SAAS,EAAE,6BAA6B,EAAE,eAAe,EAAE,eAAe;YAM5F,kBAAkB;CAejC"}
@@ -332,6 +332,31 @@ class ECClasses {
332
332
  mutableClass.setName(name);
333
333
  return {};
334
334
  }
335
+ /**
336
+ * Sets the Category to the Property.
337
+ * @param classKey The SchemaItemKey of the class.
338
+ * @param propertyName The name of the property.
339
+ * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.
340
+ */
341
+ async setPropertyCategory(classKey, propertyName, categoryKey) {
342
+ let mutableClass;
343
+ try {
344
+ mutableClass = await this.getClass(classKey);
345
+ }
346
+ catch (e) {
347
+ return { errorMessage: e.message };
348
+ }
349
+ const property = await mutableClass.getProperty(propertyName);
350
+ if (property === undefined) {
351
+ return { errorMessage: `An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };
352
+ }
353
+ const category = await mutableClass.schema.lookupItem(categoryKey);
354
+ if (category === undefined) {
355
+ return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${mutableClass.schema.fullName}.` };
356
+ }
357
+ property.setCategory(new ecschema_metadata_1.DelayedPromiseWithProps(categoryKey, async () => category));
358
+ return { itemKey: classKey, propertyName };
359
+ }
335
360
  async getClass(classKey) {
336
361
  const schema = await this._schemaEditor.getSchema(classKey.schemaKey);
337
362
  if (schema === undefined)
@@ -1 +1 @@
1
- {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAMkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAEvE;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAAuB,EAAE,IAAY,EAAE,IAAmB,EAAE,MAAc;QACpG,IAAI,YAA0B,CAAC;QAE/B,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,QAAQ;eAChG,IAAI,KAAK,iCAAa,CAAC,OAAO;YACjC,MAAM,IAAI,KAAK,CAAE,gFAAgF,CAAC,CAAC;QAErG,IAAI,EAAE,KA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,EAAC,SAAS,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC;QACjD,MAAM,GAAG,GAAG,SAAS,CAAC,gBAAgD,CAAC;QACvE,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;IACxC,CAAC;IAEO,KAAK,CAAC,kBAAkB,CAAC,YAA0B;QACzD,MAAM,cAAc,GAAwB,EAAE,CAAC;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,cAAc,EAAE,CAAC;QACtE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,EAAE;YACZ,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE;gBAChC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACxC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;aACF;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;SACxC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAvZD,8BAuZC","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 Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n ECClass, ECName, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses {\n\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n return { itemKey: classKey, propertyName: prefixedName };\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.deleteProperty(name);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return {};\n\n await schema.deleteClass(ecClass.name);\n\n return { itemKey: classKey };\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\n * @param classKey The SchemaItemKey identifying the class.\n * @param propertyName The name of the property.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (!property) {\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n property.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(property, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Renames the property on the specified class. The rename will fail if the new\n * name causes a conflict with a base or derived property. All derived classes\n * containing a property override will be renamed, as well.\n * @param classKey The SchemaItemKey identifying the class.\n * @param existingPropertyName The name of the property.\n * @param newPropertyName The new property name.\n */\n public async setPropertyName(classKey: SchemaItemKey, existingPropertyName: string, newPropertyName: string): Promise<PropertyEditResults> {\n const newName = new ECName(newPropertyName);\n\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const existingProperty = await mutableClass.getProperty(existingPropertyName) as MutableProperty;\n if (!existingProperty) {\n return { errorMessage: `An ECProperty with the name ${existingPropertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n const baseProperty = await mutableClass.getProperty(newPropertyName, true) as MutableProperty;\n if (baseProperty)\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.` };\n\n // Handle derived classes\n const derivedProperties: Array<MutableProperty> = [];\n const derivedClasses = await this.findDerivedClasses(mutableClass);\n for (const derivedClass of derivedClasses) {\n if (await derivedClass.getProperty(newPropertyName))\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.` };\n\n const propertyOverride = await derivedClass.getProperty(existingPropertyName) as MutableProperty;\n // If found the property is overridden in the derived class.\n if (propertyOverride)\n derivedProperties.push(propertyOverride);\n }\n\n // Re-name the overridden property in all derived classes\n derivedProperties.forEach((prop: MutableProperty) => {\n prop.setName(newName);\n });\n\n existingProperty.setName(newName);\n\n return { itemKey: classKey, propertyName: newName.name };\n }\n\n /**\n * Sets the name of the ECClass.\n * @param classKey The SchemaItemKey of the class.\n * @param name The new name of the class.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined) {\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n }\n\n const ecClass = await schema.getItem<MutableClass>(name);\n if (ecClass !== undefined)\n return { errorMessage: `An EC Class with the name ${name} already exists within the schema ${schema.name}` };\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n mutableClass.setName(name);\n\n return {};\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\n\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\n if (ecClass === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\n }\n\n return ecClass;\n }\n\n private removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n const schemaItems = this._schemaEditor.schemaContext.getSchemaItems();\n let { value, done } = schemaItems.next();\n while (!done) {\n if (await value.is(mutableClass)) {\n if (!mutableClass.key.matches(value.key)) {\n derivedClasses.push(value);\n }\n }\n ({ value, done } = schemaItems.next());\n }\n\n return derivedClasses;\n }\n}\n\n"]}
1
+ {"version":3,"file":"ECClasses.js","sourceRoot":"","sources":["../../../src/Editing/ECClasses.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gEAOkC;AAClC,sDAA6C;AAG7C,+CAA+C;AAG/C;;;GAGG;AACH,MAAa,SAAS;IAEpB,YAAgC,aAAkC;QAAlC,kBAAa,GAAb,aAAa,CAAqB;IAAI,CAAC;IAEvE;;;;;;OAMG;IACI,KAAK,CAAC,cAAc,CAAC,QAAuB,EAAE,IAAY,EAAE,IAAmB,EAAE,MAAc;QACpG,IAAI,YAA0B,CAAC;QAE/B,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,MAAM,IAAI,IAAI,KAAK,iCAAa,CAAC,QAAQ;eAChG,IAAI,KAAK,iCAAa,CAAC,OAAO;YACjC,MAAM,IAAI,KAAK,CAAE,gFAAgF,CAAC,CAAC;QAErG,IAAI,EAAE,KAAK,MAAM;YACf,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;QAEnE,MAAM,YAAY,GAAG,GAAG,MAAM,IAAI,IAAI,EAAE,CAAC;QAEzC,IAAI;YACF,YAAY,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAC9C;QAAC,OAAO,CAAM,EA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,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;oBACxC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;iBAC5B;aACF;YACD,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;SACxC;QAED,OAAO,cAAc,CAAC;IACxB,CAAC;CACF;AAnbD,8BAmbC","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 Editing\n */\n\nimport {\n CustomAttribute,\n CustomAttributeContainerProps,\n DelayedPromiseWithProps,\n ECClass, ECName, ECObjectsError, ECObjectsStatus, Enumeration, EnumerationPropertyProps, PrimitiveArrayPropertyProps,\n PrimitivePropertyProps, PrimitiveType, PropertyCategory, SchemaItemKey, SchemaItemType, StructArrayPropertyProps,\n StructClass, StructPropertyProps,\n} from \"@itwin/ecschema-metadata\";\nimport { assert } from \"@itwin/core-bentley\";\nimport { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from \"./Editor\";\nimport { MutableClass } from \"./Mutable/MutableClass\";\nimport * as Rules from \"../Validation/ECRules\";\nimport { MutableProperty } from \"./Mutable/MutableProperty\";\n\n/**\n * @alpha\n * Acts as a base class for schema class creation. Enables property creation.\n */\nexport class ECClasses {\n\n protected constructor(protected _schemaEditor: SchemaContextEditor) { }\n\n /**\n * Creates a property on class identified by the given SchemaItemKey. This method restricts the\n * property type to primitives of type Double, String, DateTime and Integer.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType, prefix: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n\n if (type !== PrimitiveType.Double && type !== PrimitiveType.String && type !== PrimitiveType.DateTime\n && type !== PrimitiveType.Integer)\n throw new Error (\"Property creation is restricted to type Double, String, DateTime, and Integer.\");\n\n if (\"\" === prefix)\n throw new Error(\"The specified property name prefix is invalid\");\n\n const prefixedName = `${prefix}_${name}`;\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(prefixedName, type);\n return { itemKey: classKey, propertyName: prefixedName };\n }\n\n /**\n * Create a primitive property on class identified by the given SchemaItemKey.\n * @param classKey The SchemaItemKey of the class.\n * @param name The name of the new property.\n * @param type The PrimitiveType assigned to the new property.\n */\n public async createPrimitiveProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitivePropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitivePropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const enumSchemaItemKey = mutableClass.schema.getSchemaItemKey(type.fullName);\n if (enumSchemaItemKey === undefined)\n throw new ECObjectsError(ECObjectsStatus.InvalidECJson, `Unable to locate the enumeration ${type.fullName}.`);\n\n await mutableClass.createPrimitiveProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, enumProps: EnumerationPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveProperty(name, type);\n await newProperty.fromJSON(enumProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayProperty(classKey: SchemaItemKey, name: string, type: PrimitiveType): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createPrimitiveArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: PrimitiveType, primitiveProps: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(primitiveProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayProperty(classKey: SchemaItemKey, name: string, type: Enumeration): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createPrimitiveArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createEnumerationArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: Enumeration, props: PrimitiveArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createPrimitiveArrayProperty(name, type);\n await newProperty.fromJSON(props);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayProperty(classKey: SchemaItemKey, name: string, type: StructClass): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.createStructArrayProperty(name, type);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async createStructArrayPropertyFromProps(classKey: SchemaItemKey, name: string, type: StructClass, structProps: StructArrayPropertyProps): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const newProperty = await mutableClass.createStructArrayProperty(name, type);\n await newProperty.fromJSON(structProps);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async deleteProperty(classKey: SchemaItemKey, name: string): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n await mutableClass.deleteProperty(name);\n return { itemKey: classKey, propertyName: name };\n }\n\n public async delete(classKey: SchemaItemKey): Promise<SchemaItemEditResults> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n\n const ecClass = await schema.getItem<ECClass>(classKey.name);\n if (ecClass === undefined)\n return {};\n\n await schema.deleteClass(ecClass.name);\n\n return { itemKey: classKey };\n }\n\n /**\n * Adds a CustomAttribute instance to the Class identified by the given SchemaItemKey\n * @param classKey The SchemaItemKey identifying the schema.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttribute(classKey: SchemaItemKey, customAttribute: CustomAttribute): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n mutableClass.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(mutableClass, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(mutableClass, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Adds a CustomAttribute instance to the Property identified by the given SchemaItemKey and property name.\n * @param classKey The SchemaItemKey identifying the class.\n * @param propertyName The name of the property.\n * @param customAttribute The CustomAttribute instance to add.\n */\n public async addCustomAttributeToProperty(classKey: SchemaItemKey, propertyName: string, customAttribute: CustomAttribute): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (!property) {\n return { errorMessage: `Property with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n property.addCustomAttribute(customAttribute);\n\n const diagnostics = Rules.validateCustomAttributeInstance(property, customAttribute);\n\n const result: SchemaItemEditResults = { errorMessage: \"\" };\n for await (const diagnostic of diagnostics) {\n result.errorMessage += `${diagnostic.code}: ${diagnostic.messageText}\\r\\n`;\n }\n\n if (result.errorMessage) {\n this.removeCustomAttribute(property, customAttribute);\n return result;\n }\n\n return {};\n }\n\n /**\n * Renames the property on the specified class. The rename will fail if the new\n * name causes a conflict with a base or derived property. All derived classes\n * containing a property override will be renamed, as well.\n * @param classKey The SchemaItemKey identifying the class.\n * @param existingPropertyName The name of the property.\n * @param newPropertyName The new property name.\n */\n public async setPropertyName(classKey: SchemaItemKey, existingPropertyName: string, newPropertyName: string): Promise<PropertyEditResults> {\n const newName = new ECName(newPropertyName);\n\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const existingProperty = await mutableClass.getProperty(existingPropertyName) as MutableProperty;\n if (!existingProperty) {\n return { errorMessage: `An ECProperty with the name ${existingPropertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n const baseProperty = await mutableClass.getProperty(newPropertyName, true) as MutableProperty;\n if (baseProperty)\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${baseProperty.class.name}.` };\n\n // Handle derived classes\n const derivedProperties: Array<MutableProperty> = [];\n const derivedClasses = await this.findDerivedClasses(mutableClass);\n for (const derivedClass of derivedClasses) {\n if (await derivedClass.getProperty(newPropertyName))\n return { errorMessage: `An ECProperty with the name ${newPropertyName} already exists in the class ${derivedClass.fullName}.` };\n\n const propertyOverride = await derivedClass.getProperty(existingPropertyName) as MutableProperty;\n // If found the property is overridden in the derived class.\n if (propertyOverride)\n derivedProperties.push(propertyOverride);\n }\n\n // Re-name the overridden property in all derived classes\n derivedProperties.forEach((prop: MutableProperty) => {\n prop.setName(newName);\n });\n\n existingProperty.setName(newName);\n\n return { itemKey: classKey, propertyName: newName.name };\n }\n\n /**\n * Sets the name of the ECClass.\n * @param classKey The SchemaItemKey of the class.\n * @param name The new name of the class.\n * @throws ECObjectsError if `name` does not meet the criteria for a valid EC name\n */\n public async setName(classKey: SchemaItemKey, name: string): Promise<SchemaItemEditResults> {\n let mutableClass: MutableClass;\n\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined) {\n return { errorMessage: `Schema Key ${classKey.schemaKey.toString(true)} not found in context` };\n }\n\n const ecClass = await schema.getItem<MutableClass>(name);\n if (ecClass !== undefined)\n return { errorMessage: `An EC Class with the name ${name} already exists within the schema ${schema.name}` };\n\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n mutableClass.setName(name);\n\n return {};\n }\n\n /**\n * Sets the Category to the Property.\n * @param classKey The SchemaItemKey of the class.\n * @param propertyName The name of the property.\n * @param categoryKey The SchemaItemKey of the PropertyCategory assigned to the property.\n */\n public async setPropertyCategory(classKey: SchemaItemKey, propertyName: string, categoryKey: SchemaItemKey): Promise<PropertyEditResults> {\n let mutableClass: MutableClass;\n try {\n mutableClass = await this.getClass(classKey);\n } catch (e: any) {\n return { errorMessage: e.message };\n }\n\n const property = await mutableClass.getProperty(propertyName) as MutableProperty;\n if (property === undefined) {\n return { errorMessage: `An ECProperty with the name ${propertyName} could not be found in the class ${classKey.fullName}.` };\n }\n\n const category = await mutableClass.schema.lookupItem<PropertyCategory>(categoryKey);\n if (category === undefined) {\n return { errorMessage: `Can't locate the Property Category ${categoryKey.fullName} in the schema ${mutableClass.schema.fullName}.` };\n }\n\n property.setCategory(new DelayedPromiseWithProps<SchemaItemKey, PropertyCategory>(categoryKey, async () => category));\n return { itemKey: classKey, propertyName };\n }\n\n private async getClass(classKey: SchemaItemKey): Promise<MutableClass> {\n const schema = await this._schemaEditor.getSchema(classKey.schemaKey);\n if (schema === undefined)\n throw new ECObjectsError(ECObjectsStatus.UnableToLocateSchema,`Schema Key ${classKey.schemaKey.toString(true)} not found in context`);\n\n const ecClass = await schema.getItem<MutableClass>(classKey.name);\n if (ecClass === undefined)\n throw new ECObjectsError(ECObjectsStatus.ClassNotFound, `Class ${classKey.name} was not found in schema ${classKey.schemaKey.toString(true)}`);\n\n switch (ecClass.schemaItemType) {\n case SchemaItemType.EntityClass:\n case SchemaItemType.Mixin:\n case SchemaItemType.StructClass:\n case SchemaItemType.CustomAttributeClass:\n case SchemaItemType.RelationshipClass:\n break;\n default:\n throw new ECObjectsError(ECObjectsStatus.InvalidSchemaItemType, `Schema item type not supported`);\n }\n\n return ecClass;\n }\n\n protected removeCustomAttribute(container: CustomAttributeContainerProps, customAttribute: CustomAttribute) {\n assert(container.customAttributes !== undefined);\n const map = container.customAttributes as Map<string, CustomAttribute>;\n map.delete(customAttribute.className);\n }\n\n private async findDerivedClasses(mutableClass: MutableClass): Promise<Array<MutableClass>>{\n const derivedClasses: Array<MutableClass> = [];\n const schemaItems = this._schemaEditor.schemaContext.getSchemaItems();\n let { value, done } = schemaItems.next();\n while (!done) {\n if (await value.is(mutableClass)) {\n if (!mutableClass.key.matches(value.key)) {\n derivedClasses.push(value);\n }\n }\n ({ value, done } = schemaItems.next());\n }\n\n return derivedClasses;\n }\n}\n\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module Editing
3
3
  */
4
- import { ECClassModifier, EntityClassProps, Mixin, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
4
+ import { ECClassModifier, EntityClassProps, Mixin, NavigationPropertyProps, RelationshipClass, SchemaItemKey, SchemaKey, StrengthDirection } from "@itwin/ecschema-metadata";
5
5
  import { PropertyEditResults, SchemaContextEditor, SchemaItemEditResults } from "./Editor";
6
6
  import { ECClasses } from "./ECClasses";
7
7
  /**
@@ -20,8 +20,14 @@ export declare class Entities extends ECClasses {
20
20
  * @param entityProps a json object that will be used to populate the new EntityClass. Needs a name value passed in.
21
21
  */
22
22
  createFromProps(schemaKey: SchemaKey, entityProps: EntityClassProps): Promise<SchemaItemEditResults>;
23
- addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<void>;
23
+ addMixin(entityKey: SchemaItemKey, mixinKey: SchemaItemKey): Promise<SchemaItemEditResults>;
24
24
  createNavigationProperty(entityKey: SchemaItemKey, name: string, relationship: string | RelationshipClass, direction: string | StrengthDirection): Promise<PropertyEditResults>;
25
+ /**
26
+ * Creates a Navigation Property through a NavigationPropertyProps.
27
+ * @param classKey a SchemaItemKey of the Entity Class that will house the new property.
28
+ * @param navigationProps a json object that will be used to populate the new Navigation Property.
29
+ */
30
+ createNavigationPropertyFromProps(classKey: SchemaItemKey, navigationProps: NavigationPropertyProps): Promise<PropertyEditResults>;
25
31
  /**
26
32
  * Sets the base class of an Entity.
27
33
  * @param entityKey The SchemaItemKey of the Entity.
@@ -1 +1 @@
1
- {"version":3,"file":"Entities.d.ts","sourceRoot":"","sources":["../../../src/Editing/Entities.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACoB,eAAe,EAAgD,gBAAgB,EACxG,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAkB,SAAS,EAAE,iBAAiB,EACtF,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC;;;GAGG;AACH,qBAAa,QAAS,SAAQ,SAAS;gBAClB,aAAa,EAAE,mBAAmB;IAIxC,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAelL,yBAAyB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAe9L,wBAAwB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,YAAY,EAAE,aAAa,EAAE,YAA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AC,mBAAmB,CAAC;IAa5L;;;;OAIG;IACU,iCAAiC,CAAC,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAc/I;;;;OAIG;IACU,YAAY,CAAC,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA0BlH"}
@@ -96,16 +96,24 @@ class Entities extends ECClasses_1.ECClasses {
96
96
  }
97
97
  async addMixin(entityKey, mixinKey) {
98
98
  const entity = (await this._schemaEditor.schemaContext.getSchemaItem(entityKey));
99
+ if (entity === undefined) {
100
+ return { errorMessage: `Entity Class ${entityKey.fullName} not found in schema context.` };
101
+ }
102
+ if (entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass) {
103
+ return { errorMessage: `Expected ${entityKey.fullName} to be of type Entity Class.` };
104
+ }
99
105
  const mixin = (await this._schemaEditor.schemaContext.getSchemaItem(mixinKey));
100
- // TODO: have a helpful returns
101
- if (!entity || entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
102
- return;
103
- if (!mixin || mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin)
104
- return;
106
+ if (mixin === undefined) {
107
+ return { errorMessage: `Mixin Class ${mixinKey.fullName} not found in schema context.` };
108
+ }
109
+ if (mixin.schemaItemType !== ecschema_metadata_1.SchemaItemType.Mixin) {
110
+ return { errorMessage: `Expected ${mixinKey.fullName} to be of type Mixin.` };
111
+ }
105
112
  entity.addMixin(mixin);
113
+ return { itemKey: entityKey };
106
114
  }
107
115
  async createNavigationProperty(entityKey, name, relationship, direction) {
108
- const entity = (await this._schemaEditor.schemaContext.getSchemaItem(entityKey));
116
+ const entity = await this._schemaEditor.schemaContext.getSchemaItem(entityKey);
109
117
  if (entity === undefined)
110
118
  throw new ecschema_metadata_1.ECObjectsError(ecschema_metadata_1.ECObjectsStatus.ClassNotFound, `Entity Class ${entityKey.fullName} not found in schema context.`);
111
119
  if (entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
@@ -113,6 +121,21 @@ class Entities extends ECClasses_1.ECClasses {
113
121
  await entity.createNavigationProperty(name, relationship, direction);
114
122
  return { itemKey: entityKey, propertyName: name };
115
123
  }
124
+ /**
125
+ * Creates a Navigation Property through a NavigationPropertyProps.
126
+ * @param classKey a SchemaItemKey of the Entity Class that will house the new property.
127
+ * @param navigationProps a json object that will be used to populate the new Navigation Property.
128
+ */
129
+ async createNavigationPropertyFromProps(classKey, navigationProps) {
130
+ const entity = await this._schemaEditor.schemaContext.getSchemaItem(classKey);
131
+ if (entity === undefined)
132
+ return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Entity Class ${classKey.fullName} not found in schema context.` };
133
+ if (entity.schemaItemType !== ecschema_metadata_1.SchemaItemType.EntityClass)
134
+ return { itemKey: classKey, propertyName: navigationProps.name, errorMessage: `Expected ${classKey.fullName} to be of type EntityClass.` };
135
+ const navigationProperty = await entity.createNavigationProperty(navigationProps.name, navigationProps.relationshipName, navigationProps.direction);
136
+ await navigationProperty.fromJSON(navigationProps);
137
+ return { itemKey: classKey, propertyName: navigationProps.name };
138
+ }
116
139
  /**
117
140
  * Sets the base class of an Entity.
118
141
  * @param entityKey The SchemaItemKey of the Entity.