@herdingbits/trailhead-types 0.0.1

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/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @herdingbits/trailhead-types
2
+
3
+ TypeScript type definitions for the Trailhead micro-frontend framework.
4
+
5
+ **Note:** This package is auto-generated from `@herdingbits/trailhead-core` during build. Do not edit these files directly.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install --save-dev @herdingbits/trailhead-types
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import type { ShellAPI } from '@herdingbits/trailhead-types';
17
+ import type { DesignSystemAdapter } from '@herdingbits/trailhead-types/adapters';
18
+
19
+ // Use in your SPA apps
20
+ export function init(shell: ShellAPI) {
21
+ shell.feedback.success('App loaded!');
22
+ }
23
+
24
+ // Use when creating custom adapters
25
+ export class MyAdapter implements DesignSystemAdapter {
26
+ // ...
27
+ }
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ See the [main Trailhead documentation](https://github.com/herdingbits/trailhead) for more information.
33
+
34
+ ## License
35
+
36
+ MIT
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Public Adapter API - For creating custom design system adapters
3
+ */
4
+ export type { DesignSystemAdapter, FeedbackAdapter, ToastVariant, DialogButton, DialogConfig, DialogResult, } from './types.js';
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Design System Adapter Interfaces
3
+ *
4
+ * These interfaces define the contract between Trailhead core and design system implementations.
5
+ */
6
+ export type ToastVariant = "success" | "error" | "warning" | "info";
7
+ export interface DialogButton<T extends string = string> {
8
+ label: string;
9
+ value: T;
10
+ variant?: string;
11
+ }
12
+ export interface DialogConfig<T extends string = string> {
13
+ message: string;
14
+ title?: string;
15
+ buttons: DialogButton<T>[];
16
+ }
17
+ export interface DialogResult<T extends string = string> {
18
+ value: T | null;
19
+ }
20
+ /**
21
+ * Feedback Adapter - Handles user feedback (toasts, dialogs, busy states)
22
+ */
23
+ export interface FeedbackAdapter {
24
+ /**
25
+ * Show a busy overlay with a message
26
+ */
27
+ showBusy(message: string): void;
28
+ /**
29
+ * Clear the busy overlay
30
+ */
31
+ clearBusy(): void;
32
+ /**
33
+ * Show a toast notification
34
+ */
35
+ showToast(message: string, variant: ToastVariant, duration?: number): void;
36
+ /**
37
+ * Show a dialog with custom buttons
38
+ */
39
+ showDialog<T extends string>(config: DialogConfig<T>): Promise<DialogResult<T>>;
40
+ }
41
+ /**
42
+ * Design System Adapter - Main adapter interface
43
+ */
44
+ export interface DesignSystemAdapter {
45
+ /**
46
+ * Adapter name (e.g., "shoelace", "cloudscape")
47
+ */
48
+ name: string;
49
+ /**
50
+ * Adapter version
51
+ */
52
+ version: string;
53
+ /**
54
+ * Initialize the design system (load assets, set base paths, etc.)
55
+ */
56
+ init(basePath: string): Promise<void>;
57
+ /**
58
+ * Feedback adapter for user notifications
59
+ */
60
+ feedback: FeedbackAdapter;
61
+ }
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "@herdingbits/trailhead-types",
3
+ "version": "0.0.1",
4
+ "description": "TypeScript type definitions for Trailhead micro-frontend framework",
5
+ "type": "module",
6
+ "types": "./public-api.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./public-api.d.ts"
10
+ },
11
+ "./adapters": {
12
+ "types": "./adapters/public-api.d.ts"
13
+ }
14
+ },
15
+ "files": [
16
+ "*.d.ts",
17
+ "adapters/*.d.ts",
18
+ "README.md"
19
+ ],
20
+ "keywords": [
21
+ "micro-frontend",
22
+ "types",
23
+ "typescript",
24
+ "trailhead"
25
+ ],
26
+ "author": "HerdingBits",
27
+ "license": "MIT",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/herdingbits/trailhead.git",
34
+ "directory": "packages/types"
35
+ }
36
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Public Shell API - Only these types are exposed to plugin applications
3
+ * This file explicitly defines what's public vs internal
4
+ */
5
+ export type { ShellAPI, FeedbackAPI, AlertVariant, HttpAPI, RequestOptions, Result, SuccessResult, ErrorResult, HttpError, NavigationAPI, NavItem, } from './shell-api.js';
package/shell-api.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Shell API Interface
3
+ * Exposed to plugin applications via window.shell
4
+ */
5
+ export interface ShellAPI {
6
+ version: string;
7
+ feedback: FeedbackAPI;
8
+ http: HttpAPI;
9
+ navigation: NavigationAPI;
10
+ }
11
+ /**
12
+ * Feedback system API
13
+ */
14
+ export interface FeedbackAPI {
15
+ busy(message: string): void;
16
+ clear(): void;
17
+ success(message: string, duration?: number): void;
18
+ error(message: string, duration?: number): void;
19
+ warning(message: string, duration?: number): void;
20
+ info(message: string, duration?: number): void;
21
+ alert(message: string, variant?: AlertVariant, duration?: number): void;
22
+ confirm(message: string, title?: string): Promise<boolean>;
23
+ ok(message: string, title?: string): Promise<void>;
24
+ yesNo(message: string, title?: string): Promise<boolean>;
25
+ yesNoCancel(message: string, title?: string): Promise<"yes" | "no" | "cancel">;
26
+ custom<T extends string>(message: string, title: string, buttons: Array<{
27
+ label: string;
28
+ value: T;
29
+ variant?: string;
30
+ }>): Promise<T | null>;
31
+ }
32
+ export type AlertVariant = "success" | "error" | "warning" | "info";
33
+ /**
34
+ * HTTP client API with automatic feedback orchestration
35
+ */
36
+ export interface HttpAPI {
37
+ get<T = any>(url: string, options?: RequestOptions): Promise<Result<T>>;
38
+ post<T = any>(url: string, data?: any, options?: RequestOptions): Promise<Result<T>>;
39
+ put<T = any>(url: string, data?: any, options?: RequestOptions): Promise<Result<T>>;
40
+ patch<T = any>(url: string, data?: any, options?: RequestOptions): Promise<Result<T>>;
41
+ delete<T = any>(url: string, options?: RequestOptions): Promise<Result<T>>;
42
+ }
43
+ export interface RequestOptions {
44
+ requestKey?: string;
45
+ busyMessage?: string;
46
+ successMessage?: string;
47
+ showSuccess?: boolean;
48
+ noFeedback?: boolean;
49
+ headers?: Record<string, string>;
50
+ }
51
+ export interface SuccessResult<T> {
52
+ success: true;
53
+ data: T;
54
+ requestKey?: string;
55
+ }
56
+ export interface ErrorResult {
57
+ success: false;
58
+ error: HttpError;
59
+ requestKey?: string;
60
+ }
61
+ export type Result<T> = SuccessResult<T> | ErrorResult;
62
+ export interface HttpError {
63
+ name: string;
64
+ message: string;
65
+ status?: number;
66
+ data?: any;
67
+ }
68
+ /**
69
+ * Navigation API
70
+ */
71
+ export interface NavigationAPI {
72
+ navigate(path: string): void;
73
+ getCurrentPath(): string;
74
+ onRouteChange(callback: (path: string) => void): () => void;
75
+ }
76
+ /**
77
+ * Navigation configuration
78
+ */
79
+ export interface NavItem {
80
+ id: string;
81
+ path: string;
82
+ app: string;
83
+ icon: string;
84
+ label: string;
85
+ order: number;
86
+ badge?: () => number;
87
+ }
88
+ /**
89
+ * Global window extension
90
+ */
91
+ declare global {
92
+ interface Window {
93
+ shell: ShellAPI;
94
+ AppMount?: (container: HTMLElement) => void;
95
+ }
96
+ }