@adobe/exc-app 0.2.46 → 1.0.1

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 (101) hide show
  1. package/RuntimeConfiguration.d.ts +4 -0
  2. package/appapi.d.ts +1 -1
  3. package/appapi.js +1 -1
  4. package/appapi.js.map +1 -1
  5. package/build/preBuild.js +14 -0
  6. package/capabilityapi.d.ts +4 -2
  7. package/capabilityapi.js +4 -2
  8. package/capabilityapi.js.map +1 -1
  9. package/docs/README.md +1 -0
  10. package/docs/enums/appapi.appids.md +21 -7
  11. package/docs/enums/capabilityapi.capabilityids.md +28 -0
  12. package/docs/enums/capabilityapi.capabilitynames.md +28 -0
  13. package/docs/enums/network.routing.md +21 -1
  14. package/docs/interfaces/ims.activeproductcontext.md +13 -0
  15. package/docs/interfaces/ims.imsprofile.md +130 -0
  16. package/docs/interfaces/ims.productcontext.md +141 -0
  17. package/docs/interfaces/ims.projectedproductcontext.md +21 -0
  18. package/docs/interfaces/network.queryrequest.md +20 -0
  19. package/docs/interfaces/root.poller.md +56 -0
  20. package/docs/interfaces/root.pollerhandle.md +21 -0
  21. package/docs/interfaces/root.pollingconfiguration.md +28 -0
  22. package/docs/interfaces/root.runtimeconfiguration.md +10 -1
  23. package/docs/interfaces/root.useractivityemitter.md +110 -0
  24. package/docs/interfaces/root.useractivitymonitor.md +151 -0
  25. package/docs/interfaces/user.userapi.md +1 -1
  26. package/docs/modules/ims.md +14 -0
  27. package/docs/modules/network.md +7 -0
  28. package/docs/modules/root.md +5 -0
  29. package/docs/modules/settings.md +8 -57
  30. package/docs/modules/user.md +14 -0
  31. package/index.js +7 -0
  32. package/index.js.map +1 -1
  33. package/internal.d.ts +9 -0
  34. package/internal.js +3 -0
  35. package/internal.js.map +1 -1
  36. package/network.d.ts +17 -1
  37. package/network.js +11 -0
  38. package/network.js.map +1 -1
  39. package/package.json +6 -7
  40. package/src/Global.d.ts +3 -1
  41. package/src/Global.js.map +1 -1
  42. package/tests/index.test.js +5 -0
  43. package/tests/index.test.js.map +1 -1
  44. package/tests/version.test.d.ts +1 -0
  45. package/tests/version.test.js +23 -0
  46. package/tests/version.test.js.map +1 -0
  47. package/{settings/SettingsLevel.ts → version.d.ts} +2 -20
  48. package/{metrics/Level.ts → version.js} +6 -20
  49. package/version.js.map +1 -0
  50. package/RuntimeConfiguration.ts +0 -272
  51. package/appapi.ts +0 -140
  52. package/capabilityapi.ts +0 -162
  53. package/coverage/lcov-report/block-navigation.js +0 -79
  54. package/coverage/lcov-report/prettify.js +0 -2
  55. package/coverage/lcov-report/sorter.js +0 -170
  56. package/helpcenter.ts +0 -253
  57. package/ims/ImsProfile.ts +0 -57
  58. package/index.ts +0 -76
  59. package/internal.ts +0 -102
  60. package/metrics/Analytics.ts +0 -55
  61. package/metrics/Application.ts +0 -24
  62. package/metrics/Configuration.ts +0 -33
  63. package/metrics/Events.ts +0 -28
  64. package/metrics/History.ts +0 -36
  65. package/metrics/Metric.ts +0 -52
  66. package/metrics/Metrics.ts +0 -129
  67. package/metrics/RecordType.ts +0 -139
  68. package/metrics/User.ts +0 -30
  69. package/metrics.ts +0 -94
  70. package/network.ts +0 -554
  71. package/nps.ts +0 -83
  72. package/orgswitcher.ts +0 -109
  73. package/page.ts +0 -497
  74. package/permissions.ts +0 -103
  75. package/pulse.ts +0 -198
  76. package/session.ts +0 -116
  77. package/settings.ts +0 -147
  78. package/shell.ts +0 -107
  79. package/sidebar.ts +0 -208
  80. package/sidenav.ts +0 -287
  81. package/src/EventEmitter.ts +0 -44
  82. package/src/Global.ts +0 -109
  83. package/src/Runtime.ts +0 -23
  84. package/tests/MockRuntime.ts +0 -28
  85. package/tests/appapi.test.ts +0 -78
  86. package/tests/capabilityapi.test.ts +0 -55
  87. package/tests/helpCenter.test.ts +0 -80
  88. package/tests/index.test.ts +0 -50
  89. package/tests/metrics.test.ts +0 -34
  90. package/tests/nps.test.ts +0 -37
  91. package/tests/page.test.ts +0 -110
  92. package/tests/permissions.test.ts +0 -96
  93. package/tests/pulse.test.ts +0 -37
  94. package/tests/shell.test.ts +0 -89
  95. package/tests/sidenav.test.ts +0 -91
  96. package/tests/topbar.test.ts +0 -85
  97. package/tests/user.test.ts +0 -129
  98. package/tests/userprofile.test.ts +0 -31
  99. package/topbar.ts +0 -288
  100. package/user.ts +0 -235
  101. package/userprofile.ts +0 -93
package/sidebar.ts DELETED
@@ -1,208 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
-
12
- /**
13
- * APIs that let solutions interact with the Sidebar nav.
14
- *
15
- * ***Import:***
16
- *
17
- * ```typescript
18
- * import sidebar from '@adobe/exc-app/sidebar';
19
- * ```
20
- *
21
- * ***Default export:***
22
- *
23
- * [SidebarApi](../interfaces/sidebar.sidebarapi.md#interface-sidebarapi)
24
- *
25
- * ***Usage:***
26
- *
27
- * ```typescript
28
- * sidebar.config = {
29
- * menu: [
30
- * {absolutePath: true, id: 'home', name: 'Home', url: '/home'},
31
- * {id: 'example', name: 'Example', url: '/'},
32
- * {id: 'journeys', name: 'Journeys', url: '/journeys'},
33
- * {
34
- * heading: 'STORAGE',
35
- * items: [
36
- * {id: 'external', name: 'External', target: '_blank', url: 'https://adobe.com'}
37
- * ]
38
- * },
39
- * {
40
- * heading: 'DOCUMENTS',
41
- * items: [
42
- * {children: [{id: 'child1', name: 'Child 1'}, {id: 'child2', name: 'Child 2'}], id: '2', name: 'Item 2'}
43
- * ]
44
- * }
45
- * ],
46
- * settings: {
47
- * typeToSelect: true,
48
- * variant: 'multiLevel'
49
- * }
50
- * };
51
- *
52
- * sidebar.visible = false;
53
- * ```
54
- * @packageDocumentation
55
- * @module sidebar
56
- */
57
-
58
- import {connect} from './src/Global';
59
-
60
- export interface NavItem {
61
- /**
62
- * Whether the path is absolute or relative to the base path.
63
- */
64
- absolutePath?: boolean;
65
- /**
66
- * Nested children Sidebar nav items
67
- */
68
- children?: NavItem[];
69
- /**
70
- * Whether or not to expand children by default.
71
- */
72
- defaultExpanded?: boolean;
73
- /**
74
- * Whether or not to disable the nav item.
75
- */
76
- disabled?: boolean;
77
- /**
78
- * ID of the Sidebar nav item.
79
- */
80
- id: string;
81
- /**
82
- * The label and display name of the Sidebar nav item.
83
- */
84
- name: string;
85
- /**
86
- * Where to open external URL e.g., '_self' or '_blank' for same tab or new tab.
87
- */
88
- target: string;
89
- /**
90
- * A string url the user is taken to when this item is clicked.
91
- */
92
- url?: string;
93
- }
94
-
95
- export interface NavSettings {
96
- /**
97
- * ID of the Sidebar nav.
98
- * */
99
- id: string;
100
- /**
101
- * Whether or not to enable type to select.
102
- */
103
- typeToSelect?: boolean;
104
- /**
105
- * Type and style of Sidebar nav.
106
- */
107
- variant?: 'default' | 'multiLevel';
108
- }
109
-
110
- export interface NavConfig {
111
- /**
112
- * List of nav item objects.
113
- */
114
- menu: NavItem[];
115
- /**
116
- * Extra Sidebar nav options and configurations.
117
- */
118
- settings?: NavSettings;
119
- }
120
-
121
- /**
122
- * @deprecated APIs that let solutions interact with Sidebar nav.
123
- * This is now deprecated in favor of the sidenav api.
124
- * Remove this once all solutions have been transitioned to sidenav.
125
- */
126
- export interface SidebarApi {
127
- /**
128
- * Configuration to add headings, items, and other settings to the Sidebar nav.
129
- *
130
- * ***Example:***
131
- *
132
- * ```typescript
133
- * sidebar.config = {
134
- * menu: [
135
- * {absolutePath: true, id: 'home', name: 'Home', url: '/home'},
136
- * {id: 'example', name: 'Example', url: '/'},
137
- * {id: 'journeys', name: 'Journeys', url: '/journeys'},
138
- * {
139
- * heading: 'STORAGE',
140
- * items: [
141
- * {id: 'external', name: 'External', target: '_blank', url: 'https://adobe.com'}
142
- * ]
143
- * },
144
- * {
145
- * heading: 'DOCUMENTS',
146
- * items: [
147
- * {children: [{id: 'child1', name: 'Child 1'}, {id: 'child2', name: 'Child 2'}], id: '2', name: 'Item 2'}
148
- * ]
149
- * }
150
- * ],
151
- * settings: {
152
- * typeToSelect: true,
153
- * variant: 'multiLevel'
154
- * }
155
- * };
156
- * ```
157
- *
158
- * Options:
159
- * * menu: List of nav items and headers and their nested (children) nav items to add to the Sidebar nav. There are two types:
160
- * * Heading Nav Item
161
- * * heading: The heading name. This string needs to be translated using the locale shell provides.
162
- * * items: The list of nav items that belong under the heading. Each nav items should have the below properties
163
- * * Regular Nav Item
164
- * * id: Unique id and value of the nav item.
165
- * * name: The nav item's label and display name. This string needs to be translated using the locale shell provides.
166
- * * children: (optional) List of children nav item objects nested under the current nav item.
167
- * * defaultExpanded: (optional) Whether or not this item's children are expanded and shown by default.
168
- * * disabled: (optional) Whether or not this item is disabled.
169
- * * target: (optional) Where to open external URL e.g., '_self' or '_blank' for same tab or new tab.
170
- * * url: A string url the user is taken to when this item is clicked.
171
- * * absolutePath: Whether the path is absolute or relative to the base path.
172
- * * settings: Optional object of additional settings for the Sidebar nav.
173
- * * id: Unique id and value of the sidebar nav.
174
- * * typeToSelect: Whether to enable typing to select an item.
175
- * * variant: Can be one of two values: default or multiLevel. If there is nested children, use multiLevel.
176
- */
177
- config: NavConfig;
178
-
179
- /**
180
- * Whether the Sidebar nav should start out as collapsed or not.
181
- *
182
- * ***Example:***
183
- *
184
- * ```typescript
185
- * sidebar.collapsed = true;
186
- * ```
187
- */
188
- collapsed: boolean;
189
-
190
- /**
191
- * Whether the Sidebar nav should currently be visible or not.
192
- *
193
- * ***Example:***
194
- *
195
- * ```typescript
196
- * sidebar.visible = false;
197
- * ```
198
- */
199
- visible: boolean;
200
- }
201
-
202
- const sidebar = connect('sidebar', [
203
- ['config'],
204
- ['collapsed'],
205
- ['visible']
206
- ]);
207
-
208
- export default sidebar;
package/sidenav.ts DELETED
@@ -1,287 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
-
12
- /**
13
- * APIs that let solutions interact with the Sidenav nav.
14
- *
15
- * ***Import:***
16
- *
17
- * ```typescript
18
- * import sidenav from '@adobe/exc-app/sidenav';
19
- * ```
20
- *
21
- * ***Default export:***
22
- *
23
- * [SidenavApi](../interfaces/sidenav.sidenavapi.md#interface-sidenavapi)
24
- *
25
- * ***Usage:***
26
- *
27
- * ```typescript
28
- * sidenav.config = {
29
- * menu: [
30
- * {absolutePath: true, id: 'home', name: 'Home', url: '/home'},
31
- * {id: 'example', name: 'Example', url: '/'},
32
- * {id: 'journeys', name: 'Journeys', url: '/journeys'},
33
- * {
34
- * heading: 'STORAGE',
35
- * items: [
36
- * {id: 'external', name: 'External', target: '_blank', url: 'https://adobe.com'}
37
- * ]
38
- * },
39
- * {
40
- * heading: 'DOCUMENTS',
41
- * items: [
42
- * {children: [{id: 'child1', name: 'Child 1'}, {id: 'child2', name: 'Child 2'}], id: '2', name: 'Item 2'}
43
- * ]
44
- * }
45
- * ],
46
- * settings: {
47
- * typeToSelect: true,
48
- * variant: 'multiLevel'
49
- * }
50
- * };
51
- *
52
- * sidenav.visible = false;
53
- * sidenav.collapsed = true;
54
- *
55
- * console.log(sidenav.visible);
56
- * console.log(sidenav.collapsed);
57
- * ```
58
- *
59
- * ### Receiving updates
60
- *
61
- * You can also listen for updates on the requested data by listening to specific change events.
62
- *
63
- * These change events are emitted from the api that the data is requested from. For example, if a
64
- * user calls `await sidenav.get('shellSideNavCollapsed');` they must listen for the change event on
65
- * `user.on('change:shellSideNavCollapsed')`. Here is a more detailed example of how the promise
66
- * api and change events can be used to keep track of specific values from the config:
67
- *
68
- * ```typescript
69
- * import sidenav from '@adobe/exc-app/sidenav';
70
- *
71
- * constructor() {
72
- * this.state = {shellSideNavCollapsed: false};
73
- *
74
- * sidenav.on('change:shellSideNavCollapsed', (shellSideNavCollapsed) => {
75
- * this.setState({shellSideNavCollapsed});
76
- * });
77
- * }
78
- *
79
- * async componentDidMount() {
80
- * const shellSideNavCollapsed = await user.get('shellSideNavCollapsed');
81
- * this.setState({shellSideNavCollapsed});
82
- * }
83
- * ```
84
- * @packageDocumentation
85
- * @module sidenav
86
- */
87
-
88
- import EventEmitter from './src/EventEmitter';
89
- import {getImpl} from './src/Global';
90
-
91
- export interface NavItem {
92
- /**
93
- * Whether the path is absolute or relative to the base path.
94
- */
95
- absolutePath?: boolean;
96
- /**
97
- * Nested children Sidenav nav items
98
- */
99
- children?: NavItem[];
100
- /**
101
- * Whether or not to expand children by default.
102
- */
103
- defaultExpanded?: boolean;
104
- /**
105
- * Whether or not to disable the nav item.
106
- */
107
- disabled?: boolean;
108
- /**
109
- * ID of the Sidenav nav item.
110
- */
111
- id: string;
112
- /**
113
- * The label and display name of the Sidenav nav item.
114
- */
115
- name: string;
116
- /**
117
- * Where to open external URL e.g., '_self' or '_blank' for same tab or new tab.
118
- */
119
- target: string;
120
- /**
121
- * A string url the user is taken to when this item is clicked.
122
- */
123
- url?: string;
124
- }
125
-
126
- export interface NavSettings {
127
- /**
128
- * ID of the Sidenav nav.
129
- * */
130
- id: string;
131
- /**
132
- * Whether or not to enable type to select.
133
- */
134
- typeToSelect?: boolean;
135
- /**
136
- * Type and style of Sidenav nav.
137
- */
138
- variant?: 'default' | 'multiLevel';
139
- }
140
-
141
- export interface NavConfig {
142
- /**
143
- * List of nav item objects.
144
- */
145
- menu: NavItem[];
146
- /**
147
- * Extra Sidenav nav options and configurations.
148
- */
149
- settings?: NavSettings;
150
- }
151
-
152
- export interface SidenavInfo {
153
- shellSideNavCollapsed: boolean;
154
- }
155
-
156
- interface SidenavInfoEvent {
157
- 'change:shellSideNavCollapsed': boolean;
158
- }
159
-
160
- /**
161
- * APIs that let solutions interact with Sidenav nav.
162
- */
163
- export interface SidenavApi extends EventEmitter<SidenavInfoEvent> {
164
- /**
165
- * Configuration to add headings, items, and other settings to the Sidenav nav.
166
- *
167
- * ***Example:***
168
- *
169
- * ```typescript
170
- * sidenav.config = {
171
- * menu: [
172
- * {absolutePath: true, id: 'home', name: 'Home', url: '/home'},
173
- * {id: 'example', name: 'Example', url: '/'},
174
- * {id: 'journeys', name: 'Journeys', url: '/journeys'},
175
- * {
176
- * heading: 'STORAGE',
177
- * items: [
178
- * {id: 'external', name: 'External', target: '_blank', url: 'https://adobe.com'}
179
- * ]
180
- * },
181
- * {
182
- * heading: 'DOCUMENTS',
183
- * items: [
184
- * {children: [{id: 'child1', name: 'Child 1'}, {id: 'child2', name: 'Child 2'}], id: '2', name: 'Item 2'}
185
- * ]
186
- * }
187
- * ],
188
- * settings: {
189
- * typeToSelect: true,
190
- * variant: 'multiLevel'
191
- * }
192
- * };
193
- * ```
194
- *
195
- * Options:
196
- * * menu: List of nav items and headers and their nested (children) nav items to add to the Sidenav nav. There are two types:
197
- * * Heading Nav Item
198
- * * heading: The heading name. This string needs to be translated using the locale shell provides.
199
- * * items: The list of nav items that belong under the heading. Each nav items should have the below properties
200
- * * Regular Nav Item
201
- * * id: Unique id and value of the nav item.
202
- * * name: The nav item's label and display name. This string needs to be translated using the locale shell provides.
203
- * * children: (optional) List of children nav item objects nested under the current nav item.
204
- * * defaultExpanded: (optional) Whether or not this item's children are expanded and shown by default.
205
- * * disabled: (optional) Whether or not this item is disabled.
206
- * * target: (optional) Where to open external URL e.g., '_self' or '_blank' for same tab or new tab.
207
- * * url: A string url the user is taken to when this item is clicked.
208
- * * absolutePath: Whether the path is absolute or relative to the base path.
209
- * * settings: Optional object of additional settings for the Sidenav nav.
210
- * * id: Unique id and value of the sidenav nav.
211
- * * typeToSelect: Whether to enable typing to select an item.
212
- * * variant: Can be one of two values: default or multiLevel. If there is nested children, use multiLevel.
213
- */
214
- config?: NavConfig;
215
-
216
- /**
217
- * Whether the Sidenav nav should start out as collapsed or not.
218
- *
219
- * ***Example:***
220
- *
221
- * ```typescript
222
- * sidenav.collapsed = true;
223
- * ```
224
- */
225
- collapsed?: boolean;
226
-
227
- /**
228
- * Gets the specified type of information about the sidenav.
229
- * @param type The type of information to get.
230
- */
231
- get<T extends keyof SidenavInfo>(type: T): Promise<SidenavInfo[T]>;
232
-
233
- /**
234
- * Whether the Sidenav nav should currently be visible or not.
235
- *
236
- * ***Example:***
237
- *
238
- * ```typescript
239
- * sidenav.visible = false;
240
- * ```
241
- */
242
- visible?: boolean;
243
- }
244
-
245
- const sidenav = {
246
- emit: (type, evt) => {
247
- return getImpl('sidenav')().emit(type, evt);
248
- },
249
- get: params => {
250
- return getImpl('sidenav')().get(params);
251
- },
252
- off: (type, handler) => {
253
- return getImpl('sidenav')().off(type, handler);
254
- },
255
- on: (type, handler) => {
256
- return getImpl('sidenav')().on(type, handler);
257
- }
258
- } as SidenavApi;
259
-
260
- Object.defineProperty(sidenav, 'config', {
261
- get: (): NavConfig | undefined => {
262
- return getImpl('sidenav')().config;
263
- },
264
- set: (value: NavConfig | undefined) => {
265
- getImpl('sidenav')().config = value;
266
- }
267
- });
268
-
269
- Object.defineProperty(sidenav, 'collapsed', {
270
- get: (): boolean | undefined => {
271
- return getImpl('sidenav')().collapsed;
272
- },
273
- set: (value: boolean) => {
274
- getImpl('sidenav')().collapsed = value;
275
- }
276
- });
277
-
278
- Object.defineProperty(sidenav, 'visible', {
279
- get: (): boolean | undefined => {
280
- return getImpl('sidenav')().visible;
281
- },
282
- set: (value: boolean) => {
283
- getImpl('sidenav')().visible = value;
284
- }
285
- });
286
-
287
- export default sidenav;
@@ -1,44 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
-
12
- /**
13
- * @packageDocumentation
14
- * @module "index"
15
- */
16
-
17
- /**
18
- * @ignore
19
- */
20
- export default interface EventEmitter<T = Record<string, any>> {
21
- /**
22
- * Register an event handler for the given type.
23
- * @param type Type of event to listen for.
24
- * @param handler Function to call in response to given event.
25
- * @category EventEmitter
26
- */
27
- on<K extends keyof T>(type: K, handler: (event?: T[K]) => void): void;
28
-
29
- /**
30
- * Remove an event handler for the given type.
31
- * @param type Type of event to unregister `handler` from.
32
- * @param handler Handler function to remove.
33
- * @category EventEmitter
34
- */
35
- off<K extends keyof T>(type: K, handler: (event?: T[K]) => void): void;
36
-
37
- /**
38
- * Invoke all handlers for the given type.
39
- * @param type The event type to invoke.
40
- * @param event Any value (object is recommended and powerful), passed to each handler.
41
- * @category EventEmitter
42
- */
43
- emit<K extends keyof T>(type: K, event?: T[K]): void;
44
- }
package/src/Global.ts DELETED
@@ -1,109 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
-
12
- /**
13
- * @packageDocumentation
14
- * @module "index"
15
- */
16
- import {AppApi} from '../appapi';
17
- import {CapabilityApi} from '../capabilityapi';
18
- import {HelpCenterApi} from '../helpcenter';
19
- import {InternalApi} from '../internal';
20
- import {MetricsApi} from '../metrics';
21
- import {NetworkApi} from '../network';
22
- import {Nps} from '../nps';
23
- import {OrgSwitcherApi} from '../orgswitcher';
24
- import {PageApi} from '../page';
25
- import {PermissionsApi} from '../permissions';
26
- import {PulseApi} from '../pulse';
27
- import Runtime from './Runtime';
28
- import {SessionApi} from '../session';
29
- import {SettingsApi} from '../settings';
30
- import {ShellApi} from '../shell';
31
- import {SidebarApi} from '../sidebar';
32
- import {SidenavApi} from '../sidenav';
33
- import {TopbarApi} from '../topbar';
34
- import {UserApi} from '../user';
35
- import {UserProfileApi} from '../userprofile';
36
-
37
- export interface Modules {
38
- readonly appApi: () => AppApi;
39
- readonly capabilityApi: () => CapabilityApi;
40
- readonly default: (options?: any) => Runtime;
41
- readonly helpCenter: HelpCenterApi;
42
- readonly internal: InternalApi;
43
- readonly metrics: MetricsApi;
44
- readonly network: NetworkApi;
45
- readonly nps: Nps;
46
- readonly orgSwitcher: OrgSwitcherApi;
47
- readonly page: PageApi;
48
- readonly permissions: () => PermissionsApi;
49
- readonly pulse: () => PulseApi;
50
- runtime: Runtime;
51
- readonly settings: () => SettingsApi;
52
- readonly topbar: TopbarApi;
53
- readonly session: () => SessionApi;
54
- readonly shell: () => ShellApi;
55
- readonly sidebar: SidebarApi;
56
- readonly sidenav: () => SidenavApi;
57
- readonly user: () => UserApi;
58
- readonly userProfile: UserProfileApi;
59
- }
60
-
61
- type Global = typeof window & {
62
- readonly 'exc-module-runtime': Modules;
63
- EXC_MR_READY: () => void;
64
- };
65
-
66
- /**
67
- * Gets the implementation for the module.
68
- * @ignore
69
- * @param moduleName The name of the module.
70
- * @returns The implementation.
71
- */
72
- export function getImpl<T extends keyof Modules>(moduleName: T): Modules[T] {
73
- const emr = (window as Global)['exc-module-runtime'];
74
- if (!emr) {
75
- throw new Error('module-runtime APIs not available.');
76
- }
77
- return emr[moduleName];
78
- }
79
-
80
- /**
81
- * Connects attributes of the specified API.
82
- * @ignore
83
- * @param apiName Name of the API.
84
- * @param attributes The attributes to connect.
85
- * @returns The API instance.
86
- */
87
- export function connect<T extends keyof Modules>(apiName: T, attributes: [keyof Modules[T], boolean?][]): Modules[T] {
88
- const api = {} as Modules[T];
89
- attributes.forEach(feature => {
90
- const featureName = feature[0];
91
- if (feature[1]) {
92
- api[featureName] = ((...args: any[]) => {
93
- return (getImpl(apiName)[featureName] as any)(...args);
94
- }) as any;
95
- } else {
96
- Object.defineProperty(api, featureName, {
97
- get: () => {
98
- return getImpl(apiName)[featureName];
99
- },
100
- set: value => {
101
- getImpl(apiName)[featureName] = value;
102
- }
103
- });
104
- }
105
- });
106
- return api;
107
- }
108
-
109
- export default (window as Global);
package/src/Runtime.ts DELETED
@@ -1,23 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
-
12
- /**
13
- * @packageDocumentation
14
- * @module "index"
15
- */
16
-
17
- import EventEmitter from './EventEmitter';
18
-
19
- /**
20
- * Defines the runtime object providing all unified-shell APIs for solution authors.
21
- */
22
- export default interface Runtime extends EventEmitter { // eslint-disable-line @typescript-eslint/no-empty-interface
23
- }
@@ -1,28 +0,0 @@
1
- /*************************************************************************
2
- * Copyright 2020 Adobe
3
- * All Rights Reserved.
4
- *
5
- * NOTICE: Adobe permits you to use, modify, and distribute this file in
6
- * accordance with the terms of the Adobe license agreement accompanying
7
- * it. If you have received this file from a source other than Adobe,
8
- * then your use, modification, or distribution of it requires the prior
9
- * written permission of Adobe.
10
- **************************************************************************/
11
- import {Runtime} from '..';
12
-
13
- export default class MockRuntime implements Runtime {
14
- on(type: string, handler: (event?: any) => void): void {
15
- console.log(type, handler); // eslint-disable-line no-console
16
- throw new Error('Method not implemented.');
17
- }
18
-
19
- off(type: string, handler: (event?: any) => void): void {
20
- console.log(type, handler); // eslint-disable-line no-console
21
- throw new Error('Method not implemented.');
22
- }
23
-
24
- emit(type: string, evt?: any): void {
25
- console.log(type, evt); // eslint-disable-line no-console
26
- throw new Error('Method not implemented.');
27
- }
28
- }