Skip to content

Commit

Permalink
build: release v3.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pozil committed Nov 13, 2023
1 parent 9d57ecb commit b9601bc
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 25 deletions.
34 changes: 32 additions & 2 deletions dist/client.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,33 @@ function base64url(input) {
}

// src/client.js
var CUSTOM_LONG_AVRO_TYPE = import_avro_js2.default.types.LongType.using({
fromBuffer: (buf) => {
const big = buf.readBigInt64LE();
if (big > Number.MAX_SAFE_INTEGER) {
return big;
}
return Number(BigInt.asIntN(64, big));
},
toBuffer: (n) => {
const buf = Buffer.alloc(8);
if (n instanceof BigInt) {
buf.writeBigInt64LE(n);
} else {
buf.writeBigInt64LE(BigInt(n));
}
return buf;
},
fromJSON: BigInt,
toJSON: Number,
isValid: (n) => {
const type = typeof n;
return type === "bigint" || type === "number";
},
compare: (n1, n2) => {
return n1 === n2 ? 0 : n1 < n2 ? -1 : 1;
}
});
var PubSubApiClient = class {
/**
* gRPC client
Expand Down Expand Up @@ -688,7 +715,7 @@ var PubSubApiClient = class {
replayId = decodeReplayId(event.replayId);
} catch (error2) {
}
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})`;
const message = replayId ? `Failed to parse event with replay ID ${replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
const parseError = new EventParseError(
message,
error,
Expand All @@ -697,6 +724,7 @@ var PubSubApiClient = class {
latestReplayId
);
eventEmitter.emit("error", parseError);
this.#logger.error(parseError);
}
if (eventEmitter.getReceivedEventCount() === eventEmitter.getRequestedEventCount()) {
eventEmitter.emit("lastevent");
Expand Down Expand Up @@ -825,7 +853,9 @@ var PubSubApiClient = class {
if (schemaError) {
reject(schemaError);
} else {
const schemaType = import_avro_js2.default.parse(res.schemaJson);
const schemaType = import_avro_js2.default.parse(res.schemaJson, {
registry: { long: CUSTOM_LONG_AVRO_TYPE }
});
this.#logger.info(
`Topic schema loaded: ${topicName}`
);
Expand Down
19 changes: 0 additions & 19 deletions dist/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/**
* @typedef {Object} PublishResult
* @property {number} replayId
* @property {string} correlationKey
* @global
*/
/**
* @typedef {Object} Schema
* @property {string} id
* @property {Object} type
* @protected
*/
/**
* @typedef {Object} Logger
* @property {Function} debug
* @property {Function} info
* @property {Function} error
* @protected
*/
/**
* Client for the Salesforce Pub/Sub API
* @alias PubSubApiClient
Expand Down
2 changes: 1 addition & 1 deletion dist/client.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 32 additions & 2 deletions dist/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,33 @@ function base64url(input) {
}

// src/client.js
var CUSTOM_LONG_AVRO_TYPE = avro2.types.LongType.using({
fromBuffer: (buf) => {
const big = buf.readBigInt64LE();
if (big > Number.MAX_SAFE_INTEGER) {
return big;
}
return Number(BigInt.asIntN(64, big));
},
toBuffer: (n) => {
const buf = Buffer.alloc(8);
if (n instanceof BigInt) {
buf.writeBigInt64LE(n);
} else {
buf.writeBigInt64LE(BigInt(n));
}
return buf;
},
fromJSON: BigInt,
toJSON: Number,
isValid: (n) => {
const type = typeof n;
return type === "bigint" || type === "number";
},
compare: (n1, n2) => {
return n1 === n2 ? 0 : n1 < n2 ? -1 : 1;
}
});
var PubSubApiClient = class {
/**
* gRPC client
Expand Down Expand Up @@ -655,7 +682,7 @@ var PubSubApiClient = class {
replayId = decodeReplayId(event.replayId);
} catch (error2) {
}
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})`;
const message = replayId ? `Failed to parse event with replay ID ${replayId}` : `Failed to parse event with unknown replay ID (latest replay ID was ${latestReplayId})`;
const parseError = new EventParseError(
message,
error,
Expand All @@ -664,6 +691,7 @@ var PubSubApiClient = class {
latestReplayId
);
eventEmitter.emit("error", parseError);
this.#logger.error(parseError);
}
if (eventEmitter.getReceivedEventCount() === eventEmitter.getRequestedEventCount()) {
eventEmitter.emit("lastevent");
Expand Down Expand Up @@ -792,7 +820,9 @@ var PubSubApiClient = class {
if (schemaError) {
reject(schemaError);
} else {
const schemaType = avro2.parse(res.schemaJson);
const schemaType = avro2.parse(res.schemaJson, {
registry: { long: CUSTOM_LONG_AVRO_TYPE }
});
this.#logger.info(
`Topic schema loaded: ${topicName}`
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "salesforce-pubsub-api-client",
"version": "3.2.0",
"version": "3.2.1",
"type": "module",
"description": "A node client for the Salesforce Pub/Sub API",
"author": "pozil",
Expand Down

0 comments on commit b9601bc

Please sign in to comment.