Socket
Socket
Sign inDemoInstall

@datocms/rest-api-events

Package Overview
Dependencies
Maintainers
6
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datocms/rest-api-events - npm Package Compare versions

Comparing version 1.1.19 to 1.1.20

15

dist/cjs/JobResultsFetcher.js
"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) {

@@ -46,3 +57,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

}
JobResultsFetcher.prototype.subscribeToEvents = function () {
JobResultsFetcher.prototype.subscribeToEvents = function (config) {
return __awaiter(this, void 0, void 0, function () {

@@ -61,3 +72,3 @@ var channelName, _a;

_a = this;
return [4 /*yield*/, (0, subscribeToEvents_1.subscribeToEvents)("".concat(this.client.baseUrl, "/pusher/authenticate"), this.client.config.apiToken, channelName)];
return [4 /*yield*/, (0, subscribeToEvents_1.subscribeToEvents)(__assign(__assign({}, config), { authEndpoint: "".concat(this.client.baseUrl, "/pusher/authenticate"), apiToken: this.client.config.apiToken, channelName: channelName }))];
case 2:

@@ -64,0 +75,0 @@ _a.eventsSubscription = _b.sent();

8

dist/cjs/subscribeToEvents.js

@@ -8,5 +8,6 @@ "use strict";

var pusher_js_1 = __importDefault(require("pusher-js"));
var pusherAppKey = '75e6ef0fe5d39f481626';
var DEFAULT_APP_KEY = '75e6ef0fe5d39f481626';
var channelPromisesCache = {};
function subscribeToEvents(authEndpoint, apiToken, channelName) {
function subscribeToEvents(_a) {
var authEndpoint = _a.authEndpoint, apiToken = _a.apiToken, channelName = _a.channelName, cluster = _a.cluster, appKey = _a.appKey;
var cacheKey = [authEndpoint, channelName, apiToken].join('---');

@@ -18,4 +19,5 @@ var cachedPromise = channelPromisesCache[cacheKey];

var promise = new Promise(function (resolve, reject) {
var pusher = new pusher_js_1.default(pusherAppKey, {
var pusher = new pusher_js_1.default(appKey || DEFAULT_APP_KEY, {
authEndpoint: authEndpoint,
cluster: cluster,
auth: {

@@ -22,0 +24,0 @@ headers: {

import { GenericClient, JobResult } from './internalTypes';
import { SubscriptionConfig as SubscribeToEventsSubscriptionConfig } from './subscribeToEvents';
declare type SubscriptionConfig = Pick<SubscribeToEventsSubscriptionConfig, 'cluster' | 'appKey'>;
export declare class JobResultsFetcher<T extends GenericClient> {

@@ -6,5 +8,6 @@ private eventsSubscription;

constructor(client: T);
subscribeToEvents(): Promise<void>;
subscribeToEvents(config?: SubscriptionConfig): Promise<void>;
fetch(jobId: string): Promise<JobResult>;
unsubscribeToEvents(): void;
}
export {};

@@ -0,1 +1,12 @@

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) {

@@ -37,3 +48,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { subscribeToEvents } from './subscribeToEvents';
import { subscribeToEvents, } from './subscribeToEvents';
var JobResultsFetcher = /** @class */ (function () {

@@ -44,3 +55,3 @@ function JobResultsFetcher(client) {

}
JobResultsFetcher.prototype.subscribeToEvents = function () {
JobResultsFetcher.prototype.subscribeToEvents = function (config) {
return __awaiter(this, void 0, void 0, function () {

@@ -59,3 +70,3 @@ var channelName, _a;

_a = this;
return [4 /*yield*/, subscribeToEvents("".concat(this.client.baseUrl, "/pusher/authenticate"), this.client.config.apiToken, channelName)];
return [4 /*yield*/, subscribeToEvents(__assign(__assign({}, config), { authEndpoint: "".concat(this.client.baseUrl, "/pusher/authenticate"), apiToken: this.client.config.apiToken, channelName: channelName }))];
case 2:

@@ -62,0 +73,0 @@ _a.eventsSubscription = _b.sent();

@@ -1,2 +0,2 @@

import { Channel } from 'pusher-js';
import { Channel, Options } from 'pusher-js';
import { JobResult } from './internalTypes';

@@ -8,2 +8,9 @@ export declare type EventsSubscription = {

};
export declare function subscribeToEvents(authEndpoint: string, apiToken: string, channelName: string): Promise<EventsSubscription>;
export declare type SubscriptionConfig = {
authEndpoint: string;
apiToken: string;
channelName: string;
cluster?: Options['cluster'];
appKey?: string;
};
export declare function subscribeToEvents({ authEndpoint, apiToken, channelName, cluster, appKey, }: SubscriptionConfig): Promise<EventsSubscription>;
import Pusher from 'pusher-js';
var pusherAppKey = '75e6ef0fe5d39f481626';
var DEFAULT_APP_KEY = '75e6ef0fe5d39f481626';
var channelPromisesCache = {};
export function subscribeToEvents(authEndpoint, apiToken, channelName) {
export function subscribeToEvents(_a) {
var authEndpoint = _a.authEndpoint, apiToken = _a.apiToken, channelName = _a.channelName, cluster = _a.cluster, appKey = _a.appKey;
var cacheKey = [authEndpoint, channelName, apiToken].join('---');

@@ -11,4 +12,5 @@ var cachedPromise = channelPromisesCache[cacheKey];

var promise = new Promise(function (resolve, reject) {
var pusher = new Pusher(pusherAppKey, {
var pusher = new Pusher(appKey || DEFAULT_APP_KEY, {
authEndpoint: authEndpoint,
cluster: cluster,
auth: {

@@ -15,0 +17,0 @@ headers: {

import { GenericClient, JobResult } from './internalTypes';
import { SubscriptionConfig as SubscribeToEventsSubscriptionConfig } from './subscribeToEvents';
declare type SubscriptionConfig = Pick<SubscribeToEventsSubscriptionConfig, 'cluster' | 'appKey'>;
export declare class JobResultsFetcher<T extends GenericClient> {

@@ -6,5 +8,6 @@ private eventsSubscription;

constructor(client: T);
subscribeToEvents(): Promise<void>;
subscribeToEvents(config?: SubscriptionConfig): Promise<void>;
fetch(jobId: string): Promise<JobResult>;
unsubscribeToEvents(): void;
}
export {};

@@ -1,2 +0,2 @@

import { Channel } from 'pusher-js';
import { Channel, Options } from 'pusher-js';
import { JobResult } from './internalTypes';

@@ -8,2 +8,9 @@ export declare type EventsSubscription = {

};
export declare function subscribeToEvents(authEndpoint: string, apiToken: string, channelName: string): Promise<EventsSubscription>;
export declare type SubscriptionConfig = {
authEndpoint: string;
apiToken: string;
channelName: string;
cluster?: Options['cluster'];
appKey?: string;
};
export declare function subscribeToEvents({ authEndpoint, apiToken, channelName, cluster, appKey, }: SubscriptionConfig): Promise<EventsSubscription>;
{
"name": "@datocms/rest-api-events",
"version": "1.1.19",
"version": "1.1.20",
"description": "Utilities to receive real-time events from DatoCMS REST APIs",

@@ -42,6 +42,6 @@ "keywords": [

"devDependencies": {
"@datocms/cma-client": "^1.1.19",
"@datocms/dashboard-client": "^1.1.19"
"@datocms/cma-client": "^1.1.20",
"@datocms/dashboard-client": "^1.1.20"
},
"gitHead": "41205ec99771d32222980bbd95501b31c3d7042b"
"gitHead": "9722f987847c036cdd97f1d8815537495ceff53d"
}
import { GenericClient, JobResult } from './internalTypes';
import { EventsSubscription, subscribeToEvents } from './subscribeToEvents';
import {
EventsSubscription,
subscribeToEvents,
SubscriptionConfig as SubscribeToEventsSubscriptionConfig,
} from './subscribeToEvents';
type SubscriptionConfig = Pick<
SubscribeToEventsSubscriptionConfig,
'cluster' | 'appKey'
>;
export class JobResultsFetcher<T extends GenericClient> {

@@ -13,3 +22,3 @@ private eventsSubscription: EventsSubscription | undefined;

async subscribeToEvents() {
async subscribeToEvents(config?: SubscriptionConfig) {
if (!this.client.config.apiToken) {

@@ -22,7 +31,8 @@ throw new Error('Missing API token!');

if (!this.eventsSubscription) {
this.eventsSubscription = await subscribeToEvents(
`${this.client.baseUrl}/pusher/authenticate`,
this.client.config.apiToken,
this.eventsSubscription = await subscribeToEvents({
...config,
authEndpoint: `${this.client.baseUrl}/pusher/authenticate`,
apiToken: this.client.config.apiToken,
channelName,
);
});
}

@@ -29,0 +39,0 @@ }

@@ -1,2 +0,2 @@

import Pusher, { Channel } from 'pusher-js';
import Pusher, { Channel, Options } from 'pusher-js';
import { JobResult } from './internalTypes';

@@ -10,2 +10,10 @@

export type SubscriptionConfig = {
authEndpoint: string;
apiToken: string;
channelName: string;
cluster?: Options['cluster'];
appKey?: string;
};
type JobResultMessage = {

@@ -17,11 +25,13 @@ jobId: string;

const pusherAppKey = '75e6ef0fe5d39f481626';
const DEFAULT_APP_KEY = '75e6ef0fe5d39f481626';
const channelPromisesCache: Record<string, Promise<EventsSubscription>> = {};
export function subscribeToEvents(
authEndpoint: string,
apiToken: string,
channelName: string,
) {
export function subscribeToEvents({
authEndpoint,
apiToken,
channelName,
cluster,
appKey,
}: SubscriptionConfig) {
const cacheKey = [authEndpoint, channelName, apiToken].join('---');

@@ -36,4 +46,5 @@

const promise = new Promise<EventsSubscription>((resolve, reject) => {
const pusher = new Pusher(pusherAppKey, {
const pusher = new Pusher(appKey || DEFAULT_APP_KEY, {
authEndpoint,
cluster,
auth: {

@@ -40,0 +51,0 @@ headers: {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc