@checkstack/ui 1.8.3 → 1.10.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/package.json +6 -2
  3. package/scripts/generate-stdlib-types.ts +90 -0
  4. package/src/components/CodeEditor/CodeEditor.tsx +7 -0
  5. package/src/components/CodeEditor/MonacoEditor.tsx +203 -117
  6. package/src/components/CodeEditor/generateTypeDefinitions.ts +19 -26
  7. package/src/components/CodeEditor/generated/stdlib-types.json +1 -0
  8. package/src/components/CodeEditor/index.ts +7 -0
  9. package/src/components/CodeEditor/monacoStdlib.ts +62 -0
  10. package/src/components/CodeEditor/monacoWorkers.ts +118 -0
  11. package/src/components/CodeEditor/scriptContext.test.ts +280 -0
  12. package/src/components/CodeEditor/scriptContext.ts +467 -0
  13. package/src/components/CodeEditor/shellEnvVarMatcher.test.ts +95 -0
  14. package/src/components/CodeEditor/shellEnvVarMatcher.ts +70 -0
  15. package/src/components/DynamicForm/DynamicForm.tsx +6 -0
  16. package/src/components/DynamicForm/FormField.tsx +15 -0
  17. package/src/components/DynamicForm/MultiTypeEditorField.tsx +111 -6
  18. package/src/components/DynamicForm/index.ts +2 -0
  19. package/src/components/DynamicForm/starterTemplateSelector.test.ts +96 -0
  20. package/src/components/DynamicForm/starterTemplateSelector.ts +32 -0
  21. package/src/components/DynamicForm/types.ts +34 -1
  22. package/src/components/ListEmptyState.tsx +51 -0
  23. package/src/components/QueryErrorState.tsx +64 -0
  24. package/src/components/ResponsiveTable.tsx +92 -0
  25. package/src/components/Skeleton.tsx +39 -0
  26. package/src/hooks/useInitOnceForKey.test.ts +127 -0
  27. package/src/hooks/useInitOnceForKey.ts +87 -0
  28. package/src/index.ts +6 -0
  29. package/src/utils/toastTemplates.test.ts +82 -0
  30. package/src/utils/toastTemplates.ts +47 -0
  31. package/stories/ListEmptyState.stories.tsx +48 -0
  32. package/stories/QueryErrorState.stories.tsx +40 -0
  33. package/stories/ResponsiveTable.stories.tsx +93 -0
  34. package/stories/Skeleton.stories.tsx +53 -0
  35. package/stories/toastTemplates.stories.tsx +60 -0
  36. package/tsconfig.json +3 -1
@@ -63,55 +63,48 @@ declare const context: {
63
63
  `);
64
64
  }
65
65
 
66
- // Healthcheck script context (config-based)
66
+ // Healthcheck script context (config-based, ESM module).
67
+ // The runner spawns a Bun subprocess, sets \`globalThis.context\`, then
68
+ // dynamically imports the user module. So scripts can \`import\` from the
69
+ // Node standard library and \`export default\` their result.
67
70
  if (options.collectorConfigSchema) {
68
71
  const configType = jsonSchemaToTypeScript(options.collectorConfigSchema);
69
72
 
70
73
  lines.push(`
71
- /** Expected return type for healthcheck scripts */
74
+ /** Expected return shape for inline-script health checks. */
72
75
  interface HealthCheckScriptResult {
73
- /** Whether the health check passed */
76
+ /** Whether the health check passed. */
74
77
  success: boolean;
75
- /** Optional status message */
78
+ /** Optional status message — surfaces in the run detail. */
76
79
  message?: string;
77
- /** Optional numeric value for metrics */
80
+ /** Optional numeric value feeds the value chart + anomaly detection. */
78
81
  value?: number;
79
82
  }
80
83
 
81
- /** Context available in healthcheck inline scripts */
84
+ /** Runtime context exposed as a global by the inline-script runner. */
82
85
  declare const context: {
83
- /** Collector configuration */
86
+ /** Strongly-typed collector configuration. */
84
87
  readonly config: ${configType};
85
88
  };
86
89
  `);
87
90
  }
88
91
 
89
- // Always include console and fetch
90
- lines.push(`
91
- /** Console for logging (logs appear in delivery events) */
92
- declare const console: {
93
- /** Log an info message */
94
- log(...args: unknown[]): void;
95
- /** Log a warning message */
96
- warn(...args: unknown[]): void;
97
- /** Log an error message */
98
- error(...args: unknown[]): void;
99
- /** Log an info message */
100
- info(...args: unknown[]): void;
101
- };
102
-
103
- /** Fetch API for making HTTP requests */
104
- declare function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
105
- `);
106
-
92
+ // We deliberately don't redeclare `console`, `fetch`, the Node stdlib,
93
+ // or the Bun globals here — MonacoEditor mounts the bundled upstream
94
+ // `@types/node` + `bun-types` declarations into Monaco's virtual
95
+ // filesystem via `ensureMonacoStdlib`, so all of that is already in scope.
107
96
  return lines.join("\n");
108
97
  }
109
98
 
110
99
  /**
111
100
  * Convert a JSON Schema to a TypeScript type string.
112
101
  * Handles objects, arrays, primitives, and enums.
102
+ *
103
+ * Exported for reuse by `scriptContext.ts`, which uses the same converter
104
+ * to build typed `context.config` / `context.event.payload` blocks for
105
+ * inline-script editors.
113
106
  */
114
- function jsonSchemaToTypeScript(
107
+ export function jsonSchemaToTypeScript(
115
108
  schema: JsonSchemaProperty,
116
109
  indent: number = 0,
117
110
  ): string {