New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

a1pubsub

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

a1pubsub - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

21

dist/index.d.ts
import { JSON } from './json';
declare type Base64String = string;
declare type SubscriptionId = string;
declare type MessageId = string;

@@ -27,3 +26,3 @@ /**

*/
export interface PubSubMessage<S extends string, T extends JSON> {
export interface PubSubMessage<S extends string, T> {
subscription: S;

@@ -51,3 +50,3 @@ message: {

status: EventStatus;
subscription: SubscriptionId;
subscription: string;
base64_event_data: Base64String;

@@ -57,3 +56,3 @@ }

getPubSubEvent(messageId: MessageId): Promise<PubSubEvent | undefined>;
recordMessageReceived(rawMessage: UnprocessedPubSubMessage, subscription: SubscriptionId, cachedEvent?: PubSubEvent): Promise<PubSubEvent>;
recordMessageReceived(rawMessage: UnprocessedPubSubMessage, subscription: string, cachedEvent?: PubSubEvent): Promise<PubSubEvent>;
recordMessageProcessingOutcome(cachedEvent: PubSubEvent, outcome: EventStatus): Promise<void>;

@@ -65,17 +64,17 @@ }

getPubSubEvent(messageId: MessageId): Promise<PubSubEvent | undefined>;
recordMessageReceived(rawMessage: UnprocessedPubSubMessage, subscription: SubscriptionId, cachedEvent?: PubSubEvent): Promise<PubSubEvent>;
recordMessageReceived(rawMessage: UnprocessedPubSubMessage, subscription: string, cachedEvent?: PubSubEvent): Promise<PubSubEvent>;
recordMessageProcessingOutcome(cachedEvent: PubSubEvent, outcome: EventStatus): Promise<void>;
}
declare type Validator<T> = (json: JSON) => T | undefined;
interface SubscriptionHandler<T> {
interface SubscriptionHandler<S extends string, T> {
validator: Validator<T>;
handler: (data: T) => Promise<boolean>;
handler: (data: PubSubMessage<S, T>) => Promise<boolean>;
}
export declare type DecodingTable<T> = Map<SubscriptionId, SubscriptionHandler<T>>;
export declare const getSubscription: (rawSubscription: string) => string | null;
export declare class PubSub<T> {
export declare type DecodingTable<S extends string, T> = Map<S, SubscriptionHandler<S, T>>;
export declare const getSubscription: <S extends string>(rawSubscription: string) => S | null;
export declare class PubSub<S extends string, T> {
private projectId;
private stateManager;
private decoders;
constructor(projectId: string, decodingTable: DecodingTable<T>, customStateManager?: StateManager);
constructor(projectId: string, decodingTable: DecodingTable<S, T>, customStateManager?: StateManager);
publish<J extends {}>(topic: string, data: J): Promise<void>;

@@ -82,0 +81,0 @@ handlePubSubMessage(rawMsg: UnprocessedPubSubMessage): Promise<SubscriptionError | undefined>;

@@ -142,3 +142,10 @@ "use strict";

}
const succeeded = yield handler(decodedMessage.data).catch(() => {
const pubSubMessage = {
subscription,
message: {
messageId: rawMsg.message.messageId,
data: decodedMessage.data,
},
};
const succeeded = yield handler(pubSubMessage).catch(() => {
// catching in case handler didn't catch its own errors

@@ -145,0 +152,0 @@ return false;

{
"name": "a1pubsub",
"version": "0.0.5",
"version": "0.0.6",
"description": "GCP PubSub wrapper to add idempotency",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

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