@topolo/sdk 0.14.1 → 0.14.2

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.ts CHANGED
@@ -1574,10 +1574,6 @@ declare function defineTopoloActionsWidget(widget: Omit<TopoloActionsWidget, "ty
1574
1574
  declare function createTopoloWidgetResponse({ appId, serviceName, widgets, now, }: TopoloWidgetResponseOptions): TopoloWidgetApiSuccessResponse;
1575
1575
  declare function createTopoloWidgetError({ appId, serviceName, code, message, retryable, retryAfter, now, }: TopoloWidgetErrorResponseOptions): TopoloWidgetApiErrorResponse;
1576
1576
 
1577
- type TopoloJsonSchema = Readonly<Record<string, unknown>>;
1578
- declare const TOPOLO_WIDGET_OUTPUT_SCHEMA: TopoloJsonSchema;
1579
- declare function isTopoloWidgetOutputSchema(schema: unknown): boolean;
1580
-
1581
1577
  /**
1582
1578
  * Convenience factory that returns a ready-to-use typed Topolo client plus
1583
1579
  * domain module surfaces (identity, crm, ...).
@@ -1593,4 +1589,4 @@ declare function createTopolo(options: TopoloClientOptions): {
1593
1589
  };
1594
1590
  type Topolo = ReturnType<typeof createTopolo>;
1595
1591
 
1596
- 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_OUTPUT_SCHEMA, 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 TopoloJsonSchema, 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 TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, 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, isTopoloWidgetOutputSchema, listApplicationDirectory, parseTopoloActionUploadContract, preferExactActionMatches, prepareTopoloActionBase64UploadInput, prepareTopoloActionUploadInput, publicTopoloErrorMessage, resolveApplicationDirectoryEntry, resolveCatalogServiceUrl, resolveServiceUrl, topoloErrorHint, topoloServiceOrigins, validateTopoloActionInput, validateTopoloWidgetResponse };
1592
+ 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 TopoloWidgetContribution, type TopoloWidgetDatasetDefinition, type TopoloWidgetDimension, type TopoloWidgetDimensionDefinition, type TopoloWidgetDraft, type TopoloWidgetDrilldown, type TopoloWidgetErrorResponseOptions, type TopoloWidgetEventDefinition, type TopoloWidgetLifecycleStage, type TopoloWidgetLocalization, type TopoloWidgetMetric, type TopoloWidgetMetricAggregation, type TopoloWidgetMetricComparison, type TopoloWidgetMetricDefinition, type TopoloWidgetMetricSemantic, type TopoloWidgetNotificationItem, type TopoloWidgetPeriod, type TopoloWidgetPresentation, type TopoloWidgetRefreshPolicy, type TopoloWidgetResourceBinding, type TopoloWidgetResponseOptions, type TopoloWidgetSeries, type TopoloWidgetSeriesDefinition, type TopoloWidgetSeriesPoint, type TopoloWidgetSize, type TopoloWidgetState, type TopoloWidgetStatus, type TopoloWidgetType, type TopoloWidgetValidationResult, type TopoloWidgetVisualizationFamily, type TopoloWidgetWorkspaceSelector, 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.js CHANGED
@@ -77,6 +77,7 @@ var ERROR_CODE_PATTERN = /^[a-z][a-z0-9_]{0,63}$/;
77
77
  var TOPOLO_REQUEST_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
78
78
  var CLOUDFLARE_RAY_ID_PATTERN = /^[0-9a-f]{16}-[A-Z]{3}$/;
79
79
  var PERMISSION_PATTERN = /^[a-z][a-z0-9_-]{0,63}(?:\.[a-z][a-z0-9_-]{0,63})*:(?:[a-z][a-z0-9_-]{0,63}|\*)$/;
80
+ var PUBLIC_FIELD_PATH_PATTERN = /^[$.a-z0-9_[\]-]{1,160}$/i;
80
81
  var RETRY_AFTER_DATE_PATTERN = /^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;
81
82
  var PUBLIC_DETAIL_SOURCES = /* @__PURE__ */ new Set([
82
83
  "api_key_introspection",
@@ -189,7 +190,11 @@ function extractTopoloServiceErrorDetails(body) {
189
190
  if (candidate === void 0) candidate = nestedRecord.details ?? nestedRecord;
190
191
  }
191
192
  if (candidate === void 0) candidate = record;
192
- if (!candidate || typeof candidate !== "object" || Array.isArray(candidate)) return void 0;
193
+ if (Array.isArray(candidate)) {
194
+ const paths = canonicalTopoloValidationPaths(candidate);
195
+ return paths.length ? { paths } : void 0;
196
+ }
197
+ if (!candidate || typeof candidate !== "object") return void 0;
193
198
  const source = candidate;
194
199
  const safe = {};
195
200
  for (const [key, value] of Object.entries(source)) {
@@ -226,12 +231,42 @@ function extractTopoloServiceErrorDetails(body) {
226
231
  continue;
227
232
  }
228
233
  if (["missingFields", "fields", "paths"].includes(key) && Array.isArray(value)) {
229
- const paths = value.filter((item) => typeof item === "string" && /^[$.a-z0-9_[\]-]{1,160}$/i.test(item));
234
+ const paths = value.filter((item) => typeof item === "string" && PUBLIC_FIELD_PATH_PATTERN.test(item));
230
235
  if (paths.length) safe[key] = paths;
231
236
  }
232
237
  }
233
238
  return Object.keys(safe).length ? safe : void 0;
234
239
  }
240
+ function canonicalTopoloValidationPaths(issues) {
241
+ const paths = [];
242
+ for (const issue of issues) {
243
+ if (!issue || typeof issue !== "object" || Array.isArray(issue)) continue;
244
+ const record = issue;
245
+ const path = canonicalTopoloValidationPath(record.field) ?? canonicalTopoloValidationPath(record.path);
246
+ if (path && !paths.includes(path)) paths.push(path);
247
+ if (paths.length === 32) break;
248
+ }
249
+ return paths;
250
+ }
251
+ function canonicalTopoloValidationPath(value) {
252
+ if (typeof value === "string") {
253
+ const path2 = value.trim();
254
+ return PUBLIC_FIELD_PATH_PATTERN.test(path2) ? path2 : void 0;
255
+ }
256
+ if (!Array.isArray(value) || value.length === 0 || value.length > 32) return void 0;
257
+ const segments = value.map((segment) => {
258
+ if (typeof segment === "number" && Number.isSafeInteger(segment) && segment >= 0) {
259
+ return String(segment);
260
+ }
261
+ if (typeof segment === "string" && /^[a-z0-9_$-]{1,80}$/i.test(segment)) {
262
+ return segment;
263
+ }
264
+ return null;
265
+ });
266
+ if (segments.includes(null)) return void 0;
267
+ const path = segments.join(".");
268
+ return PUBLIC_FIELD_PATH_PATTERN.test(path) ? path : void 0;
269
+ }
235
270
  function publicTopoloErrorMessage(error) {
236
271
  const code = canonicalTopoloErrorCode(
237
272
  typeof error === "string" ? error : error.code ?? extractTopoloServiceErrorCode(error.body)
@@ -3617,22 +3652,22 @@ function validateRuntimeSemantics(widget, contributionPath, declared, errors) {
3617
3652
  validateSeriesDimensions(metric.series, declared.dimensionKeys, contributionPath, errors);
3618
3653
  }
3619
3654
  }
3620
- const series2 = Array.isArray(widget.series) ? widget.series : [];
3621
- for (const item of series2) {
3655
+ const series = Array.isArray(widget.series) ? widget.series : [];
3656
+ for (const item of series) {
3622
3657
  if (!isRecord5(item)) continue;
3623
3658
  if (typeof item.id === "string" && !declared.seriesKeys.has(item.id)) errors.push(`${contributionPath}.seriesDefinitions is missing runtime series ${item.id}`);
3624
3659
  validateSeriesDimensions(item, declared.dimensionKeys, contributionPath, errors);
3625
3660
  }
3626
3661
  }
3627
- function validateSeriesDimensions(series2, known, path, errors) {
3628
- if (!Array.isArray(series2.points)) return;
3629
- for (const point of series2.points) if (isRecord5(point)) validateRuntimeDimensions(point.dimensions, known, path, errors);
3662
+ function validateSeriesDimensions(series, known, path, errors) {
3663
+ if (!Array.isArray(series.points)) return;
3664
+ for (const point of series.points) if (isRecord5(point)) validateRuntimeDimensions(point.dimensions, known, path, errors);
3630
3665
  }
3631
3666
  function validateRuntimeDimensions(value, known, path, errors) {
3632
3667
  if (!Array.isArray(value)) return;
3633
- for (const dimension2 of value) {
3634
- if (isRecord5(dimension2) && typeof dimension2.key === "string" && !known.has(dimension2.key)) {
3635
- errors.push(`${path}.dimensions is missing runtime dimension ${dimension2.key}`);
3668
+ for (const dimension of value) {
3669
+ if (isRecord5(dimension) && typeof dimension.key === "string" && !known.has(dimension.key)) {
3670
+ errors.push(`${path}.dimensions is missing runtime dimension ${dimension.key}`);
3636
3671
  }
3637
3672
  }
3638
3673
  }
@@ -3669,12 +3704,12 @@ function validatePeriod(value, path, errors) {
3669
3704
  }
3670
3705
  function validateDimensions(value, path, errors) {
3671
3706
  if (!arrayValue(value, path, errors)) return;
3672
- value.forEach((dimension2, index) => {
3707
+ value.forEach((dimension, index) => {
3673
3708
  const itemPath = `${path}[${index}]`;
3674
- if (!recordValue(dimension2, itemPath, errors)) return;
3675
- nonEmptyString(dimension2.key, `${itemPath}.key`, errors);
3676
- nonEmptyString(dimension2.label, `${itemPath}.label`, errors);
3677
- nonEmptyString(dimension2.value, `${itemPath}.value`, errors);
3709
+ if (!recordValue(dimension, itemPath, errors)) return;
3710
+ nonEmptyString(dimension.key, `${itemPath}.key`, errors);
3711
+ nonEmptyString(dimension.label, `${itemPath}.label`, errors);
3712
+ nonEmptyString(dimension.value, `${itemPath}.value`, errors);
3678
3713
  });
3679
3714
  }
3680
3715
  function validateComparison(value, path, errors) {
@@ -3688,7 +3723,7 @@ function validateComparison(value, path, errors) {
3688
3723
  }
3689
3724
  function validateSeriesCollection(value, path, errors, requireOne) {
3690
3725
  if (!arrayValue(value, path, errors, requireOne)) return;
3691
- value.forEach((series2, index) => validateSeries(series2, `${path}[${index}]`, errors));
3726
+ value.forEach((series, index) => validateSeries(series, `${path}[${index}]`, errors));
3692
3727
  }
3693
3728
  function validateSeries(value, path, errors) {
3694
3729
  if (!recordValue(value, path, errors)) return;
@@ -3886,478 +3921,6 @@ function toIsoTimestamp(input) {
3886
3921
  return input ?? (/* @__PURE__ */ new Date()).toISOString();
3887
3922
  }
3888
3923
 
3889
- // src/widget-output-schema.ts
3890
- var nonEmptyString2 = { type: "string", minLength: 1 };
3891
- var stringArray3 = { type: "array", items: nonEmptyString2 };
3892
- var actionBinding = {
3893
- type: "object",
3894
- properties: {
3895
- id: nonEmptyString2,
3896
- label: nonEmptyString2,
3897
- actionId: nonEmptyString2,
3898
- resourceType: nonEmptyString2,
3899
- resourceId: nonEmptyString2,
3900
- input: { type: "object" },
3901
- requiresConfirmation: { type: "boolean" },
3902
- destructive: { type: "boolean" },
3903
- effects: stringArray3,
3904
- verification: stringArray3,
3905
- recovery: {
3906
- type: "object",
3907
- properties: {
3908
- mode: { enum: ["not_applicable", "retry", "compensating_action"] },
3909
- actionId: nonEmptyString2,
3910
- instructions: nonEmptyString2
3911
- },
3912
- required: ["mode", "instructions"],
3913
- additionalProperties: false
3914
- }
3915
- },
3916
- required: [
3917
- "id",
3918
- "label",
3919
- "actionId",
3920
- "resourceType",
3921
- "input",
3922
- "requiresConfirmation",
3923
- "destructive",
3924
- "effects",
3925
- "verification",
3926
- "recovery"
3927
- ],
3928
- additionalProperties: false
3929
- };
3930
- var dimension = {
3931
- type: "object",
3932
- properties: { key: nonEmptyString2, label: nonEmptyString2, value: nonEmptyString2 },
3933
- required: ["key", "label", "value"],
3934
- additionalProperties: false
3935
- };
3936
- var period = {
3937
- type: "object",
3938
- properties: {
3939
- start: nonEmptyString2,
3940
- end: nonEmptyString2,
3941
- timezone: nonEmptyString2
3942
- },
3943
- required: ["start", "end", "timezone"],
3944
- additionalProperties: false
3945
- };
3946
- var series = {
3947
- type: "object",
3948
- properties: {
3949
- id: nonEmptyString2,
3950
- label: nonEmptyString2,
3951
- unit: nonEmptyString2,
3952
- points: {
3953
- type: "array",
3954
- items: {
3955
- type: "object",
3956
- properties: {
3957
- timestamp: nonEmptyString2,
3958
- value: { type: "number" },
3959
- dimensions: { type: "array", items: dimension }
3960
- },
3961
- required: ["timestamp", "value", "dimensions"],
3962
- additionalProperties: false
3963
- }
3964
- }
3965
- },
3966
- required: ["id", "label", "unit", "points"],
3967
- additionalProperties: false
3968
- };
3969
- var contribution = {
3970
- type: "object",
3971
- properties: {
3972
- summary: nonEmptyString2,
3973
- identity: {
3974
- type: "object",
3975
- properties: { iconSource: { const: "catalog" } },
3976
- required: ["iconSource"],
3977
- additionalProperties: false
3978
- },
3979
- workspaceSelector: {
3980
- type: "object",
3981
- properties: {
3982
- mode: { enum: ["none", "optional", "required"] },
3983
- resourceType: nonEmptyString2,
3984
- label: nonEmptyString2,
3985
- supportsMultiple: { type: "boolean" }
3986
- },
3987
- required: ["mode", "resourceType", "label", "supportsMultiple"],
3988
- additionalProperties: false
3989
- },
3990
- metricDefinitions: {
3991
- type: "array",
3992
- items: {
3993
- type: "object",
3994
- properties: {
3995
- key: nonEmptyString2,
3996
- label: nonEmptyString2,
3997
- description: nonEmptyString2,
3998
- unit: nonEmptyString2,
3999
- semantic: {
4000
- enum: ["gauge", "counter", "rate", "duration", "currency", "percentage"]
4001
- },
4002
- aggregation: {
4003
- enum: ["last", "sum", "average", "minimum", "maximum", "count", "distinct_count"]
4004
- }
4005
- },
4006
- required: ["key", "label", "description", "unit", "semantic", "aggregation"],
4007
- additionalProperties: false
4008
- }
4009
- },
4010
- seriesDefinitions: {
4011
- type: "array",
4012
- items: {
4013
- type: "object",
4014
- properties: {
4015
- key: nonEmptyString2,
4016
- label: nonEmptyString2,
4017
- metricKey: nonEmptyString2,
4018
- unit: nonEmptyString2
4019
- },
4020
- required: ["key", "label", "metricKey", "unit"],
4021
- additionalProperties: false
4022
- }
4023
- },
4024
- dimensions: {
4025
- type: "array",
4026
- items: {
4027
- type: "object",
4028
- properties: {
4029
- key: nonEmptyString2,
4030
- label: nonEmptyString2,
4031
- description: nonEmptyString2,
4032
- valueType: { enum: ["string", "number", "boolean", "date", "datetime"] }
4033
- },
4034
- required: ["key", "label", "description", "valueType"],
4035
- additionalProperties: false
4036
- }
4037
- },
4038
- lifecycleStages: {
4039
- type: "array",
4040
- items: {
4041
- type: "object",
4042
- properties: {
4043
- key: nonEmptyString2,
4044
- label: nonEmptyString2,
4045
- order: { type: "number" },
4046
- terminal: { type: "boolean" }
4047
- },
4048
- required: ["key", "label", "order", "terminal"],
4049
- additionalProperties: false
4050
- }
4051
- },
4052
- events: {
4053
- type: "array",
4054
- items: {
4055
- type: "object",
4056
- properties: {
4057
- key: nonEmptyString2,
4058
- label: nonEmptyString2,
4059
- description: nonEmptyString2
4060
- },
4061
- required: ["key", "label", "description"],
4062
- additionalProperties: false
4063
- }
4064
- },
4065
- datasets: {
4066
- type: "array",
4067
- minItems: 1,
4068
- items: {
4069
- type: "object",
4070
- properties: {
4071
- id: nonEmptyString2,
4072
- label: nonEmptyString2,
4073
- description: nonEmptyString2,
4074
- grain: nonEmptyString2,
4075
- metricKeys: stringArray3,
4076
- seriesKeys: stringArray3,
4077
- dimensionKeys: stringArray3,
4078
- eventKeys: stringArray3,
4079
- actionIds: stringArray3
4080
- },
4081
- required: [
4082
- "id",
4083
- "label",
4084
- "description",
4085
- "grain",
4086
- "metricKeys",
4087
- "seriesKeys",
4088
- "dimensionKeys",
4089
- "eventKeys",
4090
- "actionIds"
4091
- ],
4092
- additionalProperties: false
4093
- }
4094
- },
4095
- compatibleVisualizations: {
4096
- type: "array",
4097
- minItems: 1,
4098
- items: {
4099
- enum: ["number", "line", "area", "bar", "donut", "table", "funnel", "timeline", "actions"]
4100
- }
4101
- },
4102
- defaultVisualization: {
4103
- enum: ["number", "line", "area", "bar", "donut", "table", "funnel", "timeline", "actions"]
4104
- }
4105
- },
4106
- required: [
4107
- "summary",
4108
- "identity",
4109
- "workspaceSelector",
4110
- "metricDefinitions",
4111
- "seriesDefinitions",
4112
- "dimensions",
4113
- "lifecycleStages",
4114
- "events",
4115
- "datasets",
4116
- "compatibleVisualizations",
4117
- "defaultVisualization"
4118
- ],
4119
- additionalProperties: false
4120
- };
4121
- var widgetItem = {
4122
- type: "object",
4123
- properties: {
4124
- id: nonEmptyString2,
4125
- version: nonEmptyString2,
4126
- appId: nonEmptyString2,
4127
- serviceName: nonEmptyString2,
4128
- lastUpdated: nonEmptyString2,
4129
- type: { enum: ["stats", "chart", "activity", "notifications", "actions"] },
4130
- presentation: {
4131
- type: "object",
4132
- properties: {
4133
- title: nonEmptyString2,
4134
- description: nonEmptyString2,
4135
- contexts: {
4136
- type: "array",
4137
- minItems: 1,
4138
- items: { enum: ["personal", "organization", "workspace", "resource"] }
4139
- },
4140
- supportedSizes: {
4141
- type: "array",
4142
- minItems: 1,
4143
- items: { enum: ["compact", "medium", "wide", "full"] }
4144
- },
4145
- defaultSize: { enum: ["compact", "medium", "wide", "full"] }
4146
- },
4147
- required: ["title", "contexts", "supportedSizes", "defaultSize"],
4148
- additionalProperties: false
4149
- },
4150
- resource: {
4151
- type: "object",
4152
- properties: {
4153
- resourceType: nonEmptyString2,
4154
- resourceId: nonEmptyString2,
4155
- requiredPermissions: stringArray3
4156
- },
4157
- required: ["resourceType", "requiredPermissions"],
4158
- additionalProperties: false
4159
- },
4160
- state: {
4161
- type: "object",
4162
- properties: {
4163
- status: { enum: ["ready", "empty", "unavailable", "stale", "error"] },
4164
- observedAt: nonEmptyString2,
4165
- lastSuccessfulAt: nonEmptyString2,
4166
- code: nonEmptyString2,
4167
- message: nonEmptyString2
4168
- },
4169
- required: ["status", "observedAt"],
4170
- additionalProperties: false
4171
- },
4172
- refresh: {
4173
- type: "object",
4174
- properties: {
4175
- intervalSeconds: { type: "number" },
4176
- timeoutSeconds: { type: "number" },
4177
- maxAgeSeconds: { type: "number" },
4178
- staleWhileRevalidateSeconds: { type: "number" }
4179
- },
4180
- required: ["intervalSeconds", "timeoutSeconds", "maxAgeSeconds", "staleWhileRevalidateSeconds"],
4181
- additionalProperties: false
4182
- },
4183
- configuration: {
4184
- type: "object",
4185
- properties: {
4186
- allowMultipleInstances: { type: "boolean" },
4187
- fields: {
4188
- type: "array",
4189
- items: {
4190
- type: "object",
4191
- properties: {
4192
- key: nonEmptyString2,
4193
- label: nonEmptyString2,
4194
- type: { enum: ["string", "number", "boolean", "select", "multi-select", "date-range"] },
4195
- required: { type: "boolean" },
4196
- options: {
4197
- type: "array",
4198
- items: {
4199
- type: "object",
4200
- properties: { value: nonEmptyString2, label: nonEmptyString2 },
4201
- required: ["value", "label"],
4202
- additionalProperties: false
4203
- }
4204
- }
4205
- },
4206
- required: ["key", "label", "type", "required"],
4207
- additionalProperties: false
4208
- }
4209
- },
4210
- defaults: { type: "object" }
4211
- },
4212
- required: ["allowMultipleInstances", "fields", "defaults"],
4213
- additionalProperties: false
4214
- },
4215
- drilldowns: {
4216
- type: "array",
4217
- items: {
4218
- type: "object",
4219
- properties: { id: nonEmptyString2, label: nonEmptyString2, href: nonEmptyString2 },
4220
- required: ["id", "label", "href"],
4221
- additionalProperties: false
4222
- }
4223
- },
4224
- controls: { type: "array", items: actionBinding },
4225
- localization: {
4226
- type: "object",
4227
- properties: {
4228
- locale: nonEmptyString2,
4229
- titleKey: nonEmptyString2,
4230
- descriptionKey: nonEmptyString2,
4231
- title: nonEmptyString2,
4232
- description: nonEmptyString2
4233
- },
4234
- required: ["locale", "titleKey"],
4235
- additionalProperties: false
4236
- },
4237
- accessibility: {
4238
- type: "object",
4239
- properties: { label: nonEmptyString2, description: nonEmptyString2 },
4240
- required: ["label"],
4241
- additionalProperties: false
4242
- },
4243
- contribution,
4244
- metrics: {
4245
- type: "array",
4246
- items: {
4247
- type: "object",
4248
- properties: {
4249
- key: nonEmptyString2,
4250
- label: nonEmptyString2,
4251
- value: { type: "number" },
4252
- unit: nonEmptyString2,
4253
- semantic: {
4254
- enum: ["gauge", "counter", "rate", "duration", "currency", "percentage"]
4255
- },
4256
- aggregation: {
4257
- enum: ["last", "sum", "average", "minimum", "maximum", "count", "distinct_count"]
4258
- },
4259
- period,
4260
- dimensions: { type: "array", items: dimension },
4261
- series
4262
- },
4263
- required: ["key", "label", "value", "unit", "semantic", "aggregation", "period", "dimensions"],
4264
- additionalProperties: false
4265
- }
4266
- },
4267
- chartType: { enum: ["line", "bar", "area", "pie", "donut"] },
4268
- series: { type: "array", items: series },
4269
- activities: { type: "array", items: { type: "object" } },
4270
- notifications: { type: "array", items: { type: "object" } },
4271
- unreadCount: { type: "number" },
4272
- actions: { type: "array", items: actionBinding }
4273
- },
4274
- required: [
4275
- "id",
4276
- "version",
4277
- "appId",
4278
- "serviceName",
4279
- "lastUpdated",
4280
- "type",
4281
- "presentation",
4282
- "resource",
4283
- "state",
4284
- "refresh",
4285
- "configuration",
4286
- "drilldowns",
4287
- "controls",
4288
- "localization",
4289
- "accessibility",
4290
- "contribution"
4291
- ],
4292
- allOf: [
4293
- { if: { properties: { type: { const: "stats" } } }, then: { required: ["metrics"] } },
4294
- { if: { properties: { type: { const: "chart" } } }, then: { required: ["chartType", "series"] } },
4295
- { if: { properties: { type: { const: "activity" } } }, then: { required: ["activities"] } },
4296
- {
4297
- if: { properties: { type: { const: "notifications" } } },
4298
- then: { required: ["notifications", "unreadCount"] }
4299
- },
4300
- { if: { properties: { type: { const: "actions" } } }, then: { required: ["actions"] } }
4301
- ],
4302
- additionalProperties: false
4303
- };
4304
- var TOPOLO_WIDGET_OUTPUT_SCHEMA = Object.freeze({
4305
- $schema: "https://json-schema.org/draft/2020-12/schema",
4306
- type: "object",
4307
- properties: {
4308
- success: { type: "boolean", const: true },
4309
- contractVersion: { type: "string", const: "3.0.0" },
4310
- appId: nonEmptyString2,
4311
- serviceName: nonEmptyString2,
4312
- generatedAt: nonEmptyString2,
4313
- widgets: { type: "array", minItems: 1, items: widgetItem },
4314
- workspace: {
4315
- anyOf: [
4316
- {
4317
- type: "object",
4318
- properties: {
4319
- id: { anyOf: [{ type: "string" }, { type: "number" }] },
4320
- name: nonEmptyString2
4321
- },
4322
- required: ["id", "name"],
4323
- additionalProperties: true
4324
- },
4325
- { type: "null" }
4326
- ]
4327
- },
4328
- workspaces: {
4329
- type: "array",
4330
- items: {
4331
- type: "object",
4332
- properties: {
4333
- id: { anyOf: [{ type: "string" }, { type: "number" }] },
4334
- name: nonEmptyString2,
4335
- isDefault: { type: "boolean" }
4336
- },
4337
- required: ["id", "name"],
4338
- additionalProperties: false
4339
- }
4340
- }
4341
- },
4342
- required: ["success", "contractVersion", "appId", "serviceName", "generatedAt", "widgets"],
4343
- additionalProperties: false
4344
- });
4345
- function isTopoloWidgetOutputSchema(schema) {
4346
- if (!isRecord6(schema) || !isRecord6(schema.properties)) return false;
4347
- const properties = schema.properties;
4348
- const widgetItemSchema = isRecord6(properties.widgets) && isRecord6(properties.widgets.items) ? properties.widgets.items : void 0;
4349
- const widgetProperties = widgetItemSchema && isRecord6(widgetItemSchema.properties) ? widgetItemSchema.properties : void 0;
4350
- const contributionSchema = widgetProperties && isRecord6(widgetProperties.contribution) ? widgetProperties.contribution : void 0;
4351
- const contractVersion = isRecord6(properties.contractVersion) ? properties.contractVersion.const : void 0;
4352
- return schema.type === "object" && contractVersion === "3.0.0" && isRecord6(properties.widgets) && properties.widgets.type === "array" && widgetItemSchema?.type === "object" && hasRequired(schema, "contractVersion") && hasRequired(schema, "widgets") && hasRequired(widgetItemSchema, "contribution") && hasRequired(contributionSchema, "datasets") && hasRequired(contributionSchema, "compatibleVisualizations") && hasRequired(contributionSchema, "defaultVisualization");
4353
- }
4354
- function isRecord6(value) {
4355
- return typeof value === "object" && value !== null && !Array.isArray(value);
4356
- }
4357
- function hasRequired(schema, field) {
4358
- return isRecord6(schema) && Array.isArray(schema.required) && schema.required.includes(field);
4359
- }
4360
-
4361
3924
  // src/index.ts
4362
3925
  function createTopolo(options) {
4363
3926
  const client = new TopoloClient(options);
@@ -4378,7 +3941,6 @@ export {
4378
3941
  TOPOLO_RUNTIME_ENVIRONMENTS,
4379
3942
  TOPOLO_WIDGET_CONTRACT_VERSION,
4380
3943
  TOPOLO_WIDGET_ENDPOINT,
4381
- TOPOLO_WIDGET_OUTPUT_SCHEMA,
4382
3944
  TOPOLO_WIDGET_REFRESH_INTERVAL_MS,
4383
3945
  TopoloAuthError,
4384
3946
  TopoloClient,
@@ -4416,7 +3978,6 @@ export {
4416
3978
  extractTopoloServiceErrorDetails,
4417
3979
  formatDirectoryApplicationIds,
4418
3980
  friendlyAppId,
4419
- isTopoloWidgetOutputSchema,
4420
3981
  listApplicationDirectory,
4421
3982
  parseTopoloActionUploadContract,
4422
3983
  preferExactActionMatches,