Skip to content

Commit

Permalink
Rename block to brick in some file/methods/type names (#8666)
Browse files Browse the repository at this point in the history
  • Loading branch information
twschiller authored Jun 21, 2024
1 parent 51e1450 commit 59caadc
Show file tree
Hide file tree
Showing 40 changed files with 205 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import { castArray } from "lodash";
*
* Typically, should be called as BlockIdVisitor.collectBlockIds
*
* @see BlockIdVisitor.collectBlockIds
* @see BrickIdVisitor.collectBrickIds
*/
class BlockIdVisitor extends PipelineVisitor {
readonly _blockIds = new Set<RegistryId>();
class BrickIdVisitor extends PipelineVisitor {
readonly _brickIds = new Set<RegistryId>();

get blockIds(): Set<RegistryId> {
return new Set(this._blockIds);
get brickIds(): Set<RegistryId> {
return new Set(this._brickIds);
}

override visitBrick(
Expand All @@ -42,16 +42,16 @@ class BlockIdVisitor extends PipelineVisitor {
extra: VisitBlockExtra,
): void {
super.visitBrick(position, blockConfig, extra);
this._blockIds.add(blockConfig.id);
this._brickIds.add(blockConfig.id);
}

public static collectBlockIds(
public static collectBrickIds(
pipeline: BrickConfig | BrickConfig[],
): Set<RegistryId> {
const visitor = new BlockIdVisitor();
const visitor = new BrickIdVisitor();
visitor.visitRootPipeline(castArray(pipeline));
return visitor.blockIds;
return visitor.brickIds;
}
}

export default BlockIdVisitor;
export default BrickIdVisitor;
4 changes: 2 additions & 2 deletions src/analysis/analysisVisitors/brickTypeAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import { AnalysisVisitorWithResolvedBricksABC } from "./baseAnalysisVisitors";
import { type BrickConfig, type BrickPosition } from "@/bricks/types";
import { type VisitBlockExtra } from "@/bricks/PipelineVisitor";
import { makeIsBlockAllowedForPipeline } from "@/bricks/blockFilterHelpers";
import { makeIsBrickAllowedForPipeline } from "@/bricks/brickFilterHelpers";
import { AnnotationType } from "@/types/annotationTypes";
import TourStepTransformer from "@/bricks/transformers/tourStep/tourStep";
import { TourEffect } from "@/bricks/effects/tourEffect";
Expand All @@ -40,7 +40,7 @@ class BrickTypeAnalysis extends AnalysisVisitorWithResolvedBricksABC {
return;
}

const isBlockAllowed = makeIsBlockAllowedForPipeline(extra.pipelineFlavor)(
const isBlockAllowed = makeIsBrickAllowedForPipeline(extra.pipelineFlavor)(
typedBlock,
);

Expand Down
4 changes: 2 additions & 2 deletions src/background/deploymentUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import { type EditorState } from "@/pageEditor/pageEditorTypes";
import { editorSlice } from "@/pageEditor/slices/editorSlice";
import { removeExtensionForEveryTab } from "@/background/removeExtensionForEveryTab";
import registerBuiltinBricks from "@/bricks/registerBuiltinBricks";
import registerContribBlocks from "@/contrib/registerContribBlocks";
import registerContribBricks from "@/contrib/registerContribBricks";
import { launchSsoFlow } from "@/store/enterprise/singleSignOn";
import { readManagedStorage } from "@/store/enterprise/managedStorage";
import { type UUID } from "@/types/stringTypes";
Expand Down Expand Up @@ -708,7 +708,7 @@ async function hideUpdatePromptUntilNextAvailableUpdate() {
function initDeploymentUpdater(): void {
// Need to load the built-in bricks for permissions checks to work on initial startup
registerBuiltinBricks();
registerContribBlocks();
registerContribBricks();

setInterval(syncDeployments, UPDATE_INTERVAL_MS);
void hideUpdatePromptUntilNextAvailableUpdate();
Expand Down
2 changes: 1 addition & 1 deletion src/bricks/PipelineVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { get } from "lodash";
import {
getRootPipelineFlavor,
getSubPipelineFlavor,
} from "@/bricks/blockFilterHelpers";
} from "@/bricks/brickFilterHelpers";
import { type StarterBrickType } from "@/types/starterBrickTypes";
import { PIPELINE_BLOCKS_FIELD_NAME } from "@/pageEditor/consts";
import { isPipelineExpression } from "@/utils/expressionUtils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ const ALWAYS_SHOW = new Set([
CommentEffect.BRICK_ID,
]);

export type IsBlockAllowedPredicate = (block: TypedBrickPair) => boolean;
export type IsBrickAllowedPredicate = (block: TypedBrickPair) => boolean;

export function getRootPipelineFlavor(extensionPointType: StarterBrickType) {
if (PANEL_TYPES.includes(extensionPointType)) {
export function getRootPipelineFlavor(starterBrickType: StarterBrickType) {
if (PANEL_TYPES.includes(starterBrickType)) {
return PipelineFlavor.NoEffect;
}

Expand Down Expand Up @@ -79,9 +79,9 @@ export function getSubPipelineFlavor(
return PipelineFlavor.NoRenderer;
}

export function makeIsBlockAllowedForPipeline(
export function makeIsBrickAllowedForPipeline(
pipelineFlavor: PipelineFlavor,
): IsBlockAllowedPredicate {
): IsBrickAllowedPredicate {
if (pipelineFlavor === PipelineFlavor.AllBricks) {
return stubTrue;
}
Expand Down
4 changes: 2 additions & 2 deletions src/bricks/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import pipelineSchema from "@schemas/pipeline.json";
import { type RegistryId } from "@/types/registryTypes";
import { type Schema } from "@/types/schemaTypes";
import { type Brick } from "@/types/brickTypes";
import BlockIdVisitor from "@/analysis/analysisVisitors/blockIdVisitor";
import BrickIdVisitor from "@/analysis/analysisVisitors/brickIdVisitor";
import { removeUndefined } from "@/utils/objectUtils";
import { toExpression } from "@/utils/expressionUtils";

Expand Down Expand Up @@ -79,6 +79,6 @@ export function defaultBrickConfig(schema: Schema): BrickConfig["config"] {
export async function collectAllBricks(
config: BrickConfig | BrickPipeline,
): Promise<Brick[]> {
const ids = BlockIdVisitor.collectBlockIds(config);
const ids = BrickIdVisitor.collectBrickIds(config);
return Promise.all([...ids].map(async (id) => brickRegistry.lookup(id)));
}
2 changes: 1 addition & 1 deletion src/components/brickModalNoTags/BrickResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { Button, ListGroup } from "react-bootstrap";
import cx from "classnames";
// TODO: Refactor to properly share styles across components (e.g. full component inheritance);
// the "brickEditor/referenceTab/BlockResult" component probably doesn't expect to also affect a global component
import styles from "@/extensionConsole/pages/brickEditor/referenceTab/BlockResult.module.scss";
import styles from "@/extensionConsole/pages/brickEditor/referenceTab/BrickResult.module.scss";
import BrickIcon from "@/components/BrickIcon";
import { OfficialBadge } from "@/components/OfficialBadge";
import { type Metadata } from "@/types/registryTypes";
Expand Down
4 changes: 2 additions & 2 deletions src/contentScript/contentScriptCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { initMessengerLogging } from "@/development/messengerLogging";
import registerExternalMessenger from "@/background/messenger/external/registration";
import registerMessenger from "@/contentScript/messenger/registration";
import registerBuiltinBricks from "@/bricks/registerBuiltinBricks";
import registerContribBlocks from "@/contrib/registerContribBlocks";
import registerContribBricks from "@/contrib/registerContribBricks";
import brickRegistry from "@/bricks/registry";
import { initNavigation } from "@/contentScript/lifecycle";
import { initTelemetry } from "@/background/messenger/api";
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function init(): Promise<void> {
registerMessenger();
registerExternalMessenger();
registerBuiltinBricks();
registerContribBlocks();
registerContribBricks();
markDocumentAsFocusableByUser();
// Since 1.8.2, the brick registry was de-coupled from the runtime to avoid circular dependencies
// Since 1.8.10, we inject the platform into the runtime
Expand Down
2 changes: 1 addition & 1 deletion src/contentScript/messenger/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const showLoginBanner = getMethod("SHOW_LOGIN_BANNER");
export const runBlock = getMethod("RUN_SINGLE_BLOCK");
export const runBrick = getMethod("RUN_BRICK");
export const runHeadlessPipeline = getMethod("RUN_HEADLESS_PIPELINE");
export const runRendererBlock = getMethod("RUN_RENDERER_BLOCK");
export const runRendererBrick = getMethod("RUN_RENDERER_BRICK");
export const runRendererPipeline = getMethod("RUN_RENDERER_PIPELINE");
export const runExtensionPointReader = getMethod("RUN_EXTENSION_POINT_READER");
export const ensureExtensionPointsInstalled = getMethod(
Expand Down
12 changes: 6 additions & 6 deletions src/contentScript/messenger/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ import {
import { runMapArgs } from "@/contentScript/pipelineProtocol/runMapArgs";
import { getCopilotHostData } from "@/contrib/automationanywhere/SetCopilotDataEffect";
import { showBannerFromConfig } from "@/contentScript/integrations/deferredLoginController";
import { runBlockPreview } from "@/contentScript/pageEditor/runBlockPreview";
import { runBrickPreview } from "@/contentScript/pageEditor/runBrickPreview";
import { runBrick } from "@/contentScript/executor";
import { runHeadlessPipeline } from "@/contentScript/pipelineProtocol/runHeadlessPipeline";
import { runRendererBlock } from "@/contentScript/pageEditor/runRendererBlock";
import { runRendererBrick } from "@/contentScript/pageEditor/runRendererBrick";
import { runRendererPipeline } from "@/contentScript/pipelineProtocol/runRendererPipeline";
import { runStarterBrickReader } from "@/contentScript/pageEditor/draft/runStarterBrickReader";
import {
Expand Down Expand Up @@ -112,10 +112,10 @@ declare global {
RUN_MAP_ARGS: typeof runMapArgs;
GET_COPILOT_HOST_DATA: typeof getCopilotHostData;
SHOW_LOGIN_BANNER: typeof showBannerFromConfig;
RUN_SINGLE_BLOCK: typeof runBlockPreview;
RUN_SINGLE_BLOCK: typeof runBrickPreview;
RUN_BRICK: typeof runBrick;
RUN_HEADLESS_PIPELINE: typeof runHeadlessPipeline;
RUN_RENDERER_BLOCK: typeof runRendererBlock;
RUN_RENDERER_BRICK: typeof runRendererBrick;
RUN_RENDERER_PIPELINE: typeof runRendererPipeline;
RUN_EXTENSION_POINT_READER: typeof runStarterBrickReader;
QUEUE_REACTIVATE_TAB: typeof queueReactivateTab;
Expand Down Expand Up @@ -166,10 +166,10 @@ export default function registerMessenger(): void {
RUN_MAP_ARGS: runMapArgs,
GET_COPILOT_HOST_DATA: getCopilotHostData,
SHOW_LOGIN_BANNER: showBannerFromConfig,
RUN_SINGLE_BLOCK: runBlockPreview,
RUN_SINGLE_BLOCK: runBrickPreview,
RUN_BRICK: runBrick,
RUN_HEADLESS_PIPELINE: runHeadlessPipeline,
RUN_RENDERER_BLOCK: runRendererBlock,
RUN_RENDERER_BRICK: runRendererBrick,
RUN_RENDERER_PIPELINE: runRendererPipeline,
RUN_EXTENSION_POINT_READER: runStarterBrickReader,
QUEUE_REACTIVATE_TAB: queueReactivateTab,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

import {
blockReducer,
brickReducer,
type IntermediateState,
type ReduceOptions,
} from "@/runtime/reducePipeline";
Expand All @@ -28,20 +28,20 @@ import extendModVariableContext from "@/runtime/extendModVariableContext";
import { $safeFind } from "@/utils/domUtils";
import { BusinessError } from "@/errors/businessErrors";
import { type RegistryId } from "@/types/registryTypes";
import { type RunBlockArgs } from "@/contentScript/pageEditor/types";
import { type RunBrickArgs } from "@/contentScript/pageEditor/types";
import { type Nullishable } from "@/utils/nullishUtils";

/**
* Run a single block (e.g., for generating output previews)
* @see BlockPreview
* Run a single brick (e.g., for generating output previews)
* @see BrickPreview
*/
export async function runBlockPreview({
export async function runBrickPreview({
blockConfig,
context,
apiVersion,
blueprintId,
rootSelector,
}: RunBlockArgs & {
}: RunBrickArgs & {
blueprintId: Nullishable<RegistryId>;
}): Promise<unknown> {
const versionOptions = apiVersionOptions(apiVersion);
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function runBlockPreview({

// Exclude the outputKey so that `output` is the output of the brick. Alternatively we could have taken then
// value from the context[outputKey] from the return value of blockReducer
const { output } = await blockReducer(
const { output } = await brickReducer(
{ ...blockConfig, outputKey: undefined },
state,
options,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import { type UUID } from "@/types/stringTypes";
import { type RegistryId } from "@/types/registryTypes";
import { createFrameSource } from "@/contentScript/ephemeralPanel";
import { showModal } from "@/contentScript/modalDom";
import { runBlockPreview } from "@/contentScript/pageEditor/runBlockPreview";
import { type RunBlockArgs } from "@/contentScript/pageEditor/types";
import { runBrickPreview } from "@/contentScript/pageEditor/runBrickPreview";
import { type RunBrickArgs } from "@/contentScript/pageEditor/types";

type Location = "modal" | "panel";

Expand All @@ -46,7 +46,7 @@ type Location = "modal" | "panel";
* Note: Currently only implemented for the temporary sidebar panels
* @see useDocumentPreviewRunBlock
*/
export async function runRendererBlock({
export async function runRendererBrick({
extensionId,
blueprintId,
runId,
Expand All @@ -58,14 +58,14 @@ export async function runRendererBlock({
blueprintId: RegistryId | null;
runId: UUID;
title: string;
args: RunBlockArgs;
args: RunBrickArgs;
location: Location;
}): Promise<void> {
const nonce = uuidv4();

let payload: PanelPayload;
try {
await runBlockPreview({ ...args, blueprintId });
await runBrickPreview({ ...args, blueprintId });
// We're expecting a HeadlessModeError (or other error) to be thrown in the line above
// noinspection ExceptionCaughtLocallyJS
throw new NoRendererError();
Expand Down
2 changes: 1 addition & 1 deletion src/contentScript/pageEditor/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export type AttributeExample = {
value: string;
};

export type RunBlockArgs = {
export type RunBrickArgs = {
/**
* The runtime API version to use
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ import { RunApiTask } from "@/contrib/automationanywhere/RunApiTask";

let registered = false;

function registerContribBlocks(): void {
function registerContribBricks(): void {
if (registered) {
console.warn(
"registerBuiltinBlocks already called; multiple calls are unnecessary and may impact startup performance",
"registerContribBricks already called; multiple calls are unnecessary and may impact startup performance",
);
}

Expand Down Expand Up @@ -89,4 +89,4 @@ function registerContribBlocks(): void {
registered = true;
}

export default registerContribBlocks;
export default registerContribBricks;
4 changes: 2 additions & 2 deletions src/development/headers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ import brickRegistry from "@/bricks/registry";
// NOTE: we don't need to also include extensionPoints because we got rid of all the legacy hard-coded extension points
// (e.g., the Pipedrive calendar extension point, and TechCrunch entity extension point)
import registerBuiltinBricks from "@/bricks/registerBuiltinBricks";
import registerContribBlocks from "@/contrib/registerContribBlocks";
import registerContribBricks from "@/contrib/registerContribBricks";

// Maintaining this number is a simple way to ensure bricks don't accidentally get dropped
const EXPECTED_HEADER_COUNT = 137;

registerBuiltinBricks();
registerContribBlocks();
registerContribBricks();

Error.stackTraceLimit = Number.POSITIVE_INFINITY;

Expand Down
4 changes: 2 additions & 2 deletions src/extensionConsole/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import ActivateExtensionPage from "@/extensionConsole/pages/activateExtension/Ac
import SetupPage from "@/extensionConsole/pages/onboarding/SetupPage";
import UpdateBanner from "@/extensionConsole/pages/UpdateBanner";
import registerBuiltinBricks from "@/bricks/registerBuiltinBricks";
import registerContribBlocks from "@/contrib/registerContribBlocks";
import registerContribBricks from "@/contrib/registerContribBricks";
import registerEditors from "@/contrib/editors";
import DeploymentBanner from "@/extensionConsole/pages/deployments/DeploymentBanner";
import { ModalProvider } from "@/components/ConfirmationModal";
Expand All @@ -59,7 +59,7 @@ import DatabaseUnresponsiveBanner from "@/components/DatabaseUnresponsiveBanner"
// Register the built-in bricks
registerEditors();
registerBuiltinBricks();
registerContribBlocks();
registerContribBricks();

// Register Widgets
registerDefaultWidgets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Fuse from "fuse.js";
import { sortBy } from "lodash";
import Loader from "@/components/Loader";
import BrickDetail from "./BrickDetail";
import BlockResult from "./BlockResult";
import BrickResult from "./BrickResult";
import { isOfficial } from "@/bricks/util";
import { find } from "@/registry/packageRegistry";
import { brickToYaml } from "@/utils/objToYaml";
Expand Down Expand Up @@ -125,9 +125,9 @@ const BrickReference = ({
</InputGroup>
<ListGroup className={styles.blockResults}>
{results.map((result) => (
<BlockResult
<BrickResult
key={result.id}
block={result}
brick={result}
active={selected?.id === result.id}
onSelect={() => {
setSelected(result);
Expand Down
Loading

0 comments on commit 59caadc

Please sign in to comment.