diff --git a/src/analysis/analysisVisitors/baseAnalysisVisitors.ts b/src/analysis/analysisVisitors/baseAnalysisVisitors.ts index f7157c1424..c8ff2fe0e8 100644 --- a/src/analysis/analysisVisitors/baseAnalysisVisitors.ts +++ b/src/analysis/analysisVisitors/baseAnalysisVisitors.ts @@ -32,7 +32,7 @@ export abstract class AnalysisVisitorABC { abstract readonly id: string; - protected extension!: ModComponentFormState; + protected formState!: ModComponentFormState; protected readonly annotations: AnalysisAnnotation[] = []; getAnnotations(): AnalysisAnnotation[] { @@ -40,21 +40,19 @@ export abstract class AnalysisVisitorABC } /** - * Visit the extension point definition. + * Visit the starter brick definition. */ - visitExtensionPoint( - extensionPoint: ModComponentFormState["extensionPoint"], - ): void { + visitStarterBrick(starterBrick: ModComponentFormState["starterBrick"]): void { // NOP } - run(extension: ModComponentFormState): void { - this.extension = extension; + run(formState: ModComponentFormState): void { + this.formState = formState; - this.visitExtensionPoint(extension.extensionPoint); + this.visitStarterBrick(formState.starterBrick); - this.visitRootPipeline(extension.extension.blockPipeline, { - extensionPointType: extension.type, + this.visitRootPipeline(formState.modComponent.brickPipeline, { + starterBrickType: formState.type, }); } } @@ -62,9 +60,9 @@ export abstract class AnalysisVisitorABC export abstract class AnalysisVisitorWithResolvedBricksABC extends AnalysisVisitorABC { protected allBlocks!: TypedBrickMap; - override async run(extension: ModComponentFormState): Promise { + override async run(formState: ModComponentFormState): Promise { this.allBlocks = await blockRegistry.allTyped(); - super.run(extension); + super.run(formState); } } diff --git a/src/analysis/analysisVisitors/brickTypeAnalysis.test.ts b/src/analysis/analysisVisitors/brickTypeAnalysis.test.ts index f85eed6d7c..a3981be8a9 100644 --- a/src/analysis/analysisVisitors/brickTypeAnalysis.test.ts +++ b/src/analysis/analysisVisitors/brickTypeAnalysis.test.ts @@ -36,16 +36,16 @@ beforeAll(() => { describe("BrickTypeAnalysis", () => { test("disallow effect in renderer", async () => { - const modComponent = sidebarPanelFormStateFactory(); + const formState = sidebarPanelFormStateFactory(); - modComponent.extension.blockPipeline = [ + formState.modComponent.brickPipeline = [ createNewConfiguredBrick(ALERT_EFFECT_ID), createNewConfiguredBrick(DocumentRenderer.BRICK_ID), ]; const analysis = new BrickTypeAnalysis(); - await analysis.run(modComponent); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(1); }); @@ -55,16 +55,16 @@ describe("BrickTypeAnalysis", () => { CancelEffect.BRICK_ID, ErrorEffect.BRICK_ID, ])("allow %s in renderer", async (brickId) => { - const modComponent = sidebarPanelFormStateFactory(); + const formState = sidebarPanelFormStateFactory(); - modComponent.extension.blockPipeline = [ + formState.modComponent.brickPipeline = [ createNewConfiguredBrick(brickId), createNewConfiguredBrick(DocumentRenderer.BRICK_ID), ]; const analysis = new BrickTypeAnalysis(); - await analysis.run(modComponent); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(0); }); diff --git a/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.test.ts b/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.test.ts index 73a17402be..5b31500ed4 100644 --- a/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.test.ts +++ b/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.test.ts @@ -28,7 +28,7 @@ import { toExpression } from "@/utils/expressionUtils"; describe("checkEventNamesAnalysis", () => { it("error on missing custom event", async () => { const formState = triggerFormStateFactory(); - formState.extensionPoint.definition.trigger = "custom"; + formState.starterBrick.definition.trigger = "custom"; const analysis = new CheckEventNamesAnalysis([formState]); await analysis.run(formState); @@ -42,8 +42,8 @@ describe("checkEventNamesAnalysis", () => { it.each(["click"])("allow dom event: %s", async (eventName) => { const formState = triggerFormStateFactory(); - formState.extensionPoint.definition.trigger = "custom"; - formState.extensionPoint.definition.customEvent = { eventName }; + formState.starterBrick.definition.trigger = "custom"; + formState.starterBrick.definition.customEvent = { eventName }; const analysis = new CheckEventNamesAnalysis([formState]); await analysis.run(formState); @@ -53,8 +53,8 @@ describe("checkEventNamesAnalysis", () => { it("warn on unknown event", async () => { const formState = triggerFormStateFactory(); - formState.extensionPoint.definition.trigger = "custom"; - formState.extensionPoint.definition.customEvent = { eventName: "unknown" }; + formState.starterBrick.definition.trigger = "custom"; + formState.starterBrick.definition.customEvent = { eventName: "unknown" }; const analysis = new CheckEventNamesAnalysis([formState]); await analysis.run(formState); @@ -68,8 +68,8 @@ describe("checkEventNamesAnalysis", () => { it("allow known event", async () => { const triggerFormState = triggerFormStateFactory(); - triggerFormState.extensionPoint.definition.trigger = "custom"; - triggerFormState.extensionPoint.definition.customEvent = { + triggerFormState.starterBrick.definition.trigger = "custom"; + triggerFormState.starterBrick.definition.customEvent = { eventName: "myevent", }; @@ -88,8 +88,8 @@ describe("checkEventNamesAnalysis", () => { it("info on unknown event with dynamic expressions", async () => { const triggerFormState = triggerFormStateFactory(); - triggerFormState.extensionPoint.definition.trigger = "custom"; - triggerFormState.extensionPoint.definition.customEvent = { + triggerFormState.starterBrick.definition.trigger = "custom"; + triggerFormState.starterBrick.definition.customEvent = { eventName: "myevent", }; @@ -117,8 +117,8 @@ describe("checkEventNamesAnalysis", () => { it("get knownEventNames() combines known and trigger names", async () => { const triggerFormState = triggerFormStateFactory(); - triggerFormState.extensionPoint.definition.trigger = "custom"; - triggerFormState.extensionPoint.definition.customEvent = { + triggerFormState.starterBrick.definition.trigger = "custom"; + triggerFormState.starterBrick.definition.customEvent = { eventName: "myevent", }; diff --git a/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.ts b/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.ts index ae6c1d905e..a653cc970d 100644 --- a/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.ts +++ b/src/analysis/analysisVisitors/eventNameAnalysis/checkEventNamesAnalysis.ts @@ -49,23 +49,23 @@ class CheckEventNamesAnalysis extends AnalysisVisitorABC { ]; } - override visitExtensionPoint( - extensionPoint: ModComponentFormState["extensionPoint"], + override visitStarterBrick( + starterBrick: ModComponentFormState["starterBrick"], ) { - super.visitExtensionPoint(extensionPoint); + super.visitStarterBrick(starterBrick); if ( - isTriggerStarterBrick(extensionPoint) && - extensionPoint.definition.trigger === "custom" + isTriggerStarterBrick(starterBrick) && + starterBrick.definition.trigger === "custom" ) { - const eventName = extensionPoint.definition.customEvent?.eventName; + const eventName = starterBrick.definition.customEvent?.eventName; if (!eventName) { this.annotations.push({ analysisId: this.id, type: AnnotationType.Error, message: "Custom event name is required", - position: { path: "extensionPoint.definition.customEvent.eventName" }, + position: { path: "starterBrick.definition.customEvent.eventName" }, }); } else if ( !DOM_EVENTS.includes(eventName) && @@ -79,7 +79,7 @@ class CheckEventNamesAnalysis extends AnalysisVisitorABC { type: AnnotationType.Info, message: `Custom event ${eventName} does not match a known emitted event in this Mod`, position: { - path: "extensionPoint.definition.customEvent.eventName", + path: "starterBrick.definition.customEvent.eventName", }, }); } else { @@ -88,7 +88,7 @@ class CheckEventNamesAnalysis extends AnalysisVisitorABC { type: AnnotationType.Warning, message: `Custom event ${eventName} is not emitted in this Mod`, position: { - path: "extensionPoint.definition.customEvent.eventName", + path: "starterBrick.definition.customEvent.eventName", }, }); } @@ -96,7 +96,7 @@ class CheckEventNamesAnalysis extends AnalysisVisitorABC { } } - override async run(extension: ModComponentFormState) { + override async run(formState: ModComponentFormState) { const results = this.formStates.map((x) => CollectEventNamesVisitor.collectNames(x), ); @@ -111,7 +111,7 @@ class CheckEventNamesAnalysis extends AnalysisVisitorABC { hasDynamicEventName: results.some((result) => result.hasDynamicEventName), }; - super.run(extension); + super.run(formState); } } diff --git a/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.test.ts b/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.test.ts index 88fb9b6c2a..671072eff3 100644 --- a/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.test.ts +++ b/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.test.ts @@ -27,7 +27,7 @@ import { toExpression } from "@/utils/expressionUtils"; describe("collectEventNamesAnalysis", () => { it("collects event name from literal", () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: CustomEventEffect.BRICK_ID, config: { eventName: "foo", @@ -45,7 +45,7 @@ describe("collectEventNamesAnalysis", () => { it("collects event name from template literal", () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: CustomEventEffect.BRICK_ID, config: { eventName: toExpression("nunjucks", "foo"), @@ -63,7 +63,7 @@ describe("collectEventNamesAnalysis", () => { it("sets dynamic event flag", () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: CustomEventEffect.BRICK_ID, config: { eventName: toExpression("nunjucks", "{{ @foo }}"), @@ -81,8 +81,8 @@ describe("collectEventNamesAnalysis", () => { it("collects custom trigger names from trigger starter bricks", () => { const formState = triggerFormStateFactory(); - formState.extensionPoint.definition.trigger = "custom"; - formState.extensionPoint.definition.customEvent = { + formState.starterBrick.definition.trigger = "custom"; + formState.starterBrick.definition.customEvent = { eventName: "foo", }; diff --git a/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.ts b/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.ts index 292047f8d7..38f37ffa8e 100644 --- a/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.ts +++ b/src/analysis/analysisVisitors/eventNameAnalysis/collectEventNamesVisitor.ts @@ -62,10 +62,10 @@ class CollectEventNamesVisitor extends PipelineVisitor { } private visitStarterBrick( - extensionPoint: ModComponentFormState["extensionPoint"], + starterBrick: ModComponentFormState["starterBrick"], ) { - if (isTriggerStarterBrick(extensionPoint)) { - const eventName = extensionPoint.definition.customEvent?.eventName; + if (isTriggerStarterBrick(starterBrick)) { + const eventName = starterBrick.definition.customEvent?.eventName; if (eventName) { this._triggerNames.add(eventName); @@ -98,8 +98,8 @@ class CollectEventNamesVisitor extends PipelineVisitor { ): EventNameAnalysisResult { const visitor = new CollectEventNamesVisitor(); - visitor.visitRootPipeline(formState.extension.blockPipeline); - visitor.visitStarterBrick(formState.extensionPoint); + visitor.visitRootPipeline(formState.modComponent.brickPipeline); + visitor.visitStarterBrick(formState.starterBrick); return visitor.result; } diff --git a/src/analysis/analysisVisitors/modComponentUrlPatternAnalysis.ts b/src/analysis/analysisVisitors/modComponentUrlPatternAnalysis.ts index 64492c99e2..8676a5e081 100644 --- a/src/analysis/analysisVisitors/modComponentUrlPatternAnalysis.ts +++ b/src/analysis/analysisVisitors/modComponentUrlPatternAnalysis.ts @@ -31,11 +31,11 @@ const hostRegexp = /^(\*|(^(\*\.)?[^*/]+))$/; // All URLs is required for certain interactions, e.g., taking screenshots without activeTab const allUrls = ""; -const urlPatternFields = ["extensionPoint.definition.isAvailable.urlPatterns"]; +const urlPatternFields = ["starterBrick.definition.isAvailable.urlPatterns"]; const stringUrlFields = [ - "extensionPoint.definition.documentUrlPatterns", - "extensionPoint.definition.isAvailable.matchPatterns", + "starterBrick.definition.documentUrlPatterns", + "starterBrick.definition.isAvailable.matchPatterns", "permissions.origins", ]; diff --git a/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.test.ts b/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.test.ts index 407ba8a359..6cd0499591 100644 --- a/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.test.ts +++ b/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.test.ts @@ -28,7 +28,7 @@ beforeAll(() => { describe("ModVariableSchemasVisitor", () => { it("collects event schema from a template literal", async () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: AssignModVariable.BRICK_ID, config: { variableName: toExpression("nunjucks", "foo"), @@ -44,7 +44,7 @@ describe("ModVariableSchemasVisitor", () => { it("unions known schemas", async () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: AssignModVariable.BRICK_ID, config: { variableName: "foo", @@ -52,7 +52,7 @@ describe("ModVariableSchemasVisitor", () => { }; const otherFormState = formStateFactory(); - otherFormState.extension.blockPipeline[0] = { + otherFormState.modComponent.brickPipeline[0] = { id: AssignModVariable.BRICK_ID, config: { variableName: "bar", @@ -71,7 +71,7 @@ describe("ModVariableSchemasVisitor", () => { it("does not duplicate schemas", async () => { const formState = formStateFactory(); - formState.extension.blockPipeline[0] = { + formState.modComponent.brickPipeline[0] = { id: AssignModVariable.BRICK_ID, config: { variableName: "foo", @@ -79,7 +79,7 @@ describe("ModVariableSchemasVisitor", () => { }; const otherFormState = formStateFactory(); - otherFormState.extension.blockPipeline[0] = { + otherFormState.modComponent.brickPipeline[0] = { id: AssignModVariable.BRICK_ID, config: { variableName: "foo", diff --git a/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.ts b/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.ts index 2fcfb692dc..022f3bf889 100644 --- a/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.ts +++ b/src/analysis/analysisVisitors/pageStateAnalysis/modVariableSchemasVisitor.ts @@ -63,7 +63,7 @@ class ModVariableSchemasVisitor extends PipelineVisitor { const visitor = new ModVariableSchemasVisitor(allBlocks); for (const formState of formStates) { - visitor.visitRootPipeline(formState.extension.blockPipeline); + visitor.visitRootPipeline(formState.modComponent.brickPipeline); } // Schema promises return undefined if not page state diff --git a/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.test.ts b/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.test.ts index 1105ef41b2..2289a3682c 100644 --- a/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.test.ts +++ b/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.test.ts @@ -129,7 +129,9 @@ describe("PageStateAnalysis", () => { }, ]); - state.recipe = { id: registryIdFactory() } as BaseFormState["recipe"]; + state.modMetadata = { + id: registryIdFactory(), + } as BaseFormState["modMetadata"]; const analysis = new PageStateAnalysis(); await analysis.run(state); diff --git a/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.ts b/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.ts index 1bc4862ee5..339aad6923 100644 --- a/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.ts +++ b/src/analysis/analysisVisitors/pageStateAnalysis/pageStateAnalysis.ts @@ -97,9 +97,9 @@ class PageStateVisitor extends AnalysisVisitorWithResolvedBricksABC { } } - override async run(extension: ModComponentFormState): Promise { - this.isInMod = Boolean(extension.recipe); - await super.run(extension); + override async run(formState: ModComponentFormState): Promise { + this.isInMod = Boolean(formState.modMetadata); + await super.run(formState); } } diff --git a/src/analysis/analysisVisitors/requestPermissionAnalysis.test.ts b/src/analysis/analysisVisitors/requestPermissionAnalysis.test.ts index 985a6b11da..15ea49957f 100644 --- a/src/analysis/analysisVisitors/requestPermissionAnalysis.test.ts +++ b/src/analysis/analysisVisitors/requestPermissionAnalysis.test.ts @@ -25,9 +25,9 @@ import { toExpression } from "@/utils/expressionUtils"; browser.permissions.contains = jest.fn().mockResolvedValue(true); const containsMock = jest.mocked(browser.permissions.contains); -function blockExtensionFactory(url: string) { - const extension = triggerFormStateFactory(); - extension.extension.blockPipeline = [ +function brickModComponentFactory(url: string) { + const formState = triggerFormStateFactory(); + formState.modComponent.brickPipeline = [ brickConfigFactory({ id: RemoteMethod.BLOCK_ID, config: { @@ -36,7 +36,7 @@ function blockExtensionFactory(url: string) { }), ]; - return extension; + return formState; } describe("requestPermissionAnalysis", () => { @@ -47,9 +47,9 @@ describe("requestPermissionAnalysis", () => { test("it annotates http: url", async () => { const visitor = new RequestPermissionAnalysis(); - const extension = blockExtensionFactory("http://example.com"); + const formState = brickModComponentFactory("http://example.com"); - await visitor.run(extension); + await visitor.run(formState); expect(visitor.getAnnotations()).toStrictEqual([ { analysisId: "requestPermission", @@ -57,7 +57,7 @@ describe("requestPermissionAnalysis", () => { message: "PixieBrix does not support calls using http: because they are insecure. Please use https: instead.", position: { - path: "extension.blockPipeline.0.config.url", + path: "modComponent.brickPipeline.0.config.url", }, }, ]); @@ -65,16 +65,18 @@ describe("requestPermissionAnalysis", () => { test("it annotates invalid url", async () => { const visitor = new RequestPermissionAnalysis(); - const extension = blockExtensionFactory("https://there is a space in here"); + const formState = brickModComponentFactory( + "https://there is a space in here", + ); - await visitor.run(extension); + await visitor.run(formState); expect(visitor.getAnnotations()).toStrictEqual([ { analysisId: "requestPermission", type: "error", message: "Invalid URL: https://there is a space in here", position: { - path: "extension.blockPipeline.0.config.url", + path: "modComponent.brickPipeline.0.config.url", }, }, ]); @@ -82,11 +84,11 @@ describe("requestPermissionAnalysis", () => { test("it annotates insufficient permissions", async () => { const visitor = new RequestPermissionAnalysis(); - const extension = blockExtensionFactory("https://example.com"); + const formState = brickModComponentFactory("https://example.com"); containsMock.mockResolvedValue(false); - await visitor.run(extension); + await visitor.run(formState); expect(containsMock).toHaveBeenCalledWith({ // Checking that the visitor applies a trailing slash. `contains` requires a path on the URL @@ -105,7 +107,7 @@ describe("requestPermissionAnalysis", () => { message: "Insufficient browser permissions to make request. Specify an Integration to access the API, or add an Extra Permissions rule to the starter brick.", position: { - path: "extension.blockPipeline.0.config.url", + path: "modComponent.brickPipeline.0.config.url", }, }, ]); @@ -113,9 +115,9 @@ describe("requestPermissionAnalysis", () => { test("skip relative URLs", async () => { const visitor = new RequestPermissionAnalysis(); - const extension = blockExtensionFactory("/relative/url"); + const formState = brickModComponentFactory("/relative/url"); - await visitor.run(extension); + await visitor.run(formState); expect(visitor.getAnnotations()).toHaveLength(0); }); @@ -123,9 +125,9 @@ describe("requestPermissionAnalysis", () => { test("skips valid URLs", async () => { const visitor = new RequestPermissionAnalysis(); containsMock.mockResolvedValue(true); - const extension = blockExtensionFactory("https://example.com"); + const formState = brickModComponentFactory("https://example.com"); - await visitor.run(extension); + await visitor.run(formState); expect(visitor.getAnnotations()).toHaveLength(0); }); diff --git a/src/analysis/analysisVisitors/selectorAnalysis.test.ts b/src/analysis/analysisVisitors/selectorAnalysis.test.ts index 897f3e3391..3b4b7e9618 100644 --- a/src/analysis/analysisVisitors/selectorAnalysis.test.ts +++ b/src/analysis/analysisVisitors/selectorAnalysis.test.ts @@ -73,19 +73,19 @@ describe("SelectorAnalysis", () => { async (attachMode: AttachMode) => { const analysis = new SelectorAnalysis(); - const component = triggerFormStateFactory(); + const formState = triggerFormStateFactory(); - component.extensionPoint.definition.rootSelector = 'div:contains("foo")'; - component.extensionPoint.definition.attachMode = attachMode; + formState.starterBrick.definition.rootSelector = 'div:contains("foo")'; + formState.starterBrick.definition.attachMode = attachMode; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: expect.any(String), position: { - path: "extensionPoint.definition.rootSelector", + path: "starterBrick.definition.rootSelector", }, type: expect.toBeOneOf(["warning", "info"]), }, @@ -96,18 +96,18 @@ describe("SelectorAnalysis", () => { it("detects invalid trigger selector", async () => { const analysis = new SelectorAnalysis(); - const component = triggerFormStateFactory(); + const formState = triggerFormStateFactory(); - component.extensionPoint.definition.rootSelector = '!div:contains("foo")'; + formState.starterBrick.definition.rootSelector = '!div:contains("foo")'; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: expect.any(String), position: { - path: "extensionPoint.definition.rootSelector", + path: "starterBrick.definition.rootSelector", }, type: "error", }, @@ -119,20 +119,20 @@ describe("SelectorAnalysis", () => { async (attachMode: AttachMode) => { const analysis = new SelectorAnalysis(); - const component = menuItemFormStateFactory(); + const formState = menuItemFormStateFactory(); - component.extensionPoint.definition.containerSelector = + formState.starterBrick.definition.containerSelector = 'div:contains("foo")'; - component.extensionPoint.definition.attachMode = attachMode; + formState.starterBrick.definition.attachMode = attachMode; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: expect.any(String), position: { - path: "extensionPoint.definition.containerSelector", + path: "starterBrick.definition.containerSelector", }, type: expect.toBeOneOf(["warning", "info"]), }, @@ -143,18 +143,18 @@ describe("SelectorAnalysis", () => { it("detects invalid action location selector", async () => { const analysis = new SelectorAnalysis(); - const component = menuItemFormStateFactory(); + const formState = menuItemFormStateFactory(); - component.extensionPoint.definition.containerSelector = "!div"; + formState.starterBrick.definition.containerSelector = "!div"; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: "Invalid selector.", position: { - path: "extensionPoint.definition.containerSelector", + path: "starterBrick.definition.containerSelector", }, type: "error", }, @@ -164,9 +164,9 @@ describe("SelectorAnalysis", () => { it("detects selectors passed to highlight brick", async () => { const analysis = new SelectorAnalysis(); - const component = triggerFormStateFactory(); + const formState = triggerFormStateFactory(); - component.extension.blockPipeline = [ + formState.modComponent.brickPipeline = [ { id: highlight.id, config: { @@ -180,14 +180,14 @@ describe("SelectorAnalysis", () => { }, ]; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: expect.stringMatching(/Selector appears to contain generated/), position: { - path: "extension.blockPipeline.0.config.rootSelector", + path: "modComponent.brickPipeline.0.config.rootSelector", }, type: "warning", }, @@ -195,7 +195,7 @@ describe("SelectorAnalysis", () => { analysisId: "selector", message: expect.stringMatching(/Selector appears to contain generated/), position: { - path: "extension.blockPipeline.0.config.elements.0.selector", + path: "modComponent.brickPipeline.0.config.elements.0.selector", }, type: "warning", }, @@ -205,9 +205,9 @@ describe("SelectorAnalysis", () => { it("detects selectors passed to jquery brick", async () => { const analysis = new SelectorAnalysis(); - const component = triggerFormStateFactory(); + const formState = triggerFormStateFactory(); - component.extension.blockPipeline = [ + formState.modComponent.brickPipeline = [ { id: reader.id, config: { @@ -221,14 +221,14 @@ describe("SelectorAnalysis", () => { }, ]; - await analysis.run(component); + await analysis.run(formState); expect(analysis.getAnnotations()).toStrictEqual([ { analysisId: "selector", message: expect.stringMatching(/Selector appears to contain generated/), position: { - path: "extension.blockPipeline.0.config.selectors.simple", + path: "modComponent.brickPipeline.0.config.selectors.simple", }, type: "warning", }, @@ -236,7 +236,7 @@ describe("SelectorAnalysis", () => { analysisId: "selector", message: expect.stringMatching(/Selector appears to contain generated/), position: { - path: "extension.blockPipeline.0.config.selectors.complex.selector", + path: "modComponent.brickPipeline.0.config.selectors.complex.selector", }, type: "warning", }, diff --git a/src/analysis/analysisVisitors/selectorAnalysis.ts b/src/analysis/analysisVisitors/selectorAnalysis.ts index 2f2d9eccac..859155013a 100644 --- a/src/analysis/analysisVisitors/selectorAnalysis.ts +++ b/src/analysis/analysisVisitors/selectorAnalysis.ts @@ -107,11 +107,11 @@ class SelectorAnalysis extends AnalysisVisitorWithResolvedBricksABC { await super.run(component); } - checkAction(component: ButtonFormState): void { - const selector = component.extensionPoint.definition.containerSelector; + checkAction(formState: ButtonFormState): void { + const selector = formState.starterBrick.definition.containerSelector; const position = { - path: "extensionPoint.definition.containerSelector", + path: "starterBrick.definition.containerSelector", }; if (!isEmpty(selector)) { @@ -127,7 +127,7 @@ class SelectorAnalysis extends AnalysisVisitorWithResolvedBricksABC { if (!isNativeCssSelector(selector)) { const matches = findJQueryExtensions(selector); const isWatch = - component.extensionPoint.definition.attachMode === "watch"; + formState.starterBrick.definition.attachMode === "watch"; let message = isWatch ? "Using a non-native CSS selector for location in watch mode. Button location selectors that use jQuery extensions may slow down the page." @@ -150,11 +150,11 @@ class SelectorAnalysis extends AnalysisVisitorWithResolvedBricksABC { } } - checkTrigger(component: TriggerFormState): void { - const selector = component.extensionPoint.definition.rootSelector; + checkTrigger(formState: TriggerFormState): void { + const selector = formState.starterBrick.definition.rootSelector; const position = { - path: "extensionPoint.definition.rootSelector", + path: "starterBrick.definition.rootSelector", }; if (selector) { @@ -170,7 +170,7 @@ class SelectorAnalysis extends AnalysisVisitorWithResolvedBricksABC { if (!isNativeCssSelector(selector)) { const matches = findJQueryExtensions(selector); const isWatch = - component.extensionPoint.definition.attachMode === "watch"; + formState.starterBrick.definition.attachMode === "watch"; let message = isWatch ? "Using a non-native CSS selector in watch mode. Watching selectors that use jQuery extensions may slow down the page." diff --git a/src/analysis/analysisVisitors/templateAnalysis.test.ts b/src/analysis/analysisVisitors/templateAnalysis.test.ts index b80429810c..805119d276 100644 --- a/src/analysis/analysisVisitors/templateAnalysis.test.ts +++ b/src/analysis/analysisVisitors/templateAnalysis.test.ts @@ -27,9 +27,9 @@ const position: BrickPosition = { path: "test.path.property", }; -function blockExtensionFactory(expression: Expression) { - const extension = triggerFormStateFactory(); - extension.extension.blockPipeline = [ +function httpBrickModComponentFactory(expression: Expression) { + const formState = triggerFormStateFactory(); + formState.modComponent.brickPipeline = [ brickConfigFactory({ id: RemoteMethod.BLOCK_ID, config: { @@ -38,7 +38,7 @@ function blockExtensionFactory(expression: Expression) { }), ]; - return extension; + return formState; } describe("TemplateAnalysis", () => { @@ -66,11 +66,11 @@ describe("TemplateAnalysis", () => { "accepts valid mustache [%s]", async (template) => { const analysis = new TemplateAnalysis(); - const extension = blockExtensionFactory( + const formState = httpBrickModComponentFactory( toExpression("mustache", template), ); - await analysis.run(extension); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(0); }, @@ -80,11 +80,11 @@ describe("TemplateAnalysis", () => { "rejects mustache template in non-mustache expression [%s]", async (template) => { const analysis = new TemplateAnalysis(); - const extension = blockExtensionFactory( + const formState = httpBrickModComponentFactory( toExpression("nunjucks", template), ); - await analysis.run(extension); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(1); }, @@ -96,11 +96,11 @@ describe("TemplateAnalysis", () => { "rejects invalid nunjucks [%s]", async (template) => { const analysis = new TemplateAnalysis(); - const extension = blockExtensionFactory( + const formState = httpBrickModComponentFactory( toExpression("nunjucks", template), ); - await analysis.run(extension); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(1); }, diff --git a/src/analysis/analysisVisitors/templateAnalysis.ts b/src/analysis/analysisVisitors/templateAnalysis.ts index f895cce9df..27c682d633 100644 --- a/src/analysis/analysisVisitors/templateAnalysis.ts +++ b/src/analysis/analysisVisitors/templateAnalysis.ts @@ -55,9 +55,9 @@ class TemplateAnalysis extends PipelineExpressionVisitor implements Analysis { return this.annotations; } - async run(extension: ModComponentFormState): Promise { - this.visitRootPipeline(extension.extension.blockPipeline, { - extensionPointType: extension.type, + async run(formState: ModComponentFormState): Promise { + this.visitRootPipeline(formState.modComponent.brickPipeline, { + starterBrickType: formState.type, }); await Promise.all(this.nunjucksValidationPromises); diff --git a/src/analysis/analysisVisitors/varAnalysis/varAnalysis.test.ts b/src/analysis/analysisVisitors/varAnalysis/varAnalysis.test.ts index 8960a3d340..4e1cb94e0c 100644 --- a/src/analysis/analysisVisitors/varAnalysis/varAnalysis.test.ts +++ b/src/analysis/analysisVisitors/varAnalysis/varAnalysis.test.ts @@ -26,7 +26,7 @@ import IfElse from "@/bricks/transformers/controlFlow/IfElse"; import ForEach from "@/bricks/transformers/controlFlow/ForEach"; import { EchoBrick } from "@/runtime/pipelineTests/pipelineTestHelpers"; import { type ModComponentFormState } from "@/pageEditor/starterBricks/formStateTypes"; -import recipeRegistry from "@/modDefinitions/registry"; +import modRegistry from "@/modDefinitions/registry"; import blockRegistry from "@/bricks/registry"; import { SELF_EXISTENCE, VarExistence } from "./varMap"; import TryExcept from "@/bricks/transformers/controlFlow/TryExcept"; @@ -104,8 +104,8 @@ jest.mock("@/bricks/registry", () => ({ jest.mock("@/modDefinitions/registry"); describe("Collecting available vars", () => { - function mockBlueprintWithOptions(optionsSchema: any) { - jest.mocked(recipeRegistry.lookup).mockResolvedValue( + function mockModWithOptions(optionsSchema: any) { + jest.mocked(modRegistry.lookup).mockResolvedValue( defaultModDefinitionFactory({ options: { schema: optionsSchema, @@ -125,7 +125,7 @@ describe("Collecting available vars", () => { }); test("collects the context vars", async () => { - mockBlueprintWithOptions({ + mockModWithOptions({ properties: { foo: { type: "string", @@ -133,7 +133,7 @@ describe("Collecting available vars", () => { }, }); - const extension = formStateFactory( + const formState = formStateFactory( { // Test both the PixieBrix api integration and a sample third-party service integrationDependencies: [ @@ -147,19 +147,19 @@ describe("Collecting available vars", () => { optionsArgs: { foo: "bar", }, - recipe: modMetadataFactory({ - id: validateRegistryId("test/recipe"), + modMetadata: modMetadataFactory({ + id: validateRegistryId("test/mod"), }), }, [brickConfigFactory()], ); - await analysis.run(extension); + await analysis.run(formState); const knownVars = analysis.getKnownVars(); expect(knownVars.size).toBe(1); - const foundationKnownVars = knownVars.get("extension.blockPipeline.0"); + const foundationKnownVars = knownVars.get("modComponent.brickPipeline.0"); expect(foundationKnownVars.isVariableDefined("@input.title")).toBeTrue(); expect(foundationKnownVars.isVariableDefined("@input.url")).toBeTrue(); expect(foundationKnownVars.isVariableDefined("@input.lang")).toBeTrue(); @@ -177,24 +177,24 @@ describe("Collecting available vars", () => { }); test("collects the output key", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ brickConfigFactory({ outputKey: validateOutputKey("foo"), }), brickConfigFactory(), ]); - await analysis.run(extension); + await analysis.run(formState); const block0Vars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); expect(block0Vars.isVariableDefined("@foo")).toBeFalse(); const block1Vars = analysis .getKnownVars() - .get("extension.blockPipeline.1"); + .get("modComponent.brickPipeline.1"); expect(block1Vars.isVariableDefined("@foo")).toBeTrue(); @@ -203,7 +203,7 @@ describe("Collecting available vars", () => { }); test("collects the output key of a conditional block", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ brickConfigFactory({ if: true, outputKey: validateOutputKey("foo"), @@ -211,17 +211,17 @@ describe("Collecting available vars", () => { brickConfigFactory(), ]); - await analysis.run(extension); + await analysis.run(formState); const block0Vars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); expect(block0Vars.isVariableDefined("@foo")).toBeFalse(); const block1Vars = analysis .getKnownVars() - .get("extension.blockPipeline.1"); + .get("modComponent.brickPipeline.1"); expect(block1Vars.isVariableDefined("@foo")).toBeTrue(); @@ -234,13 +234,13 @@ describe("Collecting available vars", () => { it("collects actual mod variables", async () => { const analysis = new VarAnalysis({ modState: { foo: 42 } }); - const extension = formStateFactory({}, [brickConfigFactory()]); + const formState = formStateFactory({}, [brickConfigFactory()]); - await analysis.run(extension); + await analysis.run(formState); const foundationKnownVars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); expect(foundationKnownVars.isVariableDefined("@mod")).toBeTrue(); expect(foundationKnownVars.isVariableDefined("@mod.foo")).toBeTrue(); @@ -254,13 +254,13 @@ describe("Collecting available vars", () => { }, }); - const extension = formStateFactory({}, [brickConfigFactory()]); + const formState = formStateFactory({}, [brickConfigFactory()]); - await analysis.run(extension); + await analysis.run(formState); const foundationKnownVars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); console.log(JSON.stringify(foundationKnownVars)); @@ -284,13 +284,13 @@ describe("Collecting available vars", () => { it("handles inferred mod variables", async () => { const analysis = new VarAnalysis({ modVariables: [{ foo: {} }] }); - const extension = formStateFactory({}, [brickConfigFactory()]); + const formState = formStateFactory({}, [brickConfigFactory()]); - await analysis.run(extension); + await analysis.run(formState); const foundationKnownVars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); expect(foundationKnownVars.isVariableDefined("@mod")).toBeTrue(); expect(foundationKnownVars.isVariableDefined("@mod.foo")).toBeTrue(); @@ -298,34 +298,34 @@ describe("Collecting available vars", () => { }); }); - describe("blueprint @options", () => { + describe("mod @options", () => { beforeEach(() => { analysis = new VarAnalysis(); }); test.each([{}, null, undefined])("no options", async (optionsSchema) => { - mockBlueprintWithOptions(optionsSchema); + mockModWithOptions(optionsSchema); - const extension = formStateFactory( + const formState = formStateFactory( { - recipe: modMetadataFactory({ - id: validateRegistryId("test/recipe"), + modMetadata: modMetadataFactory({ + id: validateRegistryId("test/mod"), }), }, [brickConfigFactory()], ); - await analysis.run(extension); + await analysis.run(formState); const foundationKnownVars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); expect(foundationKnownVars.isVariableDefined("@options")).toBeFalse(); }); - test("read values from blueprint and extension", async () => { - mockBlueprintWithOptions({ + test("read values from mod and mod component", async () => { + mockModWithOptions({ properties: { foo: { type: "string", @@ -336,36 +336,36 @@ describe("Collecting available vars", () => { }, }); - const extension = formStateFactory( + const formState = formStateFactory( { - // Let this extension to have a service reference + // Let this mod component have an integration reference optionsArgs: { bar: "qux", baz: "quux", }, - recipe: modMetadataFactory({ - id: validateRegistryId("test/recipe"), + modMetadata: modMetadataFactory({ + id: validateRegistryId("test/mod"), }), }, [brickConfigFactory()], ); - await analysis.run(extension); + await analysis.run(formState); const foundationKnownVars = analysis .getKnownVars() - .get("extension.blockPipeline.0"); + .get("modComponent.brickPipeline.0"); - // A variable defined in the blueprint + // A variable defined in the mod expect(foundationKnownVars.isVariableDefined("@options.foo")).toBeTrue(); - // A variable defined in the blueprint and extension options + // A variable defined in the mod and mod component options expect(foundationKnownVars.isVariableDefined("@options.bar")).toBeTrue(); - // A variable defined in the extension options but not in the blueprint + // A variable defined in the mod component options but not in the mod expect(foundationKnownVars.isVariableDefined("@options.baz")).toBeTrue(); }); test("sets DEFINITELY for required options", async () => { - mockBlueprintWithOptions({ + mockModWithOptions({ properties: { foo: { type: "string", @@ -377,29 +377,29 @@ describe("Collecting available vars", () => { required: ["foo"], }); - const extension = formStateFactory( + const formState = formStateFactory( { - recipe: modMetadataFactory({ - id: validateRegistryId("test/recipe"), + modMetadata: modMetadataFactory({ + id: validateRegistryId("test/mod"), }), }, [brickConfigFactory()], ); - await analysis.run(extension); + await analysis.run(formState); const knownVars = analysis.getKnownVars(); - const optionsVars = knownVars.get("extension.blockPipeline.0").getMap()[ - "options:test/recipe" - ]["@options"]; + const optionsVars = knownVars + .get("modComponent.brickPipeline.0") + .getMap()["options:test/mod"]["@options"]; expect(optionsVars.foo[SELF_EXISTENCE]).toBe(VarExistence.DEFINITELY); expect(optionsVars.bar[SELF_EXISTENCE]).toBe(VarExistence.MAYBE); }); test("sets DEFINITELY for the actually set values", async () => { - mockBlueprintWithOptions({ + mockModWithOptions({ properties: { foo: { type: "string", @@ -407,10 +407,10 @@ describe("Collecting available vars", () => { }, }); - const extension = formStateFactory( + const formState = formStateFactory( { - recipe: modMetadataFactory({ - id: validateRegistryId("test/recipe"), + modMetadata: modMetadataFactory({ + id: validateRegistryId("test/mod"), }), optionsArgs: { foo: "bar", @@ -419,13 +419,13 @@ describe("Collecting available vars", () => { [brickConfigFactory()], ); - await analysis.run(extension); + await analysis.run(formState); const knownVars = analysis.getKnownVars(); - const optionsVars = knownVars.get("extension.blockPipeline.0").getMap()[ - "options:test/recipe" - ]["@options"]; + const optionsVars = knownVars + .get("modComponent.brickPipeline.0") + .getMap()["options:test/mod"]["@options"]; expect(optionsVars.foo[SELF_EXISTENCE]).toBe(VarExistence.DEFINITELY); }); @@ -435,7 +435,7 @@ describe("Collecting available vars", () => { const outputKey = validateOutputKey("foo"); async function runAnalysisWithOutputSchema(outputSchema: Schema) { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ brickConfigFactory({ outputKey, }), @@ -444,7 +444,7 @@ describe("Collecting available vars", () => { jest.mocked(blockRegistry.allTyped).mockResolvedValue( new Map([ [ - extension.extension.blockPipeline[0].id, + formState.modComponent.brickPipeline[0].id, { block: { // HtmlReader's output schema, see @/bricks/readers/HtmlReader.ts @@ -455,9 +455,9 @@ describe("Collecting available vars", () => { ]) as any, ); - await analysis.run(extension); + await analysis.run(formState); - return analysis.getKnownVars().get("extension.blockPipeline.1"); + return analysis.getKnownVars().get("modComponent.brickPipeline.1"); } test("reads output schema of a block when defined", async () => { @@ -729,28 +729,28 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ ifElseBlock, brickConfigFactory(), ]); - await analysis.run(extension); + await analysis.run(formState); }); test("adds if-else output after the brick", async () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.1") + .get("modComponent.brickPipeline.1") .isVariableDefined("@ifOutput"), ).toBeTrue(); }); test.each([ - "extension.blockPipeline.0.config.if.__value__.0", - "extension.blockPipeline.0.config.if.__value__.1", - "extension.blockPipeline.0.config.else.__value__.0", - "extension.blockPipeline.0.config.else.__value__.1", + "modComponent.brickPipeline.0.config.if.__value__.0", + "modComponent.brickPipeline.0.config.if.__value__.1", + "modComponent.brickPipeline.0.config.else.__value__.0", + "modComponent.brickPipeline.0.config.else.__value__.1", ])( "doesn't add if-else output to sub pipelines (%s)", async (blockPath) => { @@ -763,7 +763,7 @@ describe("Collecting available vars", () => { test("doesn't leak sub pipeline outputs", async () => { const block1Vars = analysis .getKnownVars() - .get("extension.blockPipeline.1"); + .get("modComponent.brickPipeline.1"); expect(block1Vars.isVariableDefined("@foo")).toBeFalse(); expect(block1Vars.isVariableDefined("@bar")).toBeFalse(); }); @@ -793,16 +793,16 @@ describe("Collecting available vars", () => { ]), ); - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ brickConfiguration, brickConfiguration, ]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const knownVars = analysis.getKnownVars(); - const varMap = knownVars.get("extension.blockPipeline.1"); + const varMap = knownVars.get("modComponent.brickPipeline.1"); // Check optional chaining handled for first variable expect(varMap.isVariableDefined("@input")).toBeTrue(); @@ -840,16 +840,16 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [documentRendererBrick]); + const formState = formStateFactory(undefined, [documentRendererBrick]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds the list element key list body", () => { const knownVars = analysis.getKnownVars(); const listElementVarMap = knownVars.get( - "extension.blockPipeline.0.config.body.0.config.element.__value__", + "modComponent.brickPipeline.0.config.body.0.config.element.__value__", ); expect(listElementVarMap.isVariableDefined("@element")).toBeTrue(); @@ -865,7 +865,7 @@ describe("Collecting available vars", () => { 'Variable "@foo" might not be defined', ); expect(annotations[0].position.path).toBe( - "extension.blockPipeline.0.config.body.0.config.element.__value__.config.text", + "modComponent.brickPipeline.0.config.body.0.config.element.__value__.config.text", ); // Not available in to the peer element to the list @@ -873,7 +873,7 @@ describe("Collecting available vars", () => { 'Variable "@element" might not be defined', ); expect(annotations[1].position.path).toBe( - "extension.blockPipeline.0.config.body.1.config.text", + "modComponent.brickPipeline.0.config.body.1.config.text", ); }); }); @@ -908,16 +908,16 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [documentRendererBrick]); + const formState = formStateFactory(undefined, [documentRendererBrick]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds the list element key list body", () => { const knownVars = analysis.getKnownVars(); const buttonPipelineVarMap = knownVars.get( - "extension.blockPipeline.0.config.body.0.config.element.__value__.children.0.children.0.config.onClick.__value__.0", + "modComponent.brickPipeline.0.config.body.0.config.element.__value__.children.0.children.0.config.onClick.__value__.0", ); expect(buttonPipelineVarMap.isVariableDefined("@input")).toBeTrue(); @@ -934,7 +934,7 @@ describe("Collecting available vars", () => { message: 'Variable "@foo" might not be defined', type: "warning", position: { - path: "extension.blockPipeline.0.config.body.0.config.element.__value__.children.0.children.0.config.onClick.__value__.0.config.text", + path: "modComponent.brickPipeline.0.config.body.0.config.element.__value__.children.0.children.0.config.onClick.__value__.0.config.text", }, detail: { expression: expect.toBeObject(), @@ -955,20 +955,20 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ tryExceptBlock, brickConfigFactory(), ]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds the error key to the except branch", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.0.config.except.__value__.0") + .get("modComponent.brickPipeline.0.config.except.__value__.0") .isVariableDefined("@error"), ).toBeTrue(); }); @@ -977,7 +977,7 @@ describe("Collecting available vars", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.0.config.try.__value__.0") + .get("modComponent.brickPipeline.0.config.try.__value__.0") .isVariableDefined("@error"), ).toBeFalse(); }); @@ -995,20 +995,20 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ forEachBlock, brickConfigFactory(), ]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds the element key to the sub pipeline", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.0.config.body.__value__.0") + .get("modComponent.brickPipeline.0.config.body.__value__.0") .isVariableDefined("@element"), ).toBeTrue(); }); @@ -1031,27 +1031,27 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ forEachBlock, brickConfigFactory(), ]); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds for-each output after the brick", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.1") + .get("modComponent.brickPipeline.1") .isVariableDefined("@forEachOutput"), ).toBeTrue(); }); test.each([ - "extension.blockPipeline.0.config.body.__value__.0", - "extension.blockPipeline.0.config.body.__value__.1", + "modComponent.brickPipeline.0.config.body.__value__.0", + "modComponent.brickPipeline.0.config.body.__value__.1", ])("doesn't add for-each output to sub pipelines (%s)", (blockPath) => { expect( analysis @@ -1065,7 +1065,7 @@ describe("Collecting available vars", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.1") + .get("modComponent.brickPipeline.1") .isVariableDefined("@foo"), ).toBeFalse(); }); @@ -1074,7 +1074,7 @@ describe("Collecting available vars", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.0.config.body.__value__.0") + .get("modComponent.brickPipeline.0.config.body.__value__.0") .isVariableDefined("@element"), ).toBeTrue(); }); @@ -1083,18 +1083,18 @@ describe("Collecting available vars", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.1") + .get("modComponent.brickPipeline.1") .isVariableDefined("@element"), ).toBeFalse(); }); test.each([ - "extension.blockPipeline.0.config.body.__value__.0", - "extension.blockPipeline.0.config.body.__value__.1", + "modComponent.brickPipeline.0.config.body.__value__.0", + "modComponent.brickPipeline.0.config.body.__value__.1", ])("source of the @element key if the For-Each block (%s)", (blockPath) => { const blockVars = analysis.getKnownVars().get(blockPath).getMap(); - const expectedForEachBlockPath = "extension.blockPipeline.0"; + const expectedForEachBlockPath = "modComponent.brickPipeline.0"; // Find the source that provided the @element variable const actualForEachBlockPath = Object.entries(blockVars).find( @@ -1122,7 +1122,7 @@ describe("Collecting available vars", () => { }, }; - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ customFormBlock, brickConfigFactory(), ]); @@ -1140,14 +1140,14 @@ describe("Collecting available vars", () => { ); analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); }); test("adds the `values` to the onsubmit handler", () => { expect( analysis .getKnownVars() - .get("extension.blockPipeline.0.config.onSubmit.__value__.0") + .get("modComponent.brickPipeline.0.config.onSubmit.__value__.0") .isVariableDefined("@values"), ).toBeTrue(); }); @@ -1155,7 +1155,7 @@ describe("Collecting available vars", () => { test("adds the form fields to the onsubmit handler", () => { const blockVars = analysis .getKnownVars() - .get("extension.blockPipeline.0.config.onSubmit.__value__.0"); + .get("modComponent.brickPipeline.0.config.onSubmit.__value__.0"); expect(blockVars.isVariableDefined("@values.foo")).toBeTrue(); expect(blockVars.isVariableDefined("@values.bar")).toBeFalse(); @@ -1164,7 +1164,7 @@ describe("Collecting available vars", () => { }); describe("Invalid template", () => { - let extension: ModComponentFormState; + let formState: ModComponentFormState; let analysis: VarAnalysis; beforeEach(() => { @@ -1187,30 +1187,30 @@ describe("Invalid template", () => { }, }; - extension = formStateFactory(undefined, [invalidEchoBlock, validEchoBlock]); + formState = formStateFactory(undefined, [invalidEchoBlock, validEchoBlock]); analysis = new VarAnalysis(); }); test("analysis doesn't throw", async () => { - await expect(analysis.run(extension)).toResolve(); + await expect(analysis.run(formState)).toResolve(); }); test("analysis doesn't annotate invalid template", async () => { - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); // Only the second (index = 1) block should be annotated expect(annotations).toHaveLength(1); expect(annotations[0].position.path).toBe( - "extension.blockPipeline.1.config.message", + "modComponent.brickPipeline.1.config.message", ); }); }); describe("var expression annotations", () => { test("doesn't annotate valid expressions", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ brickConfigFactory({ outputKey: validateOutputKey("foo"), }), @@ -1223,13 +1223,13 @@ describe("var expression annotations", () => { ]); const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(0); }); test("doesn't annotate empty variable", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1239,13 +1239,13 @@ describe("var expression annotations", () => { ]); const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); expect(analysis.getAnnotations()).toHaveLength(0); }); test("annotates variable which doesn't start with @", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1255,7 +1255,7 @@ describe("var expression annotations", () => { ]); const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(1); @@ -1265,7 +1265,7 @@ describe("var expression annotations", () => { }); test("annotates variable which is just whitespace", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1275,7 +1275,7 @@ describe("var expression annotations", () => { ]); const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(1); @@ -1283,7 +1283,7 @@ describe("var expression annotations", () => { }); test("return a generic error message for a single @ character", async () => { - const extension = formStateFactory(undefined, [ + const formState = formStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1293,7 +1293,7 @@ describe("var expression annotations", () => { ]); const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(1); @@ -1303,7 +1303,7 @@ describe("var expression annotations", () => { describe("var analysis integration tests", () => { it("should handle trigger event", async () => { - const extension = triggerFormStateFactory(undefined, [ + const formState = triggerFormStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1315,17 +1315,17 @@ describe("var analysis integration tests", () => { }, ]); - extension.extensionPoint.definition.trigger = "keypress"; + formState.starterBrick.definition.trigger = "keypress"; const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(0); }); it("should handle trigger custom event", async () => { - const extension = triggerFormStateFactory(undefined, [ + const formState = triggerFormStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1337,17 +1337,17 @@ describe("var analysis integration tests", () => { }, ]); - extension.extensionPoint.definition.trigger = "custom"; + formState.starterBrick.definition.trigger = "custom"; const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(0); }); it("should handle trigger selectionchange event", async () => { - const extension = triggerFormStateFactory(undefined, [ + const formState = triggerFormStateFactory(undefined, [ { id: EchoBrick.BLOCK_ID, config: { @@ -1360,10 +1360,10 @@ describe("var analysis integration tests", () => { }, ]); - extension.extensionPoint.definition.trigger = "selectionchange"; + formState.starterBrick.definition.trigger = "selectionchange"; const analysis = new VarAnalysis(); - await analysis.run(extension); + await analysis.run(formState); const annotations = analysis.getAnnotations(); expect(annotations).toHaveLength(1); diff --git a/src/analysis/analysisVisitors/varAnalysis/varAnalysis.ts b/src/analysis/analysisVisitors/varAnalysis/varAnalysis.ts index 90c030868c..08e2b4ccdb 100644 --- a/src/analysis/analysisVisitors/varAnalysis/varAnalysis.ts +++ b/src/analysis/analysisVisitors/varAnalysis/varAnalysis.ts @@ -34,7 +34,7 @@ import { import VarMap, { VarExistence } from "./varMap"; import { type TraceRecord } from "@/telemetry/trace"; import parseTemplateVariables from "./parseTemplateVariables"; -import recipesRegistry from "@/modDefinitions/registry"; +import modRegistry from "@/modDefinitions/registry"; import blockRegistry, { type TypedBrickMap } from "@/bricks/registry"; import { isDocumentBuilderElementArray, @@ -133,22 +133,22 @@ async function setIntegrationDependencyVars( } /** - * Set the input variables from the ExtensionPoint definition (aka starter brick). + * Set the input variables from the starter brick definition. */ async function setInputVars( - extension: ModComponentFormState, + formState: ModComponentFormState, contextVars: VarMap, ): Promise { - const adapter = ADAPTERS.get(extension.extensionPoint.definition.type); + const adapter = ADAPTERS.get(formState.starterBrick.definition.type); assertNotNullish( adapter, - `Adapter not found for ${extension.extensionPoint.definition.type}`, + `Adapter not found for ${formState.starterBrick.definition.type}`, ); - const config = adapter.selectStarterBrickDefinition(extension); + const config = adapter.selectStarterBrickDefinition(formState); - const extensionPoint = fromJS(config); + const starterBrick = fromJS(config); - const reader = await extensionPoint.defaultReader(); + const reader = await starterBrick.defaultReader(); setVarsFromSchema({ schema: reader?.outputSchema ?? { @@ -193,7 +193,7 @@ type SetVarsFromSchemaArgs = { * Helper method to set variables based on a JSON Schema. * * Examples: - * - Blueprint input schema + * - Mod input schema * - Brick output schema * - Integration configuration schema */ @@ -304,24 +304,24 @@ function setVarsFromSchema({ } /** - * Set the options variables from the blueprint option definitions. + * Set the options variables from the mod option definitions. */ async function setOptionsVars( - extension: ModComponentFormState, + formState: ModComponentFormState, contextVars: VarMap, ): Promise { - if (extension.recipe == null) { + if (formState.modMetadata == null) { return; } - const recipeId = extension.recipe.id; - const recipe = await recipesRegistry.lookup(recipeId); - const optionsSchema = recipe?.options?.schema; + const modId = formState.modMetadata.id; + const mod = await modRegistry.lookup(modId); + const optionsSchema = mod?.options?.schema; if (isEmpty(optionsSchema)) { return; } - const source = `${KnownSources.OPTIONS}:${recipeId}`; + const source = `${KnownSources.OPTIONS}:${modId}`; const optionsOutputKey = "@options"; setVarsFromSchema({ @@ -332,7 +332,7 @@ async function setOptionsVars( }); // Options currently only supports primitives, so don't need to recurse - for (const optionName of Object.keys(extension.optionsArgs ?? {})) { + for (const optionName of Object.keys(formState.optionsArgs ?? {})) { contextVars.setExistence({ source, path: [optionsOutputKey, optionName], @@ -452,7 +452,7 @@ class VarAnalysis extends PipelineExpressionVisitor implements Analysis { } /** - * @param trace the trace for the latest run of the extension + * @param trace the trace for the latest run of the mod component * @param modState the current mod page state * @param modVariables statically-inferred mod variable names * @see CollectNamesVisitor @@ -682,23 +682,23 @@ class VarAnalysis extends PipelineExpressionVisitor implements Analysis { this.contextStack.pop(); } - async run(extension: ModComponentFormState): Promise { + async run(formState: ModComponentFormState): Promise { this.allBlocks = await blockRegistry.allTyped(); // Order of the following calls will determine the order of the sources in the UI const contextVars = new VarMap(); - await setOptionsVars(extension, contextVars); + await setOptionsVars(formState, contextVars); await setModVariables(this.modVariables, this.modState, contextVars); - await setIntegrationDependencyVars(extension, contextVars); - await setInputVars(extension, contextVars); + await setIntegrationDependencyVars(formState, contextVars); + await setInputVars(formState, contextVars); this.contextStack.push({ vars: contextVars, blockOutputVars: new VarMap(), }); - this.visitRootPipeline(extension.extension.blockPipeline, { - extensionPointType: extension.type, + this.visitRootPipeline(formState.modComponent.brickPipeline, { + starterBrickType: formState.type, }); } diff --git a/src/bricks/PipelineExpressionVisitor.test.ts b/src/bricks/PipelineExpressionVisitor.test.ts index 6399f17463..144db7acc2 100644 --- a/src/bricks/PipelineExpressionVisitor.test.ts +++ b/src/bricks/PipelineExpressionVisitor.test.ts @@ -19,7 +19,7 @@ import { DocumentRenderer } from "@/bricks/renderers/document"; import { type BrickPosition, type BrickPipeline } from "@/bricks/types"; import { createNewDocumentBuilderElement } from "@/pageEditor/documentBuilder/createNewDocumentBuilderElement"; import { type Expression } from "@/types/runtimeTypes"; -import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts"; +import { PIPELINE_BRICKS_FIELD_NAME } from "@/pageEditor/consts"; import PipelineExpressionVisitor from "./PipelineExpressionVisitor"; import { brickConfigFactory } from "@/testUtils/factories/brickFactories"; import { toExpression } from "@/utils/expressionUtils"; @@ -52,13 +52,13 @@ test("should invoke the callback for a brick expression", () => { expect(visitExpression).toHaveBeenCalledTimes(2); expect(visitExpression).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.text`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.text`, }, toExpression("nunjucks", "test"), ); expect(visitExpression).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.if`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.if`, }, toExpression("var", "@foo"), ); @@ -96,7 +96,7 @@ test("should invoke the callback for a Document expression", () => { expect(visitExpression).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.text`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.text`, }, toExpression("nunjucks", "test"), ); diff --git a/src/bricks/PipelineVisitor.test.ts b/src/bricks/PipelineVisitor.test.ts index 2010382a51..fd1a3d58ac 100644 --- a/src/bricks/PipelineVisitor.test.ts +++ b/src/bricks/PipelineVisitor.test.ts @@ -19,7 +19,7 @@ import { DocumentRenderer } from "@/bricks/renderers/document"; import ForEach from "@/bricks/transformers/controlFlow/ForEach"; import { type BrickPosition, type BrickConfig } from "@/bricks/types"; import { createNewDocumentBuilderElement } from "@/pageEditor/documentBuilder/createNewDocumentBuilderElement"; -import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts"; +import { PIPELINE_BRICKS_FIELD_NAME } from "@/pageEditor/consts"; import { type PipelineExpression } from "@/types/runtimeTypes"; import PipelineVisitor, { type VisitBlockExtra } from "./PipelineVisitor"; import { @@ -46,13 +46,13 @@ test("should invoke the callback for the pipeline bricks", () => { const visitor = new Visitor(); visitor.visitRootPipeline(pipeline, { - extensionPointType: StarterBrickTypes.BUTTON, + starterBrickType: StarterBrickTypes.BUTTON, }); expect(visitBlock).toHaveBeenCalledTimes(pipeline.length); expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0`, }, pipeline[0], { @@ -60,12 +60,12 @@ test("should invoke the callback for the pipeline bricks", () => { pipelineFlavor: "noRenderer", parentNodeId: undefined, pipeline, - pipelinePosition: { path: PIPELINE_BLOCKS_FIELD_NAME }, + pipelinePosition: { path: PIPELINE_BRICKS_FIELD_NAME }, }, ); expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.1`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.1`, }, pipeline[1], { @@ -73,7 +73,7 @@ test("should invoke the callback for the pipeline bricks", () => { pipelineFlavor: "noRenderer", parentNodeId: undefined, pipeline, - pipelinePosition: { path: PIPELINE_BLOCKS_FIELD_NAME }, + pipelinePosition: { path: PIPELINE_BRICKS_FIELD_NAME }, }, ); }); @@ -104,7 +104,7 @@ test("should invoke the callback for the sub pipeline bricks", () => { } const visitor = new Visitor(); visitor.visitRootPipeline(pipeline, { - extensionPointType: StarterBrickTypes.BUTTON, + starterBrickType: StarterBrickTypes.BUTTON, }); expect(visitBlock).toHaveBeenCalledTimes( @@ -113,7 +113,7 @@ test("should invoke the callback for the sub pipeline bricks", () => { expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.__value__.0`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.__value__.0`, }, subPipeline[0], { @@ -122,13 +122,13 @@ test("should invoke the callback for the sub pipeline bricks", () => { parentNodeId: forEachBrick.instanceId, pipeline: subPipeline, pipelinePosition: { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.__value__`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.__value__`, }, }, ); expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.__value__.1`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.__value__.1`, }, subPipeline[1], { @@ -137,13 +137,13 @@ test("should invoke the callback for the sub pipeline bricks", () => { parentNodeId: forEachBrick.instanceId, pipeline: subPipeline, pipelinePosition: { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.__value__`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.__value__`, }, }, ); expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0`, }, pipeline[0], { @@ -151,7 +151,7 @@ test("should invoke the callback for the sub pipeline bricks", () => { pipelineFlavor: "noRenderer", parentNodeId: undefined, pipeline, - pipelinePosition: { path: PIPELINE_BLOCKS_FIELD_NAME }, + pipelinePosition: { path: PIPELINE_BRICKS_FIELD_NAME }, }, ); }); @@ -186,13 +186,13 @@ test("should invoke the callback for the Document button pipeline", () => { } const visitor = new Visitor(); visitor.visitRootPipeline(pipeline, { - extensionPointType: StarterBrickTypes.SIDEBAR_PANEL, + starterBrickType: StarterBrickTypes.SIDEBAR_PANEL, }); expect(visitBlock).toHaveBeenCalledTimes(2); // One Document brick and one brick in the pipeline expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.onClick.__value__.0`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.onClick.__value__.0`, }, subPipeline[0], { @@ -201,13 +201,13 @@ test("should invoke the callback for the Document button pipeline", () => { parentNodeId: documentBrick.instanceId, pipeline: subPipeline, pipelinePosition: { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.onClick.__value__`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0.config.body.0.children.0.children.0.children.0.config.onClick.__value__`, }, }, ); expect(visitBlock).toHaveBeenCalledWith( { - path: `${PIPELINE_BLOCKS_FIELD_NAME}.0`, + path: `${PIPELINE_BRICKS_FIELD_NAME}.0`, }, documentBrick, { @@ -216,7 +216,7 @@ test("should invoke the callback for the Document button pipeline", () => { parentNodeId: undefined, pipeline, pipelinePosition: { - path: PIPELINE_BLOCKS_FIELD_NAME, + path: PIPELINE_BRICKS_FIELD_NAME, }, }, ); diff --git a/src/bricks/PipelineVisitor.ts b/src/bricks/PipelineVisitor.ts index 9c9c410086..dc0bab9d70 100644 --- a/src/bricks/PipelineVisitor.ts +++ b/src/bricks/PipelineVisitor.ts @@ -30,12 +30,12 @@ import { getSubPipelineFlavor, } from "@/bricks/brickFilterHelpers"; import { type StarterBrickType } from "@/types/starterBrickTypes"; -import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts"; +import { PIPELINE_BRICKS_FIELD_NAME } from "@/pageEditor/consts"; import { isPipelineExpression } from "@/utils/expressionUtils"; import { joinPathParts } from "@/utils/formUtils"; export const ROOT_POSITION = Object.freeze({ - path: PIPELINE_BLOCKS_FIELD_NAME, + path: PIPELINE_BRICKS_FIELD_NAME, }) as BrickPosition; export function nestedPosition( @@ -79,7 +79,7 @@ export type VisitPipelineExtra = { pipelinePropName?: string | undefined; }; type VisitRootPipelineExtra = { - extensionPointType: StarterBrickType; + starterBrickType: StarterBrickType; }; /** @@ -88,7 +88,7 @@ type VisitRootPipelineExtra = { class PipelineVisitor { /** * Visit a configured block. - * @param position the position in the extension + * @param position the position in the mod component * @param blockConfig the block configuration */ public visitBrick( @@ -152,7 +152,7 @@ class PipelineVisitor { /** * Run the visitor on a pipeline; loop over the blocks - * @param position Position of the pipeline in the extension + * @param position Position of the pipeline in the modComponent * @param pipeline The pipeline to analyze * @param extra Extra information about the pipeline */ @@ -176,8 +176,8 @@ class PipelineVisitor { pipeline: BrickConfig[], extra?: VisitRootPipelineExtra, ): void { - const flavor = extra?.extensionPointType - ? getRootPipelineFlavor(extra.extensionPointType) + const flavor = extra?.starterBrickType + ? getRootPipelineFlavor(extra.starterBrickType) : PipelineFlavor.AllBricks; this.visitPipeline(ROOT_POSITION, pipeline, { flavor }); } diff --git a/src/bricks/transformers/jquery/JQueryReaderOptions.test.tsx b/src/bricks/transformers/jquery/JQueryReaderOptions.test.tsx index 2d12425779..4ca6e64fe8 100644 --- a/src/bricks/transformers/jquery/JQueryReaderOptions.test.tsx +++ b/src/bricks/transformers/jquery/JQueryReaderOptions.test.tsx @@ -41,7 +41,7 @@ const getAttributeExamplesMock = jest.mocked(getAttributeExamples); function baseStateFactory() { const baseFormState = menuItemFormStateFactory(); - baseFormState.extension.blockPipeline = [ + baseFormState.modComponent.brickPipeline = [ { id: JQueryReader.BRICK_ID, config: { @@ -57,7 +57,7 @@ function renderOptions(formState: ModComponentFormState = baseStateFactory()) { @@ -82,7 +82,7 @@ describe("JQueryReaderOptions", () => { it("shows workshop message on variable selector", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { property: toExpression("var", "@foo"), }; @@ -96,7 +96,7 @@ describe("JQueryReaderOptions", () => { it("shows workshop message variable selectors", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = toExpression( + state.modComponent.brickPipeline[0].config.selectors = toExpression( "var", "@foo", ); @@ -111,7 +111,7 @@ describe("JQueryReaderOptions", () => { it("normalizes primitive selectors", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { property: "h1" }; + state.modComponent.brickPipeline[0].config.selectors = { property: "h1" }; renderOptions(state); @@ -123,7 +123,7 @@ describe("JQueryReaderOptions", () => { expect( screen.getByTestId( - "toggle-extension.blockPipeline.0.config.selectors.property.selector", + "toggle-modComponent.brickPipeline.0.config.selectors.property.selector", ).dataset.testSelected, ).toBe("Selector"); @@ -132,7 +132,7 @@ describe("JQueryReaderOptions", () => { it("normalizes nested selectors", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { outer: { selector: "div", find: { @@ -147,12 +147,12 @@ describe("JQueryReaderOptions", () => { expect( screen.getByTestId( - "toggle-extension.blockPipeline.0.config.selectors.outer.selector", + "toggle-modComponent.brickPipeline.0.config.selectors.outer.selector", ).dataset.testSelected, ).toBe("Selector"); expect( screen.getByTestId( - "toggle-extension.blockPipeline.0.config.selectors.outer.find.inner.selector", + "toggle-modComponent.brickPipeline.0.config.selectors.outer.find.inner.selector", ).dataset.testSelected, ).toBe("Selector"); @@ -161,7 +161,7 @@ describe("JQueryReaderOptions", () => { it("normalizes nunjucks literal selectors", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { outer: { selector: toExpression("nunjucks", "div"), find: { @@ -176,12 +176,12 @@ describe("JQueryReaderOptions", () => { expect( screen.getByTestId( - "toggle-extension.blockPipeline.0.config.selectors.outer.selector", + "toggle-modComponent.brickPipeline.0.config.selectors.outer.selector", ).dataset.testSelected, ).toBe("Selector"); expect( screen.getByTestId( - "toggle-extension.blockPipeline.0.config.selectors.outer.find.inner.selector", + "toggle-modComponent.brickPipeline.0.config.selectors.outer.find.inner.selector", ).dataset.testSelected, ).toBe("Selector"); @@ -190,7 +190,7 @@ describe("JQueryReaderOptions", () => { it("allows rename of property", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { outer: { selector: toExpression("nunjucks", "div"), find: { @@ -219,7 +219,7 @@ describe("JQueryReaderOptions", () => { it("clearing a property name reverts the value to the initial value on blur", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { outer: { selector: toExpression("nunjucks", "div"), find: { @@ -247,7 +247,7 @@ describe("JQueryReaderOptions", () => { it("generates example attributes for nested selectors", async () => { const state = baseStateFactory(); - state.extension.blockPipeline[0].config.selectors = { + state.modComponent.brickPipeline[0].config.selectors = { outer: { selector: "div", find: { diff --git a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.test.tsx b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.test.tsx index 0086098045..6b4e1f5819 100644 --- a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.test.tsx +++ b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.test.tsx @@ -77,14 +77,14 @@ const renderWidget = ( // Default empty, let initialValues override if needed integrationDependencies: [], ...initialValues, - extension: { blockPipeline: [{ config: { service: null } }] }, + modComponent: { brickPipeline: [{ config: { service: null } }] }, }} onSubmit={jest.fn()} > {({ values }) => ( <> @@ -214,8 +214,8 @@ describe("ServiceWidget", () => { const state = JSON.parse(screen.getByTestId("values").textContent); expect(state).toEqual({ - extension: { - blockPipeline: [ + modComponent: { + brickPipeline: [ { config: { service: toExpression("var", "@jest2"), diff --git a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx index f1f6beade7..dccafaab18 100644 --- a/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx +++ b/src/components/fields/schemaFields/integrations/IntegrationDependencyWidget.tsx @@ -316,13 +316,13 @@ const IntegrationDependencyWidget: React.FC< isEqual(makeVariableExpression(dependency.outputKey), value), ) ) { - // This currently happens when a brick is copy-pasted into a separate extension + // This currently happens when a brick is copy-pasted into a separate mod component // that does not yet have root.integrationDependencies configured, but already // has the integration dependency key set up in the (copied) BrickConfig. // Clearing the value here allows the preceding if-branch to execute again, which // runs the "detectDefault" logic and then calls the integration-dependency-select // change handler, which in turn will configure root.integrationDependencies - // properly for the extension. + // properly for the mod component. await helpers.setValue(null); } }, diff --git a/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.test.ts b/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.test.ts index 98d684902c..8d3fd3dd9e 100644 --- a/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.test.ts +++ b/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.test.ts @@ -210,9 +210,9 @@ describe("selectVariables", () => { permissions: emptyPermissionsFactory(), optionsArgs: {}, type: "actionPanel", - recipe: null, - extension: { - blockPipeline: [ + modMetadata: null, + modComponent: { + brickPipeline: [ { id: validateRegistryId("@pixiebrix/document"), config: { @@ -262,7 +262,7 @@ describe("selectVariables", () => { ], heading: "Document", }, - extensionPoint: { + starterBrick: { metadata: { id: validateRegistryId( "@internal/52d42d87-4382-4c78-b00e-bbdd21d75000", diff --git a/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.ts b/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.ts index 6544051794..db0936d9b8 100644 --- a/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.ts +++ b/src/components/fields/schemaFields/integrations/integrationDependencyFieldUtils.ts @@ -28,7 +28,7 @@ import { makeVariableExpression } from "@/utils/variableUtils"; export type IntegrationsFormSlice = Pick< ModComponentFormState, - "integrationDependencies" | "extension" + "integrationDependencies" | "modComponent" >; /** @@ -68,15 +68,15 @@ function deepFindIntegrationDependencyVariables( } /** - * Return set of integration dependency variables referenced by the extension, + * Return set of integration dependency variables referenced by the mod component, * including the `@`-prefixes */ export function selectIntegrationDependencyVariables( - state: Pick, + state: Pick, ): Set { const variables = new Set(); deepFindIntegrationDependencyVariables( - state.extension.blockPipeline, + state.modComponent.brickPipeline, variables, ); return variables; diff --git a/src/components/fields/schemaFields/widgets/varPopup/VarMenu.test.tsx b/src/components/fields/schemaFields/widgets/varPopup/VarMenu.test.tsx index 6f0bb6878d..5e82130c14 100644 --- a/src/components/fields/schemaFields/widgets/varPopup/VarMenu.test.tsx +++ b/src/components/fields/schemaFields/widgets/varPopup/VarMenu.test.tsx @@ -75,7 +75,7 @@ describe("VarMenu", () => { dispatch(editorActions.setActiveModComponentId(formState.uuid)); dispatch( editorActions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); }, @@ -110,7 +110,7 @@ describe("VarMenu", () => { dispatch(editorActions.setActiveModComponentId(formState.uuid)); dispatch( editorActions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); @@ -155,7 +155,7 @@ describe("VarMenu", () => { dispatch(editorActions.setActiveModComponentId(formState.uuid)); dispatch( editorActions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); diff --git a/src/components/fields/schemaFields/widgets/varPopup/VarMenu.tsx b/src/components/fields/schemaFields/widgets/varPopup/VarMenu.tsx index 2dab172130..dc1c33996d 100644 --- a/src/components/fields/schemaFields/widgets/varPopup/VarMenu.tsx +++ b/src/components/fields/schemaFields/widgets/varPopup/VarMenu.tsx @@ -175,7 +175,7 @@ const VarMenu: React.FunctionComponent = ({ getPageState(inspectedTab, { namespace: StateNamespaces.MOD, modComponentId: null, - modId: activeModComponentFormState.recipe?.id, + modId: activeModComponentFormState.modMetadata?.id, }), [], ); diff --git a/src/components/fields/schemaFields/widgets/varPopup/VariablesTree.stories.tsx b/src/components/fields/schemaFields/widgets/varPopup/VariablesTree.stories.tsx index 417d2ea07e..7b30c1edf1 100644 --- a/src/components/fields/schemaFields/widgets/varPopup/VariablesTree.stories.tsx +++ b/src/components/fields/schemaFields/widgets/varPopup/VariablesTree.stories.tsx @@ -59,13 +59,13 @@ const knownVars = { }, }, }, - "extension.blockPipeline.0": { + "modComponent.brickPipeline.0": { "@data": {}, }, - "extension.blockPipeline.1": { + "modComponent.brickPipeline.1": { "@ifElseOutput": {}, }, - "extension.blockPipeline.2": { + "modComponent.brickPipeline.2": { "@forEachOutput": {}, }, }; diff --git a/src/components/fields/schemaFields/widgets/varPopup/getMenuOptions.test.ts b/src/components/fields/schemaFields/widgets/varPopup/getMenuOptions.test.ts index 2c2c3e451b..67b1d88b57 100644 --- a/src/components/fields/schemaFields/widgets/varPopup/getMenuOptions.test.ts +++ b/src/components/fields/schemaFields/widgets/varPopup/getMenuOptions.test.ts @@ -50,7 +50,7 @@ describe("setting values", () => { }); knownVars.setVariableExistence({ - source: "extension.blockPipeline.0", + source: "modComponent.brickPipeline.0", variableName: "@jq", existence: VarExistence.DEFINITELY, allowAnyChild: true, @@ -73,7 +73,7 @@ describe("setting values", () => { // Validate the order of the options expect(actual.map(([key]) => key)).toEqual([ "input:Array Composite Reader", - "extension.blockPipeline.0", + "modComponent.brickPipeline.0", ]); }); @@ -94,7 +94,7 @@ describe("setting values", () => { // Validate the order of the options expect(actual.map(([key]) => key)).toEqual([ "input:Array Composite Reader", - "extension.blockPipeline.0", + "modComponent.brickPipeline.0", ]); // Function getMenuOptions produces a mix of VarMap nodes and plain values from the trace @@ -182,7 +182,9 @@ describe("mod variables", () => { const extension = formStateFactory({}, [brickConfigFactory()]); await analysis.run(extension); - const knownVars = analysis.getKnownVars().get("extension.blockPipeline.0"); + const knownVars = analysis + .getKnownVars() + .get("modComponent.brickPipeline.0"); const actual = getMenuOptions(knownVars, null); expect(actual).toEqual([ diff --git a/src/components/form/ConnectedFieldTemplate.test.tsx b/src/components/form/ConnectedFieldTemplate.test.tsx index db2b5abfe2..f08ac2457e 100644 --- a/src/components/form/ConnectedFieldTemplate.test.tsx +++ b/src/components/form/ConnectedFieldTemplate.test.tsx @@ -98,7 +98,7 @@ describe("ConnectedFieldTemplate", () => { ), ); - const path = "extension.blockPipeline[0].config.testField"; + const path = "modComponent.brickPipeline[0].config.testField"; const analysisAnnotation: AnalysisAnnotation = { analysisId: "test", @@ -147,7 +147,7 @@ describe("ConnectedFieldTemplate", () => { ), ); - const path = "extension.blockPipeline[0].config.testField"; + const path = "modComponent.brickPipeline[0].config.testField"; const analysisAnnotation: AnalysisAnnotation = { analysisId: "test", @@ -168,8 +168,8 @@ describe("ConnectedFieldTemplate", () => { { initialValues: formState, initialErrors: { - extension: { - blockPipeline: [ + modComponent: { + brickPipeline: [ { config: { testField: "test formik error", @@ -212,7 +212,7 @@ describe("ConnectedFieldTemplate", () => { ), ); - const path = "extension.blockPipeline[0].config.testField"; + const path = "modComponent.brickPipeline[0].config.testField"; const analysisAnnotation1: AnalysisAnnotation = { analysisId: "test1", @@ -281,7 +281,7 @@ describe("ConnectedFieldTemplate", () => { ), ); - const path = "extension.blockPipeline[0].config.testField"; + const path = "modComponent.brickPipeline[0].config.testField"; const annotations: AnalysisAnnotation[] = [ // The annotation appears normally when detail matches the field value diff --git a/src/components/form/lockedLabel/LockedStarterBrickLabel.tsx b/src/components/form/lockedLabel/LockedStarterBrickLabel.tsx index 2e50d032fd..68fd891404 100644 --- a/src/components/form/lockedLabel/LockedStarterBrickLabel.tsx +++ b/src/components/form/lockedLabel/LockedStarterBrickLabel.tsx @@ -32,7 +32,7 @@ const LockedStarterBrickLabel: React.FC<{ label: string; message?: string; }> = ({ label, message }) => { - const [{ value: name }] = useField("extensionPoint.metadata.name"); + const [{ value: name }] = useField("starterBrick.metadata.name"); const defaultMessage = (

Provided by Starter Brick {name}. diff --git a/src/contentScript/pageEditor/runBrickPreview.ts b/src/contentScript/pageEditor/runBrickPreview.ts index 88d8b40509..0536bd54c8 100644 --- a/src/contentScript/pageEditor/runBrickPreview.ts +++ b/src/contentScript/pageEditor/runBrickPreview.ts @@ -73,7 +73,7 @@ export async function runBrickPreview({ // Handle non-document contexts. If the selector is unique, this gives the root that would be available at runtime. // Differences in behavior: // - For triggers, the PixieBrix looks for the closest ancestor to the DOM event target matching the selector - // See TriggerExtensionPoint.eventHandler for reference + // See TriggerStarterBrick.eventHandler for reference // - For multi-menus (not currently available in the Page Editor), the below logic returns an arbitrary menu const rootElement = $safeFind(rootSelector); if (rootElement.length > 0) { diff --git a/src/contrib/automationanywhere/BotOptions.test.tsx b/src/contrib/automationanywhere/BotOptions.test.tsx index ba05396bf1..d4653c9752 100644 --- a/src/contrib/automationanywhere/BotOptions.test.tsx +++ b/src/contrib/automationanywhere/BotOptions.test.tsx @@ -70,7 +70,7 @@ function makeBaseState() { function renderOptions(formState: ModComponentFormState = makeBaseState()) { return render( - + , ); } @@ -105,7 +105,7 @@ describe("BotOptions", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.service = toExpression( + base.modComponent.brickPipeline[0].config.service = toExpression( "var", "@automationAnywhere", ); @@ -136,7 +136,7 @@ describe("BotOptions", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.service = toExpression( + base.modComponent.brickPipeline[0].config.service = toExpression( "var", "@automationAnywhere", ); @@ -168,8 +168,8 @@ describe("BotOptions", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.workspaceType = "public"; - base.extension.blockPipeline[0].config.service = toExpression( + base.modComponent.brickPipeline[0].config.workspaceType = "public"; + base.modComponent.brickPipeline[0].config.service = toExpression( "var", "@automationAnywhere", ); @@ -201,9 +201,9 @@ describe("BotOptions", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.workspaceType = "public"; - base.extension.blockPipeline[0].config.isAttended = true; - base.extension.blockPipeline[0].config.service = toExpression( + base.modComponent.brickPipeline[0].config.workspaceType = "public"; + base.modComponent.brickPipeline[0].config.isAttended = true; + base.modComponent.brickPipeline[0].config.service = toExpression( "var", "@automationAnywhere", ); @@ -235,8 +235,8 @@ describe("BotOptions", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.awaitResult = true; - base.extension.blockPipeline[0].config.service = toExpression( + base.modComponent.brickPipeline[0].config.awaitResult = true; + base.modComponent.brickPipeline[0].config.service = toExpression( "var", "@automationAnywhere", ); diff --git a/src/contrib/automationanywhere/__snapshots__/BotOptions.test.tsx.snap b/src/contrib/automationanywhere/__snapshots__/BotOptions.test.tsx.snap index 906da13bdd..c5ba32b4b2 100644 --- a/src/contrib/automationanywhere/__snapshots__/BotOptions.test.tsx.snap +++ b/src/contrib/automationanywhere/__snapshots__/BotOptions.test.tsx.snap @@ -14,7 +14,7 @@ exports[`BotOptions should require selected integration 1`] = ` @@ -67,7 +67,7 @@ exports[`BotOptions should require selected integration 1`] = ` autocomplete="off" autocorrect="off" class="" - id="extension.blockPipeline.0.config.service" + id="modComponent.brickPipeline.0.config.service" role="combobox" spellcheck="false" style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;" @@ -103,7 +103,7 @@ exports[`BotOptions should require selected integration 1`] = ` diff --git a/src/contrib/uipath/LocalProcessOptions.test.tsx b/src/contrib/uipath/LocalProcessOptions.test.tsx index bab4d20297..516284abff 100644 --- a/src/contrib/uipath/LocalProcessOptions.test.tsx +++ b/src/contrib/uipath/LocalProcessOptions.test.tsx @@ -86,7 +86,10 @@ function makeBaseState() { function renderOptions(initialValues: ModComponentFormState = makeBaseState()) { return render( - , + , { initialValues }, ); } @@ -188,7 +191,7 @@ describe("UiPath LocalProcess Options", () => { const formState = makeBaseState(); formState.integrationDependencies[0].configId = configId; - formState.extension.blockPipeline[0].config.service = "@uipath"; + formState.modComponent.brickPipeline[0].config.service = "@uipath"; renderOptions(); diff --git a/src/contrib/uipath/ProcessOptions.test.tsx b/src/contrib/uipath/ProcessOptions.test.tsx index 84bed71977..b6af31e14d 100644 --- a/src/contrib/uipath/ProcessOptions.test.tsx +++ b/src/contrib/uipath/ProcessOptions.test.tsx @@ -90,7 +90,7 @@ function makeBaseState() { function renderOptions(formState: ModComponentFormState = makeBaseState()) { return render( - + , ); } @@ -125,7 +125,7 @@ describe("UiPath Options", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.uipath = toExpression( + base.modComponent.brickPipeline[0].config.uipath = toExpression( "var", "@uipath", ); @@ -173,11 +173,11 @@ describe("UiPath Options", () => { ); const base = makeBaseState(); - base.extension.blockPipeline[0].config.uipath = toExpression( + base.modComponent.brickPipeline[0].config.uipath = toExpression( "var", "@uipath", ); - base.extension.blockPipeline[0].config.awaitResult = true; + base.modComponent.brickPipeline[0].config.awaitResult = true; renderOptions(base); diff --git a/src/contrib/uipath/__snapshots__/ProcessOptions.test.tsx.snap b/src/contrib/uipath/__snapshots__/ProcessOptions.test.tsx.snap index 1a36f2304c..e612fbb179 100644 --- a/src/contrib/uipath/__snapshots__/ProcessOptions.test.tsx.snap +++ b/src/contrib/uipath/__snapshots__/ProcessOptions.test.tsx.snap @@ -14,7 +14,7 @@ exports[`UiPath Options Render integration selector 1`] = ` @@ -67,7 +67,7 @@ exports[`UiPath Options Render integration selector 1`] = ` autocomplete="off" autocorrect="off" class="" - id="extension.blockPipeline.0.config.uipath" + id="modComponent.brickPipeline.0.config.uipath" role="combobox" spellcheck="false" style="opacity: 1; width: 100%; grid-area: 1 / 2; min-width: 2px; border: 0px; margin: 0px; outline: 0; padding: 0px;" @@ -103,7 +103,7 @@ exports[`UiPath Options Render integration selector 1`] = ` diff --git a/src/integrations/components/RequireIntegrationConfig.test.tsx b/src/integrations/components/RequireIntegrationConfig.test.tsx index c0690f16f7..635ba9863d 100644 --- a/src/integrations/components/RequireIntegrationConfig.test.tsx +++ b/src/integrations/components/RequireIntegrationConfig.test.tsx @@ -120,7 +120,7 @@ describe("RequireIntegrationConfig", () => { render( {({ sanitizedConfig }) => ( @@ -178,7 +178,7 @@ describe("RequireIntegrationConfig", () => { render( {({ sanitizedConfig }) => ( @@ -253,7 +253,7 @@ describe("RequireIntegrationConfig", () => { render( {({ sanitizedConfig }) => ( @@ -306,7 +306,7 @@ describe("RequireIntegrationConfig", () => { render( {({ sanitizedConfig }) => ( diff --git a/src/pageEditor/analysisManager.ts b/src/pageEditor/analysisManager.ts index 7f6b6e86d4..709ead0532 100644 --- a/src/pageEditor/analysisManager.ts +++ b/src/pageEditor/analysisManager.ts @@ -61,17 +61,17 @@ async function selectActiveModFormStates( ): Promise { const activeModComponentFormState = selectActiveModComponentFormState(state); - if (activeModComponentFormState?.recipe) { + if (activeModComponentFormState?.modMetadata) { const dirtyModComponentFormStates = state.editor.modComponentFormStates.filter( - (x) => x.recipe?.id === activeModComponentFormState.recipe.id, + (x) => x.modMetadata?.id === activeModComponentFormState.modMetadata.id, ); const dirtyIds = new Set(dirtyModComponentFormStates.map((x) => x.uuid)); const activatedModComponents = selectActivatedModComponents(state); const otherModComponents = activatedModComponents.filter( (x) => - x._recipe?.id === activeModComponentFormState.recipe.id && + x._recipe?.id === activeModComponentFormState.modMetadata.id && !dirtyIds.has(x.id), ); const otherModComponentFormStates = await Promise.all( @@ -215,7 +215,7 @@ async function varAnalysisFactory( const modState = await getPageState(inspectedTab, { namespace: StateNamespaces.MOD, modComponentId: activeModComponentFormState.uuid, - modId: activeModComponentFormState.recipe?.id, + modId: activeModComponentFormState.modMetadata?.id, }); return new VarAnalysis({ diff --git a/src/pageEditor/baseFormStateTypes.ts b/src/pageEditor/baseFormStateTypes.ts index 58d03b0dc3..999acbec14 100644 --- a/src/pageEditor/baseFormStateTypes.ts +++ b/src/pageEditor/baseFormStateTypes.ts @@ -50,15 +50,30 @@ export type BaseStarterBrickState = { }; }; -export interface BaseModComponentState { +/** + * @deprecated - Do not use versioned state types directly + */ +export type BaseModComponentStateV1 = { blockPipeline: BrickPipeline; -} +}; + +/** + * @deprecated - Do not use versioned state types directly + */ +export type BaseModComponentStateV2 = Except< + BaseModComponentStateV1, + "blockPipeline" +> & { + brickPipeline: BrickPipeline; +}; + +export type BaseModComponentState = BaseModComponentStateV2; /** * @deprecated - Do not use versioned state types directly */ export interface BaseFormStateV1< - TModComponent extends BaseModComponentState = BaseModComponentState, + TModComponent extends BaseModComponentStateV1 = BaseModComponentStateV1, TStarterBrick extends BaseStarterBrickState = BaseStarterBrickState, > { /** @@ -130,7 +145,7 @@ export interface BaseFormStateV1< * @deprecated - Do not use versioned state types directly */ export type BaseFormStateV2< - TModComponent extends BaseModComponentState = BaseModComponentState, + TModComponent extends BaseModComponentStateV1 = BaseModComponentStateV1, TStarterBrick extends BaseStarterBrickState = BaseStarterBrickState, > = Except, "services"> & { /** @@ -142,11 +157,46 @@ export type BaseFormStateV2< integrationDependencies: IntegrationDependencyV2[]; }; +/** + * @deprecated - Do not use versioned state types directly + */ +export type BaseFormStateV3< + TModComponent extends BaseModComponentStateV2 = BaseModComponentStateV2, + TStarterBrick extends BaseStarterBrickState = BaseStarterBrickState, +> = Except< + BaseFormStateV2, + "recipe" | "extension" | "extensionPoint" +> & { + /** + * @since 2.0.5 + * Part of the Page Editor renaming effort + * `extensionPoint` to `starterBrick` + */ + starterBrick: TStarterBrick; + + /** + * @since 2.0.5 + * Part of the Page Editor renaming effort + * `extension` to `modComponent` + */ + modComponent: TModComponent; + + /** + * @since 2.0.5 + * Part of the Page Editor renaming effort + * `recipe` to `modMetadata` + * Information about the mod used to install the mod component, or `undefined` + * if the mod component is not part of a mod. + * @see ModComponentBase._recipe + */ + modMetadata: ModComponentBase["_recipe"] | undefined; +}; + export type BaseFormState< TModComponent extends BaseModComponentState = BaseModComponentState, TStarterBrick extends BaseStarterBrickState = BaseStarterBrickState, > = Except< - BaseFormStateV2, + BaseFormStateV3, "integrationDependencies" > & { /** diff --git a/src/pageEditor/consts.ts b/src/pageEditor/consts.ts index 0de7abeeba..8470f1cd81 100644 --- a/src/pageEditor/consts.ts +++ b/src/pageEditor/consts.ts @@ -15,4 +15,4 @@ * along with this program. If not, see . */ -export const PIPELINE_BLOCKS_FIELD_NAME = "extension.blockPipeline"; +export const PIPELINE_BRICKS_FIELD_NAME = "modComponent.brickPipeline"; diff --git a/src/pageEditor/documentBuilder/edit/DocumentOptions.test.tsx b/src/pageEditor/documentBuilder/edit/DocumentOptions.test.tsx index 50a89fb6d0..e0cf652eab 100644 --- a/src/pageEditor/documentBuilder/edit/DocumentOptions.test.tsx +++ b/src/pageEditor/documentBuilder/edit/DocumentOptions.test.tsx @@ -48,8 +48,8 @@ describe("DocumentOptions", () => { stylesheets: string[] = [], ): ModComponentFormState { return formStateFactory({ - extension: baseModComponentStateFactory({ - blockPipeline: [ + modComponent: baseModComponentStateFactory({ + brickPipeline: [ brickConfigFactory({ config: { body: documentElements, @@ -66,7 +66,10 @@ describe("DocumentOptions", () => { initialActiveElement: string = null, ) { return render( - , + , { initialValues: formState, setupRedux(dispatch) { @@ -74,7 +77,7 @@ describe("DocumentOptions", () => { dispatch(actions.setActiveModComponentId(formState.uuid)); dispatch( actions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); dispatch( @@ -182,8 +185,8 @@ describe("DocumentOptions", () => { // Form state for the test const formState = formStateFactory({ integrationDependencies, - extension: baseModComponentStateFactory({ - blockPipeline: [ + modComponent: baseModComponentStateFactory({ + brickPipeline: [ brickConfigFactory({ config: documentWithButtonConfig }), ], }), @@ -229,7 +232,7 @@ describe("DocumentOptions", () => { // The form state should be updated expect( - getFormState().extension.blockPipeline[0].config.stylesheets, + getFormState().modComponent.brickPipeline[0].config.stylesheets, ).toStrictEqual([ toExpression("nunjucks", "https://example.com/stylesheet.css"), ]); diff --git a/src/pageEditor/documentBuilder/preview/DocumentPreview.test.tsx b/src/pageEditor/documentBuilder/preview/DocumentPreview.test.tsx index 6896298792..8943389539 100644 --- a/src/pageEditor/documentBuilder/preview/DocumentPreview.test.tsx +++ b/src/pageEditor/documentBuilder/preview/DocumentPreview.test.tsx @@ -52,7 +52,7 @@ function renderDocumentPreview(documentBuilderElement: DocumentBuilderElement) { const [activeElement, setActiveElement] = useState(null); return ( @@ -66,7 +66,7 @@ function renderDocumentPreview(documentBuilderElement: DocumentBuilderElement) { dispatch(actions.setActiveModComponentId(formState.uuid)); dispatch( actions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); }, @@ -176,14 +176,14 @@ describe("Show live preview", () => { const [activeElement, setActiveElement] = useState(null); return ( ); }; - const pipelineField = formState.extension.blockPipeline[0].config + const pipelineField = formState.modComponent.brickPipeline[0].config .body as PipelineExpression; return render(, { diff --git a/src/pageEditor/documentBuilder/preview/ElementPreview.test.tsx b/src/pageEditor/documentBuilder/preview/ElementPreview.test.tsx index 4376cef02f..b5d1254355 100644 --- a/src/pageEditor/documentBuilder/preview/ElementPreview.test.tsx +++ b/src/pageEditor/documentBuilder/preview/ElementPreview.test.tsx @@ -57,8 +57,8 @@ const renderElementPreview = ( }; const formState = formStateFactory({ - extension: baseModComponentStateFactory({ - blockPipeline: [ + modComponent: baseModComponentStateFactory({ + brickPipeline: [ brickConfigFactory({ config: { body: [element], @@ -75,7 +75,7 @@ const renderElementPreview = ( dispatch(actions.setActiveModComponentId(formState.uuid)); dispatch( actions.setActiveNodeId( - formState.extension.blockPipeline[0].instanceId, + formState.modComponent.brickPipeline[0].instanceId, ), ); dispatch(actions.setActiveBuilderPreviewElement("0")); diff --git a/src/pageEditor/fields/FormModalOptions.test.tsx b/src/pageEditor/fields/FormModalOptions.test.tsx index a4efe18b4e..10b709331c 100644 --- a/src/pageEditor/fields/FormModalOptions.test.tsx +++ b/src/pageEditor/fields/FormModalOptions.test.tsx @@ -37,13 +37,16 @@ describe("FormModalOptions", () => { const brick = createNewConfiguredBrick(FormTransformer.BRICK_ID); const initialValues = formStateFactory({ - extension: baseModComponentStateFactory({ - blockPipeline: [brick], + modComponent: baseModComponentStateFactory({ + brickPipeline: [brick], }), }); render( - , + , { initialValues, setupRedux(dispatch) { diff --git a/src/pageEditor/fields/FormRendererOptions.test.tsx b/src/pageEditor/fields/FormRendererOptions.test.tsx index 7f2df0d73c..670cbe0f8e 100644 --- a/src/pageEditor/fields/FormRendererOptions.test.tsx +++ b/src/pageEditor/fields/FormRendererOptions.test.tsx @@ -40,7 +40,7 @@ describe("FormRendererOptions", () => { render( , { @@ -65,7 +65,7 @@ describe("FormRendererOptions", () => { render( , { @@ -98,7 +98,7 @@ describe("FormRendererOptions", () => { render( , { diff --git a/src/pageEditor/hooks/useBuildAndValidateMod.test.ts b/src/pageEditor/hooks/useBuildAndValidateMod.test.ts index 6b550ca73b..c39685e655 100644 --- a/src/pageEditor/hooks/useBuildAndValidateMod.test.ts +++ b/src/pageEditor/hooks/useBuildAndValidateMod.test.ts @@ -180,7 +180,7 @@ describe("useBuildAndValidateMod", () => { }); const dirtyFormState1 = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result, getReduxStore } = renderHook( diff --git a/src/pageEditor/hooks/useCheckModStarterBrickInvariants.test.ts b/src/pageEditor/hooks/useCheckModStarterBrickInvariants.test.ts index 53c4fceeab..c7f91cd519 100644 --- a/src/pageEditor/hooks/useCheckModStarterBrickInvariants.test.ts +++ b/src/pageEditor/hooks/useCheckModStarterBrickInvariants.test.ts @@ -301,7 +301,7 @@ describe("useCheckModStarterBrickInvariants", () => { integrationDependencies: [], }); const formState = await modComponentToFormState(activatedModComponent); - delete formState.recipe; + delete formState.modMetadata; const { result } = renderHook(() => useCheckModStarterBrickInvariants(), { setupRedux(dispatch) { diff --git a/src/pageEditor/hooks/useCheckModStarterBrickInvariants.ts b/src/pageEditor/hooks/useCheckModStarterBrickInvariants.ts index 28ef42c6e9..3c4d0530c7 100644 --- a/src/pageEditor/hooks/useCheckModStarterBrickInvariants.ts +++ b/src/pageEditor/hooks/useCheckModStarterBrickInvariants.ts @@ -53,7 +53,7 @@ function useCheckModStarterBrickInvariants(): ( * - For each clean mod component, every entry in definitions should exist * in the {modDefinition.definitions} object * - For each dirty mod component with @internal starter brick definition, - * formState.extensionPoint.definition should exist in the + * formState.starterBrick.definition should exist in the * {modDefinition.definitions} object, but the key may be different, * e.g. "extensionPoint" vs. "extensionPoint3" in the modDefinition, * also need to run it through the adapter because of some cleanup logic @@ -80,9 +80,7 @@ function useCheckModStarterBrickInvariants(): ( } for (const formState of dirtyModComponentFormStates) { - if ( - !isInnerDefinitionRegistryId(formState.extensionPoint.metadata.id) - ) { + if (!isInnerDefinitionRegistryId(formState.starterBrick.metadata.id)) { continue; } diff --git a/src/pageEditor/hooks/useCompareModComponentCounts.test.ts b/src/pageEditor/hooks/useCompareModComponentCounts.test.ts index 2b9b505e1d..4db7e8af58 100644 --- a/src/pageEditor/hooks/useCompareModComponentCounts.test.ts +++ b/src/pageEditor/hooks/useCompareModComponentCounts.test.ts @@ -51,7 +51,7 @@ describe("useCompareModComponentCounts", () => { metadata: modMetadata, }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -95,7 +95,7 @@ describe("useCompareModComponentCounts", () => { }); const dirtyFormState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -130,10 +130,10 @@ describe("useCompareModComponentCounts", () => { }); const dirtyFormState1 = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const dirtyFormState2 = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -163,7 +163,7 @@ describe("useCompareModComponentCounts", () => { metadata: modMetadata, }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -193,7 +193,7 @@ describe("useCompareModComponentCounts", () => { }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -282,7 +282,7 @@ describe("useCompareModComponentCounts", () => { }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -313,7 +313,7 @@ describe("useCompareModComponentCounts", () => { }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -344,7 +344,7 @@ describe("useCompareModComponentCounts", () => { }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { @@ -375,7 +375,7 @@ describe("useCompareModComponentCounts", () => { }); const formState = formStateFactory({ - recipe: modMetadata, + modMetadata, }); const { result } = renderHook(() => useCompareModComponentCounts(), { diff --git a/src/pageEditor/hooks/useCreateModFromModComponent.test.ts b/src/pageEditor/hooks/useCreateModFromModComponent.test.ts index ba8c67fd27..19e2b97e69 100644 --- a/src/pageEditor/hooks/useCreateModFromModComponent.test.ts +++ b/src/pageEditor/hooks/useCreateModFromModComponent.test.ts @@ -48,7 +48,9 @@ describe("useCreateModFromModComponent", () => { it("saves with no dirty changes", async () => { const metadata = modMetadataFactory(); - const menuItemFormState = menuItemFormStateFactory({ recipe: metadata }); + const menuItemFormState = menuItemFormStateFactory({ + modMetadata: metadata, + }); appApiMock .onPost("/api/bricks/") @@ -75,7 +77,9 @@ describe("useCreateModFromModComponent", () => { it("does not throw an error if the mod fails the compareModComponentCounts check", async () => { compareModComponentCountsMock.mockReturnValue(() => false); const metadata = modMetadataFactory(); - const menuItemFormState = menuItemFormStateFactory({ recipe: metadata }); + const menuItemFormState = menuItemFormStateFactory({ + modMetadata: metadata, + }); appApiMock .onPost("/api/bricks/") @@ -95,7 +99,9 @@ describe("useCreateModFromModComponent", () => { it("does not throw an error if the mod fails the checkModStarterBrickInvariants check", async () => { checkModStarterBrickInvariantsMock.mockReturnValue(async () => false); const metadata = modMetadataFactory(); - const menuItemFormState = menuItemFormStateFactory({ recipe: metadata }); + const menuItemFormState = menuItemFormStateFactory({ + modMetadata: metadata, + }); appApiMock .onPost("/api/bricks/") diff --git a/src/pageEditor/hooks/useCreateModFromModComponent.ts b/src/pageEditor/hooks/useCreateModFromModComponent.ts index 42ebfc8f11..3604dfce8a 100644 --- a/src/pageEditor/hooks/useCreateModFromModComponent.ts +++ b/src/pageEditor/hooks/useCreateModFromModComponent.ts @@ -84,7 +84,10 @@ function useCreateModFromModComponent( }).unwrap(); const newModComponent = produce(newModComponentFormState, (draft) => { - draft.recipe = selectModMetadata(newModDefinition, upsertResponse); + draft.modMetadata = selectModMetadata( + newModDefinition, + upsertResponse, + ); }); dispatch(editorActions.addModComponentFormState(newModComponent)); diff --git a/src/pageEditor/hooks/useResetMod.ts b/src/pageEditor/hooks/useResetMod.ts index 9eb7e3976b..4f15db8ae4 100644 --- a/src/pageEditor/hooks/useResetMod.ts +++ b/src/pageEditor/hooks/useResetMod.ts @@ -45,7 +45,7 @@ function useResetMod(): (modId: RegistryId) => Promise { modComponentFormStates .filter( (modComponentFormState) => - modComponentFormState.recipe?.id === modId, + modComponentFormState.modMetadata?.id === modId, ) .map(async (modComponentFormState) => resetModComponent({ diff --git a/src/pageEditor/hooks/useUpsertModComponentFormState.test.ts b/src/pageEditor/hooks/useUpsertModComponentFormState.test.ts index 63d9fd90df..f20aa07369 100644 --- a/src/pageEditor/hooks/useUpsertModComponentFormState.test.ts +++ b/src/pageEditor/hooks/useUpsertModComponentFormState.test.ts @@ -69,7 +69,7 @@ describe("useUpsertModComponentFormState", () => { expect(modComponents[0]).toEqual( expect.objectContaining({ id: modComponentFormState.uuid, - extensionPointId: modComponentFormState.extensionPoint.metadata.id, + extensionPointId: modComponentFormState.starterBrick.metadata.id, updateTimestamp: expectedUpdateDate.toISOString(), }), ); @@ -95,7 +95,7 @@ describe("useUpsertModComponentFormState", () => { const expectedFields = { id: modComponentFormState.uuid, - extensionPointId: modComponentFormState.extensionPoint.metadata.id, + extensionPointId: modComponentFormState.starterBrick.metadata.id, updateTimestamp: expectedUpdateDate.toISOString(), }; diff --git a/src/pageEditor/hooks/useUpsertModComponentFormState.ts b/src/pageEditor/hooks/useUpsertModComponentFormState.ts index d011874c4d..a6ad9db16a 100644 --- a/src/pageEditor/hooks/useUpsertModComponentFormState.ts +++ b/src/pageEditor/hooks/useUpsertModComponentFormState.ts @@ -148,7 +148,7 @@ function useUpsertModComponentFormState(): SaveCallback { `No adapter found for ${modComponentFormState.type}`, ); - const starterBrickId = modComponentFormState.extensionPoint.metadata.id; + const starterBrickId = modComponentFormState.starterBrick.metadata.id; const hasInnerStarterBrick = isInnerDefinitionRegistryId(starterBrickId); let isEditable = false; diff --git a/src/pageEditor/modals/addBrickModal/AddBrickModal.test.tsx b/src/pageEditor/modals/addBrickModal/AddBrickModal.test.tsx index 58b0f91f6c..5977061fcc 100644 --- a/src/pageEditor/modals/addBrickModal/AddBrickModal.test.tsx +++ b/src/pageEditor/modals/addBrickModal/AddBrickModal.test.tsx @@ -20,7 +20,7 @@ import { render, screen } from "@/pageEditor/testHelpers"; import AddBrickModal from "@/pageEditor/modals/addBrickModal/AddBrickModal"; import { actions } from "@/pageEditor/slices/editorSlice"; import userEvent from "@testing-library/user-event"; -import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts"; +import { PIPELINE_BRICKS_FIELD_NAME } from "@/pageEditor/consts"; import { array } from "cooky-cutter"; import { waitForEffect } from "@/testUtils/testHelpers"; import bricksRegistry from "@/bricks/registry"; @@ -80,7 +80,7 @@ describe("AddBrickModal", () => { dispatch(actions.setActiveModComponentId(formState.uuid)); dispatch( actions.showAddBlockModal({ - path: PIPELINE_BLOCKS_FIELD_NAME, + path: PIPELINE_BRICKS_FIELD_NAME, flavor: PipelineFlavor.AllBricks, index: 0, }), diff --git a/src/pageEditor/pageEditorTypes.ts b/src/pageEditor/pageEditorTypes.ts index f049b6fec9..43138009ac 100644 --- a/src/pageEditor/pageEditorTypes.ts +++ b/src/pageEditor/pageEditorTypes.ts @@ -36,6 +36,7 @@ import { type SessionRootState } from "@/pageEditor/slices/sessionSliceTypes"; import { type ModOptionsDefinition } from "@/types/modDefinitionTypes"; import { type Except } from "type-fest"; import { + type BaseFormStateV3, type BaseFormStateV1, type BaseFormStateV2, } from "@/pageEditor/baseFormStateTypes"; @@ -271,7 +272,7 @@ export type EditorStateV3 = Except< * When a mod component is selected in the Page Editor, a mod component form state is created for it and stored here; * that is, "touched" mod component form states. */ - readonly modComponentFormStates: ModComponentFormState[]; + readonly modComponentFormStates: BaseFormStateV2[]; /** * Brick ids (not UUIDs) that the user has access to edit @@ -317,10 +318,7 @@ export type EditorStateV3 = Except< /** * Unsaved mod components that have been deleted from a mod */ - deletedModComponentFormStatesByModId: Record< - RegistryId, - ModComponentFormState[] - >; + deletedModComponentFormStatesByModId: Record; /** * The available activated mod components for the current tab @@ -343,7 +341,24 @@ export type EditorStateV3 = Except< isPendingDraftModComponents: boolean; }; -export type EditorState = EditorStateV3; +/** + * @deprecated - Do not use versioned state types directly, exported for testing + */ +export type EditorStateV4 = Except< + EditorStateV3, + "modComponentFormStates" | "deletedModComponentFormStatesByModId" +> & { + modComponentFormStates: BaseFormStateV3[]; + deletedModComponentFormStatesByModId: Record; +}; + +export type EditorState = Except< + EditorStateV4, + "modComponentFormStates" | "deletedModComponentFormStatesByModId" +> & { + modComponentFormStates: ModComponentFormState[]; + deletedModComponentFormStatesByModId: Record; +}; export type EditorRootState = { editor: EditorState; diff --git a/src/pageEditor/panes/EditorPane.test.tsx b/src/pageEditor/panes/EditorPane.test.tsx index 1d47f0af89..a610fde03a 100644 --- a/src/pageEditor/panes/EditorPane.test.tsx +++ b/src/pageEditor/panes/EditorPane.test.tsx @@ -38,7 +38,7 @@ import AddBrickModal from "@/pageEditor/modals/addBrickModal/AddBrickModal"; import { type EditablePackageMetadata } from "@/types/contract"; import { fireTextInput } from "@/testUtils/formHelpers"; import MarkdownRenderer from "@/bricks/renderers/MarkdownRenderer"; -import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts"; +import { PIPELINE_BRICKS_FIELD_NAME } from "@/pageEditor/consts"; import getType from "@/runtime/getType"; import { type ModComponentFormState } from "@/pageEditor/starterBricks/formStateTypes"; import { MULTIPLE_RENDERERS_ERROR_MESSAGE } from "@/analysis/analysisVisitors/renderersAnalysis"; @@ -205,7 +205,7 @@ describe("renders", () => { test("the first selected node", async () => { const formState = getPlainFormState(); - const { instanceId } = formState.extension.blockPipeline[0]; + const { instanceId } = formState.modComponent.brickPipeline[0]; const { asFragment } = render(, { setupRedux(dispatch) { dispatch(editorActions.addModComponentFormState(formState)); @@ -343,7 +343,7 @@ describe("can add a node", () => { const activeModComponentFormState = selectActiveModComponentFormState(reduxState); const jqNodeId = ( - activeModComponentFormState.extension.blockPipeline[1].config + activeModComponentFormState.modComponent.brickPipeline[1].config .body as PipelineExpression ).__value__[0].instanceId; const addButtonInSubPipeline = screen.getByTestId( @@ -366,7 +366,7 @@ describe("can add a node", () => { async function renderEditorPaneWithBasicFormState() { const modComponentFormState = getFormStateWithSubPipelines(); const activeNodeId = - modComponentFormState.extension.blockPipeline[0].instanceId; + modComponentFormState.modComponent.brickPipeline[0].instanceId; const utils = render(

@@ -620,7 +620,7 @@ describe("validation", () => { test("validates string templates", async () => { const formState = getFormStateWithSubPipelines(); const subEchoNode = ( - formState.extension.blockPipeline[1].config.body as PipelineExpression + formState.modComponent.brickPipeline[1].config.body as PipelineExpression ).__value__[0]; const { container } = render(, { setupRedux(dispatch) { @@ -658,7 +658,7 @@ describe("validation", () => { // Selecting the Echo brick in the first mod component const { instanceId: echoBlockInstanceId } = - modComponent1.extension.blockPipeline[0]; + modComponent1.modComponent.brickPipeline[0]; const { container, getReduxStore } = render( <> @@ -744,7 +744,7 @@ describe("validation", () => { test("validates multiple renderers on add", async () => { const formState = getPlainFormState(); - formState.extension.blockPipeline.push( + formState.modComponent.brickPipeline.push( brickConfigFactory({ id: MarkdownRenderer.BRICK_ID, config: { @@ -781,7 +781,7 @@ describe("validation", () => { test("validates that renderer is the last node on move", async () => { const formState = getPlainFormState(); - formState.extension.blockPipeline.push( + formState.modComponent.brickPipeline.push( brickConfigFactory({ id: MarkdownRenderer.BRICK_ID, config: { @@ -791,7 +791,7 @@ describe("validation", () => { ); // Selecting the last node (renderer) - const { instanceId } = formState.extension.blockPipeline[2]; + const { instanceId } = formState.modComponent.brickPipeline[2]; const { container } = render(, { setupRedux(dispatch) { dispatch(editorActions.addModComponentFormState(formState)); @@ -843,7 +843,7 @@ describe("validation", () => { dispatch( editorActions.addNode({ block: disallowedBlockConfig, - pipelinePath: PIPELINE_BLOCKS_FIELD_NAME, + pipelinePath: PIPELINE_BRICKS_FIELD_NAME, pipelineIndex: 0, }), ); diff --git a/src/pageEditor/panes/EditorPane.tsx b/src/pageEditor/panes/EditorPane.tsx index dc3289ea94..e9485e02a3 100644 --- a/src/pageEditor/panes/EditorPane.tsx +++ b/src/pageEditor/panes/EditorPane.tsx @@ -58,12 +58,12 @@ const EditorPaneContent: React.VoidFunctionComponent<{ useEffect(() => { const messageContext = { extensionId: modComponentFormState.uuid, - blueprintId: modComponentFormState.recipe - ? modComponentFormState.recipe.id + blueprintId: modComponentFormState.modMetadata + ? modComponentFormState.modMetadata.id : undefined, }; dispatch(logActions.setContext(messageContext)); - }, [modComponentFormState.uuid, modComponentFormState.recipe, dispatch]); + }, [modComponentFormState.uuid, modComponentFormState.modMetadata, dispatch]); return ( diff --git a/src/pageEditor/panes/__snapshots__/EditorPane.test.tsx.snap b/src/pageEditor/panes/__snapshots__/EditorPane.test.tsx.snap index ba63fd2378..92baea7069 100644 --- a/src/pageEditor/panes/__snapshots__/EditorPane.test.tsx.snap +++ b/src/pageEditor/panes/__snapshots__/EditorPane.test.tsx.snap @@ -607,7 +607,7 @@ exports[`renders a mod component with sub pipeline 1`] = `
@@ -616,8 +616,8 @@ exports[`renders a mod component with sub pipeline 1`] = ` >