@corva/ui 3.20.0-6 → 3.20.0-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs-bundle/clients/subscriptions/constants.js +1 -1
- package/cjs-bundle/clients/subscriptions/subscriptions-client.factory.js +1 -1
- package/cjs-bundle/clients/subscriptions/subscriptions-client.factory.js.map +1 -1
- package/cjs-bundle/clients/subscriptions/subscriptions-client.js +1 -1
- package/cjs-bundle/clients/subscriptions/subscriptions-client.js.map +1 -1
- package/cjs-bundle/clients/subscriptions.v1.js +1 -1
- package/cjs-bundle/clients/subscriptions.v1.js.map +1 -1
- package/clients/subscriptions/constants.d.ts +0 -7
- package/clients/subscriptions/constants.d.ts.map +1 -1
- package/clients/subscriptions/constants.js +1 -1
- package/clients/subscriptions/subscriptions-client.d.ts +2 -2
- package/clients/subscriptions/subscriptions-client.d.ts.map +1 -1
- package/clients/subscriptions/subscriptions-client.factory.d.ts +1 -1
- package/clients/subscriptions/subscriptions-client.factory.d.ts.map +1 -1
- package/clients/subscriptions/subscriptions-client.factory.js +1 -1
- package/clients/subscriptions/subscriptions-client.factory.js.map +1 -1
- package/clients/subscriptions/subscriptions-client.js +1 -1
- package/clients/subscriptions/subscriptions-client.js.map +1 -1
- package/clients/subscriptions.v1.d.ts.map +1 -1
- package/clients/subscriptions.v1.js +1 -1
- package/clients/subscriptions.v1.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("query-string"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("query-string"),r=require("../../utils/env.js");function t(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,s.get?s:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}var s=t(e).parse(window.location.search),o=r.isDevOrQAEnv||r.isBetaEnv,n=o?"2":"1",i=s.subscriptions_version||localStorage.getItem("subscriptions_version")||n;o&&"2"!==localStorage.getItem("subscriptions_version_forced")&&(localStorage.setItem("subscriptions_version","2"),localStorage.setItem("subscriptions_version_forced","2"));var c=function(){return"1"===i?"/":"/".concat(i)},a=process.env.REACT_APP_SUBSCRIPTIONS_URL||s.subscriptions_url||"https://subscriptions.qa.corva.ai",u="".concat(a).concat(c()),p=new RegExp("^/reports.*$");exports.IGNORED_ROUTES_REGEXP=p,exports.SUBSCRIPTIONS_URL=u,exports.getNamespace=c,exports.handleSubscriptionsVersion=function(e,r){return"1"===i?e:r};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("socket.io-client"),e=require("./constants.js"),n=require("./subscriptions-client.js"),i=require("./subscriptions-client.dummy.js"),r=function(){function r(){}return r.init=function(){return this.instance||(this.instance=this.create()),this.instance},r.create=function(){if(e.IGNORED_ROUTES_REGEXP.test(window.location.pathname))return new i.DummySubscriptionsClient;var r=t.io(e.SUBSCRIPTIONS_URL,{transports:["websocket"],autoConnect:!0}),c=0;return r.on("connect",(function(){(c+=1,r.recovered)||1!==c&&Object.keys(r._callbacks).filter((function(t){return t.startsWith("$data#")})).map((function(t){return t.replace("$data#","")})).forEach((function(t){r.emit("subscribe",{channel:t,_current_location_href:window.top.location.href})}))})),new n.SubscriptionsClientV2(r)},r}();exports.SubscriptionsClientFactory=r;
|
|
2
2
|
//# sourceMappingURL=subscriptions-client.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"subscriptions-client.factory.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=function(){function t(t){var n=this;this._socket=t,this.onConnectionChange=function(t){var e=function(){return t({status:"connected"})},o=function(n){return t({status:"disconnected",reason:n})},r=function(){return t({status:"reconnecting"})},c=function(n){return t({status:"error",reason:(null==n?void 0:n.message)||String(n)})};return n._socket.on("connect",e),n._socket.on("disconnect",o),n._socket.on("reconnect",r),n._socket.on("connect_error",c),function(){n._socket.off("connect",e),n._socket.off("disconnect",o),n._socket.off("reconnect",r),n._socket.off("connect_error",c)}}}return t.prototype.subscribe=function(t,n,e){var o=this;this._validateArgs(t,n,e),this._socket.on("data#".concat(t),n),this._emit("subscribe",t,e);var r=function(){return o.unsubscribe(t,n,e)};return Object.defineProperty(r,"name",{value:"unsubscribe_".concat(t.replace(/[^\w]/g,"_")),writable:!1}),r},t.prototype.unsubscribe=function(t,n,e){this._validateArgs(t,n,e),this._emit("unsubscribe",t,e),this._socket.off("data#".concat(t),n)},t.prototype.disconnect=function(){return this._socket.disconnect(),this._socket.removeAllListeners(),this},t.prototype._validateArgs=function(t,n,e){if("string"!=typeof t||!t)throw new Error("Channel must be a non-empty string");if("function"!=typeof n)throw new Error("onData handler must be a function");if(void 0!==e&&"function"!=typeof e)throw new Error("ack must be a function")},t.prototype._shouldEmitToServer=function(t){return 1===this._socket.listeners("data#".concat(t)).length},t.prototype._emit=function(t,n,e){if(!this._shouldEmitToServer(n))return null==e?void 0:e();e?this._socket.emitWithAck(t,{channel:n,_current_location_href:window.top.location.href},(function(o){return o.ok?e():e(new Error("Failed to ".concat(t," to channel ").concat(n,": ").concat(o.error)))})):this._socket.emit(t,{channel:n,_current_location_href:window.top.location.href})},t}();exports.SubscriptionsClientV2=t;
|
|
2
2
|
//# sourceMappingURL=subscriptions-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"subscriptions-client.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("socket.io-client"),n=require("query-string"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("socket.io-client"),n=require("query-string"),o=require("lodash/noop");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function r(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var i=c(e),a=c(t),s=r(n),u=c(o);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function b(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){i.default(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var f=new RegExp("^/reports.*$"),d=s.parse(window.location.search).subscriptions_url||process.env.REACT_APP_SUBSCRIPTIONS_URL||"https://subscriptions.qa.corva.ai";function p(e){return f.test(window.location.pathname)?u.default:e}function v(e,t){return"".concat(e.appInstanceId||t,":").concat(e.companyId,":").concat(e.userId,":").concat(e.collection)}function w(e,t){return"".concat(e.appInstanceId||t,":").concat(e.companyId,":").concat(e.collection)}function O(e,t){return e.event?"".concat(e.appInstanceId||t,":").concat(e.provider,":").concat(e.collection,":").concat(e.assetId,":").concat(e.event):"".concat(e.appInstanceId||t,":").concat(e.provider,":").concat(e.collection,":").concat(e.assetId)}function y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"userId"in e?v(e,t):"companyId"in e?w(e,t):O(e,t)}function h(){var e,t={},n=!1,o=p((function(n){if(!e)throw new Error("Not connected");var o=y(n);o in t&&(delete t[o],e.emit("unsubscribe",b(b({},n),{},{_current_location_href:window.top.location.href})))})),c=p((function(o){if(!e)throw new Error("Not connected");var c=y(o);t[c]=o,n&&e.emit("subscribe",b(b({},o),{},{_current_location_href:window.top.location.href}))})),r=p((function(){var o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=o.onDataReceive,i=void 0===r?void 0:r,s=o.onResubscribe,u=void 0===s?void 0:s,l=!1;return(e=a.default(d,{transports:["websocket"]})).on("authenticated",(function(){n=!0,Object.values(t).forEach((function(e){c(e),l&&u&&u(e)})),l=!1})),i&&e.on("data",i),e.on("reconnect",(function(){l=!0})),e}));return{connect:r,disconnect:p((function(){e&&(e.disconnect(),e=null)})),subscribe:c,unsubscribe:o}}exports.getSubscriptionId=y,exports.getSubscriptionsClient=h,exports.initializeSocketClient=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.onDataReceive,n=e.onResubscribe,o=window[Symbol.for("socket")];null!=o&&o.socket&&(console.warn("Existing socket, disconnecting."),o.disconnect());var c=h(),r=c.connect,i=c.disconnect,a=c.subscribe,s=c.unsubscribe,u=r({onDataReceive:t,onResubscribe:n});window[Symbol.for("socket")]={subscribe:a,unsubscribe:s,disconnect:i,socket:u}};
|
|
2
2
|
//# sourceMappingURL=subscriptions.v1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.v1.js","sources":["../../../src/clients/subscriptions.v1.js"],"sourcesContent":["import io from 'socket.io-client';\nimport * as queryString from 'query-string';\nimport noop from 'lodash/noop';\n\
|
|
1
|
+
{"version":3,"file":"subscriptions.v1.js","sources":["../../../src/clients/subscriptions.v1.js"],"sourcesContent":["import io from 'socket.io-client';\nimport * as queryString from 'query-string';\nimport noop from 'lodash/noop';\n\nconst REPORTS_ROUTE_REG_EXP = new RegExp('^/reports.*$');\n\nconst parameters = queryString.parse(window.location.search);\nconst socketUrl =\n parameters.subscriptions_url ||\n process.env.REACT_APP_SUBSCRIPTIONS_URL ||\n 'https://subscriptions.qa.corva.ai';\n\nfunction reportsDisableDecorator(func) {\n // NOTE: Disable subscription events on reports pages\n return REPORTS_ROUTE_REG_EXP.test(window.location.pathname) ? noop : func;\n}\n\nfunction getUserSubscriptionId(options, hookId) {\n return `${options.appInstanceId || hookId}:${options.companyId}:${options.userId}:${\n options.collection\n }`;\n}\n\nfunction getCompanySubscriptionId(options, hookId) {\n return `${options.appInstanceId || hookId}:${options.companyId}:${options.collection}`;\n}\n\nfunction getAssetSubscriptionId(options, hookId) {\n return options.event\n ? `${options.appInstanceId || hookId}:${options.provider}:${options.collection}:${\n options.assetId\n }:${options.event}`\n : `${options.appInstanceId || hookId}:${options.provider}:${options.collection}:${\n options.assetId\n }`;\n}\n\nexport function getSubscriptionId(options, hookId = '') {\n if ('userId' in options) return getUserSubscriptionId(options, hookId);\n else if ('companyId' in options) return getCompanySubscriptionId(options, hookId);\n return getAssetSubscriptionId(options, hookId);\n}\n\nexport function getSubscriptionsClient() {\n let socket;\n\n // NOTE: Is used in order to reset subscriptions in case of network failure\n const subscriptions = {};\n let isAuthenticated = false;\n\n const unsubscribe = reportsDisableDecorator(options => {\n if (!socket) {\n throw new Error('Not connected');\n }\n const subscriptionId = getSubscriptionId(options);\n\n if (subscriptionId in subscriptions) {\n delete subscriptions[subscriptionId];\n socket.emit('unsubscribe', { ...options, _current_location_href: window.top.location.href });\n }\n });\n\n const subscribe = reportsDisableDecorator(options => {\n if (!socket) {\n throw new Error('Not connected');\n }\n\n const subscriptionId = getSubscriptionId(options);\n subscriptions[subscriptionId] = options;\n\n // NOTE: Events could be:\n // 1) 'update' - fires in case of records are updated;\n // 2) 'destroy' - fires in case or records are destroyed;\n // 3) '' (empty) - fires in case of new records are created;\n if (isAuthenticated) {\n socket.emit('subscribe', { ...options, _current_location_href: window.top.location.href });\n }\n });\n\n const connect = reportsDisableDecorator(\n ({ onDataReceive = undefined, onResubscribe = undefined } = {}) => {\n let resubscribe = false;\n\n socket = io(socketUrl, { transports: ['websocket'] });\n // TODO: Once authentication is moved on connect, move this as well\n socket.on('authenticated', () => {\n isAuthenticated = true;\n Object.values(subscriptions).forEach(subscription => {\n subscribe(subscription);\n if (resubscribe && onResubscribe) onResubscribe(subscription);\n });\n resubscribe = false;\n });\n if (onDataReceive) socket.on('data', onDataReceive);\n\n socket.on('reconnect', () => {\n resubscribe = true;\n });\n\n return socket;\n }\n );\n\n const disconnect = reportsDisableDecorator(() => {\n if (socket) {\n socket.disconnect();\n socket = null;\n }\n });\n\n return { connect, disconnect, subscribe, unsubscribe };\n}\n\nexport const initializeSocketClient = ({ onDataReceive, onResubscribe } = {}) => {\n const existingSocket = window[Symbol.for('socket')];\n if (existingSocket?.socket) {\n console.warn('Existing socket, disconnecting.');\n existingSocket.disconnect();\n }\n const { connect, disconnect, subscribe, unsubscribe } = getSubscriptionsClient();\n const socket = connect({ onDataReceive, onResubscribe });\n window[Symbol.for('socket')] = {\n subscribe,\n unsubscribe,\n disconnect,\n socket,\n };\n};\n"],"names":["REPORTS_ROUTE_REG_EXP","RegExp","socketUrl","queryString","parse","window","location","search","subscriptions_url","process","env","REACT_APP_SUBSCRIPTIONS_URL","reportsDisableDecorator","func","test","pathname","noop","getUserSubscriptionId","options","hookId","concat","appInstanceId","companyId","userId","collection","getCompanySubscriptionId","getAssetSubscriptionId","event","provider","assetId","getSubscriptionId","getSubscriptionsClient","socket","subscriptions","isAuthenticated","unsubscribe","Error","subscriptionId","emit","_current_location_href","top","href","subscribe","connect","_ref","arguments","length","undefined","_ref$onDataReceive","onDataReceive","_ref$onResubscribe","onResubscribe","resubscribe","io","transports","on","Object","values","forEach","subscription","disconnect","_ref2","existingSocket","Symbol","for","console","warn","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,OAAOC,IAAI,WAAa,CAC7BtB,UAAAA,EACAP,YAAAA,EACAyB,WAAAA,EACA5B,OAAAA,EAEJ"}
|
|
@@ -2,11 +2,4 @@ export declare const handleSubscriptionsVersion: <V1, V2>(v1: V1, v2: V2) => V1
|
|
|
2
2
|
export declare const getNamespace: () => string;
|
|
3
3
|
export declare const SUBSCRIPTIONS_URL: string;
|
|
4
4
|
export declare const IGNORED_ROUTES_REGEXP: RegExp;
|
|
5
|
-
export declare const LOGIN_ROUTES_REGEXP: RegExp;
|
|
6
|
-
/**
|
|
7
|
-
* Returns a safe href for debugging that never includes query or hash and is omitted on login routes.
|
|
8
|
-
*/
|
|
9
|
-
export declare const getHrefDebugField: () => {
|
|
10
|
-
_current_location_href?: string;
|
|
11
|
-
};
|
|
12
5
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/constants.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,0BAA0B,GAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAMhE,CAAC;AAEF,eAAO,MAAM,YAAY,cAMxB,CAAC;AAOF,eAAO,MAAM,iBAAiB,QAA4B,CAAC;AAC3D,eAAO,MAAM,qBAAqB,QAA6B,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/constants.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,0BAA0B,GAAI,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,YAMhE,CAAC;AAEF,eAAO,MAAM,YAAY,cAMxB,CAAC;AAOF,eAAO,MAAM,iBAAiB,QAA4B,CAAC;AAC3D,eAAO,MAAM,qBAAqB,QAA6B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import*as o from"query-string";import{isDevOrQAEnv as r,isBetaEnv as s}from"../../utils/env.js";var t=o.parse(window.location.search),e=r||s,i=e?"2":"1",n=t.subscriptions_version||localStorage.getItem("subscriptions_version")||i;e&&"2"!==localStorage.getItem("subscriptions_version_forced")&&(localStorage.setItem("subscriptions_version","2"),localStorage.setItem("subscriptions_version_forced","2"));var c=function(o,r){return"1"===n?o:r},a=function(){return"1"===n?"/":"/".concat(n)},p=process.env.REACT_APP_SUBSCRIPTIONS_URL||t.subscriptions_url||"https://subscriptions.qa.corva.ai",u="".concat(p).concat(a()),l=new RegExp("^/reports.*$");export{l as IGNORED_ROUTES_REGEXP,u as SUBSCRIPTIONS_URL,a as getNamespace,c as handleSubscriptionsVersion};
|
|
2
2
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Socket } from
|
|
2
|
-
import { SubcriptionsClient, SubscriptionsClientV2Events, SubscriptionsClientV2ServerEvents, AcknowledgeCb, OnDataReceive, OnConnectionChange } from
|
|
1
|
+
import { Socket } from "socket.io-client";
|
|
2
|
+
import { SubcriptionsClient, SubscriptionsClientV2Events, SubscriptionsClientV2ServerEvents, AcknowledgeCb, OnDataReceive, OnConnectionChange } from "./types";
|
|
3
3
|
export declare class SubscriptionsClientV2 implements SubcriptionsClient {
|
|
4
4
|
private readonly _socket;
|
|
5
5
|
constructor(_socket: Socket<SubscriptionsClientV2Events, SubscriptionsClientV2ServerEvents>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions-client.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/subscriptions-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"subscriptions-client.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/subscriptions-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,iCAAiC,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE/J,qBAAa,qBAAsB,YAAW,kBAAkB;IAClD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,MAAM,CAAC,2BAA2B,EAAE,iCAAiC,CAAC;IAE5G,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,aAAa;IAiB3E,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,aAAa;IAQ7E,UAAU;IAOV,kBAAkB,EAAE,CAAC,OAAO,EAAE,kBAAkB,KAAK,MAAM,IAAI,CAmB9D;IAED,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,KAAK;CAmBd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions-client.factory.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/subscriptions-client.factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,0BAA0B;WACvB,IAAI;IAQlB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAC5C,OAAO,CAAC,MAAM,CAAC,MAAM;
|
|
1
|
+
{"version":3,"file":"subscriptions-client.factory.d.ts","sourceRoot":"","sources":["../../../src/clients/subscriptions/subscriptions-client.factory.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAE7C,qBAAa,0BAA0B;WACvB,IAAI;IAQlB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAqB;IAC5C,OAAO,CAAC,MAAM,CAAC,MAAM;CAkDtB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{io as t}from"socket.io-client";import{IGNORED_ROUTES_REGEXP as n,SUBSCRIPTIONS_URL as e}from"./constants.js";import{SubscriptionsClientV2 as r}from"./subscriptions-client.js";import{DummySubscriptionsClient as i}from"./subscriptions-client.dummy.js";var o=function(){function o(){}return o.init=function(){return this.instance||(this.instance=this.create()),this.instance},o.create=function(){if(n.test(window.location.pathname))return new i;var o=t(e,{transports:["websocket"],autoConnect:!0}),c=0;return o.on("connect",(function(){(c+=1,o.recovered)||1!==c&&Object.keys(o._callbacks).filter((function(t){return t.startsWith("$data#")})).map((function(t){return t.replace("$data#","")})).forEach((function(t){o.emit("subscribe",{channel:t,_current_location_href:window.top.location.href})}))})),new r(o)},o}();export{o as SubscriptionsClientFactory};
|
|
2
2
|
//# sourceMappingURL=subscriptions-client.factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"subscriptions-client.factory.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
var t=function(){function t(t){var n=this;this._socket=t,this.onConnectionChange=function(t){var o=function(){return t({status:"connected"})},e=function(n){return t({status:"disconnected",reason:n})},r=function(){return t({status:"reconnecting"})},c=function(n){return t({status:"error",reason:(null==n?void 0:n.message)||String(n)})};return n._socket.on("connect",o),n._socket.on("disconnect",e),n._socket.on("reconnect",r),n._socket.on("connect_error",c),function(){n._socket.off("connect",o),n._socket.off("disconnect",e),n._socket.off("reconnect",r),n._socket.off("connect_error",c)}}}return t.prototype.subscribe=function(t,n,o){var e=this;this._validateArgs(t,n,o),this._socket.on("data#".concat(t),n),this._emit("subscribe",t,o);var r=function(){return e.unsubscribe(t,n,o)};return Object.defineProperty(r,"name",{value:"unsubscribe_".concat(t.replace(/[^\w]/g,"_")),writable:!1}),r},t.prototype.unsubscribe=function(t,n,o){this._validateArgs(t,n,o),this._emit("unsubscribe",t,o),this._socket.off("data#".concat(t),n)},t.prototype.disconnect=function(){return this._socket.disconnect(),this._socket.removeAllListeners(),this},t.prototype._validateArgs=function(t,n,o){if("string"!=typeof t||!t)throw new Error("Channel must be a non-empty string");if("function"!=typeof n)throw new Error("onData handler must be a function");if(void 0!==o&&"function"!=typeof o)throw new Error("ack must be a function")},t.prototype._shouldEmitToServer=function(t){return 1===this._socket.listeners("data#".concat(t)).length},t.prototype._emit=function(t,n,o){if(!this._shouldEmitToServer(n))return null==o?void 0:o();o?this._socket.emitWithAck(t,{channel:n,_current_location_href:window.top.location.href},(function(e){return e.ok?o():o(new Error("Failed to ".concat(t," to channel ").concat(n,": ").concat(e.error)))})):this._socket.emit(t,{channel:n,_current_location_href:window.top.location.href})},t}();export{t as SubscriptionsClientV2};
|
|
2
2
|
//# sourceMappingURL=subscriptions-client.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":
|
|
1
|
+
{"version":3,"file":"subscriptions-client.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.v1.d.ts","sourceRoot":"","sources":["../../src/clients/subscriptions.v1.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"subscriptions.v1.d.ts","sourceRoot":"","sources":["../../src/clients/subscriptions.v1.js"],"names":[],"mappings":"AAqCA,yEAIC;AAED;;;;;EAoEC;AAEM,oFAcN"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import n from"@babel/runtime/helpers/defineProperty";import t from"socket.io-client";import*as e from"query-string";import o from"lodash/noop";
|
|
1
|
+
import n from"@babel/runtime/helpers/defineProperty";import t from"socket.io-client";import*as e from"query-string";import o from"lodash/noop";function c(n,t){var e=Object.keys(n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(n);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),e.push.apply(e,o)}return e}function r(t){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?c(Object(o),!0).forEach((function(e){n(t,e,o[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach((function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(o,n))}))}return t}var i=new RegExp("^/reports.*$"),s=e.parse(window.location.search).subscriptions_url||process.env.REACT_APP_SUBSCRIPTIONS_URL||"https://subscriptions.qa.corva.ai";function a(n){return i.test(window.location.pathname)?o:n}function u(n,t){return"".concat(n.appInstanceId||t,":").concat(n.companyId,":").concat(n.userId,":").concat(n.collection)}function p(n,t){return"".concat(n.appInstanceId||t,":").concat(n.companyId,":").concat(n.collection)}function b(n,t){return n.event?"".concat(n.appInstanceId||t,":").concat(n.provider,":").concat(n.collection,":").concat(n.assetId,":").concat(n.event):"".concat(n.appInstanceId||t,":").concat(n.provider,":").concat(n.collection,":").concat(n.assetId)}function d(n){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"userId"in n?u(n,t):"companyId"in n?p(n,t):b(n,t)}function f(){var n,e={},o=!1,c=a((function(t){if(!n)throw new Error("Not connected");var o=d(t);o in e&&(delete e[o],n.emit("unsubscribe",r(r({},t),{},{_current_location_href:window.top.location.href})))})),i=a((function(t){if(!n)throw new Error("Not connected");var c=d(t);e[c]=t,o&&n.emit("subscribe",r(r({},t),{},{_current_location_href:window.top.location.href}))})),u=a((function(){var c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=c.onDataReceive,a=void 0===r?void 0:r,u=c.onResubscribe,p=void 0===u?void 0:u,b=!1;return(n=t(s,{transports:["websocket"]})).on("authenticated",(function(){o=!0,Object.values(e).forEach((function(n){i(n),b&&p&&p(n)})),b=!1})),a&&n.on("data",a),n.on("reconnect",(function(){b=!0})),n}));return{connect:u,disconnect:a((function(){n&&(n.disconnect(),n=null)})),subscribe:i,unsubscribe:c}}var l=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=n.onDataReceive,e=n.onResubscribe,o=window[Symbol.for("socket")];null!=o&&o.socket&&(console.warn("Existing socket, disconnecting."),o.disconnect());var c=f(),r=c.connect,i=c.disconnect,s=c.subscribe,a=c.unsubscribe,u=r({onDataReceive:t,onResubscribe:e});window[Symbol.for("socket")]={subscribe:s,unsubscribe:a,disconnect:i,socket:u}};export{d as getSubscriptionId,f as getSubscriptionsClient,l as initializeSocketClient};
|
|
2
2
|
//# sourceMappingURL=subscriptions.v1.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.v1.js","sources":["../../src/clients/subscriptions.v1.js"],"sourcesContent":["import io from 'socket.io-client';\nimport * as queryString from 'query-string';\nimport noop from 'lodash/noop';\n\
|
|
1
|
+
{"version":3,"file":"subscriptions.v1.js","sources":["../../src/clients/subscriptions.v1.js"],"sourcesContent":["import io from 'socket.io-client';\nimport * as queryString from 'query-string';\nimport noop from 'lodash/noop';\n\nconst REPORTS_ROUTE_REG_EXP = new RegExp('^/reports.*$');\n\nconst parameters = queryString.parse(window.location.search);\nconst socketUrl =\n parameters.subscriptions_url ||\n process.env.REACT_APP_SUBSCRIPTIONS_URL ||\n 'https://subscriptions.qa.corva.ai';\n\nfunction reportsDisableDecorator(func) {\n // NOTE: Disable subscription events on reports pages\n return REPORTS_ROUTE_REG_EXP.test(window.location.pathname) ? noop : func;\n}\n\nfunction getUserSubscriptionId(options, hookId) {\n return `${options.appInstanceId || hookId}:${options.companyId}:${options.userId}:${\n options.collection\n }`;\n}\n\nfunction getCompanySubscriptionId(options, hookId) {\n return `${options.appInstanceId || hookId}:${options.companyId}:${options.collection}`;\n}\n\nfunction getAssetSubscriptionId(options, hookId) {\n return options.event\n ? `${options.appInstanceId || hookId}:${options.provider}:${options.collection}:${\n options.assetId\n }:${options.event}`\n : `${options.appInstanceId || hookId}:${options.provider}:${options.collection}:${\n options.assetId\n }`;\n}\n\nexport function getSubscriptionId(options, hookId = '') {\n if ('userId' in options) return getUserSubscriptionId(options, hookId);\n else if ('companyId' in options) return getCompanySubscriptionId(options, hookId);\n return getAssetSubscriptionId(options, hookId);\n}\n\nexport function getSubscriptionsClient() {\n let socket;\n\n // NOTE: Is used in order to reset subscriptions in case of network failure\n const subscriptions = {};\n let isAuthenticated = false;\n\n const unsubscribe = reportsDisableDecorator(options => {\n if (!socket) {\n throw new Error('Not connected');\n }\n const subscriptionId = getSubscriptionId(options);\n\n if (subscriptionId in subscriptions) {\n delete subscriptions[subscriptionId];\n socket.emit('unsubscribe', { ...options, _current_location_href: window.top.location.href });\n }\n });\n\n const subscribe = reportsDisableDecorator(options => {\n if (!socket) {\n throw new Error('Not connected');\n }\n\n const subscriptionId = getSubscriptionId(options);\n subscriptions[subscriptionId] = options;\n\n // NOTE: Events could be:\n // 1) 'update' - fires in case of records are updated;\n // 2) 'destroy' - fires in case or records are destroyed;\n // 3) '' (empty) - fires in case of new records are created;\n if (isAuthenticated) {\n socket.emit('subscribe', { ...options, _current_location_href: window.top.location.href });\n }\n });\n\n const connect = reportsDisableDecorator(\n ({ onDataReceive = undefined, onResubscribe = undefined } = {}) => {\n let resubscribe = false;\n\n socket = io(socketUrl, { transports: ['websocket'] });\n // TODO: Once authentication is moved on connect, move this as well\n socket.on('authenticated', () => {\n isAuthenticated = true;\n Object.values(subscriptions).forEach(subscription => {\n subscribe(subscription);\n if (resubscribe && onResubscribe) onResubscribe(subscription);\n });\n resubscribe = false;\n });\n if (onDataReceive) socket.on('data', onDataReceive);\n\n socket.on('reconnect', () => {\n resubscribe = true;\n });\n\n return socket;\n }\n );\n\n const disconnect = reportsDisableDecorator(() => {\n if (socket) {\n socket.disconnect();\n socket = null;\n }\n });\n\n return { connect, disconnect, subscribe, unsubscribe };\n}\n\nexport const initializeSocketClient = ({ onDataReceive, onResubscribe } = {}) => {\n const existingSocket = window[Symbol.for('socket')];\n if (existingSocket?.socket) {\n console.warn('Existing socket, disconnecting.');\n existingSocket.disconnect();\n }\n const { connect, disconnect, subscribe, unsubscribe } = getSubscriptionsClient();\n const socket = connect({ onDataReceive, onResubscribe });\n window[Symbol.for('socket')] = {\n subscribe,\n unsubscribe,\n disconnect,\n socket,\n };\n};\n"],"names":["REPORTS_ROUTE_REG_EXP","RegExp","socketUrl","queryString","parse","window","location","search","subscriptions_url","process","env","REACT_APP_SUBSCRIPTIONS_URL","reportsDisableDecorator","func","test","pathname","noop","getUserSubscriptionId","options","hookId","concat","appInstanceId","companyId","userId","collection","getCompanySubscriptionId","getAssetSubscriptionId","event","provider","assetId","getSubscriptionId","getSubscriptionsClient","socket","subscriptions","isAuthenticated","unsubscribe","Error","subscriptionId","emit","_current_location_href","top","href","subscribe","connect","_ref","arguments","length","undefined","_ref$onDataReceive","onDataReceive","_ref$onResubscribe","onResubscribe","resubscribe","io","transports","on","Object","values","forEach","subscription","disconnect","initializeSocketClient","_ref2","existingSocket","Symbol","for","console","warn","_getSubscriptionsClie"],"mappings":"8sBAIA,IAAMA,EAAwB,IAAIC,OAAO,gBAGnCC,EADaC,EAAYC,MAAMC,OAAOC,SAASC,QAExCC,mBACXC,QAAQC,IAAIC,6BACZ,oCAEF,SAASC,EAAwBC,GAE/B,OAAOb,EAAsBc,KAAKT,OAAOC,SAASS,UAAYC,EAAOH,CACvE,CAEA,SAASI,EAAsBC,EAASC,GACtC,MAAA,GAAAC,OAAUF,EAAQG,eAAiBF,cAAUD,EAAQI,UAAS,KAAAF,OAAIF,EAAQK,OACxEL,KAAAA,OAAAA,EAAQM,WAEZ,CAEA,SAASC,EAAyBP,EAASC,GACzC,MAAA,GAAAC,OAAUF,EAAQG,eAAiBF,EAAM,KAAAC,OAAIF,EAAQI,UAAS,KAAAF,OAAIF,EAAQM,WAC5E,CAEA,SAASE,EAAuBR,EAASC,GACvC,OAAOD,EAAQS,gBACRT,EAAQG,eAAiBF,cAAUD,EAAQU,SAAYV,KAAAA,OAAAA,EAAQM,WAAU,KAAAJ,OAC1EF,EAAQW,oBACNX,EAAQS,OACT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