@topolo/sdk 0.11.11 → 0.12.0

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.d.cts CHANGED
@@ -1248,47 +1248,157 @@ declare class TopoloOAuth {
1248
1248
  }): Promise<TokenResponse>;
1249
1249
  }
1250
1250
 
1251
+ declare function validateTopoloWidgetResponse(response: unknown): TopoloWidgetValidationResult;
1252
+
1251
1253
  declare const TOPOLO_WIDGET_ENDPOINT = "/api/widget";
1252
1254
  declare const TOPOLO_WIDGET_REFRESH_INTERVAL_MS = 60000;
1253
- type TopoloWidgetType = "stats" | "recent-activity" | "quick-actions" | "notifications" | "chart";
1255
+ declare const TOPOLO_WIDGET_CONTRACT_VERSION: "2.0.0";
1256
+ type TopoloWidgetType = "stats" | "chart" | "activity" | "notifications" | "actions";
1257
+ type TopoloWidgetContext = "personal" | "organization" | "workspace" | "resource";
1258
+ type TopoloWidgetSize = "compact" | "medium" | "wide" | "full";
1259
+ type TopoloWidgetStatus = "ready" | "empty" | "unavailable" | "stale" | "error";
1260
+ interface TopoloWidgetPresentation {
1261
+ title: string;
1262
+ description?: string;
1263
+ contexts: TopoloWidgetContext[];
1264
+ supportedSizes: TopoloWidgetSize[];
1265
+ defaultSize: TopoloWidgetSize;
1266
+ }
1267
+ interface TopoloWidgetResourceBinding {
1268
+ resourceType: string;
1269
+ resourceId?: string;
1270
+ requiredPermissions: string[];
1271
+ }
1272
+ interface TopoloWidgetState {
1273
+ status: TopoloWidgetStatus;
1274
+ observedAt: string;
1275
+ lastSuccessfulAt?: string;
1276
+ code?: string;
1277
+ message?: string;
1278
+ }
1279
+ interface TopoloWidgetRefreshPolicy {
1280
+ intervalSeconds: number;
1281
+ timeoutSeconds: number;
1282
+ maxAgeSeconds: number;
1283
+ staleWhileRevalidateSeconds: number;
1284
+ }
1285
+ interface TopoloWidgetConfigurationOption {
1286
+ value: string;
1287
+ label: string;
1288
+ }
1289
+ interface TopoloWidgetConfigurationField {
1290
+ key: string;
1291
+ label: string;
1292
+ type: "string" | "number" | "boolean" | "select" | "multi-select" | "date-range";
1293
+ required: boolean;
1294
+ options?: TopoloWidgetConfigurationOption[];
1295
+ }
1296
+ interface TopoloWidgetConfiguration {
1297
+ allowMultipleInstances: boolean;
1298
+ fields: TopoloWidgetConfigurationField[];
1299
+ defaults: Record<string, unknown>;
1300
+ }
1301
+ interface TopoloWidgetDrilldown {
1302
+ id: string;
1303
+ label: string;
1304
+ href: string;
1305
+ }
1306
+ interface TopoloWidgetActionRecovery {
1307
+ mode: "not_applicable" | "retry" | "compensating_action";
1308
+ actionId?: string;
1309
+ instructions: string;
1310
+ }
1311
+ interface TopoloWidgetActionBinding {
1312
+ id: string;
1313
+ label: string;
1314
+ actionId: string;
1315
+ resourceType: string;
1316
+ resourceId?: string;
1317
+ input: Record<string, unknown>;
1318
+ requiresConfirmation: boolean;
1319
+ destructive: boolean;
1320
+ effects: string[];
1321
+ verification: string[];
1322
+ recovery: TopoloWidgetActionRecovery;
1323
+ }
1324
+ interface TopoloWidgetLocalization {
1325
+ locale: string;
1326
+ titleKey: string;
1327
+ descriptionKey?: string;
1328
+ }
1329
+ interface TopoloWidgetAccessibility {
1330
+ label: string;
1331
+ description?: string;
1332
+ }
1254
1333
  interface TopoloWidgetBase {
1334
+ id: string;
1335
+ version: string;
1255
1336
  appId: string;
1256
1337
  serviceName: string;
1257
1338
  serviceIcon?: string;
1258
1339
  type: TopoloWidgetType;
1259
1340
  lastUpdated: string;
1260
- snapshot: TopoloWidgetSnapshotMetadata;
1341
+ presentation: TopoloWidgetPresentation;
1342
+ resource: TopoloWidgetResourceBinding;
1343
+ state: TopoloWidgetState;
1344
+ refresh: TopoloWidgetRefreshPolicy;
1345
+ configuration: TopoloWidgetConfiguration;
1346
+ drilldowns: TopoloWidgetDrilldown[];
1347
+ controls: TopoloWidgetActionBinding[];
1348
+ localization: TopoloWidgetLocalization;
1349
+ accessibility: TopoloWidgetAccessibility;
1350
+ }
1351
+ type TopoloWidgetMetricSemantic = "gauge" | "counter" | "rate" | "duration" | "currency" | "percentage";
1352
+ type TopoloWidgetMetricAggregation = "last" | "sum" | "average" | "minimum" | "maximum" | "count" | "distinct_count";
1353
+ interface TopoloWidgetPeriod {
1354
+ start: string;
1355
+ end: string;
1356
+ timezone: string;
1357
+ }
1358
+ interface TopoloWidgetDimension {
1359
+ key: string;
1360
+ label: string;
1361
+ value: string;
1261
1362
  }
1262
- interface TopoloWidgetMetric {
1263
- key?: string;
1363
+ interface TopoloWidgetMetricComparison {
1364
+ value: number;
1365
+ absoluteChange: number;
1366
+ percentageChange?: number;
1367
+ direction: "up" | "down" | "flat";
1264
1368
  label: string;
1265
- value: string | number;
1266
- change?: number;
1267
- changeLabel?: string;
1268
- icon?: string;
1369
+ period: TopoloWidgetPeriod;
1370
+ }
1371
+ interface TopoloWidgetSeriesPoint {
1372
+ timestamp: string;
1373
+ value: number;
1374
+ dimensions: TopoloWidgetDimension[];
1375
+ }
1376
+ interface TopoloWidgetSeries {
1377
+ id: string;
1378
+ label: string;
1379
+ unit: string;
1380
+ points: TopoloWidgetSeriesPoint[];
1269
1381
  }
1270
- interface TopoloWidgetSnapshotMetric {
1382
+ interface TopoloWidgetMetric {
1271
1383
  key: string;
1272
1384
  label: string;
1273
1385
  value: number;
1274
- unit?: string;
1275
- change?: number;
1276
- changeLabel?: string;
1277
- }
1278
- interface TopoloWidgetSnapshotMetadata {
1279
- presetKey?: string;
1280
- audience?: string;
1281
- scope?: string;
1282
- scopeLabel?: string;
1283
- generatedAt?: string;
1284
- summary: string;
1285
- defaultMetricKeys?: string[];
1286
- availableMetrics?: TopoloWidgetSnapshotMetric[];
1287
- highlights?: string[];
1386
+ unit: string;
1387
+ semantic: TopoloWidgetMetricSemantic;
1388
+ aggregation: TopoloWidgetMetricAggregation;
1389
+ period: TopoloWidgetPeriod;
1390
+ dimensions: TopoloWidgetDimension[];
1391
+ comparison?: TopoloWidgetMetricComparison;
1392
+ series?: TopoloWidgetSeries;
1288
1393
  }
1289
1394
  interface TopoloStatsWidget extends TopoloWidgetBase {
1290
1395
  type: "stats";
1291
- stats: TopoloWidgetMetric[];
1396
+ metrics: TopoloWidgetMetric[];
1397
+ }
1398
+ interface TopoloChartWidget extends TopoloWidgetBase {
1399
+ type: "chart";
1400
+ chartType: "line" | "bar" | "area" | "pie" | "donut";
1401
+ series: TopoloWidgetSeries[];
1292
1402
  }
1293
1403
  interface TopoloWidgetActivityItem {
1294
1404
  id: string;
@@ -1296,60 +1406,74 @@ interface TopoloWidgetActivityItem {
1296
1406
  description?: string;
1297
1407
  timestamp: string;
1298
1408
  icon?: string;
1299
- link?: string;
1409
+ drilldownId?: string;
1410
+ actionId?: string;
1300
1411
  }
1301
- interface TopoloRecentActivityWidget extends TopoloWidgetBase {
1302
- type: "recent-activity";
1412
+ interface TopoloActivityWidget extends TopoloWidgetBase {
1413
+ type: "activity";
1303
1414
  activities: TopoloWidgetActivityItem[];
1304
1415
  }
1305
- interface TopoloWidgetActionItem {
1306
- id: string;
1307
- label: string;
1308
- icon?: string;
1309
- link: string;
1310
- primary?: boolean;
1311
- }
1312
- interface TopoloQuickActionsWidget extends TopoloWidgetBase {
1313
- type: "quick-actions";
1314
- actions: TopoloWidgetActionItem[];
1315
- }
1316
1416
  interface TopoloWidgetNotificationItem {
1317
1417
  id: string;
1318
1418
  title: string;
1319
1419
  message: string;
1320
- type: "info" | "warning" | "error" | "success";
1420
+ severity: "info" | "warning" | "error" | "success";
1321
1421
  timestamp: string;
1322
1422
  read: boolean;
1323
- link?: string;
1423
+ drilldownId?: string;
1424
+ actionId?: string;
1324
1425
  }
1325
1426
  interface TopoloNotificationsWidget extends TopoloWidgetBase {
1326
1427
  type: "notifications";
1327
1428
  notifications: TopoloWidgetNotificationItem[];
1328
1429
  unreadCount: number;
1329
1430
  }
1330
- interface TopoloChartWidget extends TopoloWidgetBase {
1331
- type: "chart";
1332
- chartType: "line" | "bar" | "pie" | "donut";
1333
- title: string;
1334
- data: {
1335
- labels: string[];
1336
- values: number[];
1337
- };
1431
+ interface TopoloActionsWidget extends TopoloWidgetBase {
1432
+ type: "actions";
1433
+ actions: TopoloWidgetActionBinding[];
1338
1434
  }
1339
- type TopoloWidget = TopoloStatsWidget | TopoloRecentActivityWidget | TopoloQuickActionsWidget | TopoloNotificationsWidget | TopoloChartWidget;
1340
- type TopoloWidgetWithOptionalMetadata<T extends TopoloWidget> = Omit<T, "appId" | "serviceName" | "lastUpdated"> & Partial<Pick<TopoloWidgetBase, "appId" | "serviceName" | "lastUpdated">>;
1341
- type TopoloWidgetDraft = TopoloWidget extends infer Widget ? Widget extends TopoloWidget ? TopoloWidgetWithOptionalMetadata<Widget> : never : never;
1342
- interface TopoloWidgetApiResponse {
1343
- success: boolean;
1435
+ type TopoloWidget = TopoloStatsWidget | TopoloChartWidget | TopoloActivityWidget | TopoloNotificationsWidget | TopoloActionsWidget;
1436
+ type TopoloWidgetWithOptionalServiceMetadata<T extends TopoloWidget> = Omit<T, "appId" | "serviceName" | "lastUpdated"> & Partial<Pick<TopoloWidgetBase, "appId" | "serviceName" | "lastUpdated">>;
1437
+ type TopoloWidgetDraft = TopoloWidget extends infer Widget ? Widget extends TopoloWidget ? TopoloWidgetWithOptionalServiceMetadata<Widget> : never : never;
1438
+ interface TopoloWidgetApiSuccessResponse {
1439
+ success: true;
1440
+ contractVersion: typeof TOPOLO_WIDGET_CONTRACT_VERSION;
1441
+ appId: string;
1442
+ serviceName: string;
1443
+ generatedAt: string;
1344
1444
  widgets: TopoloWidget[];
1345
- error?: string;
1346
1445
  }
1446
+ interface TopoloWidgetApiError {
1447
+ code: string;
1448
+ message: string;
1449
+ retryable: boolean;
1450
+ retryAfter?: string;
1451
+ }
1452
+ interface TopoloWidgetApiErrorResponse {
1453
+ success: false;
1454
+ contractVersion: typeof TOPOLO_WIDGET_CONTRACT_VERSION;
1455
+ appId: string;
1456
+ serviceName: string;
1457
+ generatedAt: string;
1458
+ widgets: [];
1459
+ error: TopoloWidgetApiError;
1460
+ }
1461
+ type TopoloWidgetApiResponse = TopoloWidgetApiSuccessResponse | TopoloWidgetApiErrorResponse;
1347
1462
  interface TopoloWidgetResponseOptions {
1348
1463
  appId: string;
1349
1464
  serviceName: string;
1350
1465
  widgets: TopoloWidgetDraft[];
1351
1466
  now?: Date | string;
1352
1467
  }
1468
+ interface TopoloWidgetErrorResponseOptions {
1469
+ appId: string;
1470
+ serviceName: string;
1471
+ code: string;
1472
+ message: string;
1473
+ retryable: boolean;
1474
+ retryAfter?: Date | string;
1475
+ now?: Date | string;
1476
+ }
1353
1477
  interface TopoloWidgetValidationResult {
1354
1478
  ok: boolean;
1355
1479
  errors: string[];
@@ -1363,13 +1487,12 @@ interface TopoloWidgetConfig {
1363
1487
  refreshInterval: number;
1364
1488
  }
1365
1489
  declare function defineTopoloStatsWidget(widget: Omit<TopoloStatsWidget, "type">): TopoloStatsWidget;
1366
- declare function defineTopoloRecentActivityWidget(widget: Omit<TopoloRecentActivityWidget, "type">): TopoloRecentActivityWidget;
1367
- declare function defineTopoloQuickActionsWidget(widget: Omit<TopoloQuickActionsWidget, "type">): TopoloQuickActionsWidget;
1368
- declare function defineTopoloNotificationsWidget(widget: Omit<TopoloNotificationsWidget, "type">): TopoloNotificationsWidget;
1369
1490
  declare function defineTopoloChartWidget(widget: Omit<TopoloChartWidget, "type">): TopoloChartWidget;
1370
- declare function createTopoloWidgetResponse({ appId, serviceName, widgets, now, }: TopoloWidgetResponseOptions): TopoloWidgetApiResponse;
1371
- declare function createTopoloWidgetError(error: string): TopoloWidgetApiResponse;
1372
- declare function validateTopoloWidgetResponse(response: unknown): TopoloWidgetValidationResult;
1491
+ declare function defineTopoloActivityWidget(widget: Omit<TopoloActivityWidget, "type">): TopoloActivityWidget;
1492
+ declare function defineTopoloNotificationsWidget(widget: Omit<TopoloNotificationsWidget, "type">): TopoloNotificationsWidget;
1493
+ declare function defineTopoloActionsWidget(widget: Omit<TopoloActionsWidget, "type">): TopoloActionsWidget;
1494
+ declare function createTopoloWidgetResponse({ appId, serviceName, widgets, now, }: TopoloWidgetResponseOptions): TopoloWidgetApiSuccessResponse;
1495
+ declare function createTopoloWidgetError({ appId, serviceName, code, message, retryable, retryAfter, now, }: TopoloWidgetErrorResponseOptions): TopoloWidgetApiErrorResponse;
1373
1496
 
1374
1497
  /**
1375
1498
  * Convenience factory that returns a ready-to-use typed Topolo client plus
@@ -1386,4 +1509,4 @@ declare function createTopolo(options: TopoloClientOptions): {
1386
1509
  };
1387
1510
  type Topolo = ReturnType<typeof createTopolo>;
1388
1511
 
1389
- export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
1512
+ export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetDimension, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
package/dist/index.d.ts CHANGED
@@ -1248,47 +1248,157 @@ declare class TopoloOAuth {
1248
1248
  }): Promise<TokenResponse>;
1249
1249
  }
1250
1250
 
1251
+ declare function validateTopoloWidgetResponse(response: unknown): TopoloWidgetValidationResult;
1252
+
1251
1253
  declare const TOPOLO_WIDGET_ENDPOINT = "/api/widget";
1252
1254
  declare const TOPOLO_WIDGET_REFRESH_INTERVAL_MS = 60000;
1253
- type TopoloWidgetType = "stats" | "recent-activity" | "quick-actions" | "notifications" | "chart";
1255
+ declare const TOPOLO_WIDGET_CONTRACT_VERSION: "2.0.0";
1256
+ type TopoloWidgetType = "stats" | "chart" | "activity" | "notifications" | "actions";
1257
+ type TopoloWidgetContext = "personal" | "organization" | "workspace" | "resource";
1258
+ type TopoloWidgetSize = "compact" | "medium" | "wide" | "full";
1259
+ type TopoloWidgetStatus = "ready" | "empty" | "unavailable" | "stale" | "error";
1260
+ interface TopoloWidgetPresentation {
1261
+ title: string;
1262
+ description?: string;
1263
+ contexts: TopoloWidgetContext[];
1264
+ supportedSizes: TopoloWidgetSize[];
1265
+ defaultSize: TopoloWidgetSize;
1266
+ }
1267
+ interface TopoloWidgetResourceBinding {
1268
+ resourceType: string;
1269
+ resourceId?: string;
1270
+ requiredPermissions: string[];
1271
+ }
1272
+ interface TopoloWidgetState {
1273
+ status: TopoloWidgetStatus;
1274
+ observedAt: string;
1275
+ lastSuccessfulAt?: string;
1276
+ code?: string;
1277
+ message?: string;
1278
+ }
1279
+ interface TopoloWidgetRefreshPolicy {
1280
+ intervalSeconds: number;
1281
+ timeoutSeconds: number;
1282
+ maxAgeSeconds: number;
1283
+ staleWhileRevalidateSeconds: number;
1284
+ }
1285
+ interface TopoloWidgetConfigurationOption {
1286
+ value: string;
1287
+ label: string;
1288
+ }
1289
+ interface TopoloWidgetConfigurationField {
1290
+ key: string;
1291
+ label: string;
1292
+ type: "string" | "number" | "boolean" | "select" | "multi-select" | "date-range";
1293
+ required: boolean;
1294
+ options?: TopoloWidgetConfigurationOption[];
1295
+ }
1296
+ interface TopoloWidgetConfiguration {
1297
+ allowMultipleInstances: boolean;
1298
+ fields: TopoloWidgetConfigurationField[];
1299
+ defaults: Record<string, unknown>;
1300
+ }
1301
+ interface TopoloWidgetDrilldown {
1302
+ id: string;
1303
+ label: string;
1304
+ href: string;
1305
+ }
1306
+ interface TopoloWidgetActionRecovery {
1307
+ mode: "not_applicable" | "retry" | "compensating_action";
1308
+ actionId?: string;
1309
+ instructions: string;
1310
+ }
1311
+ interface TopoloWidgetActionBinding {
1312
+ id: string;
1313
+ label: string;
1314
+ actionId: string;
1315
+ resourceType: string;
1316
+ resourceId?: string;
1317
+ input: Record<string, unknown>;
1318
+ requiresConfirmation: boolean;
1319
+ destructive: boolean;
1320
+ effects: string[];
1321
+ verification: string[];
1322
+ recovery: TopoloWidgetActionRecovery;
1323
+ }
1324
+ interface TopoloWidgetLocalization {
1325
+ locale: string;
1326
+ titleKey: string;
1327
+ descriptionKey?: string;
1328
+ }
1329
+ interface TopoloWidgetAccessibility {
1330
+ label: string;
1331
+ description?: string;
1332
+ }
1254
1333
  interface TopoloWidgetBase {
1334
+ id: string;
1335
+ version: string;
1255
1336
  appId: string;
1256
1337
  serviceName: string;
1257
1338
  serviceIcon?: string;
1258
1339
  type: TopoloWidgetType;
1259
1340
  lastUpdated: string;
1260
- snapshot: TopoloWidgetSnapshotMetadata;
1341
+ presentation: TopoloWidgetPresentation;
1342
+ resource: TopoloWidgetResourceBinding;
1343
+ state: TopoloWidgetState;
1344
+ refresh: TopoloWidgetRefreshPolicy;
1345
+ configuration: TopoloWidgetConfiguration;
1346
+ drilldowns: TopoloWidgetDrilldown[];
1347
+ controls: TopoloWidgetActionBinding[];
1348
+ localization: TopoloWidgetLocalization;
1349
+ accessibility: TopoloWidgetAccessibility;
1350
+ }
1351
+ type TopoloWidgetMetricSemantic = "gauge" | "counter" | "rate" | "duration" | "currency" | "percentage";
1352
+ type TopoloWidgetMetricAggregation = "last" | "sum" | "average" | "minimum" | "maximum" | "count" | "distinct_count";
1353
+ interface TopoloWidgetPeriod {
1354
+ start: string;
1355
+ end: string;
1356
+ timezone: string;
1357
+ }
1358
+ interface TopoloWidgetDimension {
1359
+ key: string;
1360
+ label: string;
1361
+ value: string;
1261
1362
  }
1262
- interface TopoloWidgetMetric {
1263
- key?: string;
1363
+ interface TopoloWidgetMetricComparison {
1364
+ value: number;
1365
+ absoluteChange: number;
1366
+ percentageChange?: number;
1367
+ direction: "up" | "down" | "flat";
1264
1368
  label: string;
1265
- value: string | number;
1266
- change?: number;
1267
- changeLabel?: string;
1268
- icon?: string;
1369
+ period: TopoloWidgetPeriod;
1370
+ }
1371
+ interface TopoloWidgetSeriesPoint {
1372
+ timestamp: string;
1373
+ value: number;
1374
+ dimensions: TopoloWidgetDimension[];
1375
+ }
1376
+ interface TopoloWidgetSeries {
1377
+ id: string;
1378
+ label: string;
1379
+ unit: string;
1380
+ points: TopoloWidgetSeriesPoint[];
1269
1381
  }
1270
- interface TopoloWidgetSnapshotMetric {
1382
+ interface TopoloWidgetMetric {
1271
1383
  key: string;
1272
1384
  label: string;
1273
1385
  value: number;
1274
- unit?: string;
1275
- change?: number;
1276
- changeLabel?: string;
1277
- }
1278
- interface TopoloWidgetSnapshotMetadata {
1279
- presetKey?: string;
1280
- audience?: string;
1281
- scope?: string;
1282
- scopeLabel?: string;
1283
- generatedAt?: string;
1284
- summary: string;
1285
- defaultMetricKeys?: string[];
1286
- availableMetrics?: TopoloWidgetSnapshotMetric[];
1287
- highlights?: string[];
1386
+ unit: string;
1387
+ semantic: TopoloWidgetMetricSemantic;
1388
+ aggregation: TopoloWidgetMetricAggregation;
1389
+ period: TopoloWidgetPeriod;
1390
+ dimensions: TopoloWidgetDimension[];
1391
+ comparison?: TopoloWidgetMetricComparison;
1392
+ series?: TopoloWidgetSeries;
1288
1393
  }
1289
1394
  interface TopoloStatsWidget extends TopoloWidgetBase {
1290
1395
  type: "stats";
1291
- stats: TopoloWidgetMetric[];
1396
+ metrics: TopoloWidgetMetric[];
1397
+ }
1398
+ interface TopoloChartWidget extends TopoloWidgetBase {
1399
+ type: "chart";
1400
+ chartType: "line" | "bar" | "area" | "pie" | "donut";
1401
+ series: TopoloWidgetSeries[];
1292
1402
  }
1293
1403
  interface TopoloWidgetActivityItem {
1294
1404
  id: string;
@@ -1296,60 +1406,74 @@ interface TopoloWidgetActivityItem {
1296
1406
  description?: string;
1297
1407
  timestamp: string;
1298
1408
  icon?: string;
1299
- link?: string;
1409
+ drilldownId?: string;
1410
+ actionId?: string;
1300
1411
  }
1301
- interface TopoloRecentActivityWidget extends TopoloWidgetBase {
1302
- type: "recent-activity";
1412
+ interface TopoloActivityWidget extends TopoloWidgetBase {
1413
+ type: "activity";
1303
1414
  activities: TopoloWidgetActivityItem[];
1304
1415
  }
1305
- interface TopoloWidgetActionItem {
1306
- id: string;
1307
- label: string;
1308
- icon?: string;
1309
- link: string;
1310
- primary?: boolean;
1311
- }
1312
- interface TopoloQuickActionsWidget extends TopoloWidgetBase {
1313
- type: "quick-actions";
1314
- actions: TopoloWidgetActionItem[];
1315
- }
1316
1416
  interface TopoloWidgetNotificationItem {
1317
1417
  id: string;
1318
1418
  title: string;
1319
1419
  message: string;
1320
- type: "info" | "warning" | "error" | "success";
1420
+ severity: "info" | "warning" | "error" | "success";
1321
1421
  timestamp: string;
1322
1422
  read: boolean;
1323
- link?: string;
1423
+ drilldownId?: string;
1424
+ actionId?: string;
1324
1425
  }
1325
1426
  interface TopoloNotificationsWidget extends TopoloWidgetBase {
1326
1427
  type: "notifications";
1327
1428
  notifications: TopoloWidgetNotificationItem[];
1328
1429
  unreadCount: number;
1329
1430
  }
1330
- interface TopoloChartWidget extends TopoloWidgetBase {
1331
- type: "chart";
1332
- chartType: "line" | "bar" | "pie" | "donut";
1333
- title: string;
1334
- data: {
1335
- labels: string[];
1336
- values: number[];
1337
- };
1431
+ interface TopoloActionsWidget extends TopoloWidgetBase {
1432
+ type: "actions";
1433
+ actions: TopoloWidgetActionBinding[];
1338
1434
  }
1339
- type TopoloWidget = TopoloStatsWidget | TopoloRecentActivityWidget | TopoloQuickActionsWidget | TopoloNotificationsWidget | TopoloChartWidget;
1340
- type TopoloWidgetWithOptionalMetadata<T extends TopoloWidget> = Omit<T, "appId" | "serviceName" | "lastUpdated"> & Partial<Pick<TopoloWidgetBase, "appId" | "serviceName" | "lastUpdated">>;
1341
- type TopoloWidgetDraft = TopoloWidget extends infer Widget ? Widget extends TopoloWidget ? TopoloWidgetWithOptionalMetadata<Widget> : never : never;
1342
- interface TopoloWidgetApiResponse {
1343
- success: boolean;
1435
+ type TopoloWidget = TopoloStatsWidget | TopoloChartWidget | TopoloActivityWidget | TopoloNotificationsWidget | TopoloActionsWidget;
1436
+ type TopoloWidgetWithOptionalServiceMetadata<T extends TopoloWidget> = Omit<T, "appId" | "serviceName" | "lastUpdated"> & Partial<Pick<TopoloWidgetBase, "appId" | "serviceName" | "lastUpdated">>;
1437
+ type TopoloWidgetDraft = TopoloWidget extends infer Widget ? Widget extends TopoloWidget ? TopoloWidgetWithOptionalServiceMetadata<Widget> : never : never;
1438
+ interface TopoloWidgetApiSuccessResponse {
1439
+ success: true;
1440
+ contractVersion: typeof TOPOLO_WIDGET_CONTRACT_VERSION;
1441
+ appId: string;
1442
+ serviceName: string;
1443
+ generatedAt: string;
1344
1444
  widgets: TopoloWidget[];
1345
- error?: string;
1346
1445
  }
1446
+ interface TopoloWidgetApiError {
1447
+ code: string;
1448
+ message: string;
1449
+ retryable: boolean;
1450
+ retryAfter?: string;
1451
+ }
1452
+ interface TopoloWidgetApiErrorResponse {
1453
+ success: false;
1454
+ contractVersion: typeof TOPOLO_WIDGET_CONTRACT_VERSION;
1455
+ appId: string;
1456
+ serviceName: string;
1457
+ generatedAt: string;
1458
+ widgets: [];
1459
+ error: TopoloWidgetApiError;
1460
+ }
1461
+ type TopoloWidgetApiResponse = TopoloWidgetApiSuccessResponse | TopoloWidgetApiErrorResponse;
1347
1462
  interface TopoloWidgetResponseOptions {
1348
1463
  appId: string;
1349
1464
  serviceName: string;
1350
1465
  widgets: TopoloWidgetDraft[];
1351
1466
  now?: Date | string;
1352
1467
  }
1468
+ interface TopoloWidgetErrorResponseOptions {
1469
+ appId: string;
1470
+ serviceName: string;
1471
+ code: string;
1472
+ message: string;
1473
+ retryable: boolean;
1474
+ retryAfter?: Date | string;
1475
+ now?: Date | string;
1476
+ }
1353
1477
  interface TopoloWidgetValidationResult {
1354
1478
  ok: boolean;
1355
1479
  errors: string[];
@@ -1363,13 +1487,12 @@ interface TopoloWidgetConfig {
1363
1487
  refreshInterval: number;
1364
1488
  }
1365
1489
  declare function defineTopoloStatsWidget(widget: Omit<TopoloStatsWidget, "type">): TopoloStatsWidget;
1366
- declare function defineTopoloRecentActivityWidget(widget: Omit<TopoloRecentActivityWidget, "type">): TopoloRecentActivityWidget;
1367
- declare function defineTopoloQuickActionsWidget(widget: Omit<TopoloQuickActionsWidget, "type">): TopoloQuickActionsWidget;
1368
- declare function defineTopoloNotificationsWidget(widget: Omit<TopoloNotificationsWidget, "type">): TopoloNotificationsWidget;
1369
1490
  declare function defineTopoloChartWidget(widget: Omit<TopoloChartWidget, "type">): TopoloChartWidget;
1370
- declare function createTopoloWidgetResponse({ appId, serviceName, widgets, now, }: TopoloWidgetResponseOptions): TopoloWidgetApiResponse;
1371
- declare function createTopoloWidgetError(error: string): TopoloWidgetApiResponse;
1372
- declare function validateTopoloWidgetResponse(response: unknown): TopoloWidgetValidationResult;
1491
+ declare function defineTopoloActivityWidget(widget: Omit<TopoloActivityWidget, "type">): TopoloActivityWidget;
1492
+ declare function defineTopoloNotificationsWidget(widget: Omit<TopoloNotificationsWidget, "type">): TopoloNotificationsWidget;
1493
+ declare function defineTopoloActionsWidget(widget: Omit<TopoloActionsWidget, "type">): TopoloActionsWidget;
1494
+ declare function createTopoloWidgetResponse({ appId, serviceName, widgets, now, }: TopoloWidgetResponseOptions): TopoloWidgetApiSuccessResponse;
1495
+ declare function createTopoloWidgetError({ appId, serviceName, code, message, retryable, retryAfter, now, }: TopoloWidgetErrorResponseOptions): TopoloWidgetApiErrorResponse;
1373
1496
 
1374
1497
  /**
1375
1498
  * Convenience factory that returns a ready-to-use typed Topolo client plus
@@ -1386,4 +1509,4 @@ declare function createTopolo(options: TopoloClientOptions): {
1386
1509
  };
1387
1510
  type Topolo = ReturnType<typeof createTopolo>;
1388
1511
 
1389
- export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloQuickActionsWidget, type TopoloRecentActivityWidget, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetActionItem, type TopoloWidgetActivityItem, type TopoloWidgetApiResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetDraft, type TopoloWidgetMetric, type TopoloWidgetNotificationItem, type TopoloWidgetResponseOptions, type TopoloWidgetSnapshotMetadata, type TopoloWidgetSnapshotMetric, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloQuickActionsWidget, defineTopoloRecentActivityWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
1512
+ export { ACTION_CATALOG_DIGEST_ALGORITHM, type ActionContractManifest, type ActionContractSource, type AgentIdentity, type AppApiId, type ApplicationCatalogEntry, type ApplicationDeployTarget, type ApplicationDirectory, type ApplicationDirectoryApplication, type ApplicationDirectoryClient, type ApplicationDirectorySource, type ApplicationId, type CredentialIntrospection, type CrmContactSummary, CrmModule, DEFAULT_APP_URLS, type DeviceAuthorizationResponse, IdentityModule, type ListContactsOptions, type ListContactsResult, type OAuthHelperOptions, type P2PActionDetail, type P2PActionRequestInput, type P2PActionRequestResult, type P2PActionRow, type P2PActionRun, type P2PCapability, type P2PConnection, type P2PHold, type P2PLedgerEntry, P2PModule, type P2PPolicy, type P2PPricingModel, type P2PSettlementBatch, type P2PSettlementGroup, type PublishCapabilityInput, type RequestOptions, type ServiceCatalogUrlEntry, TOPOLO_ENVIRONMENT_SERVICE_URLS, TOPOLO_RUNTIME_ENVIRONMENTS, TOPOLO_WIDGET_CONTRACT_VERSION, TOPOLO_WIDGET_ENDPOINT, TOPOLO_WIDGET_REFRESH_INTERVAL_MS, type TokenResponse, type Topolo, type TopoloActionAgentContract, type TopoloActionCatalogEntry, type TopoloActionCatalogSummary, type TopoloActionDigestInput, type TopoloActionPlan, type TopoloActionPreparation, type TopoloActionUploadOptions, type TopoloActionValidationIssue, type TopoloActionValidationResult, type TopoloActionsWidget, type TopoloActivityWidget, type TopoloAgentExecutionContext, type TopoloApiKeyResourceMetadata, TopoloAuthError, type TopoloBinaryResponse, type TopoloBindableResource, type TopoloBindableResourceCatalog, type TopoloChartWidget, TopoloClient, type TopoloClientOptions, TopoloConfirmationRequiredError, type TopoloCredential, type TopoloDebugEvent, TopoloHttpError, type TopoloInlineBase64UploadContract, type TopoloNotificationsWidget, TopoloOAuth, TopoloPermissionError, type TopoloRuntimeEnvironment, TopoloSdkError, type TopoloServiceCatalogEntry, type TopoloStatsWidget, type TopoloWidget, type TopoloWidgetAccessibility, type TopoloWidgetActionBinding, type TopoloWidgetActionRecovery, type TopoloWidgetActivityItem, type TopoloWidgetApiError, type TopoloWidgetApiErrorResponse, type TopoloWidgetApiResponse, type TopoloWidgetApiSuccessResponse, type TopoloWidgetBase, type TopoloWidgetConfig, type TopoloWidgetConfiguration, type TopoloWidgetConfigurationField, type TopoloWidgetConfigurationOption, type TopoloWidgetContext, type TopoloWidgetDimension, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWorkspace, type TopoloWorkspaceListResult, type TopoloWorkspaceMutationResult, type TopoloWorkspacePolicy, WorkspacesModule, actionContractCompleteness, applicationEntryFromCatalog, assertTopoloServiceUrlEnvironment, canonicalTopoloErrorCode, canonicalTopoloRequestId, canonicalTopoloRequired, canonicalTopoloRetryAfter, compactActionCatalogEntry, compactActionPlan, compactActionPreparation, compactActionResult, compactActionValidation, createTopolo, createTopoloAgentExecutionContext, createTopoloWidgetError, createTopoloWidgetResponse, defineTopoloActionsWidget, defineTopoloActivityWidget, defineTopoloChartWidget, defineTopoloNotificationsWidget, defineTopoloStatsWidget, digestTopoloActionCatalog, encodeTopoloActionBase64, enrichActionContract, extractTopoloServiceErrorCode, extractTopoloServiceErrorDetails, formatDirectoryApplicationIds, friendlyAppId, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };