working rss feed to nostr publish
This commit is contained in:
Generated
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EventStreamMarshaller = void 0;
|
||||
const eventstream_codec_1 = require("@smithy/eventstream-codec");
|
||||
const getChunkedStream_1 = require("./getChunkedStream");
|
||||
const getUnmarshalledStream_1 = require("./getUnmarshalledStream");
|
||||
class EventStreamMarshaller {
|
||||
constructor({ utf8Encoder, utf8Decoder }) {
|
||||
this.eventStreamCodec = new eventstream_codec_1.EventStreamCodec(utf8Encoder, utf8Decoder);
|
||||
this.utfEncoder = utf8Encoder;
|
||||
}
|
||||
deserialize(body, deserializer) {
|
||||
const inputStream = (0, getChunkedStream_1.getChunkedStream)(body);
|
||||
return new eventstream_codec_1.SmithyMessageDecoderStream({
|
||||
messageStream: new eventstream_codec_1.MessageDecoderStream({ inputStream, decoder: this.eventStreamCodec }),
|
||||
deserializer: (0, getUnmarshalledStream_1.getMessageUnmarshaller)(deserializer, this.utfEncoder),
|
||||
});
|
||||
}
|
||||
serialize(inputStream, serializer) {
|
||||
return new eventstream_codec_1.MessageEncoderStream({
|
||||
messageStream: new eventstream_codec_1.SmithyMessageEncoderStream({ inputStream, serializer }),
|
||||
encoder: this.eventStreamCodec,
|
||||
includeEndFrame: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.EventStreamMarshaller = EventStreamMarshaller;
|
||||
node_modules/@smithy/eventstream-serde-universal/dist-cjs/fixtures/MockEventMessageSource.fixture.js
Generated
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.MockEventMessageSource = void 0;
|
||||
const stream_1 = require("stream");
|
||||
class MockEventMessageSource extends stream_1.Readable {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this.readCount = 0;
|
||||
this.data = Buffer.concat(options.messages);
|
||||
this.emitSize = options.emitSize;
|
||||
this.throwError = options.throwError;
|
||||
}
|
||||
_read() {
|
||||
const self = this;
|
||||
if (this.readCount === this.data.length) {
|
||||
if (this.throwError) {
|
||||
process.nextTick(function () {
|
||||
self.emit("error", new Error("Throwing an error!"));
|
||||
});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
this.push(null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
const bytesLeft = this.data.length - this.readCount;
|
||||
const numBytesToSend = Math.min(bytesLeft, this.emitSize);
|
||||
const chunk = this.data.slice(this.readCount, this.readCount + numBytesToSend);
|
||||
this.readCount += numBytesToSend;
|
||||
this.push(chunk);
|
||||
}
|
||||
}
|
||||
exports.MockEventMessageSource = MockEventMessageSource;
|
||||
Generated
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.exception = exports.endEventMessage = exports.statsEventMessage = exports.recordEventMessage = void 0;
|
||||
exports.recordEventMessage = Buffer.from("AAAA0AAAAFX31gVLDTptZXNzYWdlLXR5cGUHAAVldmVudAs6ZXZlbnQtdHlwZQcAB1JlY29yZHMNOmNvbnRlbnQtdHlwZQcAGGFwcGxpY2F0aW9uL29jdGV0LXN0cmVhbTEsRm9vLFdoZW4gbGlmZSBnaXZlcyB5b3UgZm9vLi4uCjIsQmFyLG1ha2UgQmFyIQozLEZpenosU29tZXRpbWVzIHBhaXJlZCB3aXRoLi4uCjQsQnV6eix0aGUgaW5mYW1vdXMgQnV6eiEKzxKeSw==", "base64");
|
||||
exports.statsEventMessage = Buffer.from("AAAA0QAAAEM+YpmqDTptZXNzYWdlLXR5cGUHAAVldmVudAs6ZXZlbnQtdHlwZQcABVN0YXRzDTpjb250ZW50LXR5cGUHAAh0ZXh0L3htbDxTdGF0cyB4bWxucz0iIj48Qnl0ZXNTY2FubmVkPjEyNjwvQnl0ZXNTY2FubmVkPjxCeXRlc1Byb2Nlc3NlZD4xMjY8L0J5dGVzUHJvY2Vzc2VkPjxCeXRlc1JldHVybmVkPjEwNzwvQnl0ZXNSZXR1cm5lZD48L1N0YXRzPiJ0pLk=", "base64");
|
||||
exports.endEventMessage = Buffer.from("AAAAOAAAACjBxoTUDTptZXNzYWdlLXR5cGUHAAVldmVudAs6ZXZlbnQtdHlwZQcAA0VuZM+X05I=", "base64");
|
||||
exports.exception = Buffer.from("AAAAtgAAAF8BcW64DTpjb250ZW50LXR5cGUHABhhcHBsaWNhdGlvbi9vY3RldC1zdHJlYW0NOm1lc3NhZ2UtdHlwZQcACWV4Y2VwdGlvbg86ZXhjZXB0aW9uLXR5cGUHAAlFeGNlcHRpb25UaGlzIGlzIGEgbW9kZWxlZCBleGNlcHRpb24gZXZlbnQgdGhhdCB3b3VsZCBiZSB0aHJvd24gaW4gZGVzZXJpYWxpemVyLj6Gc60=", "base64");
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getChunkedStream = void 0;
|
||||
function getChunkedStream(source) {
|
||||
let currentMessageTotalLength = 0;
|
||||
let currentMessagePendingLength = 0;
|
||||
let currentMessage = null;
|
||||
let messageLengthBuffer = null;
|
||||
const allocateMessage = (size) => {
|
||||
if (typeof size !== "number") {
|
||||
throw new Error("Attempted to allocate an event message where size was not a number: " + size);
|
||||
}
|
||||
currentMessageTotalLength = size;
|
||||
currentMessagePendingLength = 4;
|
||||
currentMessage = new Uint8Array(size);
|
||||
const currentMessageView = new DataView(currentMessage.buffer);
|
||||
currentMessageView.setUint32(0, size, false);
|
||||
};
|
||||
const iterator = async function* () {
|
||||
const sourceIterator = source[Symbol.asyncIterator]();
|
||||
while (true) {
|
||||
const { value, done } = await sourceIterator.next();
|
||||
if (done) {
|
||||
if (!currentMessageTotalLength) {
|
||||
return;
|
||||
}
|
||||
else if (currentMessageTotalLength === currentMessagePendingLength) {
|
||||
yield currentMessage;
|
||||
}
|
||||
else {
|
||||
throw new Error("Truncated event message received.");
|
||||
}
|
||||
return;
|
||||
}
|
||||
const chunkLength = value.length;
|
||||
let currentOffset = 0;
|
||||
while (currentOffset < chunkLength) {
|
||||
if (!currentMessage) {
|
||||
const bytesRemaining = chunkLength - currentOffset;
|
||||
if (!messageLengthBuffer) {
|
||||
messageLengthBuffer = new Uint8Array(4);
|
||||
}
|
||||
const numBytesForTotal = Math.min(4 - currentMessagePendingLength, bytesRemaining);
|
||||
messageLengthBuffer.set(value.slice(currentOffset, currentOffset + numBytesForTotal), currentMessagePendingLength);
|
||||
currentMessagePendingLength += numBytesForTotal;
|
||||
currentOffset += numBytesForTotal;
|
||||
if (currentMessagePendingLength < 4) {
|
||||
break;
|
||||
}
|
||||
allocateMessage(new DataView(messageLengthBuffer.buffer).getUint32(0, false));
|
||||
messageLengthBuffer = null;
|
||||
}
|
||||
const numBytesToWrite = Math.min(currentMessageTotalLength - currentMessagePendingLength, chunkLength - currentOffset);
|
||||
currentMessage.set(value.slice(currentOffset, currentOffset + numBytesToWrite), currentMessagePendingLength);
|
||||
currentMessagePendingLength += numBytesToWrite;
|
||||
currentOffset += numBytesToWrite;
|
||||
if (currentMessageTotalLength && currentMessageTotalLength === currentMessagePendingLength) {
|
||||
yield currentMessage;
|
||||
currentMessage = null;
|
||||
currentMessageTotalLength = 0;
|
||||
currentMessagePendingLength = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
return {
|
||||
[Symbol.asyncIterator]: iterator,
|
||||
};
|
||||
}
|
||||
exports.getChunkedStream = getChunkedStream;
|
||||
Generated
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getMessageUnmarshaller = exports.getUnmarshalledStream = void 0;
|
||||
function getUnmarshalledStream(source, options) {
|
||||
const messageUnmarshaller = getMessageUnmarshaller(options.deserializer, options.toUtf8);
|
||||
return {
|
||||
[Symbol.asyncIterator]: async function* () {
|
||||
for await (const chunk of source) {
|
||||
const message = options.eventStreamCodec.decode(chunk);
|
||||
const type = await messageUnmarshaller(message);
|
||||
if (type === undefined)
|
||||
continue;
|
||||
yield type;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
exports.getUnmarshalledStream = getUnmarshalledStream;
|
||||
function getMessageUnmarshaller(deserializer, toUtf8) {
|
||||
return async function (message) {
|
||||
const { value: messageType } = message.headers[":message-type"];
|
||||
if (messageType === "error") {
|
||||
const unmodeledError = new Error(message.headers[":error-message"].value || "UnknownError");
|
||||
unmodeledError.name = message.headers[":error-code"].value;
|
||||
throw unmodeledError;
|
||||
}
|
||||
else if (messageType === "exception") {
|
||||
const code = message.headers[":exception-type"].value;
|
||||
const exception = { [code]: message };
|
||||
const deserializedException = await deserializer(exception);
|
||||
if (deserializedException.$unknown) {
|
||||
const error = new Error(toUtf8(message.body));
|
||||
error.name = code;
|
||||
throw error;
|
||||
}
|
||||
throw deserializedException[code];
|
||||
}
|
||||
else if (messageType === "event") {
|
||||
const event = {
|
||||
[message.headers[":event-type"].value]: message,
|
||||
};
|
||||
const deserialized = await deserializer(event);
|
||||
if (deserialized.$unknown)
|
||||
return;
|
||||
return deserialized;
|
||||
}
|
||||
else {
|
||||
throw Error(`Unrecognizable event type: ${message.headers[":event-type"].value}`);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.getMessageUnmarshaller = getMessageUnmarshaller;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const tslib_1 = require("tslib");
|
||||
tslib_1.__exportStar(require("./EventStreamMarshaller"), exports);
|
||||
tslib_1.__exportStar(require("./provider"), exports);
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.eventStreamSerdeProvider = void 0;
|
||||
const EventStreamMarshaller_1 = require("./EventStreamMarshaller");
|
||||
const eventStreamSerdeProvider = (options) => new EventStreamMarshaller_1.EventStreamMarshaller(options);
|
||||
exports.eventStreamSerdeProvider = eventStreamSerdeProvider;
|
||||
Reference in New Issue
Block a user