@redhat-cloud-services/types 0.0.4 → 0.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.
Files changed (2) hide show
  1. package/index.d.ts +39 -2
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -11,6 +11,7 @@ declare type ChromeUser = {
11
11
  };
12
12
  identity: {
13
13
  account_number: string;
14
+ org_id: string;
14
15
  internal?: {
15
16
  org_id: string;
16
17
  account_id: string;
@@ -55,6 +56,28 @@ declare type VisibilityFunctions = {
55
56
  /**
56
57
  * TODO: Once chrome is migrated to TS, sychronize with chrome typings
57
58
  */
59
+ export type NavDOMEvent = {
60
+ href: string;
61
+ id: string;
62
+ navId: string;
63
+ type: string;
64
+ target?: HTMLAnchorElement | null;
65
+ };
66
+
67
+ export type AppNavigationCB = (navEvent: { navId?: string; domEvent: NavDOMEvent }) => void;
68
+ export type GenericCB = (...args: unknown[]) => void;
69
+
70
+ export type OnEventCallbacks = {
71
+ APP_NAVIGATION: AppNavigationCB;
72
+ NAVIGATION_TOGGLE: GenericCB;
73
+ GLOBAL_FILTER_UPDATE: GenericCB;
74
+ };
75
+
76
+ declare function OnChromeEvent<K extends 'APP_NAVIGATION' | 'NAVIGATION_TOGGLE' | 'GLOBAL_FILTER_UPDATE'>(
77
+ event: K,
78
+ callback: OnEventCallbacks[K]
79
+ ): () => void;
80
+
58
81
  export interface ChromeAPI {
59
82
  /** @deprecated will be removed from useChrome hook */
60
83
  $internal: any;
@@ -127,8 +150,14 @@ export interface ChromeAPI {
127
150
  mapGlobalFilter: (...args: any[]) => any;
128
151
  /** @deprecated this function has no effect. */
129
152
  navigation: () => void;
130
- /** TODO: Deprecate this function */
131
- on: (...args: any[]) => any;
153
+ /**
154
+ * Example usage
155
+ * on<'APP_NAVIGATION'>('APP_NAVIGATION', (navEvent) => {
156
+ * navEvent.domEvent.href;
157
+ * navEvent.navId;
158
+ * });
159
+ */
160
+ on: typeof OnChromeEvent;
132
161
  registerModule: (module: string, manifest: string) => void;
133
162
  /** @duplicate of "hideGlobalFilter" TODO: deprecate this function */
134
163
  removeGlobalFilter: (isHidden: boolean) => {
@@ -140,3 +169,11 @@ export interface ChromeAPI {
140
169
  updateDocumentTitle: (title: string, noSuffix?: boolean) => void;
141
170
  visibilityFunctions: VisibilityFunctions;
142
171
  }
172
+
173
+ declare global {
174
+ interface Window {
175
+ insights: {
176
+ chrome: ChromeAPI;
177
+ };
178
+ }
179
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/types",
3
3
  "description": "TypeScript definitions for @redhat-cloud-services common typings",
4
- "version": "0.0.4",
4
+ "version": "0.0.7",
5
5
  "main": "",
6
6
  "types": "index.d.ts",
7
7
  "publishConfig": {