chore: some more work
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com> Co-authored-by: Fredrik Adelöw <freben@users.noreply.github.com> Co-authored-by: Camila Belo <camilaibs@users.noreply.github.com> Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
@@ -11,12 +11,15 @@ const TestCard = EntityCardBlueprint.make({
|
||||
});
|
||||
|
||||
TestCard.override({
|
||||
attachTo: { id: 'something-else', input: 'overriden' },
|
||||
// override attachment points
|
||||
attachTo: { id: 'something-else', input: 'overridden' },
|
||||
// extend the config schema
|
||||
config: {
|
||||
schema: {
|
||||
newConfig: z => z.string().optional(),
|
||||
}
|
||||
},
|
||||
// override factory
|
||||
*factory(originalFactory, { inputs, config }){
|
||||
const originalOutput = originalFactory();
|
||||
|
||||
|
||||
@@ -686,26 +686,6 @@ describe('createExtension', () => {
|
||||
},
|
||||
});
|
||||
|
||||
const overridden = testExtension.override({
|
||||
output: [numberDataRef, stringDataRef],
|
||||
*factory(originalFactory) {
|
||||
const output = originalFactory();
|
||||
yield* output.omit(numberDataRef);
|
||||
|
||||
yield numberDataRef(output.get(numberDataRef) + 1);
|
||||
},
|
||||
});
|
||||
|
||||
const overridden = testExtension.override({
|
||||
output: [numberDataRef, stringDataRef],
|
||||
*factory(originalFactory) {
|
||||
const output = originalFactory();
|
||||
yield* output;
|
||||
|
||||
yield numberDataRef(output.get(numberDataRef) + 1);
|
||||
},
|
||||
});
|
||||
|
||||
const tester = createExtensionTester(overridden);
|
||||
|
||||
expect(tester.data(numberDataRef)).toBe(43);
|
||||
|
||||
@@ -581,7 +581,7 @@ export function createExtension<
|
||||
>,
|
||||
});
|
||||
}
|
||||
return overrideOptions.factory(
|
||||
const parentResult = overrideOptions.factory(
|
||||
(innerContext?: {
|
||||
config?: {
|
||||
[key in keyof TConfigSchema]: z.infer<
|
||||
@@ -604,6 +604,13 @@ export function createExtension<
|
||||
inputs,
|
||||
},
|
||||
);
|
||||
|
||||
const deduplicatedResult = new Map<string, UOverrideFactoryOutput>();
|
||||
for (const item of parentResult) {
|
||||
deduplicatedResult.set(item.id, item);
|
||||
}
|
||||
|
||||
return deduplicatedResult.values() as Iterable<UOverrideFactoryOutput>;
|
||||
},
|
||||
} as CreateExtensionOptions<AnyExtensionDataRef extends UNewOutput ? UOutput : UNewOutput, TInputs & TExtraInputs, TConfigSchema & TExtensionConfigSchema, UOverrideFactoryOutput>);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user