UNPKG

@contentstack/live-preview-utils

Version:

Contentstack provides the Live Preview SDK to establish a communication channel between the various Contentstack SDKs and your website, transmitting live changes to the preview pane.

1 lines 1.84 kB
{"version":3,"sources":["../../../../src/visualBuilder/utils/getDiscussionIdByFieldMetaData.ts"],"sourcesContent":["import { CslpData } from \"../../cslp/types/cslp.types\";\nimport visualBuilderPostMessage from \"./visualBuilderPostMessage\";\nimport { ISchemaFieldMap } from \"./types/index.types\";\nimport { VisualBuilderPostMessageEvents } from \"./types/postMessage.types\";\nimport { IActiveDiscussion } from \"../components/CommentIcon\";\nimport { hasPostMessageError } from \"./errorHandling\";\n\n// Define an interface for the argument structure\ninterface GetDiscussionIdParams {\n fieldMetadata: CslpData;\n fieldSchema: ISchemaFieldMap;\n}\n\n/**\n * Retrieves the discussion data based on the field metadata and field UID.\n *\n * @param params The parameters including field metadata and field UID.\n * @returns A promise that resolves to the discussion data as a string.\n */\nexport async function getDiscussionIdByFieldMetaData(\n params: GetDiscussionIdParams\n): Promise<IActiveDiscussion | null> {\n const { fieldMetadata, fieldSchema } = params;\n\n // Send a message to get the discussion Data\n const discussion =\n (await visualBuilderPostMessage?.send<IActiveDiscussion | null>(\n VisualBuilderPostMessageEvents.GET_DISCUSSION_ID,\n { fieldMetadata, fieldSchema }\n )) ?? null;\n\n if(hasPostMessageError(discussion)){\n return null\n }\n \n return discussion;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,sCAAqC;AAErC,yBAA+C;AAE/C,2BAAoC;AAcpC,eAAsB,+BAClB,QACiC;AACjC,QAAM,EAAE,eAAe,YAAY,IAAI;AAGvC,QAAM,aACD,MAAM,gCAAAA,SAA0B;AAAA,IAC7B,kDAA+B;AAAA,IAC/B,EAAE,eAAe,YAAY;AAAA,EACjC,KAAM;AAEN,UAAG,0CAAoB,UAAU,GAAE;AAC/B,WAAO;AAAA,EACX;AAEJ,SAAO;AACX;","names":["visualBuilderPostMessage"]}