faa-swim-consumer
Version:
FAA SWIM Queue Consumer for SFDPS and other subscription queues
131 lines (128 loc) • 5.93 kB
JavaScript
;
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var src_exports = {};
__export(src_exports, {
SWIMConsumer: () => SWIMConsumer,
SWIMConsumerOptionsFactory: () => SWIMConsumerOptionsFactory
});
module.exports = __toCommonJS(src_exports);
// src/models.ts
var import_solclientjs = __toESM(require("solclientjs"));
var SWIMConsumerOptionsFactory = class {
constructor(options) {
this.solClientOptions = {
profile: import_solclientjs.default.SolclientFactoryProfiles.version10,
logLevel: import_solclientjs.default.LogLevel.TRACE
};
if (options.solClientOptions) {
this.solClientOptions = {
profile: options.solClientOptions.profile ? options.solClientOptions.profile : import_solclientjs.default.SolclientFactoryProfiles.version10,
logLevel: options.solClientOptions.logLevel ? options.solClientOptions.logLevel : import_solclientjs.default.LogLevel.TRACE,
logger: options.solClientOptions.logger ? options.solClientOptions.logger : void 0
};
}
this.sessionOptions = options.sessionOptions;
this.messageConsumerOptions = options.messageConsumerOptions;
}
};
// src/consumer.ts
var import_solclientjs2 = __toESM(require("solclientjs"));
var SWIMConsumer = class {
constructor(options) {
var _a, _b, _c;
this.options = new SWIMConsumerOptionsFactory(options);
const factoryOptions = new import_solclientjs2.default.SolclientFactoryProperties({
profile: (_a = this.options.solClientOptions) == null ? void 0 : _a.profile,
logLevel: (_b = this.options.solClientOptions) == null ? void 0 : _b.logLevel,
logger: (_c = this.options.solClientOptions) == null ? void 0 : _c.logger
});
import_solclientjs2.default.SolclientFactory.init(factoryOptions);
const extraSessionProperties = this.options.sessionOptions.extraSessionProperties ? this.options.sessionOptions.extraSessionProperties : {};
this.session = import_solclientjs2.default.SolclientFactory.createSession(__spreadValues({
authenticationScheme: import_solclientjs2.default.AuthenticationScheme.BASIC,
url: this.options.sessionOptions.url,
vpnName: this.options.sessionOptions.vpnName,
userName: this.options.sessionOptions.userName,
password: this.options.sessionOptions.password
}, extraSessionProperties));
const extraConsumerProperties = this.options.messageConsumerOptions.extraConsumerProperties ? this.options.messageConsumerOptions.extraConsumerProperties : {};
this.consumer = this.session.createMessageConsumer({
acknowledgeMode: this.options.messageConsumerOptions.acknowledgeMode,
queueDescriptor: new import_solclientjs2.default.QueueDescriptor(__spreadValues({
type: import_solclientjs2.default.QueueType.QUEUE,
name: this.options.messageConsumerOptions.queueName
}, extraConsumerProperties)),
queueProperties: this.options.messageConsumerOptions.queueProperties
});
if (this.options.messageConsumerOptions.onNewRawMessage) {
this.consumer.on(import_solclientjs2.default.MessageConsumerEventName.MESSAGE, (msg) => {
this.options.messageConsumerOptions.onNewRawMessage(msg.getXmlContent());
const isAutoAcknowledge = this.options.messageConsumerOptions.acknowledgeMode === import_solclientjs2.default.MessageConsumerAcknowledgeMode.AUTO;
if (!this.options.messageConsumerOptions.disableAutoAcknowledge && !isAutoAcknowledge) {
msg.acknowledge();
}
});
}
}
/**
* Shortcut to session.connect() and consumer.connect()
*/
connect() {
this.session.connect();
this.consumer.connect();
}
/**
* Shortcut to consumer.disconnect() and session.disconnect()
*/
disconnect() {
this.consumer.disconnect();
this.session.disconnect();
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
SWIMConsumer,
SWIMConsumerOptionsFactory
});
//# sourceMappingURL=index.js.map