commandbar 1.8.5 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- package/build/commandbar-js/src/index.js +1 -1
- package/build/internal/src/client/AddContextOptions.d.ts +141 -0
- package/build/internal/src/client/AnalyticsEventTypes.d.ts +1 -0
- package/build/internal/src/client/CommandBarClientSDK.d.ts +403 -0
- package/build/internal/src/client/CommandBarProxySDK.d.ts +49 -0
- package/build/internal/src/client/CommandBarSDK.d.ts +79 -0
- package/build/internal/src/client/EventHandler.d.ts +282 -0
- package/build/internal/src/client/OrgConfig.d.ts +5 -0
- package/build/internal/src/client/SDKConfig.d.ts +13 -0
- package/build/internal/src/client/SentryReporter.d.ts +63 -0
- package/build/internal/src/client/globals.d.ts +20 -0
- package/build/internal/src/client/proxy.d.ts +15 -0
- package/build/internal/src/client/symbols.d.ts +50 -0
- package/build/internal/src/middleware/CommandFromClientV.d.ts +283 -0
- package/build/internal/src/middleware/ICommandFromClientType.d.ts +5 -0
- package/build/internal/src/middleware/IResourceSettings.d.ts +3 -0
- package/build/internal/src/middleware/OrganizationV.d.ts +329 -0
- package/build/internal/src/middleware/ResourceSettingsV.d.ts +119 -0
- package/build/internal/src/middleware/additionalResource.d.ts +302 -0
- package/build/internal/src/middleware/billing.d.ts +41 -0
- package/build/internal/src/middleware/chatAnalytics.d.ts +2601 -0
- package/build/internal/src/middleware/checklist.d.ts +1014 -0
- package/build/internal/src/middleware/command.d.ts +8908 -0
- package/build/internal/src/middleware/commandCategory.d.ts +192 -0
- package/build/internal/src/middleware/confetti.d.ts +16 -0
- package/build/internal/src/middleware/context.d.ts +40 -0
- package/build/internal/src/middleware/dashboardFlags.d.ts +9 -0
- package/build/internal/src/middleware/detailPreview.d.ts +24 -0
- package/build/internal/src/middleware/environment.d.ts +11 -0
- package/build/internal/src/middleware/generics.d.ts +42 -0
- package/build/internal/src/middleware/guide.d.ts +37 -0
- package/build/internal/src/middleware/helpDocsIntegration.d.ts +72 -0
- package/build/internal/src/middleware/helpDocsSync.d.ts +63 -0
- package/build/internal/src/middleware/helpers/actions.d.ts +184 -0
- package/build/internal/src/middleware/helpers/argument.d.ts +318 -0
- package/build/internal/src/middleware/helpers/audience.d.ts +15 -0
- package/build/internal/src/middleware/helpers/commandTemplate.d.ts +252 -0
- package/build/internal/src/middleware/helpers/endUser.d.ts +11 -0
- package/build/internal/src/middleware/helpers/frequencyLimit.d.ts +2 -0
- package/build/internal/src/middleware/helpers/goals.d.ts +26 -0
- package/build/internal/src/middleware/helpers/optionGroup.d.ts +2 -0
- package/build/internal/src/middleware/helpers/pushTrigger.d.ts +26 -0
- package/build/internal/src/middleware/helpers/rules.d.ts +289 -0
- package/build/internal/src/middleware/helpers/tags.d.ts +7 -0
- package/build/internal/src/middleware/historyEvent.d.ts +21 -0
- package/build/internal/src/middleware/network.d.ts +3 -0
- package/build/internal/src/middleware/nudge.d.ts +1669 -0
- package/build/internal/src/middleware/organization.d.ts +1540 -0
- package/build/internal/src/middleware/organizationSettings.d.ts +330 -0
- package/build/internal/src/middleware/placeholder.d.ts +47 -0
- package/build/internal/src/middleware/profile.d.ts +11 -0
- package/build/internal/src/middleware/qaPair.d.ts +676 -0
- package/build/internal/src/middleware/recommendationSet.d.ts +1199 -0
- package/build/internal/src/middleware/releases.d.ts +261 -0
- package/build/internal/src/middleware/skin.d.ts +102 -0
- package/build/internal/src/middleware/tab.d.ts +27 -0
- package/build/internal/src/middleware/types.d.ts +218 -0
- package/build/internal/src/middleware/user.d.ts +15 -0
- package/build/internal/src/middleware/utils.d.ts +11 -0
- package/build/internal/src/util/Disposable.d.ts +17 -0
- package/build/internal/src/util/LocalStorage.d.ts +6 -0
- package/build/internal/src/util/Logger.d.ts +18 -0
- package/build/internal/src/util/dispatchCustomEvent.d.ts +12 -0
- package/build/internal/src/util/integrations.d.ts +1 -0
- package/package.json +3 -3
- package/jest.config.js +0 -4
- package/scripts/minify-snippet.ts +0 -36
- package/scripts/watch.ts +0 -5
- package/src/commandbar-launcher.d.ts +0 -7
- package/test/init.test.ts +0 -3
- package/tsconfig.json +0 -24
- package/webpack.config.js +0 -35
@@ -0,0 +1,403 @@
|
|
1
|
+
import { AddContextOptions, ArgumentOptions, DataRow, RecordOptions } from './AddContextOptions';
|
2
|
+
import { EventHandler, EventSubscriber } from './EventHandler';
|
3
|
+
import { ICommandFromClientType } from '../middleware/ICommandFromClientType';
|
4
|
+
import { IResourceSettings } from '../middleware/IResourceSettings';
|
5
|
+
import { ICommandCategoryType, DetailPreviewType, ISkinType } from '../middleware/types';
|
6
|
+
import { DataRowMetadata } from '../middleware/detailPreview';
|
7
|
+
export type { DataRow } from './AddContextOptions';
|
8
|
+
export type { DataRowMetadata } from '../middleware/types';
|
9
|
+
/**
|
10
|
+
* WARNING: We wary with adding methods to this list that have a fn as the first arg.
|
11
|
+
* Updating ASYNC_METHODS_SNIPPET will change how we parse a call in the queue. If a method is in this list, we assume
|
12
|
+
* it has Promise.resolve and Promise.reject unshifted to the arguments list. */
|
13
|
+
export declare const ASYNC_METHODS_SNIPPET: Array<keyof CommandBarClientSDK>;
|
14
|
+
export declare const ASYNC_METHODS: Array<keyof CommandBarClientSDK>;
|
15
|
+
export type BootOptions = string | null | undefined | (UserAttributes & {
|
16
|
+
id: string | null | undefined;
|
17
|
+
});
|
18
|
+
export type Metadata = Record<string, unknown>;
|
19
|
+
export type CommandDetails = {
|
20
|
+
category?: number | null;
|
21
|
+
/**
|
22
|
+
* The unique id of the command. For commands defined via the Editor, the value will be a number. For programmatic
|
23
|
+
* commands, the `name` (string) provided will be used.
|
24
|
+
*/
|
25
|
+
command: number | string | undefined;
|
26
|
+
/** The text of the command */
|
27
|
+
commandText: string;
|
28
|
+
/** The source of the command. */
|
29
|
+
source: string;
|
30
|
+
shortcut_mac: string;
|
31
|
+
shortcut_win: string;
|
32
|
+
customShortcut: string | undefined;
|
33
|
+
callbackKey: string | undefined;
|
34
|
+
};
|
35
|
+
export type UserAttributes = Record<string, unknown>;
|
36
|
+
export type ModalFormFactor = {
|
37
|
+
type: 'modal';
|
38
|
+
};
|
39
|
+
export type InlineFormFactor = {
|
40
|
+
type: 'inline';
|
41
|
+
rootElement: string | HTMLElement;
|
42
|
+
};
|
43
|
+
export type FormFactorConfig = ModalFormFactor | InlineFormFactor;
|
44
|
+
export type ProductConfig = Array<'bar' | 'nudges' | 'questlists' | 'help_hub'>;
|
45
|
+
export type FormFactor = Pick<FormFactorConfig, 'type'>;
|
46
|
+
export type InstanceAttributes = {
|
47
|
+
canOpenEditor: boolean;
|
48
|
+
hmac?: string;
|
49
|
+
formFactor: FormFactorConfig;
|
50
|
+
products: ProductConfig;
|
51
|
+
};
|
52
|
+
export type MetaAttributes = {
|
53
|
+
wp_plugin_version?: string;
|
54
|
+
};
|
55
|
+
export declare const DEFAULT_INSTANCE_ATTRIBUTES: InstanceAttributes;
|
56
|
+
export declare const DEFAULT_META_ATTRIBUTES: MetaAttributes;
|
57
|
+
export type CallbackFunction<T, U = Metadata> = (args: T, context: U) => void;
|
58
|
+
export type ContextLoader = (chosenValues?: undefined | Record<string, unknown[]>) => unknown;
|
59
|
+
export type RecordsOrArgumentListLoader = (chosenValues?: undefined | Record<string, unknown[]>) => DataRow[] | Promise<DataRow[]>;
|
60
|
+
export type CallbackMap = {
|
61
|
+
[name: string]: CallbackFunction<any, any>;
|
62
|
+
};
|
63
|
+
export type CustomComponent = {
|
64
|
+
mount: (node: HTMLElement) => CustomComponentInstance;
|
65
|
+
};
|
66
|
+
export type CustomComponentInstance = {
|
67
|
+
render: (data?: DataRow, metadata?: DataRowMetadata) => void;
|
68
|
+
unmount: () => void;
|
69
|
+
};
|
70
|
+
export type CommandBarClientSDK = Readonly<{
|
71
|
+
/**
|
72
|
+
* Adds a callback function to CommandBar. The callback function provided is mapped to `callbackKey`, and can be
|
73
|
+
* attached to commands by referencing `callbackKey` in a command config.
|
74
|
+
*
|
75
|
+
* @param callbackKey Key to reference the provided function
|
76
|
+
* @param callbackFn Callback function, with the following signature:
|
77
|
+
* * `args`: Depends on the callback, but typically a dictionary of argument keys and the values entered by the user.
|
78
|
+
* * `context`: A dictionary reflecting the state of context when the callback was triggered by a command execution
|
79
|
+
*/
|
80
|
+
addCallback<T, U>(callbackKey: string, callbackFn: CallbackFunction<T, U>): void;
|
81
|
+
addCallbacks(callbacks: CallbackMap): void;
|
82
|
+
/**
|
83
|
+
* Add a command to CommandBar.
|
84
|
+
*
|
85
|
+
* @param command The command schema
|
86
|
+
*/
|
87
|
+
addCommand(command: ICommandFromClientType): Promise<void>;
|
88
|
+
/**
|
89
|
+
* Configure a Category
|
90
|
+
*
|
91
|
+
* @param category The id (or name) of the category. If you provide a name and that category doesn't exist, it will be created automatically.
|
92
|
+
* @param config The Category config schema
|
93
|
+
*/
|
94
|
+
setCategoryConfig(category: string | number, config: Partial<ICommandCategoryType>): void;
|
95
|
+
/**
|
96
|
+
* Provides a list of argument choices to CommandBar. For any keys previously set, updates values.
|
97
|
+
*
|
98
|
+
* @param key Key for the argument choices. Used to associate an argument with choices in the Editor.
|
99
|
+
*
|
100
|
+
* @param initialValue The initial choices
|
101
|
+
*
|
102
|
+
* There are two options:
|
103
|
+
* * Static: A literal value (e.g. `["foo", "bar"]`)
|
104
|
+
* * Dynamic: A function to load a set of values for `key`, used to lazily load a list of values. This function will
|
105
|
+
* be passed as an argument a dictionary of the previously selected argument values, if the argument is not the first. Useful for
|
106
|
+
* lazily loading longer lists, or loading lists that are dependent on previous arguments.
|
107
|
+
*
|
108
|
+
* If providing a list of objects, there are some reserved fields that will trigger special behavior. See DataRow type
|
109
|
+
* for the list of those fields.
|
110
|
+
*
|
111
|
+
* @param options Options to customize CommandBar properties for `key`.
|
112
|
+
*
|
113
|
+
* @see [ArgumentOptions](#ArgumentOptions).
|
114
|
+
*/
|
115
|
+
addArgumentChoices(key: string, initial: DataRow[] | RecordsOrArgumentListLoader | null, options?: ArgumentOptions): void;
|
116
|
+
/**
|
117
|
+
* Adds a key, value pair to CommandBar that can be referenced to customize commands: such as in command URLs, availability rules, and recommendation rules.
|
118
|
+
*
|
119
|
+
* @param key Key for the metadata. Used to reference metadata.
|
120
|
+
*
|
121
|
+
* @param value The value of the key
|
122
|
+
*
|
123
|
+
* There are two options:
|
124
|
+
* * Static: A literal value (e.g. `addMetadata('isAdmin', true)`)
|
125
|
+
* * Dynamic: A function to load a set of values for `key`, used to lazily load a value. Useful for
|
126
|
+
* lazily loading data.
|
127
|
+
*/
|
128
|
+
addMetadata(key: string, value: unknown | ContextLoader, addToUserProperties?: boolean): void;
|
129
|
+
addMetadataBatch(data: Metadata, addToUserProperties?: boolean): void;
|
130
|
+
trackEvent(key: string, properties: Metadata): void;
|
131
|
+
/**
|
132
|
+
* Resets a nudge to a specific step. If no step is provided, resets the nudge to initial step.
|
133
|
+
* If the nudge is currently active, it will become inactive.
|
134
|
+
*
|
135
|
+
* @param id The id of the nudge to reset
|
136
|
+
* @param step The step to reset the nudge to
|
137
|
+
*/
|
138
|
+
resetNudge(id: number, step?: number): void;
|
139
|
+
/** @deprecated Use addRecords, addArgumentChoices, or addMetadata instead. */
|
140
|
+
addContext(key: string, initialValue: ContextLoader, options?: AddContextOptions): void;
|
141
|
+
/** @deprecated Use addRecords, addArgumentChoices, or addMetadata instead. */
|
142
|
+
addContext(key: string, initialValue: unknown, options?: AddContextOptions): void;
|
143
|
+
/** @deprecated Use setContext instead. */
|
144
|
+
addContext(ctx: Metadata): void;
|
145
|
+
/** @deprecated Use addEventSubscriber instead. */
|
146
|
+
addEventHandler(eventHandler: EventHandler): Promise<void>;
|
147
|
+
/**
|
148
|
+
* Captures CommandBar events to be handled in your code / stored in your database. Ask the CommandBar team if you're
|
149
|
+
* interested in this feature.
|
150
|
+
*
|
151
|
+
* @param eventSubscriber A function for handling events generated by CommandBar. It should have the following signature:
|
152
|
+
* * `eventName`: The name of the event type. Here are the different event types:
|
153
|
+
* * `opened`: Bar open
|
154
|
+
* * `closed`: Bar close. When the bar is closed with input text, it triggers both a `closed` event and a
|
155
|
+
* `abandoned_search` (deadend). Executions do not trigger `closed` events.
|
156
|
+
* * `abandoned_search`: A deadend
|
157
|
+
* * `command_suggestion`: A command suggestion
|
158
|
+
* * `command_execution`: A command execution
|
159
|
+
* * `no_results_for_query`: When a user's query does not retrieve any results
|
160
|
+
* * `client_error`: An error encountered by CommandBar
|
161
|
+
* * `shortcut_edited`: When a user assigns or edits a command's shortcut
|
162
|
+
* * `eventData`: Event attributes (will differ based on the type of event). In addition to the data below, any
|
163
|
+
* [eventData you pass to .boot()](https://app.commandbar.com/sdk#boot-eventdata) will be added to each event.
|
164
|
+
* @returns A function to remove the event handler
|
165
|
+
*/
|
166
|
+
addEventSubscriber(eventSubscriber: EventSubscriber): Promise<() => void>;
|
167
|
+
/**
|
168
|
+
* Add a record action for a key
|
169
|
+
*
|
170
|
+
* @param recordKey The key for record for which to attach an action to
|
171
|
+
*
|
172
|
+
* @param action The record action
|
173
|
+
*
|
174
|
+
* @param isDefault Whether this record action should be the default. Only needs to be included if multiple record actions are provided
|
175
|
+
*
|
176
|
+
* @param showInDefaultList Whether this record action should also be shown in the default list as a command
|
177
|
+
*/
|
178
|
+
addRecordAction(recordKey: string, action: ICommandFromClientType, isDefault?: boolean, showInDefaultList?: boolean): Promise<void>;
|
179
|
+
/**
|
180
|
+
* Makes records available to CommandBar. Records are searchable data. For any keys previously set, updates values.
|
181
|
+
*
|
182
|
+
* @param key Key for the records. Used to refer to records in the Editor, such as when creating record actions.
|
183
|
+
*
|
184
|
+
* @param initialValue The initial records
|
185
|
+
*
|
186
|
+
* There are two options:
|
187
|
+
* * Static: A literal value (e.g. `["foo", "bar"]`)
|
188
|
+
* * Dynamic: A function to load a set of values for `key`, used to lazily load a list of values. * Useful for
|
189
|
+
* lazily loading longer lists of records.
|
190
|
+
*
|
191
|
+
* If providing a list of objects, there are some reserved fields that will trigger special behavior. See DataRow type
|
192
|
+
* for the list of those fields.
|
193
|
+
*
|
194
|
+
* @param options Options to customize CommandBar properties for `key`.
|
195
|
+
*
|
196
|
+
* @see [RecordOptions](#RecordOptions).
|
197
|
+
*/
|
198
|
+
addRecords(key: string, initial: DataRow[] | RecordsOrArgumentListLoader | null, options?: RecordOptions): void;
|
199
|
+
/**
|
200
|
+
* Adds a search endpoint to CommandBar that returns results for multiple record types.
|
201
|
+
*
|
202
|
+
* @param onInputChange search endpoint to call for the specified record keys
|
203
|
+
* @param keys Record keys that this search endppoint covers
|
204
|
+
*/
|
205
|
+
addMultiSearch(onInputChange: (input: string) => Promise<any>, keys: string[]): void;
|
206
|
+
/**
|
207
|
+
* Sets a router function that link command can use to update the page's URL without triggering a reload. To lean more about using `addRouter` see [Adding a router](https://app.commandbar.com/docs/dev/router).
|
208
|
+
*
|
209
|
+
* @param routerFn The router function. It should accept the following arguments:
|
210
|
+
* * `url` {string} The url to navigate to
|
211
|
+
*/
|
212
|
+
addRouter(routerFn: (url: string) => void): void;
|
213
|
+
/** @deprecated Use addContext instead. */
|
214
|
+
addSearch(name: string, func: (...args: unknown[]) => unknown): void;
|
215
|
+
/**
|
216
|
+
* Make CommandBar available to the user. CommandBar will not be available before `.boot` is called, even if the
|
217
|
+
* snippet has been run on the page they are on.
|
218
|
+
*
|
219
|
+
* @param id ID corresponding to the currently logged-in end user. Used to tag analytics events. If ID is an empty string, null, or undefined, CommandBar will be booted in anonymous mode.
|
220
|
+
* @param metadata Key-value pairs to be associated with the end user for whom CommandBar is being booted. You can
|
221
|
+
* filter on these attributes from the analytics page in your dashboard. In addition, events passed to a supplied
|
222
|
+
* event handler will include metadata you provide via `boot`.
|
223
|
+
*/
|
224
|
+
boot(id?: string | null, userAttributes?: UserAttributes, instanceAttributes?: Partial<InstanceAttributes>): Promise<void>;
|
225
|
+
/**
|
226
|
+
* @deprecated Passing an object to boot will be deprecated in a future version of CommandBar.
|
227
|
+
*/
|
228
|
+
boot(opts: BootOptions): Promise<void>;
|
229
|
+
/**
|
230
|
+
* Changes the Bar form factor; can be set to either Modal (the default) or Inline.
|
231
|
+
*
|
232
|
+
* @param formFactorConfig either {type: 'modal'} or {type: 'inline', rootElement: (id of an element on the page) or an HTMLElement}
|
233
|
+
*/
|
234
|
+
setFormFactor(formFactorConfig: FormFactorConfig): Promise<void>;
|
235
|
+
close(): void;
|
236
|
+
/**
|
237
|
+
* Open the HelpHub.
|
238
|
+
*/
|
239
|
+
closeHelpHub(): void;
|
240
|
+
/**
|
241
|
+
* Force closes all active nudges
|
242
|
+
* Analytics events will not be sent for nudges that are closed.
|
243
|
+
*/
|
244
|
+
closeAllNudges(): void;
|
245
|
+
/**
|
246
|
+
* Executes a command. If this command has arguments, the Bar will open so the user can complete those arguments.
|
247
|
+
*
|
248
|
+
* @param id The command id to execute. For commands defined via the Editor, you can find this id in the Editor by selecting "Copy code" in the command's ellipsis menu. For commands defined via the SDK, this is the `name` field.
|
249
|
+
*/
|
250
|
+
execute(id: number | string): void;
|
251
|
+
/**
|
252
|
+
* Defines a function
|
253
|
+
*
|
254
|
+
* @param fn The preview detail generator function. It should accept the following arguments:
|
255
|
+
* * `row` {any}
|
256
|
+
* * `node` {any}
|
257
|
+
*/
|
258
|
+
generateDetailPreview(fn: (data: DataRow, metadata: DataRowMetadata) => undefined | DetailPreviewType): void;
|
259
|
+
addComponent(key: string, name: string, component: CustomComponent): void;
|
260
|
+
removeComponent(key: string): void;
|
261
|
+
/**
|
262
|
+
* Returns an array returning all commands that fit the optional filter function. By default, all commands are returned
|
263
|
+
* @param filter A function that filters out commands based on its properties. These are:
|
264
|
+
* * `command`: The unqiue id of the command. For commands defined via the Editor, the value will be a number. For programmatic commands, the name (string) provided will be used.
|
265
|
+
* * `commandText`: The text of the command
|
266
|
+
* * `category`: The category id of the command. Only provided if the command has a category
|
267
|
+
* * `callbackKey`: The command's callback key, if the command has one
|
268
|
+
* * `shortcut_mac`: Default shortcut set for macOS
|
269
|
+
* * `shortcut_win`:Default shortcut set for Windows and Linux devices
|
270
|
+
* * `source`: Source of the executed command
|
271
|
+
* * `customShortcut`: Shortcut string if this command has a custom user-set shortcut
|
272
|
+
*/
|
273
|
+
getCommands(filter?: (entry: CommandDetails) => boolean): CommandDetails[];
|
274
|
+
/**
|
275
|
+
* Returns `true` if the Bar is currently open, `false` if it is not, or `undefined` if the CommandBar is not fully
|
276
|
+
* initialized yet.
|
277
|
+
*/
|
278
|
+
isOpen(): boolean | undefined;
|
279
|
+
/**
|
280
|
+
* Open the Bar. If an input is supplied, will prefill the search input with that value.
|
281
|
+
*
|
282
|
+
* @param input Optional input ot prefill the Bar's search field.
|
283
|
+
* @param options FIXME: UNDOCUMENTED
|
284
|
+
*/
|
285
|
+
open(input?: string, options?: {
|
286
|
+
categoryFilter?: number | string;
|
287
|
+
}): void;
|
288
|
+
/**
|
289
|
+
* Open the in-app Editor
|
290
|
+
*/
|
291
|
+
openEditor(): void;
|
292
|
+
/**
|
293
|
+
* Open the HelpHub.
|
294
|
+
*/
|
295
|
+
openHelpHub(): void;
|
296
|
+
/**
|
297
|
+
* Open/close the Help Hub.
|
298
|
+
*/
|
299
|
+
toggleHelpHub(): void;
|
300
|
+
/**
|
301
|
+
* Removes the callback function referenced by `callbackKey` from CommandBar.
|
302
|
+
*
|
303
|
+
* When you remove a callback, any commands for which the callback is a dependency will become unavailable. Learn
|
304
|
+
* more about availability [here](https://app.commandbar.com/docs/commands/availability).
|
305
|
+
*
|
306
|
+
* @param callbackKey Callback key for the callback to be removed.
|
307
|
+
*/
|
308
|
+
removeCallback(callbackKey: string): void;
|
309
|
+
/**
|
310
|
+
* Remove a command, making it unavailable to a user.
|
311
|
+
*
|
312
|
+
* @param commandName The `name` field of the command
|
313
|
+
*/
|
314
|
+
removeCommand(commandName: string): void;
|
315
|
+
/**
|
316
|
+
* Removes a key and its corresponding value from context. When you remove a context key, any commands for which the
|
317
|
+
* key was a depencdency will become unavailable. To learn more about availability, see
|
318
|
+
* [When are commands available to users?](https://app.commandbar.com/docs/commands/availability)
|
319
|
+
*
|
320
|
+
* @param keyToRemove Context key to remove
|
321
|
+
*/
|
322
|
+
removeContext(keyToRemove: string): void;
|
323
|
+
/**
|
324
|
+
* Overrides certain components with provided options. Ask the CommandBar team if you're interested in this feature.
|
325
|
+
* Custom UI components are only available for enterprise customers. Please contact CommandBar.
|
326
|
+
* @param slug Component slug
|
327
|
+
* @param getHTML Function that returns an html string to be rendered as the component
|
328
|
+
*/
|
329
|
+
setCustomComponent(slug: 'header' | 'menuHeader' | 'tabHeader' | 'input' | 'sidepanel' | 'footer' | 'navPaneHeader' | 'navPaneFooter' | 'defaultState' | 'emptyState', getHTML: (meta?: {
|
330
|
+
step?: 'base' | 'multiselect' | 'longtextinput' | 'textinput' | 'select' | 'dashboard';
|
331
|
+
majorCategory?: string;
|
332
|
+
}) => string | CustomComponent): void;
|
333
|
+
/**
|
334
|
+
* Similar to `addContext`, but also removes any keys that are omitted from the supplied `ctx` from context. It may be
|
335
|
+
* helpful to use this to make large context changes, such as when a user logs out.
|
336
|
+
*
|
337
|
+
* @param context Dictionary to overwrite context
|
338
|
+
* @param meta FIXME: UNDOCUMENTED
|
339
|
+
*/
|
340
|
+
setContext(context: Metadata, meta?: Metadata & {
|
341
|
+
useCustom?: boolean;
|
342
|
+
customID?: string | number;
|
343
|
+
}): void;
|
344
|
+
/**
|
345
|
+
* This method will override the hotkey used by the current user to summon CommandBar.
|
346
|
+
*
|
347
|
+
* Please note that this method will only work if your Organization as End User Customizable Shortcuts enabled.
|
348
|
+
*
|
349
|
+
* @param {string} hotkey Any mousetrap.js compliant string (e.g. 'mod+k')
|
350
|
+
* @returns {boolean} Returns false if the hotkey string is invalid
|
351
|
+
*/
|
352
|
+
setSummonHotkey(hotkey: string | null): boolean;
|
353
|
+
/**
|
354
|
+
* Changes the background and primary color of the CommandBar to the supplied color.
|
355
|
+
*
|
356
|
+
* @param theme A hex color. Using 'light' or 'dark' will trigger CommandBar's default light or dark theme.
|
357
|
+
* @param [primaryColor] A hex color.
|
358
|
+
*/
|
359
|
+
setTheme(theme: string | 'light' | 'dark' | Pick<ISkinType, 'logo' | 'skin'>, primaryColor?: string): void;
|
360
|
+
/**
|
361
|
+
* Returns dictionary representing the current callbacks currently stored within CommandBar. The keys represent
|
362
|
+
* callback keys, and the values are the supplied functions.
|
363
|
+
*/
|
364
|
+
shareCallbacks(): Record<string, CallbackFunction<unknown>>;
|
365
|
+
/**
|
366
|
+
* Returns dictionary representing the Custom Components currently defined (via addComponent).
|
367
|
+
*
|
368
|
+
* The keys represent component keys, and the value is the name of the component.
|
369
|
+
*/
|
370
|
+
shareComponentNamesByKey(): Record<string, string>;
|
371
|
+
/** Returns the key value dictionary representing the current state of context */
|
372
|
+
shareContext(): Metadata;
|
373
|
+
/**
|
374
|
+
* Get information about the current status of CommandBar
|
375
|
+
*/
|
376
|
+
shareState(): {
|
377
|
+
isBooted: boolean;
|
378
|
+
currentInput: string;
|
379
|
+
config: {
|
380
|
+
helphub_enabled: boolean;
|
381
|
+
};
|
382
|
+
};
|
383
|
+
/** Returns whether or not the end user is successfully verified using HMAC */
|
384
|
+
isUserVerified(): boolean;
|
385
|
+
/**
|
386
|
+
* Make CommandBar unavailable to the user. Does nothing unless `.boot` has been called. `shutdown` is typically used
|
387
|
+
* to make CommandBar unavailable after logout.
|
388
|
+
*/
|
389
|
+
shutdown(): void;
|
390
|
+
/**
|
391
|
+
* Manually trigger client search functions.
|
392
|
+
*
|
393
|
+
* Allows search functions to be re-triggered with the same input text.
|
394
|
+
*/
|
395
|
+
triggerSearchFunctions(): void;
|
396
|
+
/** @deprecated Use addContext instead. */
|
397
|
+
updateContextSettings(key: string, settings: IResourceSettings): void;
|
398
|
+
/**
|
399
|
+
* Completely remove CommandBar from the page. You will need to re-run the snippet or call the init() function again
|
400
|
+
* (depending on your deployment method) to load CommandBar again.
|
401
|
+
*/
|
402
|
+
unmount(): void;
|
403
|
+
}>;
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import { OrgConfig } from './OrgConfig';
|
2
|
+
import { SDKConfig } from './CommandBarSDK';
|
3
|
+
import { _configuration, _disposed, _isProxy, _queue, _reporter, _unwrap, _orgConfig, _eventSubscriptions } from './symbols';
|
4
|
+
/**
|
5
|
+
* A proxy object that absorbs function calls into a queue that can be later consumed. The queue contains the name of
|
6
|
+
* properties accessed for function calls including any arguments passed.
|
7
|
+
*
|
8
|
+
* This is useful to allow clients to "queue up" calls to the SDK before it can be "upgraded" with state and callbacks
|
9
|
+
* from the React component tree.
|
10
|
+
*/
|
11
|
+
export type CommandBarProxySDK = CommandBarProxyGlobal & Record<string, Function> & {
|
12
|
+
[_configuration]?: Function | Partial<SDKConfig>;
|
13
|
+
[_orgConfig]?: Function | OrgConfig;
|
14
|
+
[_reporter]?: Function | any;
|
15
|
+
};
|
16
|
+
/**
|
17
|
+
* The global SDK object, which is usually hidden behind a Proxy at `window.CommandBar`. Use
|
18
|
+
* `window.CommandBar[_unwrap]()` (or ideally `getProxySDK()`) from anywhere to access this.
|
19
|
+
*
|
20
|
+
* The properties defined here are the minimal properties that can always be expected to be present in the global
|
21
|
+
* object. Many more are added once "upgraded" using `initSDK`.
|
22
|
+
*/
|
23
|
+
export interface CommandBarProxyGlobal {
|
24
|
+
/**
|
25
|
+
* Marks the proxy as disposed when true; this will cause a new global object to be created with the next `getSDK()`
|
26
|
+
* or `getProxySDK()` call.
|
27
|
+
*/
|
28
|
+
[_disposed]: boolean;
|
29
|
+
[_isProxy]: true;
|
30
|
+
/**
|
31
|
+
* A command queue that builds up commands executed early in the application lifecycle, before the App component has
|
32
|
+
* had a chance to render.
|
33
|
+
*/
|
34
|
+
[_queue]: unknown[][];
|
35
|
+
/**
|
36
|
+
* A sneaky way to get access to the object that's being proxied, the one that holds the real global state. Use this
|
37
|
+
* to avoid triggering unwanted proxy behavior when accessing properties that are unassigned.
|
38
|
+
*
|
39
|
+
* The typedefs of the optional properties (_org, _reporter) in CommandBarProxySDK illustrate the risk of working with
|
40
|
+
* a wrapped proxy global.
|
41
|
+
*/
|
42
|
+
[_unwrap]: () => CommandBarProxyGlobal;
|
43
|
+
[_configuration]?: Partial<SDKConfig>;
|
44
|
+
[_orgConfig]?: OrgConfig;
|
45
|
+
[_reporter]?: any;
|
46
|
+
[_eventSubscriptions]: undefined;
|
47
|
+
}
|
48
|
+
/** Tests if the given object is a "proxy" SDK object that has not yet been upgraded to a client SDK object. */
|
49
|
+
export declare function isProxySDK(x: unknown): x is CommandBarProxySDK;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
import { TUpdateEditorRouteDetails } from '../util/dispatchCustomEvent';
|
2
|
+
import { CommandBarClientSDK, InstanceAttributes, MetaAttributes, Metadata } from './CommandBarClientSDK';
|
3
|
+
import { EVENT_NAME } from './AnalyticsEventTypes';
|
4
|
+
import { SentryReporter } from './SentryReporter';
|
5
|
+
import { _access, _configuration, _configure, _configUser, _dispose, _disposed, _eventSubscriptions, _userAttributes, _isProxy, _loadEditor, _onEditorPathChange, _orgConfig, _perf, _programmaticTheme, _reload, _reloadCommands, _reloadOrganization, _reloadPlaceholders, _reloadNudges, _reloadHelpHub, _previewNudge, _stopChecklistPreview, _stopNudgePreview, _reloadChecklists, _report, _reporter, _search, _setDashboard, _setPreviewMode, _setTestMode, _showGuide, _showMessage, _user, _instanceAttributes, _setEditorVisible, _shareConfig, _shareContextSettings, _shareProgrammaticCommands, _metaAttributes, _previewChecklist, _shareEditorRouteWithBar, _shareInitialEditorPath, _fingerprint, _updateEditorRoute, _previewRecommendationSet, _stopRecommendationSetPreview } from './symbols';
|
6
|
+
import { SDKConfig } from './SDKConfig';
|
7
|
+
import { IChecklist, ICommandType, IConfigType, INudgeType, IResourceSettingsByContextKey } from '../middleware/types';
|
8
|
+
import { OrgConfig } from './OrgConfig';
|
9
|
+
import { EventSubscriber } from './EventHandler';
|
10
|
+
export type { SDKConfig } from './SDKConfig';
|
11
|
+
export declare const _reloadTargets: string[];
|
12
|
+
export interface CommandBarInternalSDK {
|
13
|
+
[_access]: string | undefined;
|
14
|
+
[_instanceAttributes]: InstanceAttributes;
|
15
|
+
[_metaAttributes]: MetaAttributes;
|
16
|
+
[_perf]: boolean;
|
17
|
+
[_programmaticTheme]: string | undefined;
|
18
|
+
[_reporter]: SentryReporter | undefined;
|
19
|
+
[_search]: string;
|
20
|
+
[_user]: string | null | undefined;
|
21
|
+
[_fingerprint]: string | undefined;
|
22
|
+
[_userAttributes]: Metadata | undefined;
|
23
|
+
[_eventSubscriptions]: Map<symbol, EventSubscriber> | undefined;
|
24
|
+
/** @deprecated */
|
25
|
+
readonly [_configure]: (uuid: string) => void;
|
26
|
+
readonly [_configuration]: SDKConfig;
|
27
|
+
readonly [_configUser]: () => Promise<void>;
|
28
|
+
readonly [_dispose]: () => void;
|
29
|
+
readonly [_disposed]: false;
|
30
|
+
readonly [_isProxy]: false;
|
31
|
+
readonly [_loadEditor]: () => void;
|
32
|
+
readonly [_onEditorPathChange]: (notify: (path: string) => void) => void;
|
33
|
+
readonly [_shareEditorRouteWithBar]: (path: string) => void;
|
34
|
+
readonly [_orgConfig]: OrgConfig;
|
35
|
+
readonly [_reload]: (reloadTargets: (typeof _reloadTargets)[number][]) => void;
|
36
|
+
readonly [_reloadCommands]: (preLoadedConfig?: IConfigType) => void;
|
37
|
+
readonly [_reloadOrganization]: (preLoadedConfig?: IConfigType) => void;
|
38
|
+
readonly [_reloadPlaceholders]: (preLoadedConfig?: IConfigType) => void;
|
39
|
+
readonly [_reloadNudges]: (preLoadedConfig?: IConfigType) => void;
|
40
|
+
readonly [_reloadHelpHub]: (preLoadedConfig?: IConfigType) => void;
|
41
|
+
readonly [_previewRecommendationSet]: (data: {
|
42
|
+
recommendationSetId?: number;
|
43
|
+
}) => void;
|
44
|
+
readonly [_stopRecommendationSetPreview]: () => void;
|
45
|
+
readonly [_previewNudge]: (data: {
|
46
|
+
nudge: INudgeType;
|
47
|
+
step: number;
|
48
|
+
clearData: boolean;
|
49
|
+
}) => void;
|
50
|
+
readonly [_stopChecklistPreview]: () => void;
|
51
|
+
readonly [_stopNudgePreview]: (data: {
|
52
|
+
index?: number;
|
53
|
+
}) => void;
|
54
|
+
readonly [_previewChecklist]: (data: {
|
55
|
+
checklist: IChecklist;
|
56
|
+
clearData?: boolean;
|
57
|
+
}) => void;
|
58
|
+
readonly [_reloadChecklists]: () => void;
|
59
|
+
/** @deprecated */
|
60
|
+
readonly [_report]: (event: EVENT_NAME, data?: Metadata) => void;
|
61
|
+
/** @deprecated */
|
62
|
+
readonly [_setDashboard]: (element: HTMLElement) => void;
|
63
|
+
readonly [_setPreviewMode]: (on: boolean) => void;
|
64
|
+
readonly [_setTestMode]: (on: boolean) => void;
|
65
|
+
readonly [_setEditorVisible]: (visible: boolean) => void;
|
66
|
+
readonly [_shareContextSettings]: () => {
|
67
|
+
local: IResourceSettingsByContextKey;
|
68
|
+
server: IResourceSettingsByContextKey;
|
69
|
+
};
|
70
|
+
readonly [_shareConfig]: () => any;
|
71
|
+
readonly [_shareProgrammaticCommands]: () => ICommandType[];
|
72
|
+
readonly [_shareInitialEditorPath]: () => string | null;
|
73
|
+
readonly [_updateEditorRoute]: (data: TUpdateEditorRouteDetails) => void;
|
74
|
+
/** @deprecated */
|
75
|
+
readonly [_showGuide]: (eventName: string, preview?: boolean) => void;
|
76
|
+
/** @deprecated */
|
77
|
+
readonly [_showMessage]: (eventName: string, preview?: boolean) => void;
|
78
|
+
}
|
79
|
+
export type CommandBarSDK = CommandBarInternalSDK & CommandBarClientSDK;
|