commandbar 1.6.11 → 1.6.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. package/build/commandbar-js/src/index.js +1 -1
  2. package/build/internal/src/client/AddContextOptions.d.ts +5 -0
  3. package/build/internal/src/client/CommandBarClientSDK.d.ts +55 -5
  4. package/build/internal/src/client/CommandBarProxySDK.d.ts +4 -4
  5. package/build/internal/src/client/CommandBarSDK.d.ts +4 -7
  6. package/build/internal/src/client/EventHandler.d.ts +3 -3
  7. package/build/internal/src/client/OrgConfig.d.ts +5 -0
  8. package/build/internal/src/client/SentryReporter.d.ts +24 -3
  9. package/build/internal/src/client/symbols.d.ts +1 -0
  10. package/build/internal/src/middleware/CommandFromClientV.d.ts +47 -3
  11. package/build/internal/src/middleware/OrganizationV.d.ts +16 -0
  12. package/build/internal/src/middleware/ResourceSettingsV.d.ts +4 -0
  13. package/build/internal/src/middleware/command.d.ts +1632 -213
  14. package/build/internal/src/middleware/commandCategory.d.ts +16 -0
  15. package/build/internal/src/middleware/detailPreview.d.ts +4 -2
  16. package/build/internal/src/middleware/generics.d.ts +10 -10
  17. package/build/internal/src/middleware/helpers/argument.d.ts +156 -0
  18. package/build/internal/src/middleware/helpers/commandTemplate.d.ts +34 -0
  19. package/build/internal/src/middleware/helpers/rules.d.ts +29 -26
  20. package/build/internal/src/middleware/nudge.d.ts +189 -0
  21. package/build/internal/src/middleware/organization.d.ts +164 -13
  22. package/build/internal/src/middleware/releases.d.ts +1 -1
  23. package/build/internal/src/middleware/types.d.ts +90 -10
  24. package/build/internal/src/middleware/user.d.ts +3 -1
  25. package/package.json +2 -4
  26. package/src/init.ts +6 -2
@@ -19,6 +19,8 @@ import { ProfileV } from './profile';
19
19
  import { PlaceholderV } from './placeholder';
20
20
  import { EnvReleaseInfoV, ReleaseStepV, ReleaseV } from './releases';
21
21
  import { EnvironmentV } from './environment';
22
+ import { NudgeV } from './nudge';
23
+ import { RuleExpressionAndV, RuleExpressionOrV, RuleExpressionV } from './helpers/rules';
22
24
  /*******************************************************************************/
23
25
  export declare type IContextType = t.TypeOf<typeof ContextV>;
24
26
  export declare type IUserType = t.TypeOf<typeof UserV>;
@@ -58,6 +60,9 @@ export declare type RequestTemplateType = t.TypeOf<typeof RequestTemplateV>;
58
60
  export declare type RequestType = t.TypeOf<typeof RequestV>;
59
61
  export declare type ITemplateOptions = t.TypeOf<typeof TemplateOptionsV>;
60
62
  export declare type IEndUserType = t.TypeOf<typeof EndUserV>;
63
+ export declare type IRuleExpression = t.TypeOf<typeof RuleExpressionV>;
64
+ export declare type IRuleExpressionAnd = t.TypeOf<typeof RuleExpressionAndV>;
65
+ export declare type IRuleExpressionOr = t.TypeOf<typeof RuleExpressionOrV>;
61
66
  export declare type IConditionType = t.TypeOf<typeof ConditionV>;
62
67
  export declare type IConditionOperatorType = t.TypeOf<typeof ConditionOperatorV>;
63
68
  export declare type IContextArgumentType = t.TypeOf<typeof ContextArgumentV>;
@@ -66,6 +71,12 @@ export declare type IDynamicArgumentType = t.TypeOf<typeof DynamicArgumentV>;
66
71
  export declare type IDependentArgumentType = t.TypeOf<typeof DependentArgumentV>;
67
72
  export declare type IFunctionArgumentType = t.TypeOf<typeof FunctionArgumentV>;
68
73
  export declare type OptionGroupRenderAsType = t.TypeOf<typeof OptionGroupRenderAsV>;
74
+ export declare type INudgeType = t.TypeOf<typeof NudgeV>;
75
+ export interface INudgeClientType {
76
+ nudge: INudgeType;
77
+ active: boolean;
78
+ lastTriggeredTs?: number;
79
+ }
69
80
  export interface ICommandInput {
70
81
  text: string;
71
82
  command: ICommandType;
@@ -96,6 +107,7 @@ export declare type IConfigEndpointResponse = {
96
107
  organization: any;
97
108
  environments_with_versions?: any[];
98
109
  placeholders?: any[];
110
+ nudges?: INudgeType[];
99
111
  };
100
112
  export type { IResourceSettings } from './IResourceSettings';
101
113
  export declare type IResourceSettingsByContextKey = t.TypeOf<typeof ResourceSettingsByContextKeyV>;
@@ -190,6 +202,22 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
190
202
  object?: string | undefined;
191
203
  hoverTooltip?: boolean | undefined;
192
204
  operation?: "self" | "router" | "blank" | undefined;
205
+ }) | ({
206
+ type: "video";
207
+ value: string;
208
+ } & {} & {
209
+ commandType?: "object" | "independent" | "help" | undefined;
210
+ object?: string | undefined;
211
+ hoverTooltip?: boolean | undefined;
212
+ operation?: "self" | "router" | "blank" | undefined;
213
+ }) | ({
214
+ type: "helpdoc";
215
+ value: string;
216
+ } & {} & {
217
+ commandType?: "object" | "independent" | "help" | undefined;
218
+ object?: string | undefined;
219
+ hoverTooltip?: boolean | undefined;
220
+ operation?: "self" | "router" | "blank" | undefined;
193
221
  });
194
222
  } & {
195
223
  disabledReason?: string | undefined;
@@ -220,6 +248,8 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
220
248
  allow_create_label?: string | undefined;
221
249
  show_in_record_action_list?: boolean | undefined;
222
250
  show_in_default_list?: boolean | undefined;
251
+ auto_choose?: boolean | undefined;
252
+ is_private?: boolean | undefined;
223
253
  }) | ({
224
254
  type: "set";
225
255
  value: string[] | number[] | {
@@ -241,6 +271,8 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
241
271
  loaded?: any[] | undefined;
242
272
  allow_create?: boolean | undefined;
243
273
  allow_create_label?: string | undefined;
274
+ auto_choose?: boolean | undefined;
275
+ is_private?: boolean | undefined;
244
276
  }) | ({
245
277
  type: "provided";
246
278
  value: "time" | "text";
@@ -261,6 +293,8 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
261
293
  dateTimeArgumentTypeId?: number | undefined;
262
294
  allow_create?: boolean | undefined;
263
295
  allow_create_label?: string | undefined;
296
+ auto_choose?: boolean | undefined;
297
+ is_private?: boolean | undefined;
264
298
  }) | ({
265
299
  type: "dependent";
266
300
  value: string;
@@ -280,6 +314,8 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
280
314
  loaded?: any[] | undefined;
281
315
  allow_create?: boolean | undefined;
282
316
  allow_create_label?: string | undefined;
317
+ auto_choose?: boolean | undefined;
318
+ is_private?: boolean | undefined;
283
319
  }) | ({
284
320
  type: "function";
285
321
  value: string;
@@ -299,6 +335,35 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
299
335
  loaded?: any[] | undefined;
300
336
  allow_create?: boolean | undefined;
301
337
  allow_create_label?: string | undefined;
338
+ auto_choose?: boolean | undefined;
339
+ is_private?: boolean | undefined;
340
+ }) | ({
341
+ type: "html" | "video";
342
+ value: {
343
+ source: string;
344
+ } & {
345
+ title?: string | undefined;
346
+ description?: string | undefined;
347
+ url?: string | undefined;
348
+ };
349
+ order_key: number;
350
+ } & {
351
+ label?: string | undefined;
352
+ chosen?: string | number | undefined;
353
+ selected?: any[] | undefined;
354
+ input_type?: string | undefined;
355
+ preselected_key?: string | undefined;
356
+ label_field?: string | undefined;
357
+ availability_condition?: {
358
+ field: string;
359
+ operator: "==" | "!=" | "isTruthy" | "isFalsy";
360
+ value: string | undefined;
361
+ }[] | undefined;
362
+ loaded?: any[] | undefined;
363
+ allow_create?: boolean | undefined;
364
+ allow_create_label?: string | undefined;
365
+ is_private?: boolean | undefined;
366
+ auto_choose?: boolean | undefined;
302
367
  });
303
368
  };
304
369
  tags: string[];
@@ -311,23 +376,27 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
311
376
  reason?: string | undefined;
312
377
  })[];
313
378
  recommend_rules: (({
314
- type: "always";
315
- } & {
316
- operator?: null | undefined;
317
- field?: null | undefined;
318
- value?: null | undefined;
319
- reason?: null | undefined;
320
- }) | ({
321
379
  type: "url" | "context" | "element";
322
380
  operator: "includes" | "endsWith" | "startsWith" | "is" | "isTruthy" | "isFalsy" | "isNot" | "isTrue" | "isFalse" | "doesNotInclude" | "matchesRegex" | "isGreaterThan" | "isLessThan" | "isDefined" | "isNotDefined" | "classnameOnPage" | "idOnPage";
323
381
  } & {
324
382
  field?: string | undefined;
325
383
  value?: string | undefined;
326
384
  reason?: string | undefined;
385
+ }) | ({
386
+ type: "always";
387
+ } & {
388
+ operator?: null | undefined;
389
+ field?: null | undefined;
390
+ value?: null | undefined;
391
+ reason?: null | undefined;
327
392
  }))[];
393
+ availability_expression: import("./helpers/rules").RuleExpression | null;
394
+ recommend_expression: import("./helpers/rules").RuleExpression | null;
395
+ always_recommend: boolean;
328
396
  confirm: string;
329
397
  shortcut: string[];
330
398
  explanation: string;
399
+ heading: string;
331
400
  is_live: boolean;
332
401
  category: number | null;
333
402
  sort_key: number | null;
@@ -351,13 +420,18 @@ export declare const isCommand: (command?: ICommandType | any) => command is {
351
420
  shortcut_win: string[];
352
421
  hotkey_mac: string;
353
422
  hotkey_win: string;
354
- detail: string | {
423
+ detail: string | ({
355
424
  type: "html" | "video" | "plaintext" | "markdown" | "react" | null;
356
425
  value: string;
357
- } | (string | {
426
+ } & {
427
+ position?: "inline" | "popover" | undefined;
428
+ }) | (string | ({
358
429
  type: "html" | "video" | "plaintext" | "markdown" | "react" | null;
359
430
  value: string;
360
- })[] | null;
431
+ } & {
432
+ position?: "inline" | "popover" | undefined;
433
+ }))[] | null;
434
+ next_steps: (string | number)[];
361
435
  };
362
436
  export declare const isResource: (option: any) => option is IResourceType;
363
437
  export declare const isContextArgument: (argument: IArgumentType) => argument is {
@@ -381,6 +455,8 @@ export declare const isContextArgument: (argument: IArgumentType) => argument is
381
455
  allow_create_label?: string | undefined;
382
456
  show_in_record_action_list?: boolean | undefined;
383
457
  show_in_default_list?: boolean | undefined;
458
+ auto_choose?: boolean | undefined;
459
+ is_private?: boolean | undefined;
384
460
  };
385
461
  export declare const isTimeArgument: (argument: IArgumentType) => argument is {
386
462
  type: "provided";
@@ -402,6 +478,8 @@ export declare const isTimeArgument: (argument: IArgumentType) => argument is {
402
478
  dateTimeArgumentTypeId?: number | undefined;
403
479
  allow_create?: boolean | undefined;
404
480
  allow_create_label?: string | undefined;
481
+ auto_choose?: boolean | undefined;
482
+ is_private?: boolean | undefined;
405
483
  };
406
484
  export declare const isFunctionArgument: (argument: IArgumentType) => argument is {
407
485
  type: "function";
@@ -422,4 +500,6 @@ export declare const isFunctionArgument: (argument: IArgumentType) => argument i
422
500
  loaded?: any[] | undefined;
423
501
  allow_create?: boolean | undefined;
424
502
  allow_create_label?: string | undefined;
503
+ auto_choose?: boolean | undefined;
504
+ is_private?: boolean | undefined;
425
505
  };
@@ -9,4 +9,6 @@ export declare const UserV: t.IntersectionC<[t.TypeC<{
9
9
  profile: t.NumberC;
10
10
  has_updated_password: t.BooleanC;
11
11
  is_active: t.BooleanC;
12
- }>, t.PartialC<{}>]>;
12
+ }>, t.PartialC<{
13
+ intercom_hash: t.StringC;
14
+ }>]>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commandbar",
3
- "version": "1.6.11",
3
+ "version": "1.6.14",
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",
@@ -22,7 +22,5 @@
22
22
  "io-ts": "2.2.13"
23
23
  },
24
24
  "devDependencies": {},
25
- "peerDependencies": {
26
- "@sentry/react": "6.19.7"
27
- }
25
+ "peerDependencies": {}
28
26
  }
package/src/init.ts CHANGED
@@ -20,8 +20,6 @@ const getSrc = (org: string) => {
20
20
  if (lc && lc.includes('local')) {
21
21
  // for debugging purposes
22
22
  origin = 'http://localhost:8000';
23
- } else if (!lc && org === '10d7dc04') {
24
- origin = 'https://api-cu.commandbar.com';
25
23
  }
26
24
 
27
25
  let src = origin + '/latest/' + org;
@@ -72,6 +70,12 @@ const init = (org: string, opts: IInitOptions = DEFAULT_OPTS) => {
72
70
  return;
73
71
  }
74
72
 
73
+ // Do nothing if CommandBar SDK has already been initialized
74
+ if (!!getProxySDK()[_configuration]?.uuid) {
75
+ console.warn('CommandBar init was called more than once. Skipping the redundant initialization...');
76
+ return;
77
+ }
78
+
75
79
  config.debug && console.log('CommandBar init...', { environment: opts.environment, version: opts.version });
76
80
 
77
81
  getProxySDK()[_configuration] = {