|
7 | 7 | EnumDefinition,
|
8 | 8 | ImportedEnumDefinition,
|
9 | 9 | InterfaceDefinition,
|
| 10 | + // CapabilityType, |
| 11 | + // CapabilityDefinition, |
10 | 12 | } from "./definitions";
|
11 | 13 |
|
12 | 14 | export * from "./definitions";
|
@@ -69,7 +71,43 @@ export function combineTypeInfo(typeInfos: TypeInfo[]): TypeInfo {
|
69 | 71 | }
|
70 | 72 |
|
71 | 73 | for (const interfaceType of typeInfo.interfaceTypes) {
|
72 |
| - tryInsert(combined.interfaceTypes, interfaceType); |
| 74 | + tryInsert( |
| 75 | + combined.interfaceTypes, |
| 76 | + interfaceType, |
| 77 | + (a, b) => (false) |
| 78 | + // compareImportedType, |
| 79 | + // ( |
| 80 | + // a: InterfaceDefinition, |
| 81 | + // b: InterfaceDefinition |
| 82 | + // ): InterfaceDefinition => { |
| 83 | + // const combinedCapabilities: CapabilityDefinition = { |
| 84 | + // ...a.capabilities, |
| 85 | + // ...b.capabilities, |
| 86 | + // }; |
| 87 | + // const combinedCapabilityTypes = Object.keys( |
| 88 | + // combinedCapabilities |
| 89 | + // ) as CapabilityType[]; |
| 90 | + // for (const capability of combinedCapabilityTypes) { |
| 91 | + // if (b.capabilities[capability] && a.capabilities[capability]) { |
| 92 | + // const combinedModules = Array.from( |
| 93 | + // new Set([ |
| 94 | + // ...a.capabilities[capability].modules, |
| 95 | + // ...b.capabilities[capability].modules, |
| 96 | + // ]) |
| 97 | + // ); |
| 98 | + // combinedCapabilities[capability] = { |
| 99 | + // enabled: true, |
| 100 | + // modules: combinedModules, |
| 101 | + // }; |
| 102 | + // } else if (a.capabilities[capability]) { |
| 103 | + // combinedCapabilities[capability] = a.capabilities[capability]; |
| 104 | + // } else if (b.capabilities[capability]) { |
| 105 | + // combinedCapabilities[capability] = b.capabilities[capability]; |
| 106 | + // } |
| 107 | + // } |
| 108 | + // return { ...a, capabilities: combinedCapabilities }; |
| 109 | + // } |
| 110 | + ); |
73 | 111 | }
|
74 | 112 |
|
75 | 113 | for (const importedObjectType of typeInfo.importedObjectTypes) {
|
@@ -100,13 +138,22 @@ const tryInsert = (
|
100 | 138 | dest: GenericDefinition[],
|
101 | 139 | value: GenericDefinition,
|
102 | 140 | compare: (a: GenericDefinition, b: GenericDefinition) => boolean = (a, b) =>
|
103 |
| - a.type === b.type |
| 141 | + a.type === b.type, |
| 142 | + join?: ( |
| 143 | + dest: GenericDefinition, |
| 144 | + source: GenericDefinition |
| 145 | + ) => GenericDefinition |
104 | 146 | ) => {
|
105 | 147 | const index = dest.findIndex((item: GenericDefinition) =>
|
106 | 148 | compare(item, value)
|
107 | 149 | );
|
108 | 150 |
|
109 | 151 | if (index > -1) {
|
| 152 | + if (join) { |
| 153 | + dest[index] = join(dest[index], value); |
| 154 | + return; |
| 155 | + } |
| 156 | + |
110 | 157 | const destType = JSON.stringify(dest[index]);
|
111 | 158 | const valueType = JSON.stringify(value);
|
112 | 159 | if (destType !== valueType) {
|
|
0 commit comments