@redhat-cloud-services/types 1.0.14 → 1.0.16

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