@redhat-cloud-services/types 1.0.12 → 1.0.14-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/index.d.ts CHANGED
@@ -3,271 +3,248 @@ import { History } from 'history';
3
3
  import { Access } from '@redhat-cloud-services/rbac-client';
4
4
  import { AnalyticsBrowser } from '@segment/analytics-next';
5
5
  import { Method } from 'axios';
6
-
6
+ import type { AxiosRequestConfig } from 'axios';
7
7
  export declare type HelpTopicLink = {
8
- href: string;
9
- text?: string;
10
- newTab?: boolean;
11
- isExternal?: boolean;
8
+ href: string;
9
+ text?: string;
10
+ newTab?: boolean;
11
+ isExternal?: boolean;
12
12
  };
13
-
14
13
  export declare type HelpTopic = {
15
- name: string;
16
- title: string;
17
- tags: string[];
18
- content: string;
19
- links?: HelpTopicLink[];
14
+ name: string;
15
+ title: string;
16
+ tags: string[];
17
+ content: string;
18
+ links?: HelpTopicLink[];
20
19
  };
21
-
22
20
  export declare type PDFRequestPayload = {
23
- manifestLocation: string;
24
- scope: string;
25
- module: string;
26
- importName?: string;
27
- fetchDataParams?: Record<string, any>;
21
+ manifestLocation: string;
22
+ scope: string;
23
+ module: string;
24
+ importName?: string;
25
+ fetchDataParams?: Record<string, any>;
28
26
  };
29
-
30
27
  export declare type PDFRequestOptions = {
31
- payload: PDFRequestPayload;
32
- filename?: string;
28
+ payload: PDFRequestPayload;
29
+ filename?: string;
30
+ };
31
+ type CreateAxiosRequest<T = any> = (service: string, config: AxiosRequestConfig) => Promise<T>;
32
+ export type FetchData = (createAsyncRequest: CreateAxiosRequest) => Promise<any>;
33
+ export type AsyncState<T = any> = {
34
+ data: T;
33
35
  };
34
-
35
36
  declare type ChromeUser = {
36
- entitlements: {
37
- [key: string]: {
38
- is_entitled: boolean;
39
- is_trial: boolean;
40
- };
41
- };
42
- identity: {
43
- account_number?: string;
44
- org_id: string;
45
- internal?: {
46
- org_id: string;
47
- account_id: string;
37
+ entitlements: {
38
+ [key: string]: {
39
+ is_entitled: boolean;
40
+ is_trial: boolean;
41
+ };
48
42
  };
49
- type: string;
50
- user?: {
51
- username: string;
52
- email: string;
53
- first_name: string;
54
- last_name: string;
55
- is_active: boolean;
56
- is_internal: boolean;
57
- is_org_admin: boolean;
58
- locale: string;
43
+ identity: {
44
+ account_number?: string;
45
+ org_id: string;
46
+ internal?: {
47
+ org_id: string;
48
+ account_id: string;
49
+ };
50
+ type: string;
51
+ user?: {
52
+ username: string;
53
+ email: string;
54
+ first_name: string;
55
+ last_name: string;
56
+ is_active: boolean;
57
+ is_internal: boolean;
58
+ is_org_admin: boolean;
59
+ locale: string;
60
+ };
59
61
  };
60
- };
61
62
  };
62
-
63
63
  export declare type VisibilityFunctions = {
64
- isOrgAdmin: () => Promise<boolean>;
65
- isActive: () => Promise<boolean>;
66
- isInternal: () => Promise<boolean>;
67
- isEntitled: (appName?: string) => Promise<{ [key: string]: boolean }>;
68
- isProd: () => boolean;
69
- isBeta: () => boolean;
70
- isHidden: () => true;
71
- withEmail: (toHave: string) => Promise<boolean>;
72
- loosePermissions: (permissions: string[]) => Promise<boolean>;
73
- hasPermissions: (permissions: string[]) => Promise<boolean>;
74
- hasLocalStorage: (key: string, value: any) => boolean;
75
- hasCookie: (key: string, value: any) => boolean;
76
- /** TODO: Extends FEC axios instance config */
77
- apiRequest: (config: {
78
- [key: string]: any;
79
- url: string;
80
- method?: Method;
81
- accessor?: string;
82
- matcher?: 'isEmpty' | 'isNotEmpty';
83
- }) => Promise<boolean>;
84
- featureFlag: (flagName: string, expectedValue: boolean) => boolean;
64
+ isOrgAdmin: () => Promise<boolean>;
65
+ isActive: () => Promise<boolean>;
66
+ isInternal: () => Promise<boolean>;
67
+ isEntitled: (appName?: string) => Promise<{
68
+ [key: string]: boolean;
69
+ }>;
70
+ isProd: () => boolean;
71
+ isBeta: () => boolean;
72
+ isHidden: () => true;
73
+ withEmail: (toHave: string) => Promise<boolean>;
74
+ loosePermissions: (permissions: string[]) => Promise<boolean>;
75
+ hasPermissions: (permissions: string[]) => Promise<boolean>;
76
+ hasLocalStorage: (key: string, value: any) => boolean;
77
+ hasCookie: (key: string, value: any) => boolean;
78
+ apiRequest: (config: {
79
+ [key: string]: any;
80
+ url: string;
81
+ method?: Method;
82
+ accessor?: string;
83
+ matcher?: 'isEmpty' | 'isNotEmpty';
84
+ }) => Promise<boolean>;
85
+ featureFlag: (flagName: string, expectedValue: boolean) => boolean;
85
86
  };
86
-
87
- /**
88
- * TODO: Once chrome is migrated to TS, sychronize with chrome typings
89
- */
90
87
  export type NavDOMEvent = {
91
- href: string;
92
- id: string;
93
- navId: string;
94
- type: string;
95
- target?: HTMLAnchorElement | null;
88
+ href: string;
89
+ id: string;
90
+ navId: string;
91
+ type: string;
92
+ target?: HTMLAnchorElement | null;
96
93
  };
97
-
98
- export type AppNavigationCB = (navEvent: { navId?: string; domEvent: NavDOMEvent }) => void;
94
+ export type AppNavigationCB = (navEvent: {
95
+ navId?: string;
96
+ domEvent: NavDOMEvent;
97
+ }) => void;
99
98
  export type GenericCB = (...args: unknown[]) => void;
100
-
101
99
  export type OnEventCallbacks = {
102
- APP_NAVIGATION: AppNavigationCB;
103
- NAVIGATION_TOGGLE: GenericCB;
104
- GLOBAL_FILTER_UPDATE: GenericCB;
100
+ APP_NAVIGATION: AppNavigationCB;
101
+ NAVIGATION_TOGGLE: GenericCB;
102
+ GLOBAL_FILTER_UPDATE: GenericCB;
105
103
  };
106
-
107
- declare function OnChromeEvent<K extends 'APP_NAVIGATION' | 'NAVIGATION_TOGGLE' | 'GLOBAL_FILTER_UPDATE'>(
108
- event: K,
109
- callback: OnEventCallbacks[K]
110
- ): undefined | (() => void) | (() => undefined) | (() => boolean);
111
-
112
- export type EnableTopicsArgs = [{ names: string[]; append?: boolean }] | string[];
113
-
104
+ declare function OnChromeEvent<K extends 'APP_NAVIGATION' | 'NAVIGATION_TOGGLE' | 'GLOBAL_FILTER_UPDATE'>(event: K, callback: OnEventCallbacks[K]): undefined | (() => void) | (() => undefined) | (() => boolean);
105
+ export type EnableTopicsArgs = [{
106
+ names: string[];
107
+ append?: boolean;
108
+ }] | string[];
114
109
  export type ChromeWsEventTypes = 'com.redhat.console.notifications.drawer';
115
110
  export type ChromeWsPayload<T> = {
116
- data: T;
117
- type: ChromeWsEventTypes;
118
- source: string;
119
- datacontenttype: string;
120
- specversion: string;
121
- time: string;
111
+ data: T;
112
+ type: ChromeWsEventTypes;
113
+ source: string;
114
+ datacontenttype: string;
115
+ specversion: string;
116
+ time: string;
122
117
  };
123
118
  export type ChromeWsEventListener<T> = (event: ChromeWsPayload<T>) => void;
124
119
  export type UnSubscribeFromChromeWsEvent = () => void;
125
120
  export type AddChromeWsEventListener = <T>(type: ChromeWsEventTypes, listener: ChromeWsEventListener<T>) => UnSubscribeFromChromeWsEvent;
126
-
127
121
  export interface ChromeAPI {
128
- /** @deprecated will be removed from useChrome hook */
129
- $internal: any;
130
- addWsEventListener: AddChromeWsEventListener;
131
- initialized: boolean;
132
- experimentalApi: boolean;
133
- /** Return true if current environment is fedramp */
134
- isFedramp: boolean;
135
- usePendoFeedback: () => void;
136
- toggleFeedbackModal: (isOpen: boolean) => void;
137
- toggleDebuggerModal: (isOpen: boolean) => void;
138
- enableDebugging: () => void;
139
- quickStarts: {
140
- version: number;
141
- set: (key: string, quickstarts: QuickStart[]) => void;
142
- toggle: (quickstartId: string) => void;
143
- Catalog: typeof QuickStartCatalogPage;
144
- activateQuickstart: (name: string) => Promise<void>;
145
- };
146
- chromeHistory: History;
147
- isProd: () => boolean;
148
- appAction: (action: string) => void;
149
- appNavClick: (payload: any) => void;
150
- appObjectId: (objectId: string) => void;
151
- auth: {
152
- doOffline?: () => void;
153
- getOfflineToken: () => Promise<any>;
154
- getRefreshToken: () => Promise<string>;
155
- getToken: () => Promise<string | undefined>;
156
- getUser: () => Promise<ChromeUser | void>;
157
- login: () => Promise<any>;
158
- logout: () => void;
159
- /** @deprecated will be removed from useChrome hook */
160
- qe: any;
161
- reAuthWithScopes: (...scopes: string[]) => Promise<void>;
162
- };
163
- createCase: (fields: Record<string, unknown>) => void;
164
- enable: {
165
- iqe: () => void;
166
- remediationsDebug: () => void;
167
- invTags: () => void;
168
- shortSession: () => void;
169
- jwtDebug: () => void;
170
- reduxDebug: () => void;
171
- forcePendo: () => void;
172
- allDetails: () => void;
173
- inventoryDrawer: () => void;
174
- globalFilter: () => void;
175
- appFilter: () => void;
176
- contextSwitcher: () => void;
177
- quickstartsDebug: () => void;
178
- };
179
- forceDemo: () => void;
180
- getApp: () => string;
181
- getBundle: () => string;
182
- getBundleData: () => {
183
- bundleId: string;
184
- bundleTitle: string;
185
- };
186
- getEnvironment: () => string;
187
- getEnvironmentDetails: () =>
188
- | undefined
189
- | {
122
+ $internal: any;
123
+ addWsEventListener: AddChromeWsEventListener;
124
+ initialized: boolean;
125
+ experimentalApi: boolean;
126
+ isFedramp: boolean;
127
+ usePendoFeedback: () => void;
128
+ toggleFeedbackModal: (isOpen: boolean) => void;
129
+ toggleDebuggerModal: (isOpen: boolean) => void;
130
+ enableDebugging: () => void;
131
+ quickStarts: {
132
+ version: number;
133
+ set: (key: string, quickstarts: QuickStart[]) => void;
134
+ toggle: (quickstartId: string) => void;
135
+ Catalog: typeof QuickStartCatalogPage;
136
+ activateQuickstart: (name: string) => Promise<void>;
137
+ };
138
+ chromeHistory: History;
139
+ isProd: () => boolean;
140
+ appAction: (action: string) => void;
141
+ appNavClick: (payload: any) => void;
142
+ appObjectId: (objectId: string) => void;
143
+ auth: {
144
+ doOffline?: () => void;
145
+ getOfflineToken: () => Promise<any>;
146
+ getRefreshToken: () => Promise<string>;
147
+ getToken: () => Promise<string | undefined>;
148
+ getUser: () => Promise<ChromeUser | void>;
149
+ login: () => Promise<any>;
150
+ logout: () => void;
151
+ qe: any;
152
+ reAuthWithScopes: (...scopes: string[]) => Promise<void>;
153
+ };
154
+ createCase: (fields: Record<string, unknown>) => void;
155
+ enable: {
156
+ iqe: () => void;
157
+ remediationsDebug: () => void;
158
+ invTags: () => void;
159
+ shortSession: () => void;
160
+ jwtDebug: () => void;
161
+ reduxDebug: () => void;
162
+ forcePendo: () => void;
163
+ allDetails: () => void;
164
+ inventoryDrawer: () => void;
165
+ globalFilter: () => void;
166
+ appFilter: () => void;
167
+ contextSwitcher: () => void;
168
+ quickstartsDebug: () => void;
169
+ };
170
+ forceDemo: () => void;
171
+ getApp: () => string;
172
+ getBundle: () => string;
173
+ getBundleData: () => {
174
+ bundleId: string;
175
+ bundleTitle: string;
176
+ };
177
+ getEnvironment: () => string;
178
+ getEnvironmentDetails: () => undefined | {
190
179
  url: string[];
191
180
  sso: string;
192
181
  portal: string;
193
- };
194
- getUserPermissions: (applicationName?: string, disableCache?: boolean) => Promise<Access[]>;
195
- globalFilterScope: (scope: string) => {
196
- type: string;
197
- payload: string;
198
- };
199
- getAvailableBundles: () => { id: string; title: string }[];
200
- helpTopics: {
201
- addHelpTopics: (topics: HelpTopic[], enabled?: boolean) => void;
202
- enableTopics: (...topicsNames: EnableTopicsArgs) => Promise<HelpTopic[]>;
203
- disableTopics: (...topicsNames: string[]) => void;
204
- setActiveTopic: (name: string) => Promise<void>;
205
- closeHelpTopic: () => void;
206
- };
207
- hideGlobalFilter: (isHidden: boolean) => void;
208
- /** @deprecated This function server no purpse. For document title update use "updateDocumentTitle" function instead. */
209
- identifyApp: (data: any, appTitle?: string, noSuffix?: boolean) => Promise<any>;
210
- /** @deprecated this function has no effect */
211
- init: () => void;
212
- isBeta: () => boolean;
213
- isChrome2: boolean;
214
- isDemo: () => boolean;
215
- isPenTest: () => boolean;
216
- /** TODO: create function typings */
217
- mapGlobalFilter: (...args: any[]) => any;
218
- /** @deprecated this function has no effect. */
219
- navigation: () => void;
220
- /**
221
- * Example usage
222
- * on<'APP_NAVIGATION'>('APP_NAVIGATION', (navEvent) => {
223
- * navEvent.domEvent.href;
224
- * navEvent.navId;
225
- * });
226
- */
227
- on: typeof OnChromeEvent;
228
- registerModule: (module: string, manifest: string) => void;
229
- /** @duplicate of "hideGlobalFilter" TODO: deprecate this function */
230
- removeGlobalFilter: (isHidden: boolean) => {
231
- type: string;
232
- payload: {
233
- isHidden: boolean;
234
182
  };
235
- };
236
- updateDocumentTitle: (title: string, noSuffix?: boolean) => void;
237
- visibilityFunctions: VisibilityFunctions;
238
- isAnsibleTrialFlagActive: () => boolean | undefined;
239
- setAnsibleTrialFlag: () => void;
240
- clearAnsibleTrialFlag: () => void;
241
- // segment API
242
- segment: {
243
- setPageMetadata: (pageOptions?: Record<string, unknown>) => void;
244
- };
245
- analytics: AnalyticsBrowser;
246
- useGlobalFilter: <T = undefined>(
247
- callback: (selectedTags?: {
248
- [key: string]: {
183
+ getUserPermissions: (applicationName?: string, disableCache?: boolean) => Promise<Access[]>;
184
+ globalFilterScope: (scope: string) => {
185
+ type: string;
186
+ payload: string;
187
+ };
188
+ getAvailableBundles: () => {
189
+ id: string;
190
+ title: string;
191
+ }[];
192
+ helpTopics: {
193
+ addHelpTopics: (topics: HelpTopic[], enabled?: boolean) => void;
194
+ enableTopics: (...topicsNames: EnableTopicsArgs) => Promise<HelpTopic[]>;
195
+ disableTopics: (...topicsNames: string[]) => void;
196
+ setActiveTopic: (name: string) => Promise<void>;
197
+ closeHelpTopic: () => void;
198
+ };
199
+ hideGlobalFilter: (isHidden: boolean) => void;
200
+ identifyApp: (data: any, appTitle?: string, noSuffix?: boolean) => Promise<any>;
201
+ init: () => void;
202
+ isBeta: () => boolean;
203
+ isChrome2: boolean;
204
+ isDemo: () => boolean;
205
+ isPenTest: () => boolean;
206
+ mapGlobalFilter: (...args: any[]) => any;
207
+ navigation: () => void;
208
+ on: typeof OnChromeEvent;
209
+ registerModule: (module: string, manifest: string) => void;
210
+ removeGlobalFilter: (isHidden: boolean) => {
211
+ type: string;
212
+ payload: {
213
+ isHidden: boolean;
214
+ };
215
+ };
216
+ updateDocumentTitle: (title: string, noSuffix?: boolean) => void;
217
+ visibilityFunctions: VisibilityFunctions;
218
+ isAnsibleTrialFlagActive: () => boolean | undefined;
219
+ setAnsibleTrialFlag: () => void;
220
+ clearAnsibleTrialFlag: () => void;
221
+ segment: {
222
+ setPageMetadata: (pageOptions?: Record<string, unknown>) => void;
223
+ };
224
+ analytics: AnalyticsBrowser;
225
+ useGlobalFilter: <T = undefined>(callback: (selectedTags?: {
249
226
  [key: string]: {
250
- isSelected?: boolean;
251
- value: string;
252
- item?: {
253
- tagKey?: string;
254
- tagValue?: string;
255
- };
256
- group?: {
257
- items?: unknown;
258
- };
227
+ [key: string]: {
228
+ isSelected?: boolean;
229
+ value: string;
230
+ item?: {
231
+ tagKey?: string;
232
+ tagValue?: string;
233
+ };
234
+ group?: {
235
+ items?: unknown;
236
+ };
237
+ };
259
238
  };
260
- };
261
- }) => T
262
- ) => T;
263
- enablePackagesDebug: () => void;
264
- requestPdf: (options: PDFRequestOptions) => Promise<void>;
239
+ }) => T) => T;
240
+ enablePackagesDebug: () => void;
241
+ requestPdf: (options: PDFRequestOptions) => Promise<void>;
265
242
  }
266
-
267
243
  declare global {
268
- interface Window {
269
- insights: {
270
- chrome: ChromeAPI;
271
- };
272
- }
244
+ interface Window {
245
+ insights: {
246
+ chrome: ChromeAPI;
247
+ };
248
+ }
273
249
  }
250
+ export {};
package/index.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/types/index.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,25 +1,26 @@
1
1
  {
2
- "name": "@redhat-cloud-services/types",
3
- "description": "TypeScript definitions for @redhat-cloud-services common typings",
4
- "version": "1.0.12",
5
- "main": "",
6
- "types": "index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/RedHatInsights/frontend-components.git",
13
- "directory": "packages/types"
14
- },
15
- "scripts": {},
16
- "devDependencies": {
17
- "@patternfly/quickstarts": "^5.0.0",
18
- "@redhat-cloud-services/rbac-client": "^1.0.111 || 2.x",
19
- "history": "^4.10.1",
20
- "glob": "10.3.3",
21
- "@segment/analytics-next": "^1.43.2"
22
- },
23
- "author": "",
24
- "license": "Apache-2.0"
2
+ "name": "@redhat-cloud-services/types",
3
+ "description": "TypeScript definitions for @redhat-cloud-services common typings",
4
+ "version": "1.0.14-0",
5
+ "main": "index.d.ts",
6
+ "types": "index.d.ts",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/RedHatInsights/frontend-components.git",
13
+ "directory": "packages/types"
14
+ },
15
+ "scripts": {},
16
+ "devDependencies": {
17
+ "@patternfly/quickstarts": "^5.0.0",
18
+ "@redhat-cloud-services/rbac-client": "^1.0.111 || 2.x",
19
+ "history": "^4.10.1",
20
+ "glob": "10.3.3",
21
+ "@segment/analytics-next": "^1.43.2"
22
+ },
23
+ "author": "",
24
+ "license": "Apache-2.0",
25
+ "type": "commonjs"
25
26
  }
package/tsconfig.json DELETED
@@ -1,18 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "lib": [
5
- "es6"
6
- ],
7
- "noImplicitAny": false,
8
- "noImplicitThis": true,
9
- "strictNullChecks": true,
10
- "strictFunctionTypes": true,
11
- "types": [],
12
- "noEmit": true,
13
- "forceConsistentCasingInFileNames": true
14
- },
15
- "files": [
16
- "index.d.ts",
17
- ]
18
- }