Skip to content

Commit

Permalink
use interfaces instead of types
Browse files Browse the repository at this point in the history
  • Loading branch information
ad1992 committed Apr 2, 2024
1 parent 2fd6de0 commit e27e56f
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions packages/mermaid/src/diagrams/sequence/sequenceDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import {
} from '../common/commonDb.js';
import { ImperativeState } from '../../utils/imperativeState.js';

type Box = {
interface Box {
name: string;
wrap: boolean;
fill: string;
actorKeys: string[];
};
}

type Actor = {
interface Actor {
box?: Box;
name: string;
description: string;
Expand All @@ -31,9 +31,9 @@ type Actor = {
actorCnt: number | null;
rectData: unknown;
type: string;
};
}

type Message = {
interface Message {
from?: { actor: string };
to?: { actor: string };
message:
Expand All @@ -48,7 +48,55 @@ type Message = {
type?: number;
activate?: boolean;
placement?: string;
};
}

interface AddMessageParams {
from: string;
to: string;
msg: string;
signalType: number;
type:
| 'addMessage'
| 'sequenceIndex'
| 'addParticipant'
| 'createParticipant'
| 'destroyParticipant'
| 'activeStart'
| 'activeEnd'
| 'addNote'
| 'addLinks'
| 'addALink'
| 'addProperties'
| 'addDetails'
| 'boxStart'
| 'boxEnd'
| 'loopStart'
| 'loopEnd'
| 'rectStart'
| 'rectEnd'
| 'optStart'
| 'optEnd'
| 'altStart'
| 'else'
| 'altEnd'
| 'setAccTitle'
| 'parStart'
| 'parAnd'
| 'parEnd'
| 'and'
| 'criticalStart'
| 'criticalOption'
| 'option'
| 'criticalEnd'
| 'breakStart'
| 'breakEnd'
| 'parOverStart'
| 'parOverEnd'
| 'parOverAnd'
| 'parOverEnd';

activate: boolean;
}

type State = {
prevActor?: string;
Expand Down Expand Up @@ -134,7 +182,7 @@ export const addActor = function (
properties: {},
actorCnt: null,
rectData: null,
type: type || 'participant',
type: type ?? 'participant',
};
if (state.records.prevActor && state.records.actors[state.records.prevActor]) {
state.records.actors[state.records.prevActor].nextActor = id;
Expand Down Expand Up @@ -188,7 +236,7 @@ export const addMessage = function (
export const addSignal = function (
idFrom?: Message['from'],
idTo?: Message['to'],
message: { text?: string; wrap?: boolean } = { text: undefined, wrap: undefined },
message?: { text: string; wrap: boolean },
messageType?: number,
activate: boolean = false
) {
Expand Down Expand Up @@ -423,7 +471,7 @@ export const addALink = function (actorId: string, text: { text: string }) {
// find the actor
const actor = getActor(actorId);
try {
const links: { [key: string]: string } = {};
const links: Record<string, string> = {};
let sanitizedText = sanitizeText(text.text, getConfig());
const sep = sanitizedText.indexOf('@');
sanitizedText = sanitizedText.replace(/&amp;/g, '&');
Expand Down Expand Up @@ -515,54 +563,6 @@ export const getActorProperty = function (actor: Actor, key: string) {
return undefined;
};

type AddMessageParams = {
from: string;
to: string;
msg: string;
signalType: number;
type:
| 'addMessage'
| 'sequenceIndex'
| 'addParticipant'
| 'createParticipant'
| 'destroyParticipant'
| 'activeStart'
| 'activeEnd'
| 'addNote'
| 'addLinks'
| 'addALink'
| 'addProperties'
| 'addDetails'
| 'boxStart'
| 'boxEnd'
| 'loopStart'
| 'loopEnd'
| 'rectStart'
| 'rectEnd'
| 'optStart'
| 'optEnd'
| 'altStart'
| 'else'
| 'altEnd'
| 'setAccTitle'
| 'parStart'
| 'parAnd'
| 'parEnd'
| 'and'
| 'criticalStart'
| 'criticalOption'
| 'option'
| 'criticalEnd'
| 'breakStart'
| 'breakEnd'
| 'parOverStart'
| 'parOverEnd'
| 'parOverAnd'
| 'parOverEnd';

activate: boolean;
};

export const apply = function (param: any | AddMessageParams | AddMessageParams[]) {
if (Array.isArray(param)) {
param.forEach(function (item) {
Expand Down

0 comments on commit e27e56f

Please sign in to comment.