{"version":3,"file":"eventbus.ee.mjs","names":[],"sources":["../src/api/eventbus.ee.ts"],"sourcesContent":["import type { IDataObject, MessageEventBusDestinationOptions } from 'n8n-workflow';\n\nimport type { IRestApiContext } from '../types';\nimport { makeRestApiRequest } from '../utils';\n\nexport type ApiMessageEventBusDestinationOptions = MessageEventBusDestinationOptions & {\n\tid: string;\n};\n\nexport function hasDestinationId(\n\tdestination: MessageEventBusDestinationOptions,\n): destination is ApiMessageEventBusDestinationOptions {\n\treturn destination.id !== undefined;\n}\n\nexport async function saveDestinationToDb(\n\tcontext: IRestApiContext,\n\tdestination: ApiMessageEventBusDestinationOptions,\n\tsubscribedEvents: string[] = [],\n) {\n\tconst data: IDataObject = {\n\t\t...destination,\n\t\tsubscribedEvents,\n\t};\n\treturn await makeRestApiRequest(context, 'POST', '/eventbus/destination', data);\n}\n\nexport async function deleteDestinationFromDb(context: IRestApiContext, destinationId: string) {\n\treturn await makeRestApiRequest(context, 'DELETE', `/eventbus/destination?id=${destinationId}`);\n}\n\nexport async function sendTestMessageToDestination(\n\tcontext: IRestApiContext,\n\tdestination: ApiMessageEventBusDestinationOptions,\n): Promise<boolean> {\n\tconst data: IDataObject = {\n\t\t...destination,\n\t};\n\treturn await makeRestApiRequest(context, 'GET', '/eventbus/testmessage', data);\n}\n\nexport async function getEventNamesFromBackend(context: IRestApiContext): Promise<string[]> {\n\treturn await makeRestApiRequest(context, 'GET', '/eventbus/eventnames');\n}\n\nexport async function getDestinationsFromBackend(\n\tcontext: IRestApiContext,\n): Promise<MessageEventBusDestinationOptions[]> {\n\treturn await makeRestApiRequest(context, 'GET', '/eventbus/destination');\n}\n"],"mappings":";;;AASA,SAAgB,iBACf,aACsD;AACtD,QAAO,YAAY,OAAO;;AAG3B,eAAsB,oBACrB,SACA,aACA,mBAA6B,EAAE,EAC9B;AAKD,QAAO,MAAM,mBAAmB,SAAS,QAAQ,yBAJvB;EACzB,GAAG;EACH;EACA,CAC8E;;AAGhF,eAAsB,wBAAwB,SAA0B,eAAuB;AAC9F,QAAO,MAAM,mBAAmB,SAAS,UAAU,4BAA4B,gBAAgB;;AAGhG,eAAsB,6BACrB,SACA,aACmB;AAInB,QAAO,MAAM,mBAAmB,SAAS,OAAO,yBAHtB,EACzB,GAAG,aACH,CAC6E;;AAG/E,eAAsB,yBAAyB,SAA6C;AAC3F,QAAO,MAAM,mBAAmB,SAAS,OAAO,uBAAuB;;AAGxE,eAAsB,2BACrB,SAC+C;AAC/C,QAAO,MAAM,mBAAmB,SAAS,OAAO,wBAAwB"}