commandbar 1.8.7 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. package/build/{internal/src/client → commandbar/src/shared/services/analytics}/EventHandler.d.ts +51 -15
  2. package/build/commandbar/src/shared/services/analytics/types.d.ts +77 -0
  3. package/build/commandbar-js/src/index.d.ts +2 -2
  4. package/build/commandbar-js/src/index.js +1 -1
  5. package/build/internal/src/client/AddContextOptions.d.ts +8 -0
  6. package/build/internal/src/client/CommandBarClientSDK.d.ts +70 -19
  7. package/build/internal/src/client/CommandBarProxySDK.d.ts +3 -3
  8. package/build/internal/src/client/CommandBarSDK.d.ts +34 -18
  9. package/build/internal/src/client/SDKConfig.d.ts +3 -2
  10. package/build/internal/src/client/globals.d.ts +6 -0
  11. package/build/internal/src/client/symbols.d.ts +13 -6
  12. package/build/internal/src/middleware/CommandFromClientV.d.ts +88 -18
  13. package/build/internal/src/middleware/IRecordSettings.d.ts +3 -0
  14. package/build/internal/src/middleware/OrganizationV.d.ts +320 -22
  15. package/build/internal/src/middleware/{ResourceSettingsV.d.ts → RecordSettingsV.d.ts} +2 -2
  16. package/build/internal/src/middleware/additionalResource.d.ts +270 -27
  17. package/build/internal/src/middleware/billing.d.ts +31 -0
  18. package/build/internal/src/middleware/chat.d.ts +12933 -0
  19. package/build/internal/src/middleware/checklist.d.ts +589 -70
  20. package/build/internal/src/middleware/command.d.ts +5433 -677
  21. package/build/internal/src/middleware/detailPreview.d.ts +12 -1
  22. package/build/internal/src/middleware/endUser.d.ts +132 -0
  23. package/build/internal/src/middleware/entityChanges.d.ts +17 -0
  24. package/build/internal/src/middleware/experienceTemplate.d.ts +59 -0
  25. package/build/internal/src/middleware/experiencesSearch.d.ts +3579 -0
  26. package/build/internal/src/middleware/flags.d.ts +20 -0
  27. package/build/internal/src/middleware/generics.d.ts +12 -11
  28. package/build/internal/src/middleware/helpDocsIntegration.d.ts +63 -8
  29. package/build/internal/src/middleware/helpDocsSearch.d.ts +2540 -0
  30. package/build/internal/src/middleware/helpHub.d.ts +26 -0
  31. package/build/internal/src/middleware/helpers/actions.d.ts +174 -16
  32. package/build/internal/src/middleware/helpers/commandTemplate.d.ts +144 -2
  33. package/build/internal/src/middleware/helpers/copilotPersonality.d.ts +12 -0
  34. package/build/internal/src/middleware/helpers/goals.d.ts +4 -2
  35. package/build/internal/src/middleware/helpers/pushTrigger.d.ts +28 -0
  36. package/build/internal/src/middleware/helpers/rules.d.ts +318 -50
  37. package/build/internal/src/middleware/network.d.ts +27 -3
  38. package/build/internal/src/middleware/nudge.d.ts +2220 -91
  39. package/build/internal/src/middleware/organization.d.ts +2289 -152
  40. package/build/internal/src/middleware/organizationSettings.d.ts +435 -20
  41. package/build/internal/src/middleware/profile.d.ts +2 -0
  42. package/build/internal/src/middleware/recommendationSet.d.ts +489 -1007
  43. package/build/internal/src/middleware/releases.d.ts +1 -1
  44. package/build/internal/src/middleware/theme.d.ts +425 -0
  45. package/build/internal/src/middleware/types.d.ts +88 -34
  46. package/build/internal/src/middleware/user.d.ts +1 -0
  47. package/build/internal/src/util/dispatchCustomEvent.d.ts +5 -3
  48. package/build/internal/src/util/operatingSystem.d.ts +11 -0
  49. package/build/internal/src/util/sentry.d.ts +23 -0
  50. package/package.json +3 -3
  51. package/src/index.ts +2 -2
  52. package/src/init.ts +11 -6
  53. package/src/snippet.ts +2 -2
  54. package/build/internal/src/client/AnalyticsEventTypes.d.ts +0 -1
  55. package/build/internal/src/client/SentryReporter.d.ts +0 -63
  56. package/build/internal/src/middleware/IResourceSettings.d.ts +0 -3
  57. package/build/internal/src/middleware/chatAnalytics.d.ts +0 -2601
  58. package/build/internal/src/middleware/dashboardFlags.d.ts +0 -9
  59. package/build/internal/src/middleware/helpers/endUser.d.ts +0 -11
  60. package/build/internal/src/middleware/qaPair.d.ts +0 -676
  61. package/build/internal/src/util/integrations.d.ts +0 -1
@@ -10,6 +10,7 @@ export declare const UserV: t.IntersectionC<[t.TypeC<{
10
10
  profile: t.NumberC;
11
11
  has_updated_password: t.BooleanC;
12
12
  is_active: t.BooleanC;
13
+ is_hijacked: t.BooleanC;
13
14
  }>, t.PartialC<{
14
15
  intercom_hash: t.StringC;
15
16
  }>]>;
@@ -1,12 +1,14 @@
1
+ import type { INudgeType } from '../middleware/types';
1
2
  export type TUpdateEditorRouteDetails = {
2
3
  type: 'nudge';
3
- nudgeId: string | number;
4
- stepId: string | number;
4
+ nudge: INudgeType;
5
+ stepIndex: number;
5
6
  } | {
6
7
  type: 'checklist';
7
8
  checklistId: string | number;
8
9
  } | {
9
- type: 'theme';
10
+ type: 'route';
10
11
  route_replacement: string;
12
+ action?: string;
11
13
  };
12
14
  export declare function dispatchCustomEvent<T>(eventType: string, detail: T, canBubble?: boolean, cancelable?: boolean): CustomEvent<T>;
@@ -0,0 +1,11 @@
1
+ export type PlatformType = 'mac' | 'ios' | 'windows' | 'android' | 'linux';
2
+ export type BrowserType = 'chrome' | 'firefox' | 'safari' | 'opera' | 'edge' | 'brave' | 'arc' | 'ie10' | 'ie11';
3
+ export type DeviceType = 'mobile' | 'desktop';
4
+ export declare const EDITOR_MOBILE_PREVIEW_SCREEN_HEIGHT = 932;
5
+ export declare const EDITOR_MOBILE_PREVIEW_SCREEN_WIDTH = 430;
6
+ export declare const isMobileDevice: () => boolean;
7
+ export declare const getDeviceType: () => DeviceType;
8
+ export declare const getBrowser: () => BrowserType | null;
9
+ export declare const getOperatingSystem: () => PlatformType;
10
+ export declare const getTriggerKey: (event: any) => any;
11
+ export declare const osControlKey: (suffix?: string) => string;
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { Hub } from '@sentry/core';
3
+ export declare const SENTRY_COMMANDBAR_DSN = "https://ebf252b62885436e858a66d157aee9ea@o451734.ingest.sentry.io/5608348";
4
+ export declare const sentryHubFactory: (dsn: string) => Hub | undefined;
5
+ export declare const initSentryAndAddToSdk: () => void;
6
+ export declare const getSentry: () => Hub | undefined;
7
+ export declare const startSentryTransaction: (context: import("@sentry/types").TransactionContext, customSamplingContext?: import("@sentry/types").CustomSamplingContext | undefined) => import("@sentry/browser").Transaction | null | undefined;
8
+ interface Props {
9
+ children: React.ReactNode;
10
+ }
11
+ interface State {
12
+ hasError: boolean;
13
+ }
14
+ export declare class SentryErrorBoundary extends React.Component<Props, State> {
15
+ constructor(props: Props);
16
+ captureRejection: (ev: PromiseRejectionEvent) => void;
17
+ static getDerivedStateFromError(_error: Error): {
18
+ hasError: boolean;
19
+ };
20
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
21
+ render(): React.ReactNode;
22
+ }
23
+ export {};
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "commandbar",
3
- "version": "1.8.7",
3
+ "version": "1.10.0",
4
4
  "description": "Javascript Utility for CommandBar",
5
5
  "main": "build/commandbar-js/src/index.js",
6
6
  "types": "build/commandbar-js/src/index.d.ts",
7
7
  "sideEffects": false,
8
8
  "scripts": {
9
9
  "clean": "rimraf build",
10
- "build": "webpack build && tsc",
10
+ "build": "NODE_ENV=production webpack build && tsc",
11
11
  "minify-snippet": "ts-node scripts/minify-snippet.ts",
12
12
  "prepublishOnly": "yarn run clean && yarn run build",
13
13
  "test": "jest --runInBand",
14
14
  "test:watch": "jest --watch --verbose false --silent false",
15
- "watch": "scripts/watch.ts"
15
+ "watch": "NODE_ENV=development scripts/watch.ts"
16
16
  },
17
17
  "keywords": [],
18
18
  "author": "",
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import Launcher, { getControlKey } from 'commandbar-launcher';
2
- import { CommandBarClientSDK } from '../../internal/src/client/CommandBarClientSDK';
2
+ import type { CommandBarClientSDK } from '@commandbar/internal/src/client/CommandBarClientSDK';
3
3
 
4
4
  export { default as init } from './init';
5
- export { initProxySDK as initProxy } from '../../internal/src/client/proxy';
5
+ export { initProxySDK as initProxy } from '@commandbar/internal/src/client/proxy';
6
6
  export { snippet } from './snippet';
7
7
  export { CommandBarClientSDK };
8
8
  export { Launcher, getControlKey };
package/src/init.ts CHANGED
@@ -5,7 +5,7 @@ import { getProxySDK } from '../../internal/src/client/proxy';
5
5
  import { _configuration } from '../../internal/src/client/symbols';
6
6
  import { IInitOptions } from '../../internal/src/middleware/types';
7
7
 
8
- const getSrc = (org: string) => {
8
+ const getSrc = (org: string, nonce?: string) => {
9
9
  let origin = 'https://api.commandbar.com';
10
10
  const params = [];
11
11
 
@@ -21,6 +21,10 @@ const getSrc = (org: string) => {
21
21
  params.push('lc=' + lc);
22
22
  }
23
23
 
24
+ if (nonce) {
25
+ params.push('nonce=' + nonce);
26
+ }
27
+
24
28
  const version = 2;
25
29
  params.push('version=' + version);
26
30
 
@@ -28,14 +32,14 @@ const getSrc = (org: string) => {
28
32
  return src;
29
33
  };
30
34
 
31
- const loadLatest = (org: string) => {
35
+ const loadLatest = (org: string, nonce?: string) => {
32
36
  if (document.readyState !== 'complete') {
33
37
  // NOTE: `once` is not supported by IE11 and this will cause a (minor!) memory leak.
34
- window.addEventListener('load', loadLatest.bind(null, org), { capture: false, once: true });
38
+ window.addEventListener('load', loadLatest.bind(null, org, nonce), { capture: false, once: true });
35
39
  return;
36
40
  }
37
41
 
38
- const src = getSrc(org);
42
+ const src = getSrc(org, nonce);
39
43
 
40
44
  const el = document.createElement('script');
41
45
  el.type = 'text/javascript';
@@ -75,9 +79,10 @@ const init = (org: string, opts: IInitOptions = DEFAULT_OPTS) => {
75
79
  uuid: org,
76
80
  environment: opts.environment,
77
81
  version: opts.version,
78
- config: opts.config,
82
+ config: opts.config, // TODO: We should update this type to correctly reflect the structure of the response from /config/ https://cmd-k.slack.com/archives/C0315KNU7FY/p1711558822136239?thread_ts=1711554558.063509&cid=C0315KNU7FY
79
83
  };
80
- loadLatest(org);
84
+
85
+ loadLatest(org, opts.nonce);
81
86
  };
82
87
 
83
88
  export default init;
package/src/snippet.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable no-template-curly-in-string */
2
2
  /* eslint-disable prefer-rest-params */
3
3
 
4
- import { _eventSubscriptions } from '../../internal/src/client/symbols';
5
-
6
4
  /* eslint-disable @typescript-eslint/no-inferrable-types */
7
5
  export const snippet = (org: string) => {
8
6
  const polyfills = ['Object.assign', 'Symbol', 'Symbol.for'].join('%2C');
@@ -29,6 +27,8 @@ export const snippet = (org: string) => {
29
27
  const _isProxy = Symbol.for('CommandBar::isProxy');
30
28
  const _queue = Symbol.for('CommandBar::queue');
31
29
  const _unwrap = Symbol.for('CommandBar::unwrap');
30
+ const _eventSubscriptions = Symbol.for('CommandBar::eventSubscriptions');
31
+
32
32
  const params = [];
33
33
  const lc = localStorage.getItem('commandbar.lc');
34
34
  const origin = lc && lc.includes('local') ? 'http://localhost:8000' : 'https://api.commandbar.com';
@@ -1 +0,0 @@
1
- export type EVENT_NAME = 'Identify' | 'New session' | 'End session' | 'Load Performance' | 'New search' | 'Exited' | 'Search input' | 'Onboarding tooltip shown' | 'Tooltip shown' | 'Onboarding started' | 'Onboarding exited' | 'Onboarding completed' | 'Abandoned search' | 'No results for query' | 'Command suggestion' | 'Command execution' | 'Unavailable shortcut' | 'Clicked branding' | 'Survey response' | 'Client-Error' | 'Internal-Error' | 'Internal-Event' | 'Sentry-Event' | 'User changed shortcut' | 'Preview shown' | 'Next step selected' | 'Preview link opened' | 'Preview engagement' | 'Nudge shown' | 'Nudge clicked' | 'Nudge completed' | 'Nudge dismissed' | 'Questlist shown' | 'Questlist engagement' | 'Questlist item engagement' | 'HelpHub opened' | 'HelpHub closed' | 'HelpHub doc opened' | 'HelpHub doc closed' | 'HelpHub doc engagement' | 'HelpHub engagement' | 'No chat response';
@@ -1,63 +0,0 @@
1
- import { IOrganizationType } from '../middleware/types';
2
- import { PublicDisposable } from '../util/Disposable';
3
- type ExtraData = Record<string, unknown>;
4
- export interface UserScopeOptions {
5
- configuration: {
6
- uuid?: string;
7
- api: string;
8
- editor: string;
9
- proxy: string;
10
- session: string;
11
- };
12
- organization?: IOrganizationType;
13
- organizationId: string | number;
14
- organizationName?: string;
15
- session: string;
16
- userId?: string;
17
- }
18
- declare enum Severity {
19
- Fatal = "fatal",
20
- Error = "error",
21
- Warning = "warning",
22
- Log = "log",
23
- Info = "info",
24
- Debug = "debug",
25
- Critical = "critical"
26
- }
27
- export interface Breadcrumb {
28
- type?: string;
29
- level?: Severity;
30
- event_id?: string;
31
- category?: string;
32
- message?: string;
33
- data?: {
34
- [key: string]: any;
35
- };
36
- timestamp?: number;
37
- hint?: BreadcrumbHint;
38
- }
39
- export interface BreadcrumbHint {
40
- [key: string]: any;
41
- }
42
- export declare abstract class SentryReporter implements PublicDisposable {
43
- _disposed: boolean;
44
- breadcrumb: (breadcrumb: Breadcrumb, hint?: BreadcrumbHint) => void;
45
- dispose(): void;
46
- /**
47
- * Report an error to Sentry. The first argument must either be a string or error object, and optionally an error
48
- * object and extra data (in the form of an object) may be provided as well.
49
- *
50
- * If a string message is provided instead of an Error object a new Error will be generated. This will cause the
51
- * stacktrace to begin at this function; for that reason it is **strongly** recommended to provide an error object
52
- * so that the original stack trace can be preserved (as originalException).
53
- */
54
- abstract exception(message: string, err?: Error, extra?: ExtraData): void;
55
- abstract exception(message: string, extra?: ExtraData): void;
56
- abstract exception(err: Error, extra?: ExtraData): void;
57
- /**
58
- * Assigns various scope properties related to the currently active user and organization so that error events can
59
- * be easily associated with them.
60
- */
61
- abstract setUserScope(opts: UserScopeOptions): void;
62
- }
63
- export {};
@@ -1,3 +0,0 @@
1
- import * as t from 'io-ts';
2
- import { ResourceSettingsV } from './ResourceSettingsV';
3
- export type IResourceSettings = t.TypeOf<typeof ResourceSettingsV> & unknown;