@equinor/subsurface-app-management 4.0.1 → 4.2.0
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/dist/components/Feature/Feature.js +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useSignalRMessages.d.ts +12 -0
- package/dist/hooks/useSignalRMessages.js +1 -0
- package/dist/index.js +1 -1
- package/dist/providers/{ApplicationInsightsProvider.d.ts → ApplicationInsightsProvider/ApplicationInsightsProvider.d.ts} +2 -0
- package/dist/providers/ApplicationInsightsProvider/ApplicationInsightsProvider.js +1 -0
- package/dist/providers/ApplicationInsightsProvider/ApplicationInsightsProvider.utils.d.ts +3 -0
- package/dist/providers/ApplicationInsightsProvider/ApplicationInsightsProvider.utils.js +1 -0
- package/dist/providers/TutorialProvider/TutorialProvider.js +1 -1
- package/dist/providers/TutorialProvider/hooks/usePrefetchTutorialStepImages.js +1 -1
- package/dist/providers/index.d.ts +2 -1
- package/package.json +2 -1
- package/dist/providers/ApplicationInsightsProvider.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as o,Fragment as
|
|
1
|
+
import{jsx as o,Fragment as r}from"react/jsx-runtime";import"../../providers/FeatureToggleProvider.js";import{useFeatureToggling as e}from"../../hooks/useFeatureToggling.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import"../../api/models/TutorialPosition.js";import"../../types/Environment.js";import"../../types/ReleaseNotes.js";import"react";import"@microsoft/signalr";const t=({children:t,fallback:i,...s})=>{const{showContent:p}=e({...s});return p?o(r,{children:t}):void 0===i?null:o(r,{children:i})};export{t as Feature};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { useFeatureToggling } from './useFeatureToggling';
|
|
|
3
3
|
export { useReleaseNotesQuery } from './useReleaseNotesQuery';
|
|
4
4
|
export { useTutorialsQuery } from './useTutorialsQuery';
|
|
5
5
|
export { useTutorialStepImage } from './useTutorialStepImage';
|
|
6
|
+
export { useSignalRMessages } from './useSignalRMessages';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function useSignalRMessages<T extends {
|
|
2
|
+
SequenceNumber?: number | null;
|
|
3
|
+
Read?: boolean | null;
|
|
4
|
+
Subject?: string | null;
|
|
5
|
+
}>(topic: string): {
|
|
6
|
+
messages: T[];
|
|
7
|
+
hasUnreadMessages: boolean;
|
|
8
|
+
setMessageAsRead: (message: T) => void;
|
|
9
|
+
setAllMessagesAsRead: () => void;
|
|
10
|
+
deleteMessage: (message: T) => Promise<void>;
|
|
11
|
+
closeConnection: () => Promise<void>;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as e,useState as r,useMemo as t,useEffect as n}from"react";import*as o from"@microsoft/signalr";import{LogLevel as i}from"@microsoft/signalr";import{useQuery as s}from"@tanstack/react-query";import{getJSEmbarkToken as c}from"../api/core/OpenAPI.js";import"../api/models/ApplicationCategory.js";import"../api/models/ServiceNowUrgency.js";import"../api/models/TutorialPosition.js";import{EnvironmentType as a}from"../types/Environment.js";import{getEnvironmentName as u}from"../utils/environment.js";function m(m){const p=e(void 0),[d,l]=r([]),[f,g]=r(),[b,v]=r(),w=e(void 0),y=e(void 0),{data:S}=s({queryKey:["get-amplify-portal-token"],queryFn:()=>c()}),N=t((()=>{const e=u(import.meta.env.VITE_ENVIRONMENT_NAME);return`wss://api-amplify-portal-${e===a.LOCALHOST?a.DEVELOP:e}.radix.equinor.com`}),[]);n((()=>{(async function(){if(void 0===S||w.current===m&&y.current===S)return;void 0!==p.current&&w.current&&y.current&&(w.current!==m||y.current!==S)&&await p.current.stop(),y.current=S,w.current=m;const e=(new o.HubConnectionBuilder).configureLogging(i.Error).withUrl(`${N}/hubs/notifications`,{accessTokenFactory:()=>S,withCredentials:!1,skipNegotiation:!0,transport:o.HttpTransportType.WebSockets}).withAutomaticReconnect().build();try{await e.start(),e.on("ActiveMessages",((e,r)=>{l(r.map((r=>({...r,Subject:e}))).reverse())})),e.onreconnected((()=>e.invoke("Subscribe",m))),e.on("NewMessage",((e,r)=>{l((t=>[{...r,Subject:e},...t]))})),e.on("UpdateMessage",((e,r)=>{v({...r,Subject:e})})),e.on("Delete",((e,r)=>{g(r)})),e.on("Error",(e=>{throw new Error("Connection error: "+e)})),await e.invoke("Subscribe",m),await e.invoke("PeekMessages")}catch(e){console.error("Connection failed",e)}p.current=e})().catch((e=>{console.error("Error setting up connection",e)}))}),[N,m,S]),n((()=>{if(b){const e=d.findIndex((e=>e.SequenceNumber===b.SequenceNumber)),r=[...d];e>-1&&(r[e]=b,l(r),v(void 0))}}),[b,d]),n((()=>{if(f){const e=d.findIndex((e=>e.SequenceNumber===f)),r=[...d];e>-1&&(r.splice(e,1),l(r),g(void 0))}}),[f,d]);const E=e=>{p.current&&(e.Read=!e.Read,p.current.invoke("PatchMessage",e.SequenceNumber,e).catch((e=>{console.error("Error setting message as read",e)})))},M=t((()=>d.some((e=>!1===e.Read))),[d]);return{messages:d,hasUnreadMessages:M,setMessageAsRead:E,setAllMessagesAsRead:()=>{d.forEach((e=>{e.Read||E(e)}))},deleteMessage:async function(e){p.current&&null!==e.SequenceNumber&&(await p.current.invoke("DeleteMessage",e.SequenceNumber),g(e.SequenceNumber))},closeConnection:async()=>{if(p.current)return await p.current.stop()}}}export{m as useSignalRMessages};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Feature}from"./components/Feature/Feature.js";export{FeatureRoute}from"./components/FeatureRoute/FeatureRoute.js";export{FeatureToggleProvider,useFeatureToggleContext}from"./providers/FeatureToggleProvider.js";export{useFeatureToggling}from"./hooks/useFeatureToggling.js";export{useReleaseNotesQuery}from"./hooks/useReleaseNotesQuery.js";export{useTutorialsQuery}from"./hooks/useTutorialsQuery.js";export{useTutorialStepImage}from"./hooks/useTutorialStepImage.js";export{TutorialProvider,useTutorials}from"./providers/TutorialProvider/TutorialProvider.js";export{ApplicationInsightsProvider}from"./providers/ApplicationInsightsProvider.js";export{EnvironmentType}from"./types/Environment.js";export{RELEASENOTE_TYPES_INFORMATION,ReleaseNoteType}from"./types/ReleaseNotes.js";import*as e from"./utils/environment.js";export{e as environment};export{ApiError}from"./api/core/ApiError.js";export{CancelError,CancelablePromise}from"./api/core/CancelablePromise.js";export{OpenAPI_APP,getJSEmbarkToken,getPortalToken,getSAMToken}from"./api/core/OpenAPI.js";export{request}from"./api/core/request.js";export{ApplicationCategory}from"./api/models/ApplicationCategory.js";export{ServiceNowUrgency}from"./api/models/ServiceNowUrgency.js";export{TutorialPosition}from"./api/models/TutorialPosition.js";export{AmplifyApplicationService}from"./api/services/AmplifyApplicationService.js";export{FeatureToggleService}from"./api/services/FeatureToggleService.js";export{ImpersonateUserService}from"./api/services/ImpersonateUserService.js";export{ReleaseNotesService}from"./api/services/ReleaseNotesService.js";export{ServiceNowService}from"./api/services/ServiceNowService.js";export{SlackService}from"./api/services/SlackService.js";export{TutorialService}from"./api/services/TutorialService.js";export{GET_FEATURE_TOGGLES_FOR_APP,GET_RELEASE_NOTES,GET_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,GET_TUTORIAL_STEP_IMAGE,SAM_QUERIES}from"./constants/queryKeys.js";
|
|
1
|
+
export{Feature}from"./components/Feature/Feature.js";export{FeatureRoute}from"./components/FeatureRoute/FeatureRoute.js";export{FeatureToggleProvider,useFeatureToggleContext}from"./providers/FeatureToggleProvider.js";export{useFeatureToggling}from"./hooks/useFeatureToggling.js";export{useReleaseNotesQuery}from"./hooks/useReleaseNotesQuery.js";export{useTutorialsQuery}from"./hooks/useTutorialsQuery.js";export{useTutorialStepImage}from"./hooks/useTutorialStepImage.js";export{useSignalRMessages}from"./hooks/useSignalRMessages.js";export{TutorialProvider,useTutorials}from"./providers/TutorialProvider/TutorialProvider.js";export{ApplicationInsightsProvider}from"./providers/ApplicationInsightsProvider/ApplicationInsightsProvider.js";export{samTrackEvent,samTrackMetric}from"./providers/ApplicationInsightsProvider/ApplicationInsightsProvider.utils.js";export{EnvironmentType}from"./types/Environment.js";export{RELEASENOTE_TYPES_INFORMATION,ReleaseNoteType}from"./types/ReleaseNotes.js";import*as e from"./utils/environment.js";export{e as environment};export{ApiError}from"./api/core/ApiError.js";export{CancelError,CancelablePromise}from"./api/core/CancelablePromise.js";export{OpenAPI_APP,getJSEmbarkToken,getPortalToken,getSAMToken}from"./api/core/OpenAPI.js";export{request}from"./api/core/request.js";export{ApplicationCategory}from"./api/models/ApplicationCategory.js";export{ServiceNowUrgency}from"./api/models/ServiceNowUrgency.js";export{TutorialPosition}from"./api/models/TutorialPosition.js";export{AmplifyApplicationService}from"./api/services/AmplifyApplicationService.js";export{FeatureToggleService}from"./api/services/FeatureToggleService.js";export{ImpersonateUserService}from"./api/services/ImpersonateUserService.js";export{ReleaseNotesService}from"./api/services/ReleaseNotesService.js";export{ServiceNowService}from"./api/services/ServiceNowService.js";export{SlackService}from"./api/services/SlackService.js";export{TutorialService}from"./api/services/TutorialService.js";export{GET_FEATURE_TOGGLES_FOR_APP,GET_RELEASE_NOTES,GET_TUTORIALS_FOR_APP,GET_TUTORIALS_SAS_TOKEN,GET_TUTORIAL_STEP_IMAGE,SAM_QUERIES}from"./constants/queryKeys.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as i}from"react/jsx-runtime";import{useEffect as e}from"react";import{ClickAnalyticsPlugin as n}from"@microsoft/applicationinsights-clickanalytics-js";import{ReactPlugin as o,AppInsightsContext as t}from"@microsoft/applicationinsights-react-js";import{ApplicationInsights as s}from"@microsoft/applicationinsights-web";import{getApplicationInsightsConnectionString as r}from"../../utils/environment.js";import{l as a}from"../../_virtual/lodash.js";const d=new o,c=new n,p=12e5,m=r(import.meta.env.VITE_APPLICATION_INSIGHTS_CONNECTION_STRING),l=m?new s({config:{connectionString:m,extensions:[d,c],extensionConfig:{[c.identifier]:{autoCapture:!0,dropInvalidEvents:!0}},autoTrackPageVisitTime:!0,enableAutoRouteTracking:!0,sessionRenewalMs:p,sessionExpirationMs:p}}):void 0;l?.loadAppInsights();const w=a.debounce((()=>{l?l.trackEvent({name:"Resolution",properties:{"Window Resolution":window.innerWidth+"x"+window.innerHeight,"Screen Resolution":screen.width+"x"+screen.height}}):console.warn('[SAM]: ApplicationInsightsProvider - "appInsights" is undefined, did you set APPLICATION_INSIGHTS_CONNECTION_STRING?')}),5e3),I=({children:n})=>(e((()=>(window.addEventListener("load",w),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),window.removeEventListener("load",w)})),[]),i(t,{value:d,children:n}));export{I as ApplicationInsightsProvider,l as appInsights};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ICustomProperties, IEventTelemetry, IMetricTelemetry } from '@microsoft/applicationinsights-web';
|
|
2
|
+
export declare function samTrackEvent(event: IEventTelemetry, customProperties?: ICustomProperties): void;
|
|
3
|
+
export declare function samTrackMetric(metric: IMetricTelemetry, customProperties?: ICustomProperties): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{appInsights as i}from"./ApplicationInsightsProvider.js";function n(n,t){i?i.trackEvent(n,t):console.warn('[SAM]: ApplicationInsightsProvider - "appInsights" is undefined, did you set APPLICATION_INSIGHTS_CONNECTION_STRING?')}function t(n,t){i?i.trackMetric(n,t):console.warn('[SAM]: ApplicationInsightsProvider - "appInsights" is undefined, did you set APPLICATION_INSIGHTS_CONNECTION_STRING?')}export{n as samTrackEvent,t as samTrackMetric};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{jsx as o}from"react/jsx-runtime";import{createContext as r,useState as i,useMemo as t,useContext as e}from"react";import{useLocation as s,matchPath as n}from"react-router";import{useSeenTutorials as a}from"./useSeenTutorials.js";import"../FeatureToggleProvider.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import{useTutorialsQuery as u}from"../../hooks/useTutorialsQuery.js";import"@microsoft/signalr";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import"../../api/models/TutorialPosition.js";import"../../types/Environment.js";import{usePrefetchTutorialStepImages as l}from"./hooks/usePrefetchTutorialStepImages.js";const p=r(void 0);function d(){const o=e(p);if(void 0===o)throw new Error("'useTutorials' must be used within provider");return o}const m=({children:r})=>{const{pathname:e}=s(),{data:d=[]}=u(),[m,c]=i(void 0),[v,f]=i(void 0),[h,T]=a();l();const w=t((()=>d?.filter((o=>null!==n(o.path,e)))),[e,d]),g=t((()=>w?.filter((o=>!h.includes(o.id)&&o.willPopUp))),[h,w]);return o(p.Provider,{value:{allTutorials:d,tutorialsOnThisPage:w,unseenTutorialsOnThisPage:g,activeTutorial:m,activeStep:v,seenTutorialIDs:h,startTutorial:o=>{if(!d?.some((r=>o===r.id)))throw new Error("Tutorial not found");c(d.find((r=>o===r.id))),f(0)},skipTutorial:o=>{m&&m.id===o&&(c(void 0),f(void 0)),T(o)},goToNextStep:()=>{if(!m)throw new Error("No currently active tutorial!");if(void 0===v)throw new Error("activeStep is undefined!");v+1>=m.steps.length?(T(m.id),c(void 0),f(void 0)):f(v+1)},goToPreviousStep:()=>{if(!m)throw new Error("No currently active tutorial!");if(void 0===v)throw new Error("activeStep is undefined!");0===v?(c(void 0),f(void 0)):f(v-1)}},children:r})};export{p as TutorialDataContext,m as TutorialProvider,d as useTutorials};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useRef as r,useEffect as
|
|
1
|
+
import{useRef as r,useEffect as o}from"react";import{useQueryClient as e}from"@tanstack/react-query";import{TutorialService as t}from"../../../api/services/TutorialService.js";import{GET_TUTORIAL_STEP_IMAGE as i}from"../../../constants/queryKeys.js";import"../../FeatureToggleProvider.js";import"../../../api/core/OpenAPI.js";import{useTutorialsQuery as s}from"../../../hooks/useTutorialsQuery.js";import"@microsoft/signalr";import"../../../api/models/ApplicationCategory.js";import"../../../api/models/ServiceNowUrgency.js";import"../../../api/models/TutorialPosition.js";import"../../../types/Environment.js";function m(){const{data:m=[]}=s(),p=e(),a=r([]);o((()=>{const r=r=>{for(const o of r.steps)o.imgUrl&&p.prefetchQuery({queryKey:[i,o.imgUrl],queryFn:()=>t.getTutorialImage(o.imgUrl),staleTime:1/0,gcTime:1/0})};for(const o of m)a.current.includes(o.id)||(a.current.push(o.id),r(o))}),[p,m])}export{m as usePrefetchTutorialStepImages};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { FeatureToggleProvider } from './FeatureToggleProvider';
|
|
2
2
|
export { TutorialProvider, useTutorials, } from './TutorialProvider/TutorialProvider';
|
|
3
|
-
export { ApplicationInsightsProvider } from './ApplicationInsightsProvider';
|
|
3
|
+
export { ApplicationInsightsProvider } from './ApplicationInsightsProvider/ApplicationInsightsProvider';
|
|
4
|
+
export * from './ApplicationInsightsProvider/ApplicationInsightsProvider.utils';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/subsurface-app-management",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "React Typescript components/hooks to communicate with equinor/sam",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"@microsoft/applicationinsights-clickanalytics-js": "^3.3.6",
|
|
114
114
|
"@microsoft/applicationinsights-react-js": "^18.3.6",
|
|
115
115
|
"@microsoft/applicationinsights-web": "^3.3.6",
|
|
116
|
+
"@microsoft/signalr": "^8.0.7",
|
|
116
117
|
"jwt-decode": "^4.0.0"
|
|
117
118
|
}
|
|
118
119
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{jsx as i}from"react/jsx-runtime";import{useEffect as e}from"react";import{ClickAnalyticsPlugin as n}from"@microsoft/applicationinsights-clickanalytics-js";import{ReactPlugin as o,AppInsightsContext as t}from"@microsoft/applicationinsights-react-js";import{ApplicationInsights as s}from"@microsoft/applicationinsights-web";import{getApplicationInsightsConnectionString as r}from"../utils/environment.js";import{l as a}from"../_virtual/lodash.js";const d=new o,c=new n,p=12e5,m=r(import.meta.env.VITE_APPLICATION_INSIGHTS_CONNECTION_STRING),l=m?new s({config:{connectionString:m,extensions:[d,c],extensionConfig:{[c.identifier]:{autoCapture:!0,dropInvalidEvents:!0}},autoTrackPageVisitTime:!0,enableAutoRouteTracking:!0,sessionRenewalMs:p,sessionExpirationMs:p}}):void 0;l?.loadAppInsights();const w=a.debounce((()=>{l?l.trackEvent({name:"Resolution",properties:{"Window Resolution":window.innerWidth+"x"+window.innerHeight,"Screen Resolution":screen.width+"x"+screen.height}}):console.warn('[SAM]: ApplicationInsightsProvider - "appInsights" is undefined, did you set APPLICATION_INSIGHTS_CONNECTION_STRING?')}),5e3),I=({children:n})=>(e((()=>(window.addEventListener("load",w),window.addEventListener("resize",w),()=>{window.removeEventListener("resize",w),window.removeEventListener("load",w)})),[]),i(t,{value:d,children:n}));export{I as ApplicationInsightsProvider};
|