Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/Personalize/ParseInstructions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
import { PersonalizationData } from "./Personalize";

export type Instruction = unknown;
export type Instruction = FragmentInstruction | CommandInstruction;

export type FragmentInstruction = {
type: "FragmentInstruction";
selector: string;
val: string;
action: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of allowing this to be any arbitrary string, make a type Action where you enumerate what the different actions can be

type Action = 'InsertBefore' | 'InsertAfter' | 'Delete' | 'Replace' // For example

manifestId: string;
targetManifestId: string | undefined;
};

export type CommandInstruction = {
type: "CommandInstruction";
action: string;
selector: string;
content: string;
selectorType: string;
manifestId: string;
targetManifestId: string | undefined;
modifiers?: string[];
attribute?: string;
completed?: boolean;
};
export const parseInstructionsFrom = async (
personalizationData: PersonalizationData
): Promise<Instruction[]> => {
Expand Down
Loading