commandbar 1.10.1 → 1.10.2-alpha
Sign up to get free protection for your applications and to get access to all the features.
- package/build/commandbar/src/shared/services/analytics/EventHandler.d.ts +7 -2
- package/build/commandbar/src/shared/services/analytics/event-queue.d.ts +13 -0
- package/build/commandbar/src/shared/services/analytics/types.d.ts +1 -1
- package/build/commandbar/src/shared/services/analytics/v2/client.d.ts +54 -0
- package/build/commandbar/src/shared/services/analytics/v2/helpers.d.ts +6 -0
- package/build/commandbar/src/shared/services/analytics/v2/schema.d.ts +152 -0
- package/build/commandbar/src/shared/services/analytics/v2/types.d.ts +4 -0
- package/build/commandbar-js/src/index.d.ts +0 -1
- package/build/commandbar-js/src/index.js +1 -1
- package/build/commandbar-js/src/snippet.d.ts +7 -1
- package/build/internal/src/client/CommandBarClientSDK.d.ts +12 -0
- package/build/internal/src/client/CommandBarProxySDK.d.ts +1 -4
- package/build/internal/src/client/CommandBarSDK.d.ts +5 -3
- package/build/internal/src/client/SDKConfig.d.ts +3 -1
- package/build/internal/src/client/globals.d.ts +1 -0
- package/build/internal/src/client/symbols.d.ts +3 -1
- package/build/internal/src/middleware/CommandFromClientV.d.ts +16 -2
- package/build/internal/src/middleware/OrganizationV.d.ts +34 -8
- package/build/internal/src/middleware/additionalResource.d.ts +9 -9
- package/build/internal/src/middleware/api.d.ts +173 -0
- package/build/internal/src/middleware/billing.d.ts +10 -0
- package/build/internal/src/middleware/chat.d.ts +3662 -172
- package/build/internal/src/middleware/checklist.d.ts +18 -10
- package/build/internal/src/middleware/command.d.ts +540 -140
- package/build/internal/src/middleware/endUser.d.ts +2 -0
- package/build/internal/src/middleware/experienceTemplate.d.ts +2874 -8
- package/build/internal/src/middleware/experiencesSearch.d.ts +233 -28
- package/build/internal/src/middleware/flags.d.ts +14 -1
- package/build/internal/src/middleware/generics.d.ts +1 -0
- package/build/internal/src/middleware/helpDocsIntegration.d.ts +98 -0
- package/build/internal/src/middleware/helpDocsSearch.d.ts +165 -20
- package/build/internal/src/middleware/helpDocsSync.d.ts +4 -0
- package/build/internal/src/middleware/helpers/actions.d.ts +6 -6
- package/build/internal/src/middleware/helpers/commandTemplate.d.ts +2 -2
- package/build/internal/src/middleware/helpers/rules.d.ts +7 -7
- package/build/internal/src/middleware/localizedMessage.d.ts +50 -0
- package/build/internal/src/middleware/network.d.ts +1 -0
- package/build/internal/src/middleware/nudge.d.ts +96 -24
- package/build/internal/src/middleware/organization.d.ts +180 -62
- package/build/internal/src/middleware/organizationSettings.d.ts +8 -8
- package/build/internal/src/middleware/profile.d.ts +8 -0
- package/build/internal/src/middleware/recommendationSet.d.ts +18 -9
- package/build/internal/src/middleware/theme.d.ts +7 -0
- package/build/internal/src/middleware/types.d.ts +23 -5
- package/build/internal/src/middleware/user.d.ts +9 -1
- package/build/internal/src/middleware/workflow.d.ts +69 -0
- package/package.json +5 -2
- package/src/index.ts +0 -1
- package/src/init.ts +27 -13
- package/src/snippet.ts +79 -74
- package/build/internal/src/client/OrgConfig.d.ts +0 -5
- 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
|
-
|
6
|
-
|
7
|
-
|
5
|
+
let org = '<org_id>';
|
6
|
+
let api = 'https://api.commandbar.com';
|
7
|
+
let cdn: string | undefined = undefined;
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
25
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
37
|
+
if (lc && lc.includes('local')) {
|
38
|
+
api = 'http://localhost:8000';
|
39
|
+
cdn = undefined;
|
40
|
+
}
|
35
41
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|
-
|
54
|
+
const ASYNC_METHODS_SNIPPET = ['addCommand', 'boot', 'addEventSubscriber', 'addRecordAction', 'setFormFactor'];
|
50
55
|
|
51
|
-
|
56
|
+
const sdk = proxy;
|
52
57
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
58
|
+
Object.assign(proxy, {
|
59
|
+
shareCallbacks: () => ({}),
|
60
|
+
shareContext: () => ({}),
|
61
|
+
});
|
57
62
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
76
|
-
|
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
|
-
|
82
|
-
|
86
|
+
if (lc !== null) params.push(`lc=${lc}`);
|
87
|
+
params.push('version=2');
|
88
|
+
if (cdn) params.push(`cdn=${encodeURIComponent(cdn)}`);
|
83
89
|
|
84
|
-
|
85
|
-
|
90
|
+
loadScript(`${api}/latest/${org}?${params.join('&')}`, true);
|
91
|
+
}
|
86
92
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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,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
|
-
}
|