Skip to content

Commit b9601bc

Browse files
committed
build: release v3.2.1
1 parent 9d57ecb commit b9601bc

File tree

5 files changed

+66
-25
lines changed

5 files changed

+66
-25
lines changed

dist/client.cjs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,33 @@ function base64url(input) {
477477
}
478478

479479
// src/client.js
480+
var CUSTOM_LONG_AVRO_TYPE = import_avro_js2.default.types.LongType.using({
481+
fromBuffer: (buf) => {
482+
const big = buf.readBigInt64LE();
483+
if (big > Number.MAX_SAFE_INTEGER) {
484+
return big;
485+
}
486+
return Number(BigInt.asIntN(64, big));
487+
},
488+
toBuffer: (n) => {
489+
const buf = Buffer.alloc(8);
490+
if (n instanceof BigInt) {
491+
buf.writeBigInt64LE(n);
492+
} else {
493+
buf.writeBigInt64LE(BigInt(n));
494+
}
495+
return buf;
496+
},
497+
fromJSON: BigInt,
498+
toJSON: Number,
499+
isValid: (n) => {
500+
const type = typeof n;
501+
return type === "bigint" || type === "number";
502+
},
503+
compare: (n1, n2) => {
504+
return n1 === n2 ? 0 : n1 < n2 ? -1 : 1;
505+
}
506+
});
480507
var PubSubApiClient = class {
481508
/**
482509
* gRPC client
@@ -688,7 +715,7 @@ var PubSubApiClient = class {
688715
replayId = decodeReplayId(event.replayId);
689716
} catch (error2) {
690717
}
691-
const message = replayId ? `Failed to parse event with replay ID ${this.replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
718+
const message = replayId ? `Failed to parse event with replay ID ${replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
692719
const parseError = new EventParseError(
693720
message,
694721
error,
@@ -697,6 +724,7 @@ var PubSubApiClient = class {
697724
latestReplayId
698725
);
699726
eventEmitter.emit("error", parseError);
727+
this.#logger.error(parseError);
700728
}
701729
if (eventEmitter.getReceivedEventCount() === eventEmitter.getRequestedEventCount()) {
702730
eventEmitter.emit("lastevent");
@@ -825,7 +853,9 @@ var PubSubApiClient = class {
825853
if (schemaError) {
826854
reject(schemaError);
827855
} else {
828-
const schemaType = import_avro_js2.default.parse(res.schemaJson);
856+
const schemaType = import_avro_js2.default.parse(res.schemaJson, {
857+
registry: { long: CUSTOM_LONG_AVRO_TYPE }
858+
});
829859
this.#logger.info(
830860
`Topic schema loaded: ${topicName}`
831861
);

dist/client.d.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,3 @@
1-
/**
2-
* @typedef {Object} PublishResult
3-
* @property {number} replayId
4-
* @property {string} correlationKey
5-
* @global
6-
*/
7-
/**
8-
* @typedef {Object} Schema
9-
* @property {string} id
10-
* @property {Object} type
11-
* @protected
12-
*/
13-
/**
14-
* @typedef {Object} Logger
15-
* @property {Function} debug
16-
* @property {Function} info
17-
* @property {Function} error
18-
* @protected
19-
*/
201
/**
212
* Client for the Salesforce Pub/Sub API
223
* @alias PubSubApiClient

dist/client.d.ts.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/client.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,33 @@ function base64url(input) {
444444
}
445445

446446
// src/client.js
447+
var CUSTOM_LONG_AVRO_TYPE = avro2.types.LongType.using({
448+
fromBuffer: (buf) => {
449+
const big = buf.readBigInt64LE();
450+
if (big > Number.MAX_SAFE_INTEGER) {
451+
return big;
452+
}
453+
return Number(BigInt.asIntN(64, big));
454+
},
455+
toBuffer: (n) => {
456+
const buf = Buffer.alloc(8);
457+
if (n instanceof BigInt) {
458+
buf.writeBigInt64LE(n);
459+
} else {
460+
buf.writeBigInt64LE(BigInt(n));
461+
}
462+
return buf;
463+
},
464+
fromJSON: BigInt,
465+
toJSON: Number,
466+
isValid: (n) => {
467+
const type = typeof n;
468+
return type === "bigint" || type === "number";
469+
},
470+
compare: (n1, n2) => {
471+
return n1 === n2 ? 0 : n1 < n2 ? -1 : 1;
472+
}
473+
});
447474
var PubSubApiClient = class {
448475
/**
449476
* gRPC client
@@ -655,7 +682,7 @@ var PubSubApiClient = class {
655682
replayId = decodeReplayId(event.replayId);
656683
} catch (error2) {
657684
}
658-
const message = replayId ? `Failed to parse event with replay ID ${this.replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
685+
const message = replayId ? `Failed to parse event with replay ID ${replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
659686
const parseError = new EventParseError(
660687
message,
661688
error,
@@ -664,6 +691,7 @@ var PubSubApiClient = class {
664691
latestReplayId
665692
);
666693
eventEmitter.emit("error", parseError);
694+
this.#logger.error(parseError);
667695
}
668696
if (eventEmitter.getReceivedEventCount() === eventEmitter.getRequestedEventCount()) {
669697
eventEmitter.emit("lastevent");
@@ -792,7 +820,9 @@ var PubSubApiClient = class {
792820
if (schemaError) {
793821
reject(schemaError);
794822
} else {
795-
const schemaType = avro2.parse(res.schemaJson);
823+
const schemaType = avro2.parse(res.schemaJson, {
824+
registry: { long: CUSTOM_LONG_AVRO_TYPE }
825+
});
796826
this.#logger.info(
797827
`Topic schema loaded: ${topicName}`
798828
);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "salesforce-pubsub-api-client",
3-
"version": "3.2.0",
3+
"version": "3.2.1",
44
"type": "module",
55
"description": "A node client for the Salesforce Pub/Sub API",
66
"author": "pozil",

0 commit comments

Comments
 (0)