@equinor/subsurface-app-management 5.1.2 → 5.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.
@@ -1,5 +1,6 @@
1
1
  import type { ApiRequestOptions } from './ApiRequestOptions';
2
2
  import { CancelablePromise } from './..';
3
+ import { EnvironmentType, EnvironmentToggleFeatures } from '../../types';
3
4
  type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
4
5
  type Headers = Record<string, string>;
5
6
  export type OpenAPIConfig = {
@@ -28,5 +29,24 @@ export declare class TokenService {
28
29
  export declare const getSAMToken: () => Promise<string>;
29
30
  export declare const OpenAPI_APP: OpenAPIConfig;
30
31
  export declare const OpenAPI_SAM: OpenAPIConfig;
31
- export declare const OpenAPI_SAM_Prod: OpenAPIConfig;
32
+ interface CustomEnvironment {
33
+ environment: EnvironmentType;
34
+ token?: Resolver<string>;
35
+ }
36
+ export declare function getCustomEnvironmentConfig(feature: EnvironmentToggleFeatures): CustomEnvironment;
37
+ /**
38
+ * Determines the environment type for a given feature based on the localStorage configuration.
39
+ *
40
+ * This function checks the `ENVIRONMENT_TOGGLE_KEY` in localStorage to determine if the specified
41
+ * feature is enabled. If the feature is enabled, it returns the current environment
42
+ * name; otherwise, it returns `null`.
43
+ *
44
+ * @param {EnvironmentToggleFeatures} feature - The feature key to check in the localStorage.
45
+ *
46
+ *
47
+ * @returns {EnvironmentType | null} - The environment type for the feature if enabled, or `null` if
48
+ * the feature is not enabled or the localStorage value is invalid.
49
+ */
50
+ export declare const getFeatureEnvironment: (feature: EnvironmentToggleFeatures) => EnvironmentType | null;
51
+ export declare const getOpenAPIConfig: (feature: EnvironmentToggleFeatures) => OpenAPIConfig;
32
52
  export {};
@@ -1 +1 @@
1
- import*as o from"../../utils/environment.js";import{request as t}from"./request.js";import{getLocalStorage as e,updateLocalStorage as r}from"../../utils/localStorage.js";import{jwtDecode as E}from"jwt-decode";const{getEnvironmentName:i,getApiUrl:n}=o,a=i(import.meta.env.VITE_ENVIRONMENT_NAME),m="localhost"===a?"development":a;class S{static getSamPortalToken(){return t(s,{method:"GET",url:"/api/v1/Token/SamPortal"})}static getSamPortalProductionToken(){return t(s,{method:"GET",url:"/api/v1/Token/SamPortal/Production"})}}const d=o=>{if(0===o.length)return!1;try{return!(o=>{const t=E(o),e=(new Date).getTime()/1e3;return t.exp&&e>t.exp})(o)}catch(o){return!1}},c=async(o,t)=>{const E=e(o,"");if(d(E))return E;const i=await t();return r(o,i),i},T=async()=>c(`sam-${a}`,S.getSamPortalToken),s={BASE:n(import.meta.env.VITE_API_URL),VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0},A={BASE:`https://api-sam-backend-${m}.radix.equinor.com`,VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:T,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0},u={BASE:"https://api-sam-backend-production.radix.equinor.com",VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:async()=>c("sam-production",S.getSamPortalProductionToken),USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0};export{s as OpenAPI_APP,A as OpenAPI_SAM,u as OpenAPI_SAM_Prod,S as TokenService,T as getSAMToken};
1
+ import*as t from"../../utils/environment.js";import{request as o}from"./request.js";import{getLocalStorage as e,updateLocalStorage as n}from"../../utils/localStorage.js";import{jwtDecode as r}from"jwt-decode";import{EnvironmentType as i}from"../../types/Environment.js";import"../../types/ReleaseNotes.js";import{ENVIRONMENT_TOGGLE_KEY as a}from"../../constants/environmentToggle.js";const{getEnvironmentName:E,getApiUrl:m}=t,s=E(import.meta.env.VITE_ENVIRONMENT_NAME),c="localhost"===s?"development":s;class l{static getSamPortalToken(){return o(d,{method:"GET",url:"/api/v1/Token/SamPortal"})}static getSamPortalProductionToken(){return o(d,{method:"GET",url:"/api/v1/Token/SamPortal/Production"})}}const S=t=>{if(0===t.length)return!1;try{return!(t=>{const o=r(t),e=(new Date).getTime()/1e3;return o.exp&&e>o.exp})(t)}catch(t){return!1}},u=async(t,o)=>{const r=e(t,"");if(S(r))return r;const i=await o();return n(t,i),i},T=async()=>u(`sam-${s}`,l.getSamPortalToken),N=async()=>u("sam-production",l.getSamPortalProductionToken),d={BASE:m(import.meta.env.VITE_API_URL),VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:void 0,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0},v={BASE:`https://api-sam-backend-${c}.radix.equinor.com`,VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:T,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0};function p(t){const o=A(t);return o===i.LOCALHOST?{environment:i.DEVELOP,token:T}:o&&o!==i.PRODUCTION?{environment:o,token:T}:{environment:i.PRODUCTION,token:N}}const A=t=>{const o=localStorage.getItem(a);if(!o)return null;try{const e=JSON.parse(o);return e.some((o=>o.value===t))?E(import.meta.env.VITE_ENVIRONMENT_NAME):null}catch(t){return console.error("Failed to parse environment toggle value from localStorage:",t),null}},R=t=>{const o=p(t);return{BASE:`https://api-sam-backend-${o.environment}.radix.equinor.com`,VERSION:"1.0",WITH_CREDENTIALS:!1,CREDENTIALS:"include",TOKEN:o.token,USERNAME:void 0,PASSWORD:void 0,HEADERS:void 0,ENCODE_PATH:void 0}};export{d as OpenAPI_APP,v as OpenAPI_SAM,l as TokenService,p as getCustomEnvironmentConfig,A as getFeatureEnvironment,R as getOpenAPIConfig,T as getSAMToken};
@@ -1 +1 @@
1
- import{OpenAPI_SAM_Prod as a}from"../core/OpenAPI.js";import{request as t}from"../core/request.js";class e{static getCategoriesWithFaqsFromApplicationName(e){return t(a,{method:"GET",url:"/api/v1/Faq/faqcategorieswithfaqs/{applicationName}",path:{applicationName:e}})}static getFaqImage(e){return t(a,{method:"GET",url:"/api/v1/Faq/getfaqimage/{path}",path:{path:e},errors:{404:"Not Found"}})}static getFaqCategoriesFromApplicationId(e){return t(a,{method:"GET",url:"/api/v1/Faq/faqcategories/{applicationId}",path:{applicationId:e}})}static getFaqsFromCategoryId(e){return t(a,{method:"GET",url:"/api/v1/Faq/faqs/{categoryId}",path:{categoryId:e}})}static getFaqById(e){return t(a,{method:"GET",url:"/api/v1/Faq/faq/{id}",path:{id:e}})}}export{e as FaqService};
1
+ import{getOpenAPIConfig as t}from"../core/OpenAPI.js";import{request as a}from"../core/request.js";import{EnvironmentToggleFeatures as e}from"../../types/Environment.js";import"../../types/ReleaseNotes.js";class r{static getCategoriesWithFaqsFromApplicationName(r){return a(t(e.FAQ),{method:"GET",url:"/api/v1/Faq/faqcategorieswithfaqs/{applicationName}",path:{applicationName:r}})}static getFaqImage(r){return a(t(e.FAQ),{method:"GET",url:"/api/v1/Faq/getfaqimage/{path}",path:{path:r},errors:{404:"Not Found"}})}static getFaqCategoriesFromApplicationId(r){return a(t(e.FAQ),{method:"GET",url:"/api/v1/Faq/faqcategories/{applicationId}",path:{applicationId:r}})}static getFaqsFromCategoryId(r){return a(t(e.FAQ),{method:"GET",url:"/api/v1/Faq/faqs/{categoryId}",path:{categoryId:r}})}static getFaqById(r){return a(t(e.FAQ),{method:"GET",url:"/api/v1/Faq/faq/{id}",path:{id:r}})}}export{r as FaqService};
@@ -1 +1 @@
1
- import{OpenAPI_SAM_Prod as r}from"../core/OpenAPI.js";import{request as e}from"../core/request.js";class t{static getMyFeatures(t,o){return e(r,{method:"GET",url:"/api/v1/FeatureToggle/{applicationName}/{currentEnvironment}/myfeatures",path:{applicationName:t,currentEnvironment:o},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}}export{t as FeatureToggleService};
1
+ import{getOpenAPIConfig as e}from"../core/OpenAPI.js";import{request as r}from"../core/request.js";import{EnvironmentToggleFeatures as t}from"../../types/Environment.js";import"../../types/ReleaseNotes.js";class o{static getMyFeatures(o,n){return r(e(t.FEATURE_TOGGLE),{method:"GET",url:"/api/v1/FeatureToggle/{applicationName}/{currentEnvironment}/myfeatures",path:{applicationName:o,currentEnvironment:n},errors:{400:"Bad Request",404:"Not Found",500:"Internal Server Error"}})}}export{o as FeatureToggleService};
@@ -1 +1 @@
1
- import{OpenAPI_SAM_Prod as e}from"../core/OpenAPI.js";import{request as r}from"../core/request.js";class t{static getApiV1ImpersonateUser(){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser",errors:{400:"Bad Request",500:"Server Error"}})}static createImpersonateUser(t){return r(e,{method:"POST",url:"/api/v1/ImpersonateUser",body:t,mediaType:"application/json-patch+json",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static putImpersonateUser(t){return r(e,{method:"PUT",url:"/api/v1/ImpersonateUser",body:t,mediaType:"application/json-patch+json",errors:{400:"Bad Request"}})}static getApiV1ImpersonateUserGetImpersonateUserForApp(t){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/GetImpersonateUserForApp/{appName}",path:{appName:t},errors:{400:"Bad Request",500:"Server Error"}})}static getAllActiveUsers(){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/ActiveUsers",errors:{400:"Bad Request",500:"Server Error"}})}static getActiveUser(){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/ActiveUser",errors:{400:"Bad Request",500:"Server Error"}})}static getImpersonateUserById(t){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/ImpersonateUser",query:{id:t},errors:{400:"Bad Request",500:"Server Error"}})}static getImpersonateUserByUserName(t){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/ImpersonateUserByUserName",query:{username:t},errors:{400:"Bad Request",500:"Server Error"}})}static canImpersonate(){return r(e,{method:"GET",url:"/api/v1/ImpersonateUser/CanImpersonate",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static startImpersonating(t){return r(e,{method:"PUT",url:"/api/v1/ImpersonateUser/StartImpersonating",query:{username:t},errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static stopImpersonating(){return r(e,{method:"PUT",url:"/api/v1/ImpersonateUser/StopImpersonating",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static deleteImpersonationUser(t){return r(e,{method:"DELETE",url:"/api/v1/ImpersonateUser/DeleteImpersonationUser",query:{impersonationUserId:t},errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}}export{t as ImpersonateUserService};
1
+ import{getOpenAPIConfig as e}from"../core/OpenAPI.js";import{request as r}from"../core/request.js";import{EnvironmentToggleFeatures as t}from"../../types/Environment.js";import"../../types/ReleaseNotes.js";class s{static getApiV1ImpersonateUser(){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser",errors:{400:"Bad Request",500:"Server Error"}})}static createImpersonateUser(s){return r(e(t.IMPERSONATE_USER),{method:"POST",url:"/api/v1/ImpersonateUser",body:s,mediaType:"application/json-patch+json",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static putImpersonateUser(s){return r(e(t.IMPERSONATE_USER),{method:"PUT",url:"/api/v1/ImpersonateUser",body:s,mediaType:"application/json-patch+json",errors:{400:"Bad Request"}})}static getApiV1ImpersonateUserGetImpersonateUserForApp(s){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/GetImpersonateUserForApp/{appName}",path:{appName:s},errors:{400:"Bad Request",500:"Server Error"}})}static getAllActiveUsers(){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/ActiveUsers",errors:{400:"Bad Request",500:"Server Error"}})}static getActiveUser(){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/ActiveUser",errors:{400:"Bad Request",500:"Server Error"}})}static getImpersonateUserById(s){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/ImpersonateUser",query:{id:s},errors:{400:"Bad Request",500:"Server Error"}})}static getImpersonateUserByUserName(s){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/ImpersonateUserByUserName",query:{username:s},errors:{400:"Bad Request",500:"Server Error"}})}static canImpersonate(){return r(e(t.IMPERSONATE_USER),{method:"GET",url:"/api/v1/ImpersonateUser/CanImpersonate",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static startImpersonating(s){return r(e(t.IMPERSONATE_USER),{method:"PUT",url:"/api/v1/ImpersonateUser/StartImpersonating",query:{username:s},errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static stopImpersonating(){return r(e(t.IMPERSONATE_USER),{method:"PUT",url:"/api/v1/ImpersonateUser/StopImpersonating",errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}static deleteImpersonationUser(s){return r(e(t.IMPERSONATE_USER),{method:"DELETE",url:"/api/v1/ImpersonateUser/DeleteImpersonationUser",query:{impersonationUserId:s},errors:{400:"Bad Request",404:"Not Found",500:"Server Error"}})}}export{s as ImpersonateUserService};
@@ -1 +1 @@
1
- import{OpenAPI_SAM_Prod as t}from"../core/OpenAPI.js";import{request as a}from"../core/request.js";class r{static getMyTutorialsForApplication(r,i=!0){return a(t,{method:"GET",url:"/api/v1/Tutorial/me/{includeDrafts}",path:{includeDrafts:i},query:{applicationName:r}})}static getDraftTutorialsForApplication(r){return a(t,{method:"GET",url:"/api/v1/Tutorial/draft/{applicationName}",path:{applicationName:r}})}static getTutorialImage(r){return a(t,{method:"GET",url:"/api/v1/Tutorial/gettutorialimage/{path}",path:{path:r},errors:{404:"Not Found"}})}}export{r as TutorialService};
1
+ import{getOpenAPIConfig as t}from"../core/OpenAPI.js";import{request as r}from"../core/request.js";import{EnvironmentToggleFeatures as a}from"../../types/Environment.js";import"../../types/ReleaseNotes.js";class e{static getMyTutorialsForApplication(e,o=!0){return r(t(a.TUTORIAL),{method:"GET",url:"/api/v1/Tutorial/me/{includeDrafts}",path:{includeDrafts:o},query:{applicationName:e}})}static getDraftTutorialsForApplication(e){return r(t(a.TUTORIAL),{method:"GET",url:"/api/v1/Tutorial/draft/{applicationName}",path:{applicationName:e}})}static getTutorialImage(e){return r(t(a.TUTORIAL),{method:"GET",url:"/api/v1/Tutorial/gettutorialimage/{path}",path:{path:e},errors:{404:"Not Found"}})}}export{e as TutorialService};
@@ -0,0 +1 @@
1
+ export declare const ENVIRONMENT_TOGGLE_KEY = "env-toggle-key";
@@ -0,0 +1 @@
1
+ const e="env-toggle-key";export{e as ENVIRONMENT_TOGGLE_KEY};
@@ -1 +1,2 @@
1
1
  export * from './queryKeys';
2
+ export * from './environmentToggle';
@@ -1 +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 s}from"@microsoft/signalr";import{useQuery as i}from"@tanstack/react-query";import{getSAMToken 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 d=e(void 0),[p,l]=r([]),[g,f]=r(),[b,v]=r(),w=e(void 0),S=e(void 0),{data:N}=i({queryKey:["get-sam-token"],queryFn:()=>c()}),y=t((()=>{const e=u(import.meta.env.VITE_ENVIRONMENT_NAME);return`wss://api-sam-backend-${e===a.LOCALHOST?a.DEVELOP:e}.radix.equinor.com`}),[]);n((()=>{(async function(){if(void 0===N||w.current===m&&S.current===N)return;void 0!==d.current&&w.current&&S.current&&(w.current!==m||S.current!==N)&&await d.current.stop(),S.current=N,w.current=m;const e=(new o.HubConnectionBuilder).configureLogging(s.Error).withUrl(`${y}/hubs/notifications`,{accessTokenFactory:()=>N,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)=>{f(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)}d.current=e})().catch((e=>{console.error("Error setting up connection",e)}))}),[y,m,N]),n((()=>{if(b){const e=p.findIndex((e=>e.SequenceNumber===b.SequenceNumber)),r=[...p];e>-1&&(r[e]=b,l(r),v(void 0))}}),[b,p]),n((()=>{if(g){const e=p.findIndex((e=>e.SequenceNumber===g)),r=[...p];e>-1&&(r.splice(e,1),l(r),f(void 0))}}),[g,p]);const E=e=>{d.current&&(e.Read=!e.Read,d.current.invoke("PatchMessage",e.SequenceNumber,e).catch((e=>{console.error("Error setting message as read",e)})))},k=t((()=>p.some((e=>!1===e.Read))),[p]);return{messages:p,hasUnreadMessages:k,setMessageAsRead:E,setAllMessagesAsRead:()=>{p.forEach((e=>{e.Read||E(e)}))},deleteMessage:async function(e){d.current&&null!==e.SequenceNumber&&(await d.current.invoke("DeleteMessage",e.SequenceNumber),f(e.SequenceNumber))},closeConnection:async()=>{if(d.current)return await d.current.stop()}}}export{m as useSignalRMessages};
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 s}from"@microsoft/signalr";import{useQuery as i}from"@tanstack/react-query";import{getSAMToken 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"../types/ReleaseNotes.js";import{getEnvironmentName as u}from"../utils/environment.js";function m(m){const p=e(void 0),[d,l]=r([]),[g,f]=r(),[b,v]=r(),w=e(void 0),N=e(void 0),{data:S}=i({queryKey:["get-sam-token"],queryFn:()=>c()}),y=t((()=>{const e=u(import.meta.env.VITE_ENVIRONMENT_NAME);return`wss://api-sam-backend-${e===a.LOCALHOST?a.DEVELOP:e}.radix.equinor.com`}),[]);n((()=>{(async function(){if(void 0===S||w.current===m&&N.current===S)return;void 0!==p.current&&w.current&&N.current&&(w.current!==m||N.current!==S)&&await p.current.stop(),N.current=S,w.current=m;const e=(new o.HubConnectionBuilder).configureLogging(s.Error).withUrl(`${y}/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)=>{f(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)}))}),[y,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(g){const e=d.findIndex((e=>e.SequenceNumber===g)),r=[...d];e>-1&&(r.splice(e,1),l(r),f(void 0))}}),[g,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)})))},k=t((()=>d.some((e=>!1===e.Read))),[d]);return{messages:d,hasUnreadMessages:k,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),f(e.SequenceNumber))},closeConnection:async()=>{if(p.current)return await p.current.stop()}}}export{m as useSignalRMessages};
@@ -1,6 +1,6 @@
1
1
  export declare function useTutorialsQuery(): import("@tanstack/react-query").UseQueryResult<{
2
2
  id: string;
3
- steps: import("../api").StepDto[];
3
+ steps: import("../types").StepDto[];
4
4
  tutorialDraftId?: string | null;
5
5
  isInteractive?: boolean | null;
6
6
  name: string;
@@ -1 +1 @@
1
- import{useQuery as r}from"@tanstack/react-query";import"../api/core/OpenAPI.js";import"../api/models/ApplicationCategory.js";import"../api/models/ServiceNowUrgency.js";import"../api/models/TutorialPosition.js";import{TutorialService as t}from"../api/services/TutorialService.js";import{GET_TUTORIALS_FOR_APP as e}from"../constants/queryKeys.js";import{EnvironmentType as o}from"../types/Environment.js";import"../types/ReleaseNotes.js";import{getEnvironmentName as i,getAppName as s}from"../utils/environment.js";function p(){return r({queryKey:[e],queryFn:async()=>{if(i(import.meta.env.VITE_ENVIRONMENT_NAME)===o.PRODUCTION){return(await t.getMyTutorialsForApplication(s(import.meta.env.VITE_NAME),!1)).map((r=>({...r,id:r.tutorialDraftId?r.tutorialDraftId:r.id,steps:r.steps.sort(((r,t)=>(r.orderBy??0)-(t.orderBy??0)))})))}return(await t.getDraftTutorialsForApplication(s(import.meta.env.VITE_NAME))).map((r=>({...r,steps:r.steps.sort(((r,t)=>(r.orderBy??0)-(t.orderBy??0)))})))}})}export{p as useTutorialsQuery};
1
+ import{useQuery as r}from"@tanstack/react-query";import"../api/core/OpenAPI.js";import"../api/models/ApplicationCategory.js";import"../api/models/ServiceNowUrgency.js";import"../api/models/TutorialPosition.js";import{EnvironmentType as t}from"../types/Environment.js";import"../types/ReleaseNotes.js";import{TutorialService as e}from"../api/services/TutorialService.js";import{GET_TUTORIALS_FOR_APP as o}from"../constants/queryKeys.js";import{getEnvironmentName as i,getAppName as s}from"../utils/environment.js";function p(){return r({queryKey:[o],queryFn:async()=>{if(i(import.meta.env.VITE_ENVIRONMENT_NAME)===t.PRODUCTION){return(await e.getMyTutorialsForApplication(s(import.meta.env.VITE_NAME),!1)).map((r=>({...r,id:r.tutorialDraftId?r.tutorialDraftId:r.id,steps:r.steps.sort(((r,t)=>(r.orderBy??0)-(t.orderBy??0)))})))}return(await e.getDraftTutorialsForApplication(s(import.meta.env.VITE_NAME))).map((r=>({...r,steps:r.steps.sort(((r,t)=>(r.orderBy??0)-(t.orderBy??0)))})))}})}export{p as useTutorialsQuery};
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{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,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{FaqService}from"./api/services/FaqService.js";export{AppAnalyticsService}from"./api/services/AppAnalyticsService.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{EnvironmentToggleFeatures,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,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{FaqService}from"./api/services/FaqService.js";export{AppAnalyticsService}from"./api/services/AppAnalyticsService.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";export{ENVIRONMENT_TOGGLE_KEY}from"./constants/environmentToggle.js";
@@ -1 +1 @@
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{useMatchRoute as s}from"@tanstack/react-router";import{useSeenTutorials as a}from"./useSeenTutorials.js";import"../FeatureToggleProvider.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import{useTutorialsQuery as n}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 u}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 l=({children:r})=>{const{data:e=[]}=n(),[d,l]=i(void 0),[c,m]=i(void 0),[v,f]=a();u();const T=s(),h=e?.filter((o=>!!T({to:o.path}))),w=t((()=>h?.filter((o=>!v.includes(o.id)&&o.willPopUp))),[v,h]);return o(p.Provider,{value:{allTutorials:e,tutorialsOnThisPage:h,unseenTutorialsOnThisPage:w,activeTutorial:d,activeStep:c,seenTutorialIDs:v,startTutorial:o=>{if(!e?.some((r=>o===r.id)))throw new Error("Tutorial not found");l(e.find((r=>o===r.id))),m(0)},skipTutorial:o=>{d&&d.id===o&&(l(void 0),m(void 0)),f(o)},goToNextStep:()=>{if(!d)throw new Error("No currently active tutorial!");if(void 0===c)throw new Error("activeStep is undefined!");c+1>=d.steps.length?(f(d.id),l(void 0),m(void 0)):m(c+1)},goToPreviousStep:()=>{if(!d)throw new Error("No currently active tutorial!");if(void 0===c)throw new Error("activeStep is undefined!");0===c?(l(void 0),m(void 0)):m(c-1)}},children:r})};export{p as TutorialDataContext,l as TutorialProvider,d as useTutorials};
1
+ import{jsx as o}from"react/jsx-runtime";import{createContext as r,useState as t,useMemo as i,useContext as e}from"react";import{useMatchRoute as s}from"@tanstack/react-router";import{useSeenTutorials as a}from"./useSeenTutorials.js";import"../FeatureToggleProvider.js";import"@tanstack/react-query";import"../../api/core/OpenAPI.js";import{useTutorialsQuery as n}from"../../hooks/useTutorialsQuery.js";import"../../types/Environment.js";import"../../types/ReleaseNotes.js";import"@microsoft/signalr";import"../../api/models/ApplicationCategory.js";import"../../api/models/ServiceNowUrgency.js";import"../../api/models/TutorialPosition.js";import{usePrefetchTutorialStepImages as u}from"./hooks/usePrefetchTutorialStepImages.js";const p=r(void 0);function l(){const o=e(p);if(void 0===o)throw new Error("'useTutorials' must be used within provider");return o}const d=({children:r})=>{const{data:e=[]}=n(),[l,d]=t(void 0),[m,c]=t(void 0),[v,f]=a();u();const T=s(),h=e?.filter((o=>!!T({to:o.path}))),w=i((()=>h?.filter((o=>!v.includes(o.id)&&o.willPopUp))),[v,h]);return o(p.Provider,{value:{allTutorials:e,tutorialsOnThisPage:h,unseenTutorialsOnThisPage:w,activeTutorial:l,activeStep:m,seenTutorialIDs:v,startTutorial:o=>{if(!e?.some((r=>o===r.id)))throw new Error("Tutorial not found");d(e.find((r=>o===r.id))),c(0)},skipTutorial:o=>{l&&l.id===o&&(d(void 0),c(void 0)),f(o)},goToNextStep:()=>{if(!l)throw new Error("No currently active tutorial!");if(void 0===m)throw new Error("activeStep is undefined!");m+1>=l.steps.length?(f(l.id),d(void 0),c(void 0)):c(m+1)},goToPreviousStep:()=>{if(!l)throw new Error("No currently active tutorial!");if(void 0===m)throw new Error("activeStep is undefined!");0===m?(d(void 0),c(void 0)):c(m-1)}},children:r})};export{p as TutorialDataContext,d as TutorialProvider,l as useTutorials};
@@ -1 +1 @@
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
+ 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";import"../../../types/ReleaseNotes.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};
@@ -4,3 +4,9 @@ export declare enum EnvironmentType {
4
4
  STAGING = "staging",
5
5
  PRODUCTION = "production"
6
6
  }
7
+ export declare enum EnvironmentToggleFeatures {
8
+ FEATURE_TOGGLE = "feature-toggle",
9
+ TUTORIAL = "tutorial",
10
+ IMPERSONATE_USER = "impersonate-user",
11
+ FAQ = "faq"
12
+ }
@@ -1 +1 @@
1
- var o;!function(o){o.LOCALHOST="localhost",o.DEVELOP="development",o.STAGING="staging",o.PRODUCTION="production"}(o||(o={}));export{o as EnvironmentType};
1
+ var t,o;!function(t){t.LOCALHOST="localhost",t.DEVELOP="development",t.STAGING="staging",t.PRODUCTION="production"}(t||(t={})),function(t){t.FEATURE_TOGGLE="feature-toggle",t.TUTORIAL="tutorial",t.IMPERSONATE_USER="impersonate-user",t.FAQ="faq"}(o||(o={}));export{o as EnvironmentToggleFeatures,t as EnvironmentType};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/subsurface-app-management",
3
- "version": "5.1.2",
3
+ "version": "5.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",