commandbar 1.10.2 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. package/build/commandbar/src/shared/services/analytics/EventHandler.d.ts +7 -2
  2. package/build/commandbar/src/shared/services/analytics/event-queue.d.ts +13 -0
  3. package/build/commandbar/src/shared/services/analytics/types.d.ts +1 -1
  4. package/build/commandbar/src/shared/services/analytics/v2/client.d.ts +54 -0
  5. package/build/commandbar/src/shared/services/analytics/v2/helpers.d.ts +6 -0
  6. package/build/commandbar/src/shared/services/analytics/v2/schema.d.ts +152 -0
  7. package/build/commandbar/src/shared/services/analytics/v2/types.d.ts +4 -0
  8. package/build/commandbar-js/src/index.d.ts +0 -1
  9. package/build/commandbar-js/src/index.js +1 -1
  10. package/build/commandbar-js/src/snippet.d.ts +7 -1
  11. package/build/internal/src/client/CommandBarClientSDK.d.ts +12 -0
  12. package/build/internal/src/client/CommandBarProxySDK.d.ts +1 -4
  13. package/build/internal/src/client/CommandBarSDK.d.ts +5 -3
  14. package/build/internal/src/client/SDKConfig.d.ts +3 -1
  15. package/build/internal/src/client/globals.d.ts +1 -0
  16. package/build/internal/src/client/symbols.d.ts +3 -1
  17. package/build/internal/src/middleware/CommandFromClientV.d.ts +16 -2
  18. package/build/internal/src/middleware/OrganizationV.d.ts +34 -8
  19. package/build/internal/src/middleware/additionalResource.d.ts +9 -9
  20. package/build/internal/src/middleware/api.d.ts +173 -0
  21. package/build/internal/src/middleware/billing.d.ts +10 -0
  22. package/build/internal/src/middleware/chat.d.ts +3662 -172
  23. package/build/internal/src/middleware/checklist.d.ts +18 -10
  24. package/build/internal/src/middleware/command.d.ts +540 -140
  25. package/build/internal/src/middleware/endUser.d.ts +2 -0
  26. package/build/internal/src/middleware/experienceTemplate.d.ts +2874 -8
  27. package/build/internal/src/middleware/experiencesSearch.d.ts +233 -28
  28. package/build/internal/src/middleware/flags.d.ts +14 -1
  29. package/build/internal/src/middleware/generics.d.ts +1 -0
  30. package/build/internal/src/middleware/helpDocsIntegration.d.ts +98 -0
  31. package/build/internal/src/middleware/helpDocsSearch.d.ts +165 -20
  32. package/build/internal/src/middleware/helpDocsSync.d.ts +4 -0
  33. package/build/internal/src/middleware/helpers/actions.d.ts +6 -6
  34. package/build/internal/src/middleware/helpers/commandTemplate.d.ts +2 -2
  35. package/build/internal/src/middleware/helpers/rules.d.ts +7 -7
  36. package/build/internal/src/middleware/localizedMessage.d.ts +50 -0
  37. package/build/internal/src/middleware/network.d.ts +1 -0
  38. package/build/internal/src/middleware/nudge.d.ts +96 -24
  39. package/build/internal/src/middleware/organization.d.ts +180 -62
  40. package/build/internal/src/middleware/organizationSettings.d.ts +8 -8
  41. package/build/internal/src/middleware/profile.d.ts +8 -0
  42. package/build/internal/src/middleware/recommendationSet.d.ts +18 -9
  43. package/build/internal/src/middleware/theme.d.ts +7 -0
  44. package/build/internal/src/middleware/types.d.ts +23 -5
  45. package/build/internal/src/middleware/user.d.ts +9 -1
  46. package/build/internal/src/middleware/workflow.d.ts +69 -0
  47. package/package.json +5 -2
  48. package/src/index.ts +0 -1
  49. package/src/init.ts +27 -13
  50. package/src/snippet.ts +79 -74
  51. package/build/internal/src/client/OrgConfig.d.ts +0 -5
  52. package/build/internal/src/middleware/guide.d.ts +0 -37
package/src/snippet.ts CHANGED
@@ -2,94 +2,99 @@
2
2
  /* eslint-disable prefer-rest-params */
3
3
 
4
4
  /* eslint-disable @typescript-eslint/no-inferrable-types */
5
- export const snippet = (org: string) => {
6
- const polyfills = ['Object.assign', 'Symbol', 'Symbol.for'].join('%2C');
7
- const w = window as unknown as Record<string, unknown>;
5
+ let org = '<org_id>';
6
+ let api = 'https://api.commandbar.com';
7
+ let cdn: string | undefined = undefined;
8
8
 
9
- function loadScript(src: string, async = false) {
10
- if (document.readyState !== 'complete') {
11
- window.addEventListener('load', loadScript.bind(null, src, async), { capture: false, once: true });
12
- }
13
- const el = document.createElement('script');
14
- el.type = 'text/javascript';
15
- el.async = async;
16
- el.src = src;
17
- document.head.appendChild(el);
9
+ const polyfills = ['Object.assign', 'Symbol', 'Symbol.for'].join('%2C');
10
+ const w = window as unknown as Record<string, unknown>;
11
+
12
+ function loadScript(src: string, async = false) {
13
+ if (document.readyState !== 'complete') {
14
+ window.addEventListener('load', loadScript.bind(null, src, async), { capture: false, once: true });
18
15
  }
16
+ const el = document.createElement('script');
17
+ el.type = 'text/javascript';
18
+ el.async = async;
19
+ el.src = src;
20
+ document.head.appendChild(el);
21
+ }
22
+
23
+ function bootstrap() {
24
+ if (w.CommandBar !== undefined) return;
25
+ delete w.__CommandBarBootstrap__;
19
26
 
20
- function bootstrap() {
21
- if (w.CommandBar !== undefined) return;
22
- delete w.__CommandBarBootstrap__;
27
+ const _configuration = Symbol.for('CommandBar::configuration');
28
+ const _disposed = Symbol.for('CommandBar::disposed');
29
+ const _isProxy = Symbol.for('CommandBar::isProxy');
30
+ const _queue = Symbol.for('CommandBar::queue');
31
+ const _unwrap = Symbol.for('CommandBar::unwrap');
32
+ const _eventSubscriptions = Symbol.for('CommandBar::eventSubscriptions');
23
33
 
24
- const _configuration = Symbol.for('CommandBar::configuration');
25
- const _orgConfig = Symbol.for('CommandBar::orgConfig');
26
- const _disposed = Symbol.for('CommandBar::disposed');
27
- const _isProxy = Symbol.for('CommandBar::isProxy');
28
- const _queue = Symbol.for('CommandBar::queue');
29
- const _unwrap = Symbol.for('CommandBar::unwrap');
30
- const _eventSubscriptions = Symbol.for('CommandBar::eventSubscriptions');
34
+ const params = [];
35
+ const lc = localStorage.getItem('commandbar.lc');
31
36
 
32
- const params = [];
33
- const lc = localStorage.getItem('commandbar.lc');
34
- const origin = lc && lc.includes('local') ? 'http://localhost:8000' : 'https://api.commandbar.com';
37
+ if (lc && lc.includes('local')) {
38
+ api = 'http://localhost:8000';
39
+ cdn = undefined;
40
+ }
35
41
 
36
- const proxy = Object.assign(
37
- {
38
- [_configuration]: { uuid: org },
39
- [_orgConfig]: {},
40
- [_disposed]: false,
41
- [_isProxy]: true,
42
- [_queue]: new Array<unknown>(),
43
- [_unwrap]: () => proxy,
44
- [_eventSubscriptions]: undefined,
45
- },
46
- w.CommandBar,
47
- );
42
+ const proxy = Object.assign(
43
+ {
44
+ [_configuration]: { uuid: org, api, cdn },
45
+ [_disposed]: false,
46
+ [_isProxy]: true,
47
+ [_queue]: new Array<unknown>(),
48
+ [_unwrap]: () => proxy,
49
+ [_eventSubscriptions]: undefined,
50
+ },
51
+ w.CommandBar,
52
+ );
48
53
 
49
- const ASYNC_METHODS_SNIPPET = ['addCommand', 'boot', 'addEventSubscriber', 'addRecordAction', 'setFormFactor'];
54
+ const ASYNC_METHODS_SNIPPET = ['addCommand', 'boot', 'addEventSubscriber', 'addRecordAction', 'setFormFactor'];
50
55
 
51
- const sdk = proxy;
56
+ const sdk = proxy;
52
57
 
53
- Object.assign(proxy, {
54
- shareCallbacks: () => ({}),
55
- shareContext: () => ({}),
56
- });
58
+ Object.assign(proxy, {
59
+ shareCallbacks: () => ({}),
60
+ shareContext: () => ({}),
61
+ });
57
62
 
58
- w.CommandBar = new Proxy(proxy, {
59
- get: function (_, prop) {
60
- if (prop in sdk) return proxy[prop];
61
- if ((prop as any) === 'then') return undefined;
62
- if (ASYNC_METHODS_SNIPPET.includes(prop as string)) {
63
- return function () {
64
- // eslint-disable-next-line prefer-rest-params
65
- const a = Array.prototype.slice.call(arguments);
66
- return new Promise((resolve, reject) => {
67
- a.unshift(prop, resolve, reject);
68
- (proxy[_queue] as Array<unknown>).push(a);
69
- });
70
- };
71
- }
63
+ w.CommandBar = new Proxy(proxy, {
64
+ get: function (_, prop) {
65
+ if (prop in sdk) return proxy[prop];
66
+ if ((prop as any) === 'then') return undefined;
67
+ if (ASYNC_METHODS_SNIPPET.includes(prop as string)) {
72
68
  return function () {
73
69
  // eslint-disable-next-line prefer-rest-params
74
70
  const a = Array.prototype.slice.call(arguments);
75
- a.unshift(prop);
76
- (proxy[_queue] as Array<unknown>).push(a);
71
+ return new Promise((resolve, reject) => {
72
+ a.unshift(prop, resolve, reject);
73
+ (proxy[_queue] as Array<unknown>).push(a);
74
+ });
77
75
  };
78
- },
79
- });
76
+ }
77
+ return function () {
78
+ // eslint-disable-next-line prefer-rest-params
79
+ const a = Array.prototype.slice.call(arguments);
80
+ a.unshift(prop);
81
+ (proxy[_queue] as Array<unknown>).push(a);
82
+ };
83
+ },
84
+ });
80
85
 
81
- if (lc !== null) params.push(`lc=${lc}`);
82
- params.push('version=2');
86
+ if (lc !== null) params.push(`lc=${lc}`);
87
+ params.push('version=2');
88
+ if (cdn) params.push(`cdn=${encodeURIComponent(cdn)}`);
83
89
 
84
- loadScript(`${origin}/latest/${org}?${params.join('&')}`, true);
85
- }
90
+ loadScript(`${api}/latest/${org}?${params.join('&')}`, true);
91
+ }
86
92
 
87
- if (typeof Object.assign === 'undefined' || typeof Symbol === 'undefined' || typeof Symbol.for === 'undefined') {
88
- w.__CommandBarBootstrap__ = bootstrap;
89
- loadScript(
90
- 'https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features=' + polyfills,
91
- );
92
- } else {
93
- bootstrap();
94
- }
95
- };
93
+ if (typeof Object.assign === 'undefined' || typeof Symbol === 'undefined' || typeof Symbol.for === 'undefined') {
94
+ w.__CommandBarBootstrap__ = bootstrap;
95
+ loadScript(
96
+ 'https://polyfill.io/v3/polyfill.min.js?version=3.101.0&callback=__CommandBarBootstrap__&features=' + polyfills,
97
+ );
98
+ } else {
99
+ bootstrap();
100
+ }
@@ -1,5 +0,0 @@
1
- export interface OrgConfig {
2
- name?: string;
3
- silent?: boolean;
4
- eventAttributeBlockList?: string[];
5
- }
@@ -1,37 +0,0 @@
1
- import * as t from 'io-ts';
2
- export declare const GuideV: t.IntersectionC<[t.TypeC<{
3
- id: t.NumberC;
4
- organization: t.StringC;
5
- event: t.StringC;
6
- nudge: t.StringC;
7
- guidance: t.StringC;
8
- }>, t.PartialC<{}>]>;
9
- export declare class Guide {
10
- static create: (object: {
11
- id: number;
12
- organization: string;
13
- event: string;
14
- nudge: string;
15
- guidance: string;
16
- } & {}, onSuccess?: (() => void) | undefined, onError?: ((err: string) => void) | undefined) => Promise<{
17
- id: number;
18
- organization: string;
19
- event: string;
20
- nudge: string;
21
- guidance: string;
22
- } & {}>;
23
- static update: (object: {
24
- id: number;
25
- organization: string;
26
- event: string;
27
- nudge: string;
28
- guidance: string;
29
- } & {}, onSuccess?: (() => void) | undefined, onError?: ((err: string) => void) | undefined) => Promise<{
30
- id: number;
31
- organization: string;
32
- event: string;
33
- nudge: string;
34
- guidance: string;
35
- } & {}>;
36
- static delete: (id: string | number, params?: Record<string, string> | undefined, onSuccess?: (() => void) | undefined, onError?: ((err: string) => void) | undefined) => Promise<void>;
37
- }