commit 17313da7f96ed215c6f51d2026df6789710622b2 Author: Darius Date: Mon Nov 17 21:22:16 2025 +0100 initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7586c68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,26 @@ +# Dependencies +node_modules/ + +# Build output +dist/ + +# IDE +.vscode/ +.idea/ +.zed/ +*.swp +*.swo + +# OS +.DS_Store +Thumbs.db + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Environment +.env +.env.local diff --git a/README.md b/README.md new file mode 100644 index 0000000..33b29a6 --- /dev/null +++ b/README.md @@ -0,0 +1,141 @@ +# Shared TypeScript Types + +This package contains shared TypeScript type definitions used across multiple applications. + +## Setup + +### 1. Initialize the package + +```bash +npm install +npm run build +``` + +### 2. Push to Git + +```bash +git init +git add . +git commit -m "Initial commit: shared types package" +git remote add origin +git push -u origin main +``` + +## Usage in Other Projects + +### Option 1: Install from Git (HTTPS) + +Add to your project's `package.json`: + +```json +{ + "dependencies": { + "@your-org/shared-types": "git+https://github.com/your-org/shared-types.git" + } +} +``` + +Or install via command: + +```bash +npm install git+https://github.com/your-org/shared-types.git +``` + +### Option 2: Install from Git (SSH) + +```json +{ + "dependencies": { + "@your-org/shared-types": "git+ssh://git@github.com:your-org/shared-types.git" + } +} +``` + +### Option 3: Install specific branch or tag + +```json +{ + "dependencies": { + "@your-org/shared-types": "git+https://github.com/your-org/shared-types.git#v1.0.0" + } +} +``` + +Or for a branch: + +```json +{ + "dependencies": { + "@your-org/shared-types": "git+https://github.com/your-org/shared-types.git#develop" + } +} +``` + +## Using the Types + +```typescript +import { User, ApiResponse, Status } from '@your-org/shared-types'; + +const user: User = { + id: '123', + email: 'user@example.com', + name: 'John Doe', + createdAt: new Date(), + updatedAt: new Date() +}; + +const response: ApiResponse = { + success: true, + data: user, + message: 'User retrieved successfully' +}; + +const status = Status.Active; +``` + +## Updating the Package + +When you make changes to the types: + +1. Update the version in `package.json` +2. Build the package: `npm run build` +3. Commit and push changes +4. Update consuming applications: `npm update @your-org/shared-types` + +## Development Workflow + +### Adding New Types + +1. Create new `.ts` files in the `src/` directory +2. Export types from `src/index.ts` +3. Build and test: `npm run build` +4. Commit changes and push + +### Versioning + +Follow semantic versioning: +- **MAJOR**: Breaking changes +- **MINOR**: New features, backward compatible +- **PATCH**: Bug fixes, backward compatible + +### Best Practices + +- Keep types focused and modular +- Use clear, descriptive names +- Document complex types with JSDoc comments +- Avoid coupling to specific implementations +- Export everything through `index.ts` + +## Structure + +``` +shared-types/ +├── src/ +│ ├── index.ts # Main export file +│ └── types.ts # Type definitions +├── dist/ # Compiled output (generated) +├── package.json +├── tsconfig.json +├── .gitignore +└── README.md +``` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..82fe86f --- /dev/null +++ b/package-lock.json @@ -0,0 +1,32 @@ +{ + "name": "@dpu/types", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@dpu/types", + "version": "1.0.0", + "devDependencies": { + "typescript": "^5.3.0" + }, + "peerDependencies": { + "typescript": ">=4.5.0" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..5de6a32 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "@dpu/types", + "version": "1.0.0", + "description": "", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "dist" + ], + "scripts": { + "build": "tsc", + "prepublishOnly": "npm run build", + "clean": "rm -rf dist" + }, + "keywords": [ + "typescript", + "types", + "shared" + ], + "author": "Darius", + "devDependencies": { + "typescript": "^5.3.0" + }, + "peerDependencies": { + "typescript": ">=4.5.0" + } +} diff --git a/src/homeassistant.ts b/src/homeassistant.ts new file mode 100644 index 0000000..10d1922 --- /dev/null +++ b/src/homeassistant.ts @@ -0,0 +1,25 @@ +export type HomeAssistantEntity = { + entity_id: string; + state: string; + attributes: { + state_class?: string; + unit_of_measurement?: string; + icon?: string; + friendly_name?: string; + [key: string]: unknown; + }; + last_changed: string; // datetime string + last_reported: string; // datetime string + last_updated: string; // datetime string + context: { + id: string; + parent_id: string | null; + user_id: string | null; + }; +}; + +export interface HomeAssistantDeskPositionResult { + raw: HomeAssistantEntity; + asBoolean: boolean; + asText: () => string; +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..7333c7a --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export * from "./homeassistant"; +export * from "./tidal"; diff --git a/src/tidal.ts b/src/tidal.ts new file mode 100644 index 0000000..5fdd16d --- /dev/null +++ b/src/tidal.ts @@ -0,0 +1,14 @@ +export type TidalSong = { + title: string; + artists: string; + album: string; + playingFrom: string; + status: "playing" | "paused"; + url: string; + current: string; + duration: string; +}; + +export type TidalVolume = { + volume: number; +}; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f309441 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "commonjs", + "lib": ["ES2020"], + "declaration": true, + "declarationMap": true, + "outDir": "./dist", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true, + "moduleResolution": "node", + "resolveJsonModule": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] +}