You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@hookdeck/pubsub

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hookdeck/pubsub - npm Package Compare versions

Comparing version

to
0.1.3-alpha

28

dist/index.d.ts
import { Hookdeck } from "@hookdeck/sdk";
export type SubscriberAuth = Hookdeck.DestinationAuthMethodConfig;
export type Event = Hookdeck.Event;
export interface SubscribeRequest {

@@ -50,5 +51,18 @@ /**

*/
name: string;
name?: string;
/**
* The Subscription ID, mapping to the ID of the underlying Hookdeck Connection.
*/
subscriptionId?: string;
}
/**
* The request object for getting events.
*/
export interface GetEventsRequest {
/**
* The ID of the subscription mapping to the underlying Hookdeck Connection.
*/
subscriptionId: string;
}
/**
* An event to be published on a {Channel}

@@ -62,2 +76,6 @@ */

/**
* Optional headers to publish with the event.
*/
headers?: Record<string, string>;
/**
* The event data

@@ -132,2 +150,10 @@ */

getSubscriptions(params?: GetSubscriptionsRequest): Promise<Subscription[]>;
/**
* Get all the events associated with a Subscription.
*
* @param {GetEventsRequest} params
*
* @returns
*/
getEvents({ subscriptionId, }: GetEventsRequest): Promise<Hookdeck.Event[]>;
}
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -49,7 +60,11 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

}
/**
* Publish an event on the channel.
*
* @param {PublishEvent} event The event to be published.
* @returns
*/
_Channel.prototype.publish = function (event) {
var _a, _b, _c, _d;
var headers = {
"Content-Type": "application/json",
};
var headers = __assign({ "Content-Type": "application/json" }, event.headers);
if (this._publishAuth !== undefined) {

@@ -65,9 +80,13 @@ switch (this._publishAuth.type) {

}
var eventPayload = {
type: event.type,
data: event.data,
};
var fetchOptions = {
method: "POST",
headers: headers,
body: JSON.stringify(event.data),
body: JSON.stringify(eventPayload),
};
this._logger.debug("Source request: " + JSON.stringify(fetchOptions));
this._logger.debug("With event: " + JSON.stringify(event));
this._logger.debug("With event: " + JSON.stringify(eventPayload));
var response = fetch(this.source.url, fetchOptions);

@@ -232,2 +251,3 @@ return response;

case 0: return [4 /*yield*/, this._sdk.connection.list({
id: params === null || params === void 0 ? void 0 : params.subscriptionId,
fullName: params === null || params === void 0 ? void 0 : params.name,

@@ -257,2 +277,30 @@ })];

};
/**
* Get all the events associated with a Subscription.
*
* @param {GetEventsRequest} params
*
* @returns
*/
HookdeckPubSub.prototype.getEvents = function (_a) {
return __awaiter(this, arguments, void 0, function (_b) {
var events, _events;
var subscriptionId = _b.subscriptionId;
return __generator(this, function (_c) {
switch (_c.label) {
case 0:
events = [];
return [4 /*yield*/, this._sdk.event.list({
webhookId: subscriptionId,
})];
case 1:
_events = _c.sent();
if (_events && _events.models) {
events = _events.models;
}
return [2 /*return*/, events];
}
});
});
};
return HookdeckPubSub;

@@ -259,0 +307,0 @@ }());

2

package.json
{
"name": "@hookdeck/pubsub",
"version": "0.1.2-alpha",
"version": "0.1.3-alpha",
"description": "An experimental SDK providing PubSub abstractions for Hookdeck",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet