@uipath/insights-sdk 1.203.0-preview.212 → 1.204.0-preview.211
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.js +899 -22
- package/dist/index.js +918 -26
- package/dist/src/dashboards.d.ts +338 -0
- package/dist/src/errors.d.ts +125 -5
- package/dist/src/export-configurations.d.ts +12 -0
- package/dist/src/index.d.ts +10 -2
- package/dist/src/machines.d.ts +67 -0
- package/dist/src/queues.d.ts +160 -0
- package/dist/src/transport.d.ts +69 -1
- package/package.json +2 -2
package/dist/index.browser.js
CHANGED
|
@@ -275,11 +275,25 @@ function settlePromiseLike(thenable) {
|
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
// src/errors.ts
|
|
278
|
+
var MODEL_NOT_FOUND_LABEL = "Model not found";
|
|
279
|
+
var DASHBOARD_NOT_FOUND_LABEL = "Dashboard not found";
|
|
280
|
+
var VALIDATION_FAILED_LABEL = "Validation failed";
|
|
281
|
+
var CREATE_BACKEND_FAILURE_LABEL = "Failed to create dashboard";
|
|
282
|
+
var UPDATE_BACKEND_FAILURE_LABEL = "Failed to update dashboard";
|
|
283
|
+
var KNOWN_ERROR_LABELS = new Set([
|
|
284
|
+
VALIDATION_FAILED_LABEL,
|
|
285
|
+
CREATE_BACKEND_FAILURE_LABEL,
|
|
286
|
+
UPDATE_BACKEND_FAILURE_LABEL,
|
|
287
|
+
DASHBOARD_NOT_FOUND_LABEL,
|
|
288
|
+
MODEL_NOT_FOUND_LABEL
|
|
289
|
+
]);
|
|
290
|
+
|
|
278
291
|
class InsightsHttpError extends Error {
|
|
279
292
|
status;
|
|
280
293
|
method;
|
|
281
294
|
endpoint;
|
|
282
295
|
bodyKind;
|
|
296
|
+
bodyHint;
|
|
283
297
|
requestId;
|
|
284
298
|
retryAfterSeconds;
|
|
285
299
|
constructor(init) {
|
|
@@ -289,6 +303,7 @@ class InsightsHttpError extends Error {
|
|
|
289
303
|
this.method = init.method;
|
|
290
304
|
this.endpoint = init.endpoint;
|
|
291
305
|
this.bodyKind = init.bodyKind;
|
|
306
|
+
this.bodyHint = init.bodyHint;
|
|
292
307
|
this.requestId = init.requestId;
|
|
293
308
|
this.retryAfterSeconds = init.retryAfterSeconds;
|
|
294
309
|
}
|
|
@@ -296,10 +311,12 @@ class InsightsHttpError extends Error {
|
|
|
296
311
|
|
|
297
312
|
class InsightsNetworkError extends Error {
|
|
298
313
|
endpoint;
|
|
314
|
+
phase;
|
|
299
315
|
constructor(endpoint, cause, phase = "request") {
|
|
300
316
|
super(phase === "request" ? `Insights request failed before a response was received for ${endpoint}` : `Insights connection failed while reading the response body for ${endpoint}`, { cause });
|
|
301
317
|
this.name = "InsightsNetworkError";
|
|
302
318
|
this.endpoint = endpoint;
|
|
319
|
+
this.phase = phase;
|
|
303
320
|
}
|
|
304
321
|
}
|
|
305
322
|
|
|
@@ -315,7 +332,136 @@ class InsightsProtocolError extends Error {
|
|
|
315
332
|
// ../common/src/telemetry/global-telemetry-properties.ts
|
|
316
333
|
var telemetryPropsSlot = singleton("TelemetryDefaultProps");
|
|
317
334
|
|
|
335
|
+
// ../common/src/telemetry/telemetry-dimensions.ts
|
|
336
|
+
var BaseDimensions = {
|
|
337
|
+
ApplicationName: "ApplicationName",
|
|
338
|
+
ProductVersion: "ProductVersion",
|
|
339
|
+
InstallationId: "InstallationId",
|
|
340
|
+
CloudUserId: "CloudUserId",
|
|
341
|
+
CloudTenantId: "CloudTenantId",
|
|
342
|
+
CloudOrganizationId: "CloudOrganizationId",
|
|
343
|
+
IsInternalUser: "IsInternalUser",
|
|
344
|
+
Environment: "Environment",
|
|
345
|
+
BaseUrl: "BaseUrl",
|
|
346
|
+
Region: "Region",
|
|
347
|
+
Agent: "Agent",
|
|
348
|
+
AgentVersion: "AgentVersion",
|
|
349
|
+
AgentModel: "AgentModel",
|
|
350
|
+
ToolName: "ToolName",
|
|
351
|
+
ToolVersion: "ToolVersion",
|
|
352
|
+
ExecutionContext: "ExecutionContext",
|
|
353
|
+
CiProvider: "CiProvider",
|
|
354
|
+
SessionIdSource: "SessionIdSource",
|
|
355
|
+
SessionId: "SessionId"
|
|
356
|
+
};
|
|
357
|
+
var CommandDimensions = {
|
|
358
|
+
IsCommand: "IsCommand",
|
|
359
|
+
IsReexec: "IsReexec",
|
|
360
|
+
CommandName: "CommandName",
|
|
361
|
+
ExitCode: "ExitCode",
|
|
362
|
+
TerminalOutcome: "TerminalOutcome",
|
|
363
|
+
ErrorClass: "ErrorClass",
|
|
364
|
+
TerminalSignal: "TerminalSignal",
|
|
365
|
+
ErrorMessage: "ErrorMessage",
|
|
366
|
+
SkillName: "SkillName",
|
|
367
|
+
ProductArea: "ProductArea",
|
|
368
|
+
Mode: "Mode"
|
|
369
|
+
};
|
|
370
|
+
var ShipDimensions = {
|
|
371
|
+
ShipKind: "ShipKind",
|
|
372
|
+
Target: "Target",
|
|
373
|
+
ProjectType: "ProjectType",
|
|
374
|
+
ProjectTypes: "ProjectTypes",
|
|
375
|
+
ArtifactCorrelationKey: "ArtifactCorrelationKey",
|
|
376
|
+
PackageName: "PackageName",
|
|
377
|
+
PackageVersion: "PackageVersion",
|
|
378
|
+
PackageVersionKey: "PackageVersionKey",
|
|
379
|
+
DeploymentKey: "DeploymentKey",
|
|
380
|
+
SolutionId: "SolutionId",
|
|
381
|
+
FolderKey: "FolderKey",
|
|
382
|
+
FeedId: "FeedId"
|
|
383
|
+
};
|
|
384
|
+
var ErrorDimensions = {
|
|
385
|
+
Result: "Result",
|
|
386
|
+
ErrorCode: "ErrorCode",
|
|
387
|
+
Retry: "Retry",
|
|
388
|
+
ErrorMessage: "ErrorMessage"
|
|
389
|
+
};
|
|
390
|
+
var AuthDimensions = {
|
|
391
|
+
AuthenticationMethod: "AuthenticationMethod",
|
|
392
|
+
Success: "Success",
|
|
393
|
+
Reason: "Reason"
|
|
394
|
+
};
|
|
395
|
+
var SkillsDimensions = {
|
|
396
|
+
SchemaVersion: "SchemaVersion",
|
|
397
|
+
AgentType: "AgentType",
|
|
398
|
+
SkillsVersion: "SkillsVersion",
|
|
399
|
+
UipSubcommand: "UipSubcommand",
|
|
400
|
+
FileExtension: "FileExtension",
|
|
401
|
+
SubagentModel: "SubagentModel",
|
|
402
|
+
SubagentType: "SubagentType",
|
|
403
|
+
PermissionMode: "PermissionMode",
|
|
404
|
+
EffortLevel: "EffortLevel",
|
|
405
|
+
SessionSource: "SessionSource",
|
|
406
|
+
Outcome: "Outcome",
|
|
407
|
+
DurationMs: "DurationMs",
|
|
408
|
+
Source: "Source"
|
|
409
|
+
};
|
|
410
|
+
var PackagerDimensions = {
|
|
411
|
+
ProjectId: "ProjectId",
|
|
412
|
+
ProjectType: "ProjectType",
|
|
413
|
+
SolutionId: "SolutionId"
|
|
414
|
+
};
|
|
415
|
+
var ScopeDimensions = {
|
|
416
|
+
FolderId: "FolderId"
|
|
417
|
+
};
|
|
418
|
+
var ID_DIMENSIONS = new Set([
|
|
419
|
+
BaseDimensions.CloudUserId,
|
|
420
|
+
BaseDimensions.CloudTenantId,
|
|
421
|
+
BaseDimensions.CloudOrganizationId,
|
|
422
|
+
BaseDimensions.InstallationId,
|
|
423
|
+
ShipDimensions.ArtifactCorrelationKey,
|
|
424
|
+
ShipDimensions.PackageVersionKey,
|
|
425
|
+
ShipDimensions.DeploymentKey,
|
|
426
|
+
ShipDimensions.SolutionId,
|
|
427
|
+
ShipDimensions.FolderKey,
|
|
428
|
+
ShipDimensions.FeedId,
|
|
429
|
+
PackagerDimensions.ProjectId
|
|
430
|
+
]);
|
|
431
|
+
var RESERVED_DIMENSION_NAMES = new Set([
|
|
432
|
+
...Object.values(BaseDimensions),
|
|
433
|
+
...Object.values(CommandDimensions),
|
|
434
|
+
...Object.values(ShipDimensions),
|
|
435
|
+
...Object.values(ErrorDimensions),
|
|
436
|
+
...Object.values(AuthDimensions),
|
|
437
|
+
...Object.values(SkillsDimensions),
|
|
438
|
+
...Object.values(PackagerDimensions),
|
|
439
|
+
...Object.values(ScopeDimensions)
|
|
440
|
+
]);
|
|
441
|
+
var CURATED_DIMENSIONS = new Set([
|
|
442
|
+
BaseDimensions.ApplicationName,
|
|
443
|
+
BaseDimensions.ProductVersion,
|
|
444
|
+
BaseDimensions.InstallationId,
|
|
445
|
+
BaseDimensions.CloudUserId,
|
|
446
|
+
BaseDimensions.CloudTenantId,
|
|
447
|
+
BaseDimensions.CloudOrganizationId,
|
|
448
|
+
BaseDimensions.IsInternalUser,
|
|
449
|
+
BaseDimensions.Environment,
|
|
450
|
+
BaseDimensions.BaseUrl,
|
|
451
|
+
BaseDimensions.Region,
|
|
452
|
+
BaseDimensions.Agent,
|
|
453
|
+
BaseDimensions.AgentVersion,
|
|
454
|
+
BaseDimensions.ToolVersion,
|
|
455
|
+
BaseDimensions.ExecutionContext,
|
|
456
|
+
BaseDimensions.CiProvider,
|
|
457
|
+
BaseDimensions.SessionIdSource,
|
|
458
|
+
BaseDimensions.SessionId,
|
|
459
|
+
...Object.values(CommandDimensions),
|
|
460
|
+
...Object.values(ShipDimensions)
|
|
461
|
+
]);
|
|
462
|
+
|
|
318
463
|
// ../common/src/sdk-user-agent.ts
|
|
464
|
+
var AGENT_PROPERTY = BaseDimensions.Agent;
|
|
319
465
|
var sdkUserAgentHostToken = singleton("SdkUserAgentHostToken");
|
|
320
466
|
function splitUserAgentTokens(value) {
|
|
321
467
|
return value?.trim().split(/\s+/).filter(Boolean) ?? [];
|
|
@@ -343,7 +489,7 @@ var package_default = {
|
|
|
343
489
|
name: "@uipath/insights-sdk",
|
|
344
490
|
author: "UiPath",
|
|
345
491
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
346
|
-
version: "1.
|
|
492
|
+
version: "1.204.0-preview.211",
|
|
347
493
|
description: "SDK for the UiPath Insights API — jobs, failures, and performance metrics.",
|
|
348
494
|
repository: {
|
|
349
495
|
type: "git",
|
|
@@ -431,7 +577,8 @@ var INSIGHTS_ROUTES = {
|
|
|
431
577
|
alertDefinitionsSnooze: {
|
|
432
578
|
service: "rtm",
|
|
433
579
|
method: "PUT",
|
|
434
|
-
template: "AlertDefinitions/{tenantId}/{alertDefinitionId}/{accountName}/{tenantName}/snooze
|
|
580
|
+
template: "AlertDefinitions/{tenantId}/{alertDefinitionId}/{accountName}/{tenantName}/snooze",
|
|
581
|
+
queryParams: ["isSnoozed"]
|
|
435
582
|
},
|
|
436
583
|
alertDefinitionsDelete: {
|
|
437
584
|
service: "rtm",
|
|
@@ -479,6 +626,59 @@ var INSIGHTS_ROUTES = {
|
|
|
479
626
|
method: "POST",
|
|
480
627
|
template: "Filters/allMachines"
|
|
481
628
|
},
|
|
629
|
+
dashboardsGet: {
|
|
630
|
+
service: "rtm",
|
|
631
|
+
method: "GET",
|
|
632
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}/{dashboardId}",
|
|
633
|
+
identityHeaders: "ids",
|
|
634
|
+
queryParams: ["localization"]
|
|
635
|
+
},
|
|
636
|
+
dashboardFiltersList: {
|
|
637
|
+
service: "rtm",
|
|
638
|
+
method: "GET",
|
|
639
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}/{dashboardId}/filters",
|
|
640
|
+
identityHeaders: "ids"
|
|
641
|
+
},
|
|
642
|
+
dashboardTemplatesGet: {
|
|
643
|
+
service: "rtm",
|
|
644
|
+
method: "GET",
|
|
645
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}/template",
|
|
646
|
+
queryParams: [
|
|
647
|
+
"tenantId",
|
|
648
|
+
"organizationId",
|
|
649
|
+
"serviceIdentifier",
|
|
650
|
+
"localization"
|
|
651
|
+
]
|
|
652
|
+
},
|
|
653
|
+
dashboardsCreate: {
|
|
654
|
+
service: "rtm",
|
|
655
|
+
method: "POST",
|
|
656
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}",
|
|
657
|
+
identityHeaders: "tenant-id",
|
|
658
|
+
queryParams: ["organizationId", "serviceIdentifier"]
|
|
659
|
+
},
|
|
660
|
+
dashboardsUpdate: {
|
|
661
|
+
service: "rtm",
|
|
662
|
+
method: "PUT",
|
|
663
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}/{dashboardId}",
|
|
664
|
+
identityHeaders: "ids"
|
|
665
|
+
},
|
|
666
|
+
dashboardsDelete: {
|
|
667
|
+
service: "rtm",
|
|
668
|
+
method: "DELETE",
|
|
669
|
+
template: "api/v1.0/standalone-dashboard/{sourceType}/{dashboardId}",
|
|
670
|
+
identityHeaders: "ids"
|
|
671
|
+
},
|
|
672
|
+
queuesQuery: {
|
|
673
|
+
service: "rtm",
|
|
674
|
+
method: "POST",
|
|
675
|
+
template: "Queues/{accountName}/{tenantName}"
|
|
676
|
+
},
|
|
677
|
+
machinesQuery: {
|
|
678
|
+
service: "rtm",
|
|
679
|
+
method: "POST",
|
|
680
|
+
template: "Machines"
|
|
681
|
+
},
|
|
482
682
|
usersList: { service: "portal", method: "GET", template: "User" },
|
|
483
683
|
usersGet: { service: "portal", method: "GET", template: "User/{userId}" },
|
|
484
684
|
rolesList: { service: "portal", method: "GET", template: "Role" },
|
|
@@ -493,12 +693,31 @@ var INSIGHTS_ROUTES = {
|
|
|
493
693
|
service: "portal",
|
|
494
694
|
method: "POST",
|
|
495
695
|
template: "Authorization/tenant/insights"
|
|
696
|
+
},
|
|
697
|
+
exportConfigurationsList: {
|
|
698
|
+
service: "portal",
|
|
699
|
+
method: "GET",
|
|
700
|
+
template: "unifiedexport/configuration"
|
|
701
|
+
},
|
|
702
|
+
exportDestinationsVerifyAll: {
|
|
703
|
+
service: "portal",
|
|
704
|
+
method: "POST",
|
|
705
|
+
template: "unifiedexport/destination/verify/all"
|
|
706
|
+
},
|
|
707
|
+
exportDestinationVerify: {
|
|
708
|
+
service: "portal",
|
|
709
|
+
method: "POST",
|
|
710
|
+
template: "unifiedexport/destination/{configurationId}/verify"
|
|
496
711
|
}
|
|
497
712
|
};
|
|
498
713
|
function insightsRouteTemplate(routeKey) {
|
|
499
714
|
return INSIGHTS_ROUTES[routeKey].template;
|
|
500
715
|
}
|
|
501
|
-
var
|
|
716
|
+
var SESSION_PATH_PARAM_NAMES = new Set([
|
|
717
|
+
"tenantId",
|
|
718
|
+
"accountName",
|
|
719
|
+
"tenantName"
|
|
720
|
+
]);
|
|
502
721
|
function sessionPathParams(config) {
|
|
503
722
|
return {
|
|
504
723
|
tenantId: config.tenantId,
|
|
@@ -506,6 +725,13 @@ function sessionPathParams(config) {
|
|
|
506
725
|
tenantName: config.tenantName
|
|
507
726
|
};
|
|
508
727
|
}
|
|
728
|
+
var SESSION_QUERY_PARAM_NAMES = new Set(["tenantId", "organizationId"]);
|
|
729
|
+
function sessionQueryParams(config) {
|
|
730
|
+
return {
|
|
731
|
+
tenantId: config.tenantId,
|
|
732
|
+
organizationId: config.organizationId
|
|
733
|
+
};
|
|
734
|
+
}
|
|
509
735
|
function encodePathSegment(routeKey, name, value) {
|
|
510
736
|
if (value.trim() === "" || value === "." || value === "..") {
|
|
511
737
|
throw new Error(`Insights route "${routeKey}" has an invalid value for "{${name}}".`);
|
|
@@ -514,7 +740,7 @@ function encodePathSegment(routeKey, name, value) {
|
|
|
514
740
|
}
|
|
515
741
|
function buildRoutePath(routeKey, template, config, pathParams) {
|
|
516
742
|
for (const name of Object.keys(pathParams)) {
|
|
517
|
-
if (
|
|
743
|
+
if (SESSION_PATH_PARAM_NAMES.has(name)) {
|
|
518
744
|
throw new Error(`Insights route segment "{${name}}" is session-derived and cannot be overridden.`);
|
|
519
745
|
}
|
|
520
746
|
if (!template.includes(`{${name}}`)) {
|
|
@@ -533,7 +759,22 @@ function buildRoutePath(routeKey, template, config, pathParams) {
|
|
|
533
759
|
return encodePathSegment(routeKey, name, value);
|
|
534
760
|
});
|
|
535
761
|
}
|
|
536
|
-
function
|
|
762
|
+
function rtmIdentityHeaders(config, profile) {
|
|
763
|
+
if (profile === "ids") {
|
|
764
|
+
return {
|
|
765
|
+
"X-UiPath-Internal-AccountId": config.organizationId,
|
|
766
|
+
"X-UiPath-Internal-TenantId": config.tenantId
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
if (profile === "tenant-id") {
|
|
770
|
+
return { "X-UiPath-Internal-TenantId": config.tenantId };
|
|
771
|
+
}
|
|
772
|
+
return {
|
|
773
|
+
"X-UiPath-Internal-AccountName": config.accountName,
|
|
774
|
+
"X-UiPath-Internal-TenantName": config.tenantName
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function buildServiceHeaders(config, route, hasBody) {
|
|
537
778
|
const headers = {
|
|
538
779
|
Authorization: `Bearer ${config.authToken}`,
|
|
539
780
|
Accept: "application/json"
|
|
@@ -541,9 +782,8 @@ function buildServiceHeaders(config, service, hasBody) {
|
|
|
541
782
|
if (hasBody) {
|
|
542
783
|
headers["Content-Type"] = "application/json";
|
|
543
784
|
}
|
|
544
|
-
if (service === "rtm") {
|
|
545
|
-
headers
|
|
546
|
-
headers["X-UiPath-Internal-TenantName"] = config.tenantName;
|
|
785
|
+
if (route.service === "rtm") {
|
|
786
|
+
Object.assign(headers, rtmIdentityHeaders(config, route.identityHeaders ?? "names"));
|
|
547
787
|
} else {
|
|
548
788
|
headers["X-UiPath-Internal-AccountId"] = config.organizationId;
|
|
549
789
|
headers["X-UiPath-Internal-TenantId"] = config.tenantId;
|
|
@@ -554,19 +794,46 @@ function buildServiceHeaders(config, service, hasBody) {
|
|
|
554
794
|
}
|
|
555
795
|
return headers;
|
|
556
796
|
}
|
|
557
|
-
|
|
797
|
+
var MODEL_PATH_PATTERN = /^[A-Za-z0-9_.[\]]{1,200}$/;
|
|
798
|
+
function describeJsonErrorBody(parsed) {
|
|
799
|
+
if (typeof parsed === "string") {
|
|
800
|
+
return { shape: "string" };
|
|
801
|
+
}
|
|
802
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
803
|
+
return { shape: "other" };
|
|
804
|
+
}
|
|
805
|
+
const record = parsed;
|
|
806
|
+
const hint = { shape: "object" };
|
|
807
|
+
if (typeof record.error === "string" && KNOWN_ERROR_LABELS.has(record.error)) {
|
|
808
|
+
hint.errorLabel = record.error;
|
|
809
|
+
}
|
|
810
|
+
if (typeof record.status === "number" && typeof record.title === "string") {
|
|
811
|
+
hint.problemDetails = true;
|
|
812
|
+
}
|
|
813
|
+
const errors = record.errors;
|
|
814
|
+
if (typeof record.status === "number" && typeof errors === "object" && errors !== null && !Array.isArray(errors)) {
|
|
815
|
+
const [firstKey] = Object.keys(errors);
|
|
816
|
+
if (firstKey !== undefined && MODEL_PATH_PATTERN.test(firstKey)) {
|
|
817
|
+
hint.firstInvalidField = firstKey;
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return hint;
|
|
821
|
+
}
|
|
822
|
+
function describeErrorBody(text) {
|
|
558
823
|
if (!text.trim()) {
|
|
559
|
-
return "absent";
|
|
824
|
+
return { kind: "absent" };
|
|
560
825
|
}
|
|
561
826
|
const head = text.trimStart().toLowerCase();
|
|
562
827
|
if (head.startsWith("<!doctype") || head.startsWith("<html")) {
|
|
563
|
-
return "html";
|
|
828
|
+
return { kind: "html" };
|
|
564
829
|
}
|
|
565
|
-
const [parseError] = catchError(() => JSON.parse(text));
|
|
830
|
+
const [parseError, parsed] = catchError(() => JSON.parse(text));
|
|
566
831
|
if (!parseError) {
|
|
567
|
-
return "json";
|
|
832
|
+
return { kind: "json", hint: describeJsonErrorBody(parsed) };
|
|
568
833
|
}
|
|
569
|
-
return
|
|
834
|
+
return {
|
|
835
|
+
kind: head.startsWith("{") || head.startsWith("[") ? "invalid-json" : "text"
|
|
836
|
+
};
|
|
570
837
|
}
|
|
571
838
|
function parseRetryAfterSeconds(header) {
|
|
572
839
|
if (header === null) {
|
|
@@ -575,28 +842,57 @@ function parseRetryAfterSeconds(header) {
|
|
|
575
842
|
const seconds = Number.parseInt(header, 10);
|
|
576
843
|
return Number.isNaN(seconds) || seconds < 0 ? undefined : seconds;
|
|
577
844
|
}
|
|
578
|
-
function httpErrorFrom(response, route,
|
|
845
|
+
function httpErrorFrom(response, route, body, cause) {
|
|
579
846
|
return new InsightsHttpError({
|
|
580
847
|
status: response.status,
|
|
581
848
|
method: route.method,
|
|
582
849
|
endpoint: route.template,
|
|
583
|
-
bodyKind,
|
|
850
|
+
bodyKind: body.kind,
|
|
851
|
+
bodyHint: body.hint,
|
|
584
852
|
requestId: response.headers.get("x-request-id") ?? undefined,
|
|
585
853
|
retryAfterSeconds: parseRetryAfterSeconds(response.headers.get("retry-after")),
|
|
586
854
|
cause
|
|
587
855
|
});
|
|
588
856
|
}
|
|
857
|
+
function buildRouteQuery(routeKey, route, config, query) {
|
|
858
|
+
const declared = route.queryParams ?? [];
|
|
859
|
+
if (declared.length > 0 && route.template.includes("?")) {
|
|
860
|
+
throw new Error(`Insights route "${routeKey}" declares query parameters and its template already has a "?".`);
|
|
861
|
+
}
|
|
862
|
+
for (const name of Object.keys(query)) {
|
|
863
|
+
if (SESSION_QUERY_PARAM_NAMES.has(name)) {
|
|
864
|
+
throw new Error(`Insights route query parameter "${name}" is session-derived and cannot be overridden.`);
|
|
865
|
+
}
|
|
866
|
+
if (!declared.includes(name)) {
|
|
867
|
+
throw new Error(`Insights route "${routeKey}" has no "${name}" query parameter.`);
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
const values = {
|
|
871
|
+
...sessionQueryParams(config),
|
|
872
|
+
...query
|
|
873
|
+
};
|
|
874
|
+
const search = new URLSearchParams;
|
|
875
|
+
for (const name of declared) {
|
|
876
|
+
const value = values[name];
|
|
877
|
+
if (value !== undefined) {
|
|
878
|
+
search.append(name, String(value));
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return search.toString();
|
|
882
|
+
}
|
|
589
883
|
async function requestInsightsRoute(config, routeKey, request = {}) {
|
|
590
884
|
const route = INSIGHTS_ROUTES[routeKey];
|
|
591
885
|
if (!route) {
|
|
592
886
|
throw new Error(`Unsupported Insights route "${routeKey}".`);
|
|
593
887
|
}
|
|
594
888
|
const path = buildRoutePath(routeKey, route.template, config, request.pathParams ?? {});
|
|
595
|
-
const
|
|
889
|
+
const basePath = `${config.baseUrl}/${encodePathSegment(routeKey, "organizationId", config.organizationId)}/${encodePathSegment(routeKey, "tenantName", config.tenantName)}/${SERVICE_ROOTS[route.service]}/${path}`;
|
|
890
|
+
const search = buildRouteQuery(routeKey, route, config, request.query ?? {});
|
|
891
|
+
const url = search === "" ? basePath : `${basePath}?${search}`;
|
|
596
892
|
const hasBody = request.body !== undefined;
|
|
597
893
|
const [fetchError, response] = await catchError(fetch(url, {
|
|
598
894
|
method: route.method,
|
|
599
|
-
headers: buildServiceHeaders(config, route
|
|
895
|
+
headers: buildServiceHeaders(config, route, hasBody),
|
|
600
896
|
body: hasBody ? JSON.stringify(request.body) : undefined
|
|
601
897
|
}));
|
|
602
898
|
if (fetchError) {
|
|
@@ -605,12 +901,12 @@ async function requestInsightsRoute(config, routeKey, request = {}) {
|
|
|
605
901
|
const [readError, text] = await catchError(response.text());
|
|
606
902
|
if (readError) {
|
|
607
903
|
if (!response.ok) {
|
|
608
|
-
throw httpErrorFrom(response, route, "
|
|
904
|
+
throw httpErrorFrom(response, route, { kind: "unreadable" }, readError);
|
|
609
905
|
}
|
|
610
906
|
throw new InsightsNetworkError(route.template, readError, "response-body");
|
|
611
907
|
}
|
|
612
908
|
if (!response.ok) {
|
|
613
|
-
throw httpErrorFrom(response, route,
|
|
909
|
+
throw httpErrorFrom(response, route, describeErrorBody(text));
|
|
614
910
|
}
|
|
615
911
|
if (!text.trim()) {
|
|
616
912
|
if (route.allowsEmptyResponse) {
|
|
@@ -722,6 +1018,331 @@ async function createInsightsConfig(tenantOverride) {
|
|
|
722
1018
|
tenantName: ctx.tenantName
|
|
723
1019
|
};
|
|
724
1020
|
}
|
|
1021
|
+
// ../common/src/guid.ts
|
|
1022
|
+
var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1023
|
+
function isGuid(value) {
|
|
1024
|
+
return GUID_REGEX.test(value);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
// src/dashboards.ts
|
|
1028
|
+
var DASHBOARD_TEMPLATE_ID_PREFIX = "UiPath-";
|
|
1029
|
+
var MAESTRO_PROCESS_DASHBOARD_PREFIX = "UiPath-Maestro-process-monitoring";
|
|
1030
|
+
var MAESTRO_CASE_DASHBOARD_PREFIX = "UiPath-Maestro-case-monitoring";
|
|
1031
|
+
var DASHBOARD_SLOT_DELIMITER = "___";
|
|
1032
|
+
var MAESTRO_DASHBOARD_SOURCE_TYPE = "AO";
|
|
1033
|
+
var SLOT_PREFIXES = {
|
|
1034
|
+
process: MAESTRO_PROCESS_DASHBOARD_PREFIX,
|
|
1035
|
+
case: MAESTRO_CASE_DASHBOARD_PREFIX
|
|
1036
|
+
};
|
|
1037
|
+
function composeDashboardSlotId(processKey, kind) {
|
|
1038
|
+
if (!isGuid(processKey)) {
|
|
1039
|
+
throw new Error("Insights dashboard slot ids are composed from a process key GUID.");
|
|
1040
|
+
}
|
|
1041
|
+
return `${SLOT_PREFIXES[kind]}${DASHBOARD_SLOT_DELIMITER}${processKey.toLowerCase()}`;
|
|
1042
|
+
}
|
|
1043
|
+
function isTemplateKeyedDashboardId(id) {
|
|
1044
|
+
return id.startsWith(DASHBOARD_TEMPLATE_ID_PREFIX);
|
|
1045
|
+
}
|
|
1046
|
+
function parseDashboardSlotId(id) {
|
|
1047
|
+
for (const [kind, prefix] of Object.entries(SLOT_PREFIXES)) {
|
|
1048
|
+
const head = `${prefix}${DASHBOARD_SLOT_DELIMITER}`;
|
|
1049
|
+
if (id.startsWith(head) && isGuid(id.slice(head.length))) {
|
|
1050
|
+
return { kind, processKey: id.slice(head.length) };
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
return;
|
|
1054
|
+
}
|
|
1055
|
+
function isRecord(value) {
|
|
1056
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1057
|
+
}
|
|
1058
|
+
function asRecord(value) {
|
|
1059
|
+
return isRecord(value) ? value : undefined;
|
|
1060
|
+
}
|
|
1061
|
+
function checkString(value, path) {
|
|
1062
|
+
return typeof value === "string" ? undefined : path;
|
|
1063
|
+
}
|
|
1064
|
+
function checkBoolean(value, path) {
|
|
1065
|
+
return typeof value === "boolean" ? undefined : path;
|
|
1066
|
+
}
|
|
1067
|
+
function checkInteger(value, path) {
|
|
1068
|
+
return typeof value === "number" && Number.isInteger(value) ? undefined : path;
|
|
1069
|
+
}
|
|
1070
|
+
function checkOptional(value, path, check) {
|
|
1071
|
+
return value === undefined || value === null ? undefined : check(value, path);
|
|
1072
|
+
}
|
|
1073
|
+
function checkNullableString(value, path) {
|
|
1074
|
+
return checkOptional(value, path, checkString);
|
|
1075
|
+
}
|
|
1076
|
+
function checkArray(value, path, checkItem) {
|
|
1077
|
+
if (!Array.isArray(value)) {
|
|
1078
|
+
return path;
|
|
1079
|
+
}
|
|
1080
|
+
for (const [index, item] of value.entries()) {
|
|
1081
|
+
const fault = checkItem(item, `${path}[${index}]`);
|
|
1082
|
+
if (fault !== undefined) {
|
|
1083
|
+
return fault;
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
function checkNullableArray(value, path, checkItem) {
|
|
1089
|
+
return checkOptional(value, path, (inner, innerPath) => checkArray(inner, innerPath, checkItem));
|
|
1090
|
+
}
|
|
1091
|
+
function firstFault(...faults) {
|
|
1092
|
+
return faults.find((fault) => fault !== undefined);
|
|
1093
|
+
}
|
|
1094
|
+
function checkFieldFormat(value, path) {
|
|
1095
|
+
const record = asRecord(value);
|
|
1096
|
+
if (record === undefined) {
|
|
1097
|
+
return path;
|
|
1098
|
+
}
|
|
1099
|
+
return firstFault(checkOptional(record.trueDisplay, `${path}.trueDisplay`, checkString), checkOptional(record.falseDisplay, `${path}.falseDisplay`, checkString));
|
|
1100
|
+
}
|
|
1101
|
+
function checkField(value, path) {
|
|
1102
|
+
const record = asRecord(value);
|
|
1103
|
+
if (record === undefined) {
|
|
1104
|
+
return path;
|
|
1105
|
+
}
|
|
1106
|
+
return firstFault(checkString(record.id, `${path}.id`), checkString(record.display, `${path}.display`), checkString(record.type, `${path}.type`), checkOptional(record.hidden, `${path}.hidden`, checkBoolean), checkOptional(record.format, `${path}.format`, checkFieldFormat));
|
|
1107
|
+
}
|
|
1108
|
+
function checkTable(value, path) {
|
|
1109
|
+
const record = asRecord(value);
|
|
1110
|
+
if (record === undefined) {
|
|
1111
|
+
return path;
|
|
1112
|
+
}
|
|
1113
|
+
return firstFault(checkString(record.id, `${path}.id`), checkString(record.display, `${path}.display`), checkArray(record.fields, `${path}.fields`, checkField));
|
|
1114
|
+
}
|
|
1115
|
+
function checkJsonArray(value, path) {
|
|
1116
|
+
return Array.isArray(value) ? undefined : path;
|
|
1117
|
+
}
|
|
1118
|
+
function checkMetricFilter(value, path) {
|
|
1119
|
+
const record = asRecord(value);
|
|
1120
|
+
if (record === undefined) {
|
|
1121
|
+
return path;
|
|
1122
|
+
}
|
|
1123
|
+
return firstFault(checkNullableString(record.kind, `${path}.kind`), checkNullableString(record.dimension, `${path}.dimension`), checkNullableString(record.type, `${path}.type`), checkBoolean(record.invert, `${path}.invert`), checkOptional(record.values, `${path}.values`, checkJsonArray), checkOptional(record.pattern, `${path}.pattern`, checkString), checkOptional(record.filterType, `${path}.filterType`, checkString));
|
|
1124
|
+
}
|
|
1125
|
+
function checkMetricExpression(value, path) {
|
|
1126
|
+
const record = asRecord(value);
|
|
1127
|
+
if (record === undefined) {
|
|
1128
|
+
return path;
|
|
1129
|
+
}
|
|
1130
|
+
return firstFault(checkNullableString(record.type, `${path}.type`), checkNullableString(record.argument, `${path}.argument`), checkNullableString(record.aggregation, `${path}.aggregation`), checkOptional(record.id, `${path}.id`, checkString), checkNullableArray(record.filters, `${path}.filters`, checkMetricFilter));
|
|
1131
|
+
}
|
|
1132
|
+
function checkMetric(value, path) {
|
|
1133
|
+
const record = asRecord(value);
|
|
1134
|
+
if (record === undefined) {
|
|
1135
|
+
return path;
|
|
1136
|
+
}
|
|
1137
|
+
return firstFault(checkString(record.id, `${path}.id`), checkString(record.display, `${path}.display`), checkOptional(record.expression, `${path}.expression`, checkMetricExpression));
|
|
1138
|
+
}
|
|
1139
|
+
function checkChartFilterRange(value, path) {
|
|
1140
|
+
const record = asRecord(value);
|
|
1141
|
+
if (record === undefined) {
|
|
1142
|
+
return path;
|
|
1143
|
+
}
|
|
1144
|
+
return firstFault(checkOptional(record.inclusive, `${path}.inclusive`, checkBoolean), checkOptional(record.preset, `${path}.preset`, checkString));
|
|
1145
|
+
}
|
|
1146
|
+
function checkChartFilter(value, path) {
|
|
1147
|
+
const record = asRecord(value);
|
|
1148
|
+
if (record === undefined) {
|
|
1149
|
+
return path;
|
|
1150
|
+
}
|
|
1151
|
+
return firstFault(checkNullableString(record.type, `${path}.type`), checkNullableString(record.field, `${path}.field`), checkNullableString(record.valueType, `${path}.valueType`), checkOptional(record.values, `${path}.values`, checkJsonArray), checkOptional(record.range, `${path}.range`, checkChartFilterRange), checkOptional(record.invert, `${path}.invert`, checkBoolean), checkOptional(record.pattern, `${path}.pattern`, checkString), checkOptional(record.searchFilterType, `${path}.searchFilterType`, checkString));
|
|
1152
|
+
}
|
|
1153
|
+
function checkChartAction(value, path) {
|
|
1154
|
+
const record = asRecord(value);
|
|
1155
|
+
if (record === undefined) {
|
|
1156
|
+
return path;
|
|
1157
|
+
}
|
|
1158
|
+
return firstFault(checkNullableString(record.type, `${path}.type`), checkNullableString(record.icon, `${path}.icon`), checkNullableString(record.testId, `${path}.testId`), checkNullableString(record.label, `${path}.label`), checkNullableString(record.tooltip, `${path}.tooltip`), checkNullableString(record.onClickAction, `${path}.onClickAction`));
|
|
1159
|
+
}
|
|
1160
|
+
function checkChart(value, path) {
|
|
1161
|
+
const record = asRecord(value);
|
|
1162
|
+
if (record === undefined) {
|
|
1163
|
+
return path;
|
|
1164
|
+
}
|
|
1165
|
+
return firstFault(checkString(record.type, `${path}.type`), checkNullableArray(record.dimensions, `${path}.dimensions`, checkString), checkNullableArray(record.metrics, `${path}.metrics`, checkString), checkString(record.id, `${path}.id`), checkString(record.name, `${path}.name`), checkNullableArray(record.filters, `${path}.filters`, checkChartFilter), checkNullableArray(record.actions, `${path}.actions`, checkChartAction));
|
|
1166
|
+
}
|
|
1167
|
+
function checkContainer(value, path) {
|
|
1168
|
+
const record = asRecord(value);
|
|
1169
|
+
if (record === undefined) {
|
|
1170
|
+
return path;
|
|
1171
|
+
}
|
|
1172
|
+
return firstFault(checkNullableString(record.id, `${path}.id`), checkOptional(record.chartId, `${path}.chartId`, checkString), checkInteger(record.rowStart, `${path}.rowStart`), checkInteger(record.rowEnd, `${path}.rowEnd`), checkInteger(record.columnStart, `${path}.columnStart`), checkInteger(record.columnEnd, `${path}.columnEnd`));
|
|
1173
|
+
}
|
|
1174
|
+
function checkCustomLayout(value, path) {
|
|
1175
|
+
const record = asRecord(value);
|
|
1176
|
+
if (record === undefined) {
|
|
1177
|
+
return path;
|
|
1178
|
+
}
|
|
1179
|
+
return firstFault(checkInteger(record.columnCount, `${path}.columnCount`), checkInteger(record.rowCount, `${path}.rowCount`), checkNullableArray(record.containers, `${path}.containers`, checkContainer));
|
|
1180
|
+
}
|
|
1181
|
+
function checkLayout(value, path) {
|
|
1182
|
+
const record = asRecord(value);
|
|
1183
|
+
if (record === undefined) {
|
|
1184
|
+
return path;
|
|
1185
|
+
}
|
|
1186
|
+
return firstFault(checkString(record.type, `${path}.type`), checkOptional(record.layout, `${path}.layout`, checkCustomLayout));
|
|
1187
|
+
}
|
|
1188
|
+
function findDashboardDefinitionFault(value) {
|
|
1189
|
+
const record = asRecord(value);
|
|
1190
|
+
if (record === undefined) {
|
|
1191
|
+
return "$";
|
|
1192
|
+
}
|
|
1193
|
+
return firstFault(checkString(record.id, "$.id"), checkString(record.dataModel, "$.dataModel"), checkArray(record.tables, "$.tables", checkTable), checkArray(record.metrics, "$.metrics", checkMetric), checkArray(record.charts, "$.charts", (inner, innerPath) => checkArray(inner, innerPath, checkChart)), checkLayout(record.layout, "$.layout"), checkOptional(record.name, "$.name", checkString), checkOptional(record.isVisible, "$.isVisible", checkBoolean), checkOptional(record.version, "$.version", checkInteger), checkNullableArray(record.filters, "$.filters", checkChartFilter), checkOptional(record.isAllowedToEdit, "$.isAllowedToEdit", checkBoolean));
|
|
1194
|
+
}
|
|
1195
|
+
function findChartFilterListFault(value) {
|
|
1196
|
+
return checkArray(value, "$", checkChartFilter);
|
|
1197
|
+
}
|
|
1198
|
+
function requireShape(parsed, routeKey, fault, contractName) {
|
|
1199
|
+
if (fault !== undefined) {
|
|
1200
|
+
throw new InsightsProtocolError(insightsRouteTemplate(routeKey), `body does not match the ${contractName} contract at ${fault}`);
|
|
1201
|
+
}
|
|
1202
|
+
return parsed;
|
|
1203
|
+
}
|
|
1204
|
+
function requireDefinition(parsed, routeKey) {
|
|
1205
|
+
return requireShape(parsed, routeKey, findDashboardDefinitionFault(parsed), "dashboard definition");
|
|
1206
|
+
}
|
|
1207
|
+
async function getDashboard(config, options) {
|
|
1208
|
+
const parsed = await requestInsightsRoute(config, "dashboardsGet", {
|
|
1209
|
+
pathParams: {
|
|
1210
|
+
sourceType: options.sourceType,
|
|
1211
|
+
dashboardId: options.dashboardId
|
|
1212
|
+
},
|
|
1213
|
+
query: { localization: options.localization }
|
|
1214
|
+
});
|
|
1215
|
+
return requireDefinition(parsed, "dashboardsGet");
|
|
1216
|
+
}
|
|
1217
|
+
async function listDashboardFilters(config, options) {
|
|
1218
|
+
const parsed = await requestInsightsRoute(config, "dashboardFiltersList", {
|
|
1219
|
+
pathParams: {
|
|
1220
|
+
sourceType: options.sourceType,
|
|
1221
|
+
dashboardId: options.dashboardId
|
|
1222
|
+
}
|
|
1223
|
+
});
|
|
1224
|
+
return requireShape(parsed, "dashboardFiltersList", findChartFilterListFault(parsed), "dashboard filter list");
|
|
1225
|
+
}
|
|
1226
|
+
async function getDashboardTemplate(config, options) {
|
|
1227
|
+
const parsed = await requestInsightsRoute(config, "dashboardTemplatesGet", {
|
|
1228
|
+
pathParams: { sourceType: options.sourceType },
|
|
1229
|
+
query: {
|
|
1230
|
+
serviceIdentifier: options.serviceIdentifier,
|
|
1231
|
+
localization: options.localization
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
if (typeof parsed !== "string") {
|
|
1235
|
+
throw new InsightsProtocolError(insightsRouteTemplate("dashboardTemplatesGet"), "template body is not a JSON string");
|
|
1236
|
+
}
|
|
1237
|
+
const [parseError, definition] = catchError(() => JSON.parse(parsed));
|
|
1238
|
+
if (parseError) {
|
|
1239
|
+
throw new InsightsProtocolError(insightsRouteTemplate("dashboardTemplatesGet"), "template body is not valid JSON");
|
|
1240
|
+
}
|
|
1241
|
+
return requireDefinition(definition, "dashboardTemplatesGet");
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
class DashboardRequestError extends Error {
|
|
1245
|
+
constructor(message) {
|
|
1246
|
+
super(message);
|
|
1247
|
+
this.name = "DashboardRequestError";
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
async function createDashboard(config, options) {
|
|
1251
|
+
const slot = parseDashboardSlotId(options.slotId);
|
|
1252
|
+
if (slot === undefined) {
|
|
1253
|
+
throw new DashboardRequestError("Insights dashboards are created into a process slot id; compose it with composeDashboardSlotId.");
|
|
1254
|
+
}
|
|
1255
|
+
const canonical = composeDashboardSlotId(slot.processKey, slot.kind);
|
|
1256
|
+
if (options.slotId !== canonical) {
|
|
1257
|
+
throw new DashboardRequestError(`Insights dashboard slot id is not canonical; compose it with composeDashboardSlotId (expected ${canonical}).`);
|
|
1258
|
+
}
|
|
1259
|
+
const requestFault = findDashboardDefinitionFault(options.definition);
|
|
1260
|
+
if (requestFault !== undefined) {
|
|
1261
|
+
throw new DashboardRequestError(`Insights dashboard definition is invalid at ${requestFault}.`);
|
|
1262
|
+
}
|
|
1263
|
+
const body = {
|
|
1264
|
+
...options.definition,
|
|
1265
|
+
id: options.slotId
|
|
1266
|
+
};
|
|
1267
|
+
const parsed = await requestInsightsRoute(config, "dashboardsCreate", {
|
|
1268
|
+
pathParams: { sourceType: MAESTRO_DASHBOARD_SOURCE_TYPE },
|
|
1269
|
+
query: { serviceIdentifier: slot.processKey },
|
|
1270
|
+
body
|
|
1271
|
+
});
|
|
1272
|
+
return requireDefinition(parsed, "dashboardsCreate");
|
|
1273
|
+
}
|
|
1274
|
+
var NUMERIC_DASHBOARD_ID = /^\d+$/;
|
|
1275
|
+
async function updateDashboard(config, options) {
|
|
1276
|
+
if (!NUMERIC_DASHBOARD_ID.test(options.dashboardId)) {
|
|
1277
|
+
throw new DashboardRequestError("Insights dashboards are updated by numeric row id; template-keyed ids are read keys only.");
|
|
1278
|
+
}
|
|
1279
|
+
const requestFault = findDashboardDefinitionFault(options.definition);
|
|
1280
|
+
if (requestFault !== undefined) {
|
|
1281
|
+
throw new DashboardRequestError(`Insights dashboard definition is invalid at ${requestFault}.`);
|
|
1282
|
+
}
|
|
1283
|
+
const parsed = await requestInsightsRoute(config, "dashboardsUpdate", {
|
|
1284
|
+
pathParams: {
|
|
1285
|
+
sourceType: options.sourceType,
|
|
1286
|
+
dashboardId: options.dashboardId
|
|
1287
|
+
},
|
|
1288
|
+
body: options.definition
|
|
1289
|
+
});
|
|
1290
|
+
return requireDefinition(parsed, "dashboardsUpdate");
|
|
1291
|
+
}
|
|
1292
|
+
function findDeleteAcknowledgementFault(value) {
|
|
1293
|
+
const record = asRecord(value);
|
|
1294
|
+
if (record === undefined) {
|
|
1295
|
+
return "$";
|
|
1296
|
+
}
|
|
1297
|
+
return checkString(record.message, "$.message");
|
|
1298
|
+
}
|
|
1299
|
+
async function deleteDashboard(config, options) {
|
|
1300
|
+
if (!NUMERIC_DASHBOARD_ID.test(options.dashboardId)) {
|
|
1301
|
+
throw new DashboardRequestError("Insights dashboards are deleted by numeric row id; template-keyed ids are read keys only.");
|
|
1302
|
+
}
|
|
1303
|
+
if (options.dashboardId.startsWith("0")) {
|
|
1304
|
+
throw new DashboardRequestError("Insights dashboard ids carry no leading zero; a padded id would delete the unpadded row and orphan the alert definitions bound to it.");
|
|
1305
|
+
}
|
|
1306
|
+
const parsed = await requestInsightsRoute(config, "dashboardsDelete", {
|
|
1307
|
+
pathParams: {
|
|
1308
|
+
sourceType: options.sourceType,
|
|
1309
|
+
dashboardId: options.dashboardId
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
requireShape(parsed, "dashboardsDelete", findDeleteAcknowledgementFault(parsed), "dashboard delete acknowledgement");
|
|
1313
|
+
}
|
|
1314
|
+
// src/export-configurations.ts
|
|
1315
|
+
var MAX_INT32 = 2147483647;
|
|
1316
|
+
var CANONICAL_ID_PATTERN = /^[1-9]\d*$/;
|
|
1317
|
+
var DESTINATION_KEYS = [
|
|
1318
|
+
"azureEventHub",
|
|
1319
|
+
"awsSqs",
|
|
1320
|
+
"genericEndpoint",
|
|
1321
|
+
"arize",
|
|
1322
|
+
"databricks"
|
|
1323
|
+
];
|
|
1324
|
+
async function listExportConfigurations(config) {
|
|
1325
|
+
return requestInsightsRoute(config, "exportConfigurationsList");
|
|
1326
|
+
}
|
|
1327
|
+
async function verifyAllExportDestinations(config) {
|
|
1328
|
+
return requestInsightsRoute(config, "exportDestinationsVerifyAll");
|
|
1329
|
+
}
|
|
1330
|
+
function countDestinationKeys(destination) {
|
|
1331
|
+
return DESTINATION_KEYS.filter((key) => destination[key] !== undefined && destination[key] !== null).length;
|
|
1332
|
+
}
|
|
1333
|
+
async function verifyExportDestination(config, configurationId, body) {
|
|
1334
|
+
if (!CANONICAL_ID_PATTERN.test(configurationId) || Number(configurationId) > MAX_INT32) {
|
|
1335
|
+
throw new Error("Insights export configuration id must be a positive integer with no sign and no leading zero.");
|
|
1336
|
+
}
|
|
1337
|
+
const keyCount = countDestinationKeys(body.destination);
|
|
1338
|
+
if (keyCount !== 1) {
|
|
1339
|
+
throw new Error(`Insights export verify body must name exactly one destination type of ${DESTINATION_KEYS.join(", ")}; it names ${keyCount}.`);
|
|
1340
|
+
}
|
|
1341
|
+
return requestInsightsRoute(config, "exportDestinationVerify", {
|
|
1342
|
+
pathParams: { configurationId },
|
|
1343
|
+
body
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
725
1346
|
// src/types.ts
|
|
726
1347
|
function isStringArrayOrNullish(value) {
|
|
727
1348
|
if (value === undefined || value === null) {
|
|
@@ -789,6 +1410,224 @@ async function listQueueFilters(config) {
|
|
|
789
1410
|
async function listMachineFilters(config) {
|
|
790
1411
|
return listFilters(config, "filtersAllMachines", isMachineFiltersResponse, "machine filters");
|
|
791
1412
|
}
|
|
1413
|
+
// src/machines.ts
|
|
1414
|
+
function isNullish(value) {
|
|
1415
|
+
return value === undefined || value === null;
|
|
1416
|
+
}
|
|
1417
|
+
function isArrayOfNullable(value, isElement) {
|
|
1418
|
+
if (isNullish(value)) {
|
|
1419
|
+
return true;
|
|
1420
|
+
}
|
|
1421
|
+
return Array.isArray(value) && value.every(isElement);
|
|
1422
|
+
}
|
|
1423
|
+
function isFiniteNumber(value) {
|
|
1424
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1425
|
+
}
|
|
1426
|
+
function isStringEntry(value) {
|
|
1427
|
+
return typeof value === "string" || value === null;
|
|
1428
|
+
}
|
|
1429
|
+
function isNumberSeries(value) {
|
|
1430
|
+
return Array.isArray(value) && value.every((entry) => isFiniteNumber(entry));
|
|
1431
|
+
}
|
|
1432
|
+
var STRING_ARRAY_FIELDS = [
|
|
1433
|
+
"machineName",
|
|
1434
|
+
"hostMachineName",
|
|
1435
|
+
"machineKey",
|
|
1436
|
+
"machineStatus",
|
|
1437
|
+
"startTime",
|
|
1438
|
+
"endTime",
|
|
1439
|
+
"eventTime",
|
|
1440
|
+
"processName",
|
|
1441
|
+
"machineType"
|
|
1442
|
+
];
|
|
1443
|
+
var NUMBER_ARRAY_FIELDS = [
|
|
1444
|
+
"jobCount",
|
|
1445
|
+
"jobDuration",
|
|
1446
|
+
"machineUtilization",
|
|
1447
|
+
"runtimeCount",
|
|
1448
|
+
"inUseCount"
|
|
1449
|
+
];
|
|
1450
|
+
var ALL_MACHINE_FIELDS = [
|
|
1451
|
+
...STRING_ARRAY_FIELDS,
|
|
1452
|
+
...NUMBER_ARRAY_FIELDS,
|
|
1453
|
+
"runtimeSlots"
|
|
1454
|
+
];
|
|
1455
|
+
function hasWellTypedFields(record) {
|
|
1456
|
+
return STRING_ARRAY_FIELDS.every((field) => isArrayOfNullable(record[field], isStringEntry)) && NUMBER_ARRAY_FIELDS.every((field) => isArrayOfNullable(record[field], isFiniteNumber)) && isArrayOfNullable(record.runtimeSlots, isNumberSeries);
|
|
1457
|
+
}
|
|
1458
|
+
function isMachinesResponse(value) {
|
|
1459
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1460
|
+
return false;
|
|
1461
|
+
}
|
|
1462
|
+
const record = value;
|
|
1463
|
+
if (!hasWellTypedFields(record)) {
|
|
1464
|
+
return false;
|
|
1465
|
+
}
|
|
1466
|
+
return Object.keys(record).length === 0 || ALL_MACHINE_FIELDS.some((field) => (field in record));
|
|
1467
|
+
}
|
|
1468
|
+
async function queryMachines(config, queryId, input) {
|
|
1469
|
+
const parsed = await requestInsightsRoute(config, "machinesQuery", {
|
|
1470
|
+
body: {
|
|
1471
|
+
...input,
|
|
1472
|
+
queryId,
|
|
1473
|
+
orgId: config.organizationId,
|
|
1474
|
+
tenantId: config.tenantId
|
|
1475
|
+
}
|
|
1476
|
+
});
|
|
1477
|
+
if (!isMachinesResponse(parsed)) {
|
|
1478
|
+
throw new InsightsProtocolError(insightsRouteTemplate("machinesQuery"), `body does not match the machine query ${queryId} contract`);
|
|
1479
|
+
}
|
|
1480
|
+
return parsed;
|
|
1481
|
+
}
|
|
1482
|
+
async function getMachineRuntimeMix(config, input) {
|
|
1483
|
+
return queryMachines(config, 1, input);
|
|
1484
|
+
}
|
|
1485
|
+
async function getMachineDetails(config, input) {
|
|
1486
|
+
return queryMachines(config, 2, input);
|
|
1487
|
+
}
|
|
1488
|
+
async function getMachineAvailabilityTimeline(config, input) {
|
|
1489
|
+
return queryMachines(config, 3, input);
|
|
1490
|
+
}
|
|
1491
|
+
async function getMachineTopFailures(config, input) {
|
|
1492
|
+
return queryMachines(config, 4, input);
|
|
1493
|
+
}
|
|
1494
|
+
async function getMachineUtilization(config, input) {
|
|
1495
|
+
return queryMachines(config, 5, input);
|
|
1496
|
+
}
|
|
1497
|
+
// src/queues.ts
|
|
1498
|
+
function isNullish2(value) {
|
|
1499
|
+
return value === undefined || value === null;
|
|
1500
|
+
}
|
|
1501
|
+
function isArrayOfNullable2(value, isElement) {
|
|
1502
|
+
if (isNullish2(value)) {
|
|
1503
|
+
return true;
|
|
1504
|
+
}
|
|
1505
|
+
return Array.isArray(value) && value.every(isElement);
|
|
1506
|
+
}
|
|
1507
|
+
function isFiniteNumber2(value) {
|
|
1508
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
1509
|
+
}
|
|
1510
|
+
function isStringEntry2(value) {
|
|
1511
|
+
return typeof value === "string" || value === null;
|
|
1512
|
+
}
|
|
1513
|
+
function isNumberSeries2(value) {
|
|
1514
|
+
return Array.isArray(value) && value.every((entry) => isFiniteNumber2(entry));
|
|
1515
|
+
}
|
|
1516
|
+
function isWfMetricsRow(value) {
|
|
1517
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1518
|
+
}
|
|
1519
|
+
var STRING_ARRAY_FIELDS2 = [
|
|
1520
|
+
"queueState",
|
|
1521
|
+
"robotName",
|
|
1522
|
+
"machineName",
|
|
1523
|
+
"processName",
|
|
1524
|
+
"folderName",
|
|
1525
|
+
"folderKey",
|
|
1526
|
+
"queueName",
|
|
1527
|
+
"dueDate",
|
|
1528
|
+
"reference",
|
|
1529
|
+
"priority",
|
|
1530
|
+
"startTime",
|
|
1531
|
+
"endTime",
|
|
1532
|
+
"hostMachineName",
|
|
1533
|
+
"processingExceptionReason",
|
|
1534
|
+
"processingExceptionType",
|
|
1535
|
+
"creationTime",
|
|
1536
|
+
"folderId",
|
|
1537
|
+
"queueItemKey",
|
|
1538
|
+
"firstBreachSLA",
|
|
1539
|
+
"firstBreachRisk"
|
|
1540
|
+
];
|
|
1541
|
+
var NUMBER_ARRAY_FIELDS2 = [
|
|
1542
|
+
"duration",
|
|
1543
|
+
"queueCount",
|
|
1544
|
+
"queueItemId",
|
|
1545
|
+
"successRate",
|
|
1546
|
+
"inSLACount",
|
|
1547
|
+
"riskSLACount",
|
|
1548
|
+
"outSLACount",
|
|
1549
|
+
"avgHandlingTime",
|
|
1550
|
+
"avgPendingTime",
|
|
1551
|
+
"runningRobotCnt",
|
|
1552
|
+
"necessaryRobotCnt",
|
|
1553
|
+
"queueId"
|
|
1554
|
+
];
|
|
1555
|
+
var NUMBER_SERIES_FIELDS = [
|
|
1556
|
+
"queueCountByTime",
|
|
1557
|
+
"queueCounts",
|
|
1558
|
+
"queueAggregate"
|
|
1559
|
+
];
|
|
1560
|
+
var SCALAR_NUMBER_FIELDS = [
|
|
1561
|
+
"averageProcessingTime",
|
|
1562
|
+
"queueItemCount",
|
|
1563
|
+
"successfulQueueItemsCount"
|
|
1564
|
+
];
|
|
1565
|
+
var ALL_QUEUE_FIELDS = [
|
|
1566
|
+
...STRING_ARRAY_FIELDS2,
|
|
1567
|
+
...NUMBER_ARRAY_FIELDS2,
|
|
1568
|
+
...NUMBER_SERIES_FIELDS,
|
|
1569
|
+
...SCALAR_NUMBER_FIELDS,
|
|
1570
|
+
"wfMetrics"
|
|
1571
|
+
];
|
|
1572
|
+
function hasWellTypedFields2(record) {
|
|
1573
|
+
return STRING_ARRAY_FIELDS2.every((field) => isArrayOfNullable2(record[field], isStringEntry2)) && NUMBER_ARRAY_FIELDS2.every((field) => isArrayOfNullable2(record[field], isFiniteNumber2)) && NUMBER_SERIES_FIELDS.every((field) => isArrayOfNullable2(record[field], isNumberSeries2)) && SCALAR_NUMBER_FIELDS.every((field) => isNullish2(record[field]) || isFiniteNumber2(record[field])) && isArrayOfNullable2(record.wfMetrics, isWfMetricsRow);
|
|
1574
|
+
}
|
|
1575
|
+
function isQueuesResponse(value) {
|
|
1576
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
1577
|
+
return false;
|
|
1578
|
+
}
|
|
1579
|
+
const record = value;
|
|
1580
|
+
if (!hasWellTypedFields2(record)) {
|
|
1581
|
+
return false;
|
|
1582
|
+
}
|
|
1583
|
+
return Object.keys(record).length === 0 || ALL_QUEUE_FIELDS.some((field) => (field in record));
|
|
1584
|
+
}
|
|
1585
|
+
var EMPTY_DEDICATED_SAAS_FILTERS = { airId: [], tenantFilter: [] };
|
|
1586
|
+
async function queryQueues(config, queryId, input) {
|
|
1587
|
+
const parsed = await requestInsightsRoute(config, "queuesQuery", {
|
|
1588
|
+
body: {
|
|
1589
|
+
...input,
|
|
1590
|
+
queryId,
|
|
1591
|
+
orgId: config.organizationId,
|
|
1592
|
+
tenantId: config.tenantId,
|
|
1593
|
+
...EMPTY_DEDICATED_SAAS_FILTERS
|
|
1594
|
+
}
|
|
1595
|
+
});
|
|
1596
|
+
if (!isQueuesResponse(parsed)) {
|
|
1597
|
+
throw new InsightsProtocolError(insightsRouteTemplate("queuesQuery"), `body does not match the queue query ${queryId} contract`);
|
|
1598
|
+
}
|
|
1599
|
+
return parsed;
|
|
1600
|
+
}
|
|
1601
|
+
async function getQueueCompletedTimeline(config, input) {
|
|
1602
|
+
return queryQueues(config, 3, input);
|
|
1603
|
+
}
|
|
1604
|
+
async function getQueueUncompletedTimeline(config, input) {
|
|
1605
|
+
return queryQueues(config, 10, input);
|
|
1606
|
+
}
|
|
1607
|
+
async function getQueueTopFailures(config, input) {
|
|
1608
|
+
return queryQueues(config, 11, input);
|
|
1609
|
+
}
|
|
1610
|
+
async function getQueueFailuresByReason(config, input) {
|
|
1611
|
+
return queryQueues(config, 12, input);
|
|
1612
|
+
}
|
|
1613
|
+
async function getQueueDetails(config, input) {
|
|
1614
|
+
return queryQueues(config, 13, input);
|
|
1615
|
+
}
|
|
1616
|
+
async function getQueueRetryOutcomes(config, input) {
|
|
1617
|
+
return queryQueues(config, 14, input);
|
|
1618
|
+
}
|
|
1619
|
+
async function getQueueSummary(config, input) {
|
|
1620
|
+
return queryQueues(config, 15, input);
|
|
1621
|
+
}
|
|
1622
|
+
async function getQueueFailureDetails(config, input) {
|
|
1623
|
+
return queryQueues(config, 16, input);
|
|
1624
|
+
}
|
|
1625
|
+
async function getQueueSla(config, input) {
|
|
1626
|
+
return queryQueues(config, 17, input);
|
|
1627
|
+
}
|
|
1628
|
+
async function getQueueOperationalMetrics(config, input) {
|
|
1629
|
+
return queryQueues(config, 18, input);
|
|
1630
|
+
}
|
|
792
1631
|
// src/rbac.ts
|
|
793
1632
|
async function listUsers(config) {
|
|
794
1633
|
return requestInsightsRoute(config, "usersList");
|
|
@@ -820,30 +1659,68 @@ async function checkInsightsAccess(config, request) {
|
|
|
820
1659
|
});
|
|
821
1660
|
}
|
|
822
1661
|
export {
|
|
1662
|
+
CREATE_BACKEND_FAILURE_LABEL,
|
|
1663
|
+
DASHBOARD_NOT_FOUND_LABEL,
|
|
1664
|
+
DASHBOARD_SLOT_DELIMITER,
|
|
1665
|
+
DASHBOARD_TEMPLATE_ID_PREFIX,
|
|
1666
|
+
DashboardRequestError,
|
|
823
1667
|
InsightsHttpError,
|
|
824
1668
|
InsightsNetworkError,
|
|
825
1669
|
InsightsProtocolError,
|
|
1670
|
+
MAESTRO_CASE_DASHBOARD_PREFIX,
|
|
1671
|
+
MAESTRO_DASHBOARD_SOURCE_TYPE,
|
|
1672
|
+
MAESTRO_PROCESS_DASHBOARD_PREFIX,
|
|
1673
|
+
MODEL_NOT_FOUND_LABEL,
|
|
1674
|
+
UPDATE_BACKEND_FAILURE_LABEL,
|
|
1675
|
+
VALIDATION_FAILED_LABEL,
|
|
826
1676
|
checkAlertEntitlement,
|
|
827
1677
|
checkInsightsAccess,
|
|
1678
|
+
composeDashboardSlotId,
|
|
1679
|
+
createDashboard,
|
|
828
1680
|
createInsightsConfig,
|
|
829
1681
|
deleteAlertDefinition,
|
|
1682
|
+
deleteDashboard,
|
|
830
1683
|
getAlertDefinition,
|
|
831
1684
|
getAlertHistoryMetrics,
|
|
1685
|
+
getDashboard,
|
|
1686
|
+
getDashboardTemplate,
|
|
832
1687
|
getDefaultDelivery,
|
|
833
1688
|
getGroup,
|
|
1689
|
+
getMachineAvailabilityTimeline,
|
|
1690
|
+
getMachineDetails,
|
|
1691
|
+
getMachineRuntimeMix,
|
|
1692
|
+
getMachineTopFailures,
|
|
1693
|
+
getMachineUtilization,
|
|
1694
|
+
getQueueCompletedTimeline,
|
|
1695
|
+
getQueueDetails,
|
|
1696
|
+
getQueueFailureDetails,
|
|
1697
|
+
getQueueFailuresByReason,
|
|
1698
|
+
getQueueOperationalMetrics,
|
|
1699
|
+
getQueueRetryOutcomes,
|
|
1700
|
+
getQueueSla,
|
|
1701
|
+
getQueueSummary,
|
|
1702
|
+
getQueueTopFailures,
|
|
1703
|
+
getQueueUncompletedTimeline,
|
|
834
1704
|
getRole,
|
|
835
1705
|
getUser,
|
|
836
1706
|
insightsPost,
|
|
1707
|
+
isTemplateKeyedDashboardId,
|
|
837
1708
|
listAgenticAlertDefinitions,
|
|
838
1709
|
listAlertDefinitions,
|
|
839
1710
|
listAlertHistoryDetails,
|
|
1711
|
+
listDashboardFilters,
|
|
1712
|
+
listExportConfigurations,
|
|
840
1713
|
listFolderFilters,
|
|
841
1714
|
listGroups,
|
|
842
1715
|
listMachineFilters,
|
|
843
1716
|
listProcessFilters,
|
|
844
1717
|
listQueueFilters,
|
|
845
1718
|
listRoles,
|
|
846
|
-
listUsers
|
|
1719
|
+
listUsers,
|
|
1720
|
+
parseDashboardSlotId,
|
|
1721
|
+
updateDashboard,
|
|
1722
|
+
verifyAllExportDestinations,
|
|
1723
|
+
verifyExportDestination
|
|
847
1724
|
};
|
|
848
1725
|
|
|
849
|
-
//# debugId=
|
|
1726
|
+
//# debugId=3D6C08297457188064756E2164756E21
|