@kb-labs/core-types 1.0.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/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # @kb-labs/core-types
2
+
3
+ > **Shared TypeScript type definitions for KB Labs core packages.** Provides common types used across all KB Labs packages for consistency and type safety.
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
+ [![Node.js](https://img.shields.io/badge/Node.js-18.18.0+-green.svg)](https://nodejs.org/)
7
+ [![pnpm](https://img.shields.io/badge/pnpm-9.0.0+-orange.svg)](https://pnpm.io/)
8
+
9
+ ## 🎯 Vision & Purpose
10
+
11
+ **@kb-labs/core-types** provides shared TypeScript type definitions for KB Labs core packages. It ensures type consistency across the ecosystem and provides a single source of truth for common types like `ProductId`.
12
+
13
+ ## 🏗️ Architecture
14
+
15
+ ### Core Components
16
+
17
+ #### Type Definitions
18
+
19
+ - **Purpose**: Define shared types
20
+ - **Responsibilities**: Export types for use in other packages
21
+ - **Dependencies**: None (types only)
22
+
23
+ ### Design Patterns
24
+
25
+ - **Type Library Pattern**: Centralized type definitions
26
+ - **Union Types**: ProductId as union type for type safety
27
+
28
+ ### Data Flow
29
+
30
+ ```
31
+ Import from @kb-labs/core-types
32
+
33
+ ├──► TypeScript compiler resolves types
34
+ ├──► Types available at compile time
35
+ └──► No runtime code
36
+ ```
37
+
38
+ ## 🚀 Quick Start
39
+
40
+ ### Installation
41
+
42
+ ```bash
43
+ pnpm add @kb-labs/core-types
44
+ ```
45
+
46
+ ### Basic Usage
47
+
48
+ ```typescript
49
+ import type { ProductId } from '@kb-labs/core-types';
50
+
51
+ function processProduct(product: ProductId) {
52
+ // Type-safe product handling
53
+ switch (product) {
54
+ case 'aiReview':
55
+ // ...
56
+ break;
57
+ case 'aiDocs':
58
+ // ...
59
+ break;
60
+ }
61
+ }
62
+ ```
63
+
64
+ ## ✨ Features
65
+
66
+ ### Type Definitions
67
+
68
+ - **ProductId**: Union type for all KB Labs products
69
+ - **Type Safety**: Strong typing prevents invalid values
70
+ - **Consistency**: Single source of truth for product IDs
71
+
72
+ ## 🔧 Configuration
73
+
74
+ ### Configuration Options
75
+
76
+ No configuration needed (types only).
77
+
78
+ ### Environment Variables
79
+
80
+ None (compile-time only).
81
+
82
+ ## 🤝 Contributing
83
+
84
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.
85
+
86
+ ## 📄 License
87
+
88
+ KB Public License v1.1 © KB Labs
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @module @kb-labs/core-types/types
3
+ * Shared types for KB Labs core packages
4
+ * This package is used to break circular dependencies between core packages
5
+ */
6
+ /**
7
+ * Product identifier for KB Labs products
8
+ */
9
+ type ProductId = 'devlink' | 'release' | 'aiReview' | 'aiDocs' | 'devkit' | 'analytics';
10
+
11
+ /**
12
+ * @module @kb-labs/core-types/telemetry
13
+ * Telemetry abstraction for KB Labs ecosystem
14
+ *
15
+ * This module provides a product-agnostic interface for telemetry/analytics,
16
+ * allowing core packages to emit events without depending on specific implementations.
17
+ */
18
+ /**
19
+ * Result of emitting a telemetry event
20
+ */
21
+ interface TelemetryEmitResult {
22
+ /** Whether the event was queued for delivery */
23
+ queued: boolean;
24
+ /** Reason if event was not queued */
25
+ reason?: string;
26
+ }
27
+ /**
28
+ * Telemetry event payload (product-agnostic)
29
+ */
30
+ interface TelemetryEvent {
31
+ /** Event type/name */
32
+ type?: string;
33
+ /** Event payload data */
34
+ payload?: Record<string, unknown>;
35
+ /** Run/execution ID for grouping events */
36
+ runId?: string;
37
+ /** Actor information */
38
+ actor?: {
39
+ type: string;
40
+ id: string;
41
+ name?: string;
42
+ };
43
+ /** Context information */
44
+ ctx?: {
45
+ workspace?: string;
46
+ command?: string;
47
+ [key: string]: unknown;
48
+ };
49
+ /** Timestamp (ISO string) */
50
+ timestamp?: string;
51
+ /** Additional event data */
52
+ [key: string]: unknown;
53
+ }
54
+ /**
55
+ * Telemetry emitter interface
56
+ *
57
+ * Implementations should never throw - failures should be handled gracefully
58
+ * and returned as part of TelemetryEmitResult.
59
+ */
60
+ interface TelemetryEmitter {
61
+ /**
62
+ * Emit a telemetry event
63
+ * @param event Event to emit
64
+ * @returns Result indicating success/failure
65
+ */
66
+ emit(event: Partial<TelemetryEvent>): Promise<TelemetryEmitResult>;
67
+ }
68
+ /**
69
+ * No-op telemetry emitter (for when telemetry is disabled or not available)
70
+ */
71
+ declare class NoOpTelemetryEmitter implements TelemetryEmitter {
72
+ emit(_event: Partial<TelemetryEvent>): Promise<TelemetryEmitResult>;
73
+ }
74
+ /**
75
+ * Create a no-op telemetry emitter
76
+ */
77
+ declare function createNoOpTelemetryEmitter(): TelemetryEmitter;
78
+
79
+ export { NoOpTelemetryEmitter, type ProductId, type TelemetryEmitResult, type TelemetryEmitter, type TelemetryEvent, createNoOpTelemetryEmitter };
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ // src/telemetry.ts
2
+ var NoOpTelemetryEmitter = class {
3
+ async emit(_event) {
4
+ return { queued: false, reason: "Telemetry disabled" };
5
+ }
6
+ };
7
+ function createNoOpTelemetryEmitter() {
8
+ return new NoOpTelemetryEmitter();
9
+ }
10
+
11
+ export { NoOpTelemetryEmitter, createNoOpTelemetryEmitter };
12
+ //# sourceMappingURL=index.js.map
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/telemetry.ts"],"names":[],"mappings":";AAgEO,IAAM,uBAAN,MAAuD;AAAA,EAC5D,MAAM,KAAK,MAAA,EAA+D;AACxE,IAAA,OAAO,EAAE,MAAA,EAAQ,KAAA,EAAO,MAAA,EAAQ,oBAAA,EAAqB;AAAA,EACvD;AACF;AAKO,SAAS,0BAAA,GAA+C;AAC7D,EAAA,OAAO,IAAI,oBAAA,EAAqB;AAClC","file":"index.js","sourcesContent":["/**\n * @module @kb-labs/core-types/telemetry\n * Telemetry abstraction for KB Labs ecosystem\n * \n * This module provides a product-agnostic interface for telemetry/analytics,\n * allowing core packages to emit events without depending on specific implementations.\n */\n\n/**\n * Result of emitting a telemetry event\n */\nexport interface TelemetryEmitResult {\n /** Whether the event was queued for delivery */\n queued: boolean;\n /** Reason if event was not queued */\n reason?: string;\n}\n\n/**\n * Telemetry event payload (product-agnostic)\n */\nexport interface TelemetryEvent {\n /** Event type/name */\n type?: string;\n /** Event payload data */\n payload?: Record<string, unknown>;\n /** Run/execution ID for grouping events */\n runId?: string;\n /** Actor information */\n actor?: {\n type: string;\n id: string;\n name?: string;\n };\n /** Context information */\n ctx?: {\n workspace?: string;\n command?: string;\n [key: string]: unknown;\n };\n /** Timestamp (ISO string) */\n timestamp?: string;\n /** Additional event data */\n [key: string]: unknown;\n}\n\n/**\n * Telemetry emitter interface\n * \n * Implementations should never throw - failures should be handled gracefully\n * and returned as part of TelemetryEmitResult.\n */\nexport interface TelemetryEmitter {\n /**\n * Emit a telemetry event\n * @param event Event to emit\n * @returns Result indicating success/failure\n */\n emit(event: Partial<TelemetryEvent>): Promise<TelemetryEmitResult>;\n}\n\n/**\n * No-op telemetry emitter (for when telemetry is disabled or not available)\n */\nexport class NoOpTelemetryEmitter implements TelemetryEmitter {\n async emit(_event: Partial<TelemetryEvent>): Promise<TelemetryEmitResult> {\n return { queued: false, reason: 'Telemetry disabled' };\n }\n}\n\n/**\n * Create a no-op telemetry emitter\n */\nexport function createNoOpTelemetryEmitter(): TelemetryEmitter {\n return new NoOpTelemetryEmitter();\n}\n\n"]}
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@kb-labs/core-types",
3
+ "version": "1.0.0",
4
+ "description": "Shared TypeScript type definitions for KB Labs core packages",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "sideEffects": false,
21
+ "devDependencies": {
22
+ "@kb-labs/devkit": "link:../../../kb-labs-devkit",
23
+ "@types/node": "^24.3.3",
24
+ "@typescript-eslint/eslint-plugin": "^8",
25
+ "@typescript-eslint/parser": "^8",
26
+ "eslint": "^9",
27
+ "rimraf": "^6.0.1",
28
+ "tsup": "^8.5.0",
29
+ "typescript": "^5.6.3",
30
+ "vitest": "^3.2.4"
31
+ },
32
+ "engines": {
33
+ "node": ">=20.0.0",
34
+ "pnpm": ">=9.0.0"
35
+ },
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "scripts": {
40
+ "clean": "rimraf dist",
41
+ "build": "pnpm clean && tsup --config tsup.config.ts",
42
+ "dev": "tsup --config tsup.config.ts --watch",
43
+ "type-check": "tsc --noEmit",
44
+ "test": "vitest run --passWithNoTests",
45
+ "lint": "eslint . --ignore-pattern 'dist/**'",
46
+ "lint:fix": "eslint . --fix --ignore-pattern 'dist/**'",
47
+ "test:watch": "vitest"
48
+ }
49
+ }