Skip to content

Commit

Permalink
fix: JOIN-37480 fix release build (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-taran authored Nov 28, 2023
2 parents 12000d6 + e5ec9f9 commit 1c65b52
Show file tree
Hide file tree
Showing 9 changed files with 1,850 additions and 1,926 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@
"conventional-changelog-conventionalcommits": "^5.0.0",
"semantic-release": "^19.0.3",
"semantic-release-monorepo": "^7.0.5"
},
"resolutions": {
"@semantic-release/npm": "8.0.3"
}
}
4 changes: 4 additions & 0 deletions packages/pubsub-legacy-factories/src/SubscriberFactory.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { PubSub } from '@google-cloud/pubsub'
import { SchemaServiceClient } from '@google-cloud/pubsub/build/src/v1'
import { ISubscriptionOptions, Subscriber, ILogger } from '@join-com/pubsub'

export type SubscriberInitializer<T> = (subscriptionName: string, options?: ISubscriptionOptions) => Subscriber<T>

export class SubscriberFactory {
private readonly client: PubSub
private readonly schemaServiceClient: SchemaServiceClient

constructor(readonly options: ISubscriptionOptions, private readonly logger: ILogger) {
this.client = new PubSub()
this.schemaServiceClient = new SchemaServiceClient()
}

public getSubscription<T>(
Expand All @@ -18,6 +21,7 @@ export class SubscriberFactory {
return new Subscriber(
{ topicName, subscriptionName, subscriptionOptions: options || this.options },
this.client,
this.schemaServiceClient,
this.logger,
)
}
Expand Down
2 changes: 1 addition & 1 deletion packages/pubsub/src/FieldsProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class FieldsProcessor {
}
}

public setEmptyArrayFieldsToUndefined(obj: Record<string, unknown>, paths: string[]) {
public setEmptyArrayFieldsToUndefined(obj: Record<string, unknown>, paths: string[]): void {
for (const path of paths) {
this.setEmptyArrayFieldsToUndefinedRecursive(obj, path.split('.'), 0)
}
Expand Down
6 changes: 3 additions & 3 deletions packages/pubsub/src/MessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ export abstract class MessageHandler<T = unknown> {

protected abstract handle(event: T , info: IMessageInfo): Promise<void>

public start() {
public start(): void {
this.subscriber.start(async (msg:IParsedMessage<T>, info:IMessageInfo) => {
await this.handle(msg.dataParsed, info)
msg.ack()
})
}

public async initialize() {
public async initialize(): Promise<void> {
await this.subscriber.initialize()
}

public async stop() {
public async stop(): Promise<void> {
await this.subscriber.stop()
}
}
2 changes: 1 addition & 1 deletion packages/pubsub/src/Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class Publisher<T = unknown> {
this.topicSchemaName = `${this.topicName}-generated-avro`
}

public async initialize() {
public async initialize(): Promise<void> {
try {
await this.initializeTopic()
await this.initializeTopicSchema()
Expand Down
4 changes: 2 additions & 2 deletions packages/pubsub/src/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class Subscriber<T = unknown> {
}
}

public async initialize() {
public async initialize(): Promise<void> {
try {
await this.initializeTopic(this.topicName, this.topic)

Expand All @@ -112,7 +112,7 @@ export class Subscriber<T = unknown> {
}
}

public start(asyncCallback: (msg: IParsedMessage<T>, info : IMessageInfo) => Promise<void>) {
public start(asyncCallback: (msg: IParsedMessage<T>, info : IMessageInfo) => Promise<void>): void {
this.subscription.on('error', this.processError)
this.subscription.on('message', this.processMsg(asyncCallback))

Expand Down
1 change: 1 addition & 0 deletions packages/pubsub/src/__tests__/support/pubsubMock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
import { ILogger } from '../../ILogger'

type EventHandler = (attrs: unknown) => Promise<unknown>
Expand Down
6 changes: 3 additions & 3 deletions packages/pubsub/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ILogger } from './ILogger'

export const replaceNullsWithUndefined = (obj: unknown, preserveNullFields?: string) => {
export const replaceNullsWithUndefined = (obj: unknown, preserveNullFields?: string): void => {
if (!preserveNullFields) {
deepNullToUndefinedInObject(obj)
} else {
Expand All @@ -16,7 +16,7 @@ export const replaceNullsWithUndefined = (obj: unknown, preserveNullFields?: str
}
}

export const logWarnWhenUndefinedInNullPreserveFields = (obj: unknown, nullPreserveFields: string, logger?: ILogger) => {
export const logWarnWhenUndefinedInNullPreserveFields = (obj: unknown, nullPreserveFields: string, logger?: ILogger): void => {
if (isObject(obj)) {
const fieldsWithOnlyNullInside = parsePreserveNullFields(nullPreserveFields)
for (const key of Object.keys(obj)) {
Expand All @@ -29,7 +29,7 @@ export const logWarnWhenUndefinedInNullPreserveFields = (obj: unknown, nullPrese
}
}

export function includesUndefined(obj: unknown) {
export function includesUndefined(obj: unknown): boolean {
if (obj === undefined) {
return true;
}
Expand Down
Loading

0 comments on commit 1c65b52

Please sign in to comment.