diff --git a/.github/co-pilot-instruction.md b/.github/co-pilot-instruction.md new file mode 100644 index 0000000..c29808b --- /dev/null +++ b/.github/co-pilot-instruction.md @@ -0,0 +1,16 @@ +# Project general coding guidelines + +## Code Style +- Use semantic HTML5 elements (header, main, section, article, etc.) +- Prefer modern JavaScript (ES6+) features like const/let, arrow functions, and template literals + +## Naming Conventions +- Use PascalCase for component names, interfaces, and type aliases +- Use camelCase for variables, functions, and methods +- Prefix private class members with underscore (_) +- Use ALL_CAPS for constants + +## Code Quality +- Use meaningful variable and function names that clearly describe their purpose +- Include helpful comments for complex logic +- Add error handling for user inputs and API calls diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml index 988b247..08d2c3d 100644 --- a/.github/workflows/api-tests.yml +++ b/.github/workflows/api-tests.yml @@ -1,4 +1,3 @@ -<<<<<<< HEAD name: API Tests and Validation on: @@ -89,95 +88,95 @@ jobs: name: generated-sdks path: sdks/ retention-days: 30 -======= -name: API Tests and Validation - -on: - push: - branches: [ main, develop ] - pull_request: - branches: [ main, develop ] - -jobs: - test: - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x, 20.x] - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Validate OpenAPI specifications - run: npm run validate:openapi - - - name: Run tests - run: npm test - - - name: Generate coverage report - run: npm run test:coverage - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v3 - with: - files: ./coverage/lcov.info - flags: unittests - name: codecov-umbrella - - validate-specs: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '20.x' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Validate all OpenAPI specifications - run: npm run validate:openapi - - generate-sdks: - runs-on: ubuntu-latest - needs: [test, validate-specs] - - steps: - - uses: actions/checkout@v3 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '20.x' - cache: 'npm' - - - name: Install dependencies - run: npm ci - - - name: Generate TypeScript SDK - run: npm run generate:sdk:typescript - - - name: Generate Python SDK - run: npm run generate:sdk:python - - - name: Upload SDK artifacts - uses: actions/upload-artifact@v3 - with: - name: generated-sdks - path: sdks/ - retention-days: 30 ->>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities +======= +name: API Tests and Validation + +on: + push: + branches: [ main, develop ] + pull_request: + branches: [ main, develop ] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x, 20.x] + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Validate OpenAPI specifications + run: npm run validate:openapi + + - name: Run tests + run: npm test + + - name: Generate coverage report + run: npm run test:coverage + + - name: Upload coverage to Codecov + uses: codecov/codecov-action@v3 + with: + files: ./coverage/lcov.info + flags: unittests + name: codecov-umbrella + + validate-specs: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Validate all OpenAPI specifications + run: npm run validate:openapi + + generate-sdks: + runs-on: ubuntu-latest + needs: [test, validate-specs] + + steps: + - uses: actions/checkout@v3 + + - name: Use Node.js + uses: actions/setup-node@v3 + with: + node-version: '20.x' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Generate TypeScript SDK + run: npm run generate:sdk:typescript + + - name: Generate Python SDK + run: npm run generate:sdk:python + + - name: Upload SDK artifacts + uses: actions/upload-artifact@v3 + with: + name: generated-sdks + path: sdks/ + retention-days: 30 +>>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities diff --git a/.github/workflows/major-updates.yml b/.github/workflows/major-updates.yml index 9aef5b5..54fe88b 100644 --- a/.github/workflows/major-updates.yml +++ b/.github/workflows/major-updates.yml @@ -5,6 +5,10 @@ on: - cron: '0 10 1 * *' # 1st of month at 10 AM workflow_dispatch: +permissions: + contents: read + issues: write + jobs: check-major: runs-on: ubuntu-latest diff --git a/MONOREPO_MAP.md b/MONOREPO_MAP.md new file mode 100644 index 0000000..f0ebe00 --- /dev/null +++ b/MONOREPO_MAP.md @@ -0,0 +1,44 @@ +# MBTQ.dev Monorepo Map + +This repository contains multiple subsystems. Each subsystem is isolated by boundaries. + +## 1. Backend Services (Python) +- app/ (Flask) +- fastapi_backend/ +- magician_api/ +- database/ + +## 2. Frontend / Static +- static/ +- templates/ +- docs/ +- GitHub Pages demo + +## 3. AI / Quantum +- magician_api/ai +- magician_api/quantum +- app/core/quantum + +## 4. Integrations +- app/integrations/ +- fastapi_backend/api/v1/integration_endpoints.py + +## 5. Infrastructure +- deployment/docker/ +- deployment/kubernetes/ +- deployment/terraform/ +- deployment/ansible/ + +## 6. Tests +- tests/unit +- tests/integration +- tests/e2e +- tests/accessibility +- tests/performance + +## 7. Scripts +- scripts/setup +- scripts/deployment +- scripts/data +- scripts/maintenance +- scripts/monitoring diff --git a/README.md b/README.md index 21e6653..c9ba349 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -<<<<<<< main +[![CodeQL](https://github.com/pinkycollie/deaf-first-platform/actions/workflows/github-code-scanning/codeql/badge.svg?branch=main)](https://github.com/pinkycollie/deaf-first-platform/actions/workflows/github-code-scanning/codeql) [![Coverage](https://codecov.io/gh/pinkycollie/deaf-first-platform/branch/main/graph/badge.svg)](https://codecov.io/gh/pinkycollie/deaf-first-platform) [![Copilot code review](https://github.com/pinkycollie/DEAF-FIRST-PLATFORM/actions/workflows/copilot-pull-request-reviewer/copilot-pull-request-reviewer/badge.svg)](https://github.com/pinkycollie/DEAF-FIRST-PLATFORM/actions/workflows/copilot-pull-request-reviewer/copilot-pull-request-reviewer) # MBTQ Deaf-First Platform @@ -681,367 +681,367 @@ MIT License - see LICENSE file for details - http platform management - Real-time synchronization - Sign language support -======= -# MBTQ Deaf-First Platform - -A comprehensive platform built with deaf-first principles, providing accessible financial services, AI-powered assistance, and decentralized governance. - -## ๐Ÿ“š MBTQ Universe Components - -This repository contains OpenAPI specifications for all five core services of the MBTQ Universe: - -### 1. **DeafAUTH - Identity Cortex** -Secure authentication system designed with deaf-first principles. - -- **Location**: `services/deafauth/` -- **Base URL**: `https://api.mbtquniverse.com/auth` -- **Documentation**: [DeafAUTH README](services/deafauth/README.md) -- **OpenAPI Spec**: [openapi.yaml](services/deafauth/openapi/openapi.yaml) - -### 2. **PinkSync - Accessibility Engine** -Real-time accessibility features and synchronization. - -- **Location**: `services/pinksync/` -- **Base URL**: `https://api.mbtquniverse.com/sync` -- **Documentation**: [PinkSync README](services/pinksync/README.md) -- **OpenAPI Spec**: [openapi.yaml](services/pinksync/openapi/openapi.yaml) - -### 3. **Fibonrose - Trust & Blockchain** -Decentralized trust and verification layer. - -- **Location**: `services/fibonrose/` -- **Base URL**: `https://api.mbtquniverse.com/blockchain` -- **Documentation**: [Fibonrose README](services/fibonrose/README.md) -- **OpenAPI Spec**: [openapi.yaml](services/fibonrose/openapi/openapi.yaml) - -### 4. **360Magicians - AI Agents** -Intelligent automation and assistance agents. - -- **Location**: `services/magicians/` -- **Base URL**: `https://api.mbtquniverse.com/ai` -- **Documentation**: [360Magicians README](services/magicians/README.md) -- **OpenAPI Spec**: [openapi.yaml](services/magicians/openapi/openapi.yaml) - -### 5. **MBTQ DAO - Governance** -Decentralized governance and community management. - -- **Location**: `services/dao/` -- **Base URL**: `https://api.mbtquniverse.com/dao` -- **Documentation**: [DAO README](services/dao/README.md) -- **OpenAPI Spec**: [openapi.yaml](services/dao/openapi/openapi.yaml) - -## ๐Ÿš€ Features - -โœ” All endpoints documented with OpenAPI 3.1 -โœ” Standardized responses across all services -โœ” Shared DeafAUTH security scheme -โœ” Tags, components, pagination, error schemas -โœ” Cloudflare-friendly JSON-only style -โœ” **Automated API testing with Jest** -โœ” **SDK generation (TypeScript + Python)** -โœ” Production-ready specifications - -## ๐Ÿ” Authentication - -All MBTQ Universe services use DeafAUTH for authentication. Include the Bearer token in the Authorization header: - -```bash -Authorization: Bearer -``` - -### Getting Started with Authentication - -1. Register a new user: -```bash -curl -X POST https://api.mbtquniverse.com/auth/register \ - -H "Content-Type: application/json" \ - -d '{"email": "user@example.com", "password": "secure_password"}' -``` - -2. Login to get tokens: -```bash -curl -X POST https://api.mbtquniverse.com/auth/login \ - -H "Content-Type: application/json" \ - -d '{"email": "user@example.com", "password": "secure_password"}' -``` - -3. Use the access token for API calls: -```bash -curl -X GET https://api.mbtquniverse.com/sync/status \ - -H "Authorization: Bearer " -``` - -## ๐Ÿ“ฆ API Endpoints Overview - -**Note:** The endpoints below show full paths including the service prefix (e.g., `/auth/`, `/sync/`). In the OpenAPI specifications, these are defined as relative paths (e.g., `/register`, `/status`) with the base URL specified in the `servers` section. - -### DeafAUTH Endpoints - -- `POST /auth/register` - User registration -- `POST /auth/login` - User authentication -- `GET /auth/verify` - Token verification -- `POST /auth/refresh` - Token refresh - -### PinkSync Endpoints - -- `GET /sync/status` - Check synchronization status -- `POST /sync/preferences` - Update accessibility preferences -- `GET /sync/features` - List available accessibility features - -### Fibonrose Endpoints - -- `POST /blockchain/verify` - Verify blockchain transaction -- `GET /blockchain/trust-score` - Get trust score -- `POST /blockchain/record` - Record new transaction - -### 360Magicians Endpoints - -Comprehensive AI agent platform with 60+ endpoints including: - -- Agent management (CRUD operations) -- Task execution and workflow orchestration -- Memory and context management -- File ingestion and RAG search -- Tool registration and management -- Scheduling and webhooks -- Analytics and cost tracking - -See [360Magicians README](services/magicians/README.md) for complete endpoint list. - -### DAO Endpoints - -- `GET /dao/proposals` - List governance proposals -- `POST /dao/vote` - Submit vote -- `GET /dao/members` - List DAO members - -## ๐Ÿ”ง Environment Configuration - -Copy `.env.example` to `.env` and configure your environment variables: - -```bash -cp .env.example .env -``` - -See [.env.example](.env.example) for all required configuration options. - -## ๐ŸŒ Integration Notes - -### Google API & AI SDKs - -**Google Cloud Integration:** - -- Google Cloud Vision API for visual accessibility features -- Google Speech-to-Text for real-time captioning -- Google Translate API for multi-language support -- PinkSync API acts as an API broker network for partners' APIs that enhance deaf accessibility - -**AI SDK Integration:** - -The platform uses multiple AI models for comprehensive coverage: - -- **OpenAI**: GPT-4, GPT-4 Turbo for natural language processing -- **Anthropic**: Claude 3 for advanced reasoning -- **Google**: Gemini Pro for multimodal tasks -- **TensorFlow.js**: Client-side AI processing -- **Hugging Face Transformers**: Specialized accessibility models - -## ๐Ÿ”„ Integration with Other Repositories - -This platform integrates with several related repositories: - -- [pinkycollie/pinksync](https://github.com/pinkycollie/pinksync) - Fastify-based accessibility engine -- [pinkycollie/deafauth-ecosystem](https://github.com/pinkycollie/deafauth-ecosystem) - Authentication ecosystem -- [pinkycollie/fibonrose](https://github.com/pinkycollie/fibonrose) - Blockchain trust layer -- [pinkycollie/pinkflow](https://github.com/pinkycollie/pinkflow) - Hub pipeline integrator - -## ๐Ÿงช Testing & Validation - -### Automated API Testing - -Run comprehensive API tests for all services: - -```bash -# Install dependencies -npm install - -# Run all tests -npm test - -# Run tests with coverage -npm run test:coverage - -# Run specific service tests -npm test -- tests/deafauth -npm test -- tests/pinksync -npm test -- tests/magicians -``` - -See [tests/README.md](tests/README.md) for detailed testing documentation. - -### OpenAPI Validation - -Validate all OpenAPI specifications: - -```bash -# Validate specs -npm run validate:openapi -``` - -All specifications are validated and ready for: - -- Documentation generation -- SDK generation (TypeScript, Python, Go, etc.) -- API gateway configuration -- Testing and mocking - -### SDK Generation - -Generate client SDKs from OpenAPI specifications: - -```bash -# Generate TypeScript SDK -npm run generate:sdk:typescript - -# Generate Python SDK -npm run generate:sdk:python - -# Generate all SDKs -npm run generate:sdk -``` - -Generated SDKs will be in the `sdks/` directory. See [SDK.md](SDK.md) for detailed documentation and usage examples. - -## ๐Ÿ“š Middleware Examples - -### DeafAUTH Middleware (Node.js/Express) - -```javascript -const deafAuthMiddleware = async (req, res, next) => { - const token = req.headers.authorization?.split(' ')[1]; - - if (!token) { - return res.status(401).json({ error: 'No token provided' }); - } - - try { - const decoded = await verifyDeafAuthToken(token); - req.user = decoded; - next(); - } catch (error) { - return res.status(403).json({ error: 'Invalid token' }); - } -}; - -module.exports = deafAuthMiddleware; -``` - -### PinkSync Middleware (Node.js/Express) - -```javascript -const pinkSyncMiddleware = async (req, res, next) => { - const userId = req.user?.id; - - if (userId) { - const preferences = await getPinkSyncPreferences(userId); - req.accessibilityPrefs = preferences; - } - - next(); -}; - -module.exports = pinkSyncMiddleware; -``` - -## ๐ŸŽฏ Quick Start for Developers - -### 1. Clone and Install - -```bash -# Clone the repository -git clone https://github.com/pinkycollie/DEAF-FIRST-PLATFORM.git -cd DEAF-FIRST-PLATFORM - -# Install dependencies -npm install -``` - -### 2. Validate OpenAPI Specifications - -```bash -npm run validate:openapi -``` - -### 3. Run Tests - -```bash -# Run all tests -npm test - -# Run with coverage -npm run test:coverage -``` - -### 4. Generate SDKs - -```bash -# Generate TypeScript SDK -npm run generate:sdk:typescript - -# Generate Python SDK -npm run generate:sdk:python -``` - -### 5. Use Generated SDKs - -See [SDK.md](SDK.md) for usage examples with TypeScript and Python. - -## ๐ŸŽฏ Next Steps - -### Generate Documentation - -Generate interactive API documentation: - -```bash -# TypeScript SDK -openapi-generator-cli generate \ - -i services/deafauth/openapi/openapi.yaml \ - -g typescript-axios \ - -o sdks/typescript/deafauth - -# Python SDK -openapi-generator-cli generate \ - -i services/deafauth/openapi/openapi.yaml \ - -g python \ - -o sdks/python/deafauth -``` - -### Option 2: Deploy with Cloudflare Workers - -Each service can be deployed as a Cloudflare Worker for edge computing benefits. - -### Option 3: Generate API Documentation - -Use Redoc, Swagger UI, or other documentation tools to generate interactive API documentation. - -### Option 4: Set Up CI/CD - -Implement automated testing, validation, and deployment for all services. - -## ๐Ÿ“– Additional Documentation - -- [Complete Infrastructure Overview](infrastructure.md) -- Individual service README files in each service directory -- OpenAPI specifications in `services/*/openapi/openapi.yaml` - -## ๐Ÿค Contributing - -Contributions are welcome! Please ensure all changes maintain accessibility standards and deaf-first principles. - -## ๐Ÿ“„ License - -See LICENSE file for details. - -## ๐ŸŒŸ Acknowledgments - -Built with deaf-first principles and a commitment to accessibility for all. ->>>>>>> e961430 +======= +# MBTQ Deaf-First Platform + +A comprehensive platform built with deaf-first principles, providing accessible financial services, AI-powered assistance, and decentralized governance. + +## ๐Ÿ“š MBTQ Universe Components + +This repository contains OpenAPI specifications for all five core services of the MBTQ Universe: + +### 1. **DeafAUTH - Identity Cortex** +Secure authentication system designed with deaf-first principles. + +- **Location**: `services/deafauth/` +- **Base URL**: `https://api.mbtquniverse.com/auth` +- **Documentation**: [DeafAUTH README](services/deafauth/README.md) +- **OpenAPI Spec**: [openapi.yaml](services/deafauth/openapi/openapi.yaml) + +### 2. **PinkSync - Accessibility Engine** +Real-time accessibility features and synchronization. + +- **Location**: `services/pinksync/` +- **Base URL**: `https://api.mbtquniverse.com/sync` +- **Documentation**: [PinkSync README](services/pinksync/README.md) +- **OpenAPI Spec**: [openapi.yaml](services/pinksync/openapi/openapi.yaml) + +### 3. **Fibonrose - Trust & Blockchain** +Decentralized trust and verification layer. + +- **Location**: `services/fibonrose/` +- **Base URL**: `https://api.mbtquniverse.com/blockchain` +- **Documentation**: [Fibonrose README](services/fibonrose/README.md) +- **OpenAPI Spec**: [openapi.yaml](services/fibonrose/openapi/openapi.yaml) + +### 4. **360Magicians - AI Agents** +Intelligent automation and assistance agents. + +- **Location**: `services/magicians/` +- **Base URL**: `https://api.mbtquniverse.com/ai` +- **Documentation**: [360Magicians README](services/magicians/README.md) +- **OpenAPI Spec**: [openapi.yaml](services/magicians/openapi/openapi.yaml) + +### 5. **MBTQ DAO - Governance** +Decentralized governance and community management. + +- **Location**: `services/dao/` +- **Base URL**: `https://api.mbtquniverse.com/dao` +- **Documentation**: [DAO README](services/dao/README.md) +- **OpenAPI Spec**: [openapi.yaml](services/dao/openapi/openapi.yaml) + +## ๐Ÿš€ Features + +โœ” All endpoints documented with OpenAPI 3.1 +โœ” Standardized responses across all services +โœ” Shared DeafAUTH security scheme +โœ” Tags, components, pagination, error schemas +โœ” Cloudflare-friendly JSON-only style +โœ” **Automated API testing with Jest** +โœ” **SDK generation (TypeScript + Python)** +โœ” Production-ready specifications + +## ๐Ÿ” Authentication + +All MBTQ Universe services use DeafAUTH for authentication. Include the Bearer token in the Authorization header: + +```bash +Authorization: Bearer +``` + +### Getting Started with Authentication + +1. Register a new user: +```bash +curl -X POST https://api.mbtquniverse.com/auth/register \ + -H "Content-Type: application/json" \ + -d '{"email": "user@example.com", "password": "secure_password"}' +``` + +2. Login to get tokens: +```bash +curl -X POST https://api.mbtquniverse.com/auth/login \ + -H "Content-Type: application/json" \ + -d '{"email": "user@example.com", "password": "secure_password"}' +``` + +3. Use the access token for API calls: +```bash +curl -X GET https://api.mbtquniverse.com/sync/status \ + -H "Authorization: Bearer " +``` + +## ๐Ÿ“ฆ API Endpoints Overview + +**Note:** The endpoints below show full paths including the service prefix (e.g., `/auth/`, `/sync/`). In the OpenAPI specifications, these are defined as relative paths (e.g., `/register`, `/status`) with the base URL specified in the `servers` section. + +### DeafAUTH Endpoints + +- `POST /auth/register` - User registration +- `POST /auth/login` - User authentication +- `GET /auth/verify` - Token verification +- `POST /auth/refresh` - Token refresh + +### PinkSync Endpoints + +- `GET /sync/status` - Check synchronization status +- `POST /sync/preferences` - Update accessibility preferences +- `GET /sync/features` - List available accessibility features + +### Fibonrose Endpoints + +- `POST /blockchain/verify` - Verify blockchain transaction +- `GET /blockchain/trust-score` - Get trust score +- `POST /blockchain/record` - Record new transaction + +### 360Magicians Endpoints + +Comprehensive AI agent platform with 60+ endpoints including: + +- Agent management (CRUD operations) +- Task execution and workflow orchestration +- Memory and context management +- File ingestion and RAG search +- Tool registration and management +- Scheduling and webhooks +- Analytics and cost tracking + +See [360Magicians README](services/magicians/README.md) for complete endpoint list. + +### DAO Endpoints + +- `GET /dao/proposals` - List governance proposals +- `POST /dao/vote` - Submit vote +- `GET /dao/members` - List DAO members + +## ๐Ÿ”ง Environment Configuration + +Copy `.env.example` to `.env` and configure your environment variables: + +```bash +cp .env.example .env +``` + +See [.env.example](.env.example) for all required configuration options. + +## ๐ŸŒ Integration Notes + +### Google API & AI SDKs + +**Google Cloud Integration:** + +- Google Cloud Vision API for visual accessibility features +- Google Speech-to-Text for real-time captioning +- Google Translate API for multi-language support +- PinkSync API acts as an API broker network for partners' APIs that enhance deaf accessibility + +**AI SDK Integration:** + +The platform uses multiple AI models for comprehensive coverage: + +- **OpenAI**: GPT-4, GPT-4 Turbo for natural language processing +- **Anthropic**: Claude 3 for advanced reasoning +- **Google**: Gemini Pro for multimodal tasks +- **TensorFlow.js**: Client-side AI processing +- **Hugging Face Transformers**: Specialized accessibility models + +## ๐Ÿ”„ Integration with Other Repositories + +This platform integrates with several related repositories: + +- [pinkycollie/pinksync](https://github.com/pinkycollie/pinksync) - Fastify-based accessibility engine +- [pinkycollie/deafauth-ecosystem](https://github.com/pinkycollie/deafauth-ecosystem) - Authentication ecosystem +- [pinkycollie/fibonrose](https://github.com/pinkycollie/fibonrose) - Blockchain trust layer +- [pinkycollie/pinkflow](https://github.com/pinkycollie/pinkflow) - Hub pipeline integrator + +## ๐Ÿงช Testing & Validation + +### Automated API Testing + +Run comprehensive API tests for all services: + +```bash +# Install dependencies +npm install + +# Run all tests +npm test + +# Run tests with coverage +npm run test:coverage + +# Run specific service tests +npm test -- tests/deafauth +npm test -- tests/pinksync +npm test -- tests/magicians +``` + +See [tests/README.md](tests/README.md) for detailed testing documentation. + +### OpenAPI Validation + +Validate all OpenAPI specifications: + +```bash +# Validate specs +npm run validate:openapi +``` + +All specifications are validated and ready for: + +- Documentation generation +- SDK generation (TypeScript, Python, Go, etc.) +- API gateway configuration +- Testing and mocking + +### SDK Generation + +Generate client SDKs from OpenAPI specifications: + +```bash +# Generate TypeScript SDK +npm run generate:sdk:typescript + +# Generate Python SDK +npm run generate:sdk:python + +# Generate all SDKs +npm run generate:sdk +``` + +Generated SDKs will be in the `sdks/` directory. See [SDK.md](SDK.md) for detailed documentation and usage examples. + +## ๐Ÿ“š Middleware Examples + +### DeafAUTH Middleware (Node.js/Express) + +```javascript +const deafAuthMiddleware = async (req, res, next) => { + const token = req.headers.authorization?.split(' ')[1]; + + if (!token) { + return res.status(401).json({ error: 'No token provided' }); + } + + try { + const decoded = await verifyDeafAuthToken(token); + req.user = decoded; + next(); + } catch (error) { + return res.status(403).json({ error: 'Invalid token' }); + } +}; + +module.exports = deafAuthMiddleware; +``` + +### PinkSync Middleware (Node.js/Express) + +```javascript +const pinkSyncMiddleware = async (req, res, next) => { + const userId = req.user?.id; + + if (userId) { + const preferences = await getPinkSyncPreferences(userId); + req.accessibilityPrefs = preferences; + } + + next(); +}; + +module.exports = pinkSyncMiddleware; +``` + +## ๐ŸŽฏ Quick Start for Developers + +### 1. Clone and Install + +```bash +# Clone the repository +git clone https://github.com/pinkycollie/DEAF-FIRST-PLATFORM.git +cd DEAF-FIRST-PLATFORM + +# Install dependencies +npm install +``` + +### 2. Validate OpenAPI Specifications + +```bash +npm run validate:openapi +``` + +### 3. Run Tests + +```bash +# Run all tests +npm test + +# Run with coverage +npm run test:coverage +``` + +### 4. Generate SDKs + +```bash +# Generate TypeScript SDK +npm run generate:sdk:typescript + +# Generate Python SDK +npm run generate:sdk:python +``` + +### 5. Use Generated SDKs + +See [SDK.md](SDK.md) for usage examples with TypeScript and Python. + +## ๐ŸŽฏ Next Steps + +### Generate Documentation + +Generate interactive API documentation: + +```bash +# TypeScript SDK +openapi-generator-cli generate \ + -i services/deafauth/openapi/openapi.yaml \ + -g typescript-axios \ + -o sdks/typescript/deafauth + +# Python SDK +openapi-generator-cli generate \ + -i services/deafauth/openapi/openapi.yaml \ + -g python \ + -o sdks/python/deafauth +``` + +### Option 2: Deploy with Cloudflare Workers + +Each service can be deployed as a Cloudflare Worker for edge computing benefits. + +### Option 3: Generate API Documentation + +Use Redoc, Swagger UI, or other documentation tools to generate interactive API documentation. + +### Option 4: Set Up CI/CD + +Implement automated testing, validation, and deployment for all services. + +## ๐Ÿ“– Additional Documentation + +- [Complete Infrastructure Overview](infrastructure.md) +- Individual service README files in each service directory +- OpenAPI specifications in `services/*/openapi/openapi.yaml` + +## ๐Ÿค Contributing + +Contributions are welcome! Please ensure all changes maintain accessibility standards and deaf-first principles. + +## ๐Ÿ“„ License + +See LICENSE file for details. + +## ๐ŸŒŸ Acknowledgments + +Built with deaf-first principles and a commitment to accessibility for all. +>>>>>>> e961430 diff --git a/backend/package.json b/backend/package.json index 8344842..23480b5 100644 --- a/backend/package.json +++ b/backend/package.json @@ -37,6 +37,6 @@ "eslint": "^9.15.0", "tsx": "^4.19.2", "typescript": "^5.7.2", - "vitest": "^2.1.5" + "vitest": "^4.1.6" } } diff --git a/cloudbuild.yaml b/cloudbuild.yaml index 35a118f..42e2438 100644 --- a/cloudbuild.yaml +++ b/cloudbuild.yaml @@ -3,13 +3,13 @@ steps: # Install dependencies - - name: 'node:20' + - name: 'node:24' id: 'install-dependencies' entrypoint: 'npm' args: ['ci'] # Run tests - - name: 'node:20' + - name: 'node:24' id: 'test' entrypoint: 'npm' args: ['run', 'test'] @@ -18,7 +18,7 @@ steps: waitFor: ['install-dependencies'] # Build all services - - name: 'node:20' + - name: 'node:24' id: 'build' entrypoint: 'npm' args: ['run', 'build'] diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a9564e1..0416bc2 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -8,7 +8,7 @@ The MBTQ Deaf-First Platform is a comprehensive microservices architecture desig ``` โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” -โ”‚ MBTQ Universe Platform โ”‚ +โ”‚ MBTQ.dev Platform โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ @@ -74,7 +74,7 @@ The MBTQ Deaf-First Platform is a comprehensive microservices architecture desig ## Service Components ### 1. DeafAUTH (Identity Cortex) -**Base URL:** `https://api.mbtquniverse.com/auth` +**Base URL:** `https://api.mbtq.DEV/auth` DeafAUTH is the central authentication and identity management service designed with deaf-first principles. @@ -141,7 +141,7 @@ Fibonrose provides blockchain-based trust verification and transaction recording | POST | `/record` | Record new transaction | ### 4. 360Magicians (AI Agent Platform) -**Base URL:** `https://api.mbtquniverse.com/ai` +**Base URL:** `https://api.mbtq.dev/ai` The comprehensive AI agent platform with 62 endpoints covering agent lifecycle, execution, tools, memory, and workflows. @@ -153,7 +153,7 @@ The comprehensive AI agent platform with 62 endpoints covering agent lifecycle, - **Workflows:** DAG-based workflow orchestration ### 5. DAO (Governance) -**Base URL:** `https://api.mbtquniverse.com/dao` +**Base URL:** `https://api.mbtq.dev/dao` Decentralized governance for platform decisions. diff --git a/docs/FETCH-API-EXAMPLES.md b/docs/FETCH-API-EXAMPLES.md index e1cf95d..85afe70 100644 --- a/docs/FETCH-API-EXAMPLES.md +++ b/docs/FETCH-API-EXAMPLES.md @@ -1,6 +1,6 @@ # Fetch API Examples -This document provides browser-compatible Fetch API examples for all MBTQ Universe services. These examples work in modern browsers and can be used directly in web applications. +This document provides browser-compatible Fetch API examples for all DEAF-FIRST services. These examples work in modern browsers and can be used directly in web applications. ## Table of Contents @@ -19,7 +19,7 @@ This document provides browser-compatible Fetch API examples for all MBTQ Univer ```javascript async function registerUser(email, password) { - const response = await fetch('https://api.mbtquniverse.com/auth/register', { + const response = await fetch('https://api.mbtq.DEV/auth/register', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -51,7 +51,7 @@ try { ```javascript async function loginUser(email, password) { - const response = await fetch('https://api.mbtquniverse.com/auth/login', { + const response = await fetch('https://api.mbtq.dev/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -91,7 +91,7 @@ try { async function verifyToken() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/auth/verify', { + const response = await fetch('https://api.mbtq.dev/auth/verify', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -120,7 +120,7 @@ if (verification.valid) { async function refreshTokens() { const refreshToken = localStorage.getItem('refreshToken'); - const response = await fetch('https://api.mbtquniverse.com/auth/refresh', { + const response = await fetch('https://api.mbtq.dev/auth/refresh', { method: 'POST', headers: { 'Content-Type': 'application/json' @@ -157,7 +157,7 @@ async function refreshTokens() { async function getSyncStatus() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/sync/status', { + const response = await fetch('https://api.mbtq.dev/sync/status', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -183,7 +183,7 @@ console.log('Latency:', status.latencyMs, 'ms'); async function updatePreferences(preferences) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/sync/preferences', { + const response = await fetch('https://api.mbtq.dev/sync/preferences', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -215,7 +215,7 @@ console.log('Preferences updated:', prefs); async function getFeatures() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/sync/features', { + const response = await fetch('https://api.mbtq.dev/sync/features', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -246,7 +246,7 @@ features.forEach(feature => { async function verifyTransaction(txId) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/blockchain/verify', { + const response = await fetch('https://api.mbtq.dev/blockchain/verify', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -273,7 +273,7 @@ console.log('Transaction valid:', verification.valid); async function getTrustScore() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/blockchain/trust-score', { + const response = await fetch('https://api.mbtq.dev/blockchain/trust-score', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -298,8 +298,8 @@ console.log('Last Updated:', score.lastUpdated); ```javascript async function recordTransaction(transaction) { const accessToken = localStorage.getItem('accessToken'); - - const response = await fetch('https://api.mbtquniverse.com/blockchain/record', { + + const response = await fetch('https://api.mbtq.dev/blockchain/record', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -337,7 +337,7 @@ console.log('Transaction recorded:', tx); async function createAgent(name, model) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/ai/agents', { + const response = await fetch('https://api.mbtq.dev/ai/agents', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -364,7 +364,7 @@ console.log('Agent created:', agent.id); async function listAgents() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/ai/agents', { + const response = await fetch('https://api.mbtq.dev/ai/agents', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -391,7 +391,7 @@ agents.forEach(agent => { async function executeAgent(agentId, input) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch(`https://api.mbtquniverse.com/ai/agents/${agentId}/execute`, { + const response = await fetch(`https://api.mbtq.dev/ai/agents/${agentId}/execute`, { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -420,7 +420,7 @@ console.log('Output:', run.output); async function getRunStatus(runId) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch(`https://api.mbtquniverse.com/ai/runs/${runId}`, { + const response = await fetch(`https://api.mbtq.dev/ai/runs/${runId}`, { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -461,7 +461,7 @@ async function waitForCompletion(runId, maxAttempts = 30) { async function listTools() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/ai/tools', { + const response = await fetch('https://api.mbtq.dev/ai/tools', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -492,7 +492,7 @@ tools.forEach(tool => { async function listProposals() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/dao/proposals', { + const response = await fetch('https://api.mbtq.dev/dao/proposals', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -520,7 +520,7 @@ proposals.forEach(proposal => { async function submitVote(proposalId, vote) { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/dao/vote', { + const response = await fetch('https://api.mbtq.dev/dao/vote', { method: 'POST', headers: { 'Authorization': `Bearer ${accessToken}`, @@ -548,7 +548,7 @@ console.log('Vote submitted successfully'); async function listMembers() { const accessToken = localStorage.getItem('accessToken'); - const response = await fetch('https://api.mbtquniverse.com/dao/members', { + const response = await fetch('https://api.mbtq.dev/dao/members', { method: 'GET', headers: { 'Authorization': `Bearer ${accessToken}` @@ -579,7 +579,7 @@ Here's a complete example of an MBTQ API client using the Fetch API: * Complete browser-compatible client using Fetch API */ class MBTQClient { - constructor(baseUrl = 'https://api.mbtquniverse.com') { + constructor(baseUrl = 'https://api.mbtq.dev') { this.baseUrl = baseUrl; this.accessToken = localStorage.getItem('accessToken'); this.refreshToken = localStorage.getItem('refreshToken'); diff --git a/docs/html/index.html b/docs/html/index.html index 64e73c5..2bcad9a 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -3,7 +3,7 @@ - Deaf-First Project - API Documentation + Deaf-First Platform - API Documentation diff --git a/envs/dev b/envs/dev new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/envs/dev @@ -0,0 +1 @@ + diff --git a/envs/prod b/envs/prod new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/envs/prod @@ -0,0 +1 @@ + diff --git a/envs/staging b/envs/staging new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/envs/staging @@ -0,0 +1 @@ + diff --git a/infrastructure.md b/infrastructure.md index af27616..e42ee5d 100644 --- a/infrastructure.md +++ b/infrastructure.md @@ -1,7 +1,7 @@ # MBTQ.dv: Complete GitHub Repository Structure ``` -mbtq-deaf-first-platform/ +deaf-first-platform/ โ”œโ”€โ”€ README.md โ”œโ”€โ”€ LICENSE โ”œโ”€โ”€ .gitignore diff --git a/package.json b/package.json index ac15ad4..b15465c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,3 @@ -<<<<<<< HEAD -{ "name": "deaf-first", "version": "2.0.0", "private": true, @@ -76,40 +74,40 @@ "mcp-server" ] } -======= -{ - "name": "mbtq-deaf-first-platform", - "version": "1.0.0", - "description": "MBTQ Universe deaf-first platform with OpenAPI specifications", - "main": "index.js", - "scripts": { - "test": "jest", - "test:watch": "jest --watch", - "test:coverage": "jest --coverage", - "validate:openapi": "node scripts/validate-openapi.js", - "generate:sdk": "npm run generate:sdk:typescript && npm run generate:sdk:python", - "generate:sdk:typescript": "node scripts/generate-sdk.js typescript", - "generate:sdk:python": "node scripts/generate-sdk.js python", - "lint": "eslint .", - "format": "prettier --write ." - }, - "keywords": [ - "deaf-first", - "accessibility", - "openapi", - "api", - "mbtq" - ], - "author": "MBTQ Universe", - "license": "MIT", - "devDependencies": { - "@apidevtools/swagger-parser": "^10.1.0", - "@openapitools/openapi-generator-cli": "^2.13.4", - "axios": "^1.6.0", - "eslint": "^8.57.0", - "jest": "^29.7.0", - "prettier": "^3.2.5", - "yaml": "^2.3.4" - } -} ->>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities +======= +{ + "name": "mbtq-deaf-first-platform", + "version": "1.0.0", + "description": "MBTQ Universe deaf-first platform with OpenAPI specifications", + "main": "index.js", + "scripts": { + "test": "jest", + "test:watch": "jest --watch", + "test:coverage": "jest --coverage", + "validate:openapi": "node scripts/validate-openapi.js", + "generate:sdk": "npm run generate:sdk:typescript && npm run generate:sdk:python", + "generate:sdk:typescript": "node scripts/generate-sdk.js typescript", + "generate:sdk:python": "node scripts/generate-sdk.js python", + "lint": "eslint .", + "format": "prettier --write ." + }, + "keywords": [ + "deaf-first", + "accessibility", + "openapi", + "api", + "mbtq" + ], + "author": "MBTQ Universe", + "license": "MIT", + "devDependencies": { + "@apidevtools/swagger-parser": "^10.1.0", + "@openapitools/openapi-generator-cli": "^2.13.4", + "axios": "^1.6.0", + "eslint": "^8.57.0", + "jest": "^29.7.0", + "prettier": "^3.2.5", + "yaml": "^2.3.4" + } +} +>>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities diff --git a/scripts/generate-sdk.js b/scripts/generate-sdk.js index 30b7db3..e1e6ba7 100644 --- a/scripts/generate-sdk.js +++ b/scripts/generate-sdk.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD /** * SDK Generator Script * Generates TypeScript and Python SDKs from OpenAPI specifications @@ -129,135 +128,135 @@ console.log('\n๐Ÿš€ MBTQ Universe SDK Generator\n'); ensureDirectoryExists(SDK_OUTPUT_DIR); generateAllSDKs(language); -======= -/** - * SDK Generator Script - * Generates TypeScript and Python SDKs from OpenAPI specifications - */ - -const fs = require('fs'); -const path = require('path'); -const { execSync } = require('child_process'); - -const SERVICES_DIR = path.join(__dirname, '..', 'services'); -const SDK_OUTPUT_DIR = path.join(__dirname, '..', 'sdks'); - -const SDK_CONFIGS = { - typescript: { - generator: 'typescript-axios', - outputDir: 'typescript', - additionalProps: { - npmName: '@mbtq/sdk', - npmVersion: '1.0.0', - supportsES6: true, - withSeparateModelsAndApi: true - } - }, - python: { - generator: 'python', - outputDir: 'python', - additionalProps: { - packageName: 'mbtq_sdk', - projectName: 'mbtq-sdk', - packageVersion: '1.0.0' - } - } -}; - -function ensureDirectoryExists(dir) { - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, { recursive: true }); - } -} - -function generateSDK(service, specPath, language) { - const config = SDK_CONFIGS[language]; - const outputDir = path.join(SDK_OUTPUT_DIR, config.outputDir, service); - - console.log(`\n๐Ÿ“ฆ Generating ${language} SDK for ${service}...`); - - ensureDirectoryExists(outputDir); - - // Build additional properties string - const additionalProps = Object.entries(config.additionalProps) - .map(([key, value]) => `${key}=${value}`) - .join(','); - - try { - // Use openapi-generator-cli - const command = [ - 'npx', - '@openapitools/openapi-generator-cli', - 'generate', - `-i ${specPath}`, - `-g ${config.generator}`, - `-o ${outputDir}`, - `--additional-properties=${additionalProps}`, - '--skip-validate-spec' // We already validated - ].join(' '); - - execSync(command, { stdio: 'inherit' }); - - console.log(` โœ… ${language} SDK generated successfully`); - console.log(` ๐Ÿ“ Output: ${outputDir}`); - - return true; - } catch (error) { - console.error(` โŒ Failed to generate ${language} SDK: ${error.message}`); - return false; - } -} - -function generateAllSDKs(language) { - console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - console.log(` Generating ${language.toUpperCase()} SDKs`); - console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - - const services = fs.readdirSync(SERVICES_DIR) - .filter(name => { - const servicePath = path.join(SERVICES_DIR, name); - return fs.statSync(servicePath).isDirectory(); - }); - - let successCount = 0; - - for (const service of services) { - const specPath = path.join(SERVICES_DIR, service, 'openapi', 'openapi.yaml'); - - if (fs.existsSync(specPath)) { - const success = generateSDK(service, specPath, language); - if (success) successCount++; - } else { - console.log(`\nโš ๏ธ ${service}: No OpenAPI spec found`); - } - } - - console.log('\nโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - console.log(`\n๐Ÿ“Š Summary:`); - console.log(` Services processed: ${services.length}`); - console.log(` SDKs generated: ${successCount}`); - - if (successCount === services.length) { - console.log(`\nโœ… All ${language} SDKs generated successfully!`); - console.log(`๐Ÿ“ Output directory: ${path.join(SDK_OUTPUT_DIR, SDK_CONFIGS[language].outputDir)}`); - } else { - console.log(`\nโš ๏ธ Some SDKs failed to generate`); - } -} - -// Main execution -const language = process.argv[2]; - -if (!language || !SDK_CONFIGS[language]) { - console.error('Usage: node generate-sdk.js [typescript|python]'); - console.error('Available languages:', Object.keys(SDK_CONFIGS).join(', ')); - process.exit(1); -} - -console.log('\n๐Ÿš€ MBTQ Universe SDK Generator\n'); - -// Ensure SDK output directory exists -ensureDirectoryExists(SDK_OUTPUT_DIR); - -generateAllSDKs(language); ->>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities +======= +/** + * SDK Generator Script + * Generates TypeScript and Python SDKs from OpenAPI specifications + */ + +const fs = require('fs'); +const path = require('path'); +const { execSync } = require('child_process'); + +const SERVICES_DIR = path.join(__dirname, '..', 'services'); +const SDK_OUTPUT_DIR = path.join(__dirname, '..', 'sdks'); + +const SDK_CONFIGS = { + typescript: { + generator: 'typescript-axios', + outputDir: 'typescript', + additionalProps: { + npmName: '@mbtq/sdk', + npmVersion: '1.0.0', + supportsES6: true, + withSeparateModelsAndApi: true + } + }, + python: { + generator: 'python', + outputDir: 'python', + additionalProps: { + packageName: 'mbtq_sdk', + projectName: 'mbtq-sdk', + packageVersion: '1.0.0' + } + } +}; + +function ensureDirectoryExists(dir) { + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } +} + +function generateSDK(service, specPath, language) { + const config = SDK_CONFIGS[language]; + const outputDir = path.join(SDK_OUTPUT_DIR, config.outputDir, service); + + console.log(`\n๐Ÿ“ฆ Generating ${language} SDK for ${service}...`); + + ensureDirectoryExists(outputDir); + + // Build additional properties string + const additionalProps = Object.entries(config.additionalProps) + .map(([key, value]) => `${key}=${value}`) + .join(','); + + try { + // Use openapi-generator-cli + const command = [ + 'npx', + '@openapitools/openapi-generator-cli', + 'generate', + `-i ${specPath}`, + `-g ${config.generator}`, + `-o ${outputDir}`, + `--additional-properties=${additionalProps}`, + '--skip-validate-spec' // We already validated + ].join(' '); + + execSync(command, { stdio: 'inherit' }); + + console.log(` โœ… ${language} SDK generated successfully`); + console.log(` ๐Ÿ“ Output: ${outputDir}`); + + return true; + } catch (error) { + console.error(` โŒ Failed to generate ${language} SDK: ${error.message}`); + return false; + } +} + +function generateAllSDKs(language) { + console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + console.log(` Generating ${language.toUpperCase()} SDKs`); + console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + + const services = fs.readdirSync(SERVICES_DIR) + .filter(name => { + const servicePath = path.join(SERVICES_DIR, name); + return fs.statSync(servicePath).isDirectory(); + }); + + let successCount = 0; + + for (const service of services) { + const specPath = path.join(SERVICES_DIR, service, 'openapi', 'openapi.yaml'); + + if (fs.existsSync(specPath)) { + const success = generateSDK(service, specPath, language); + if (success) successCount++; + } else { + console.log(`\nโš ๏ธ ${service}: No OpenAPI spec found`); + } + } + + console.log('\nโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + console.log(`\n๐Ÿ“Š Summary:`); + console.log(` Services processed: ${services.length}`); + console.log(` SDKs generated: ${successCount}`); + + if (successCount === services.length) { + console.log(`\nโœ… All ${language} SDKs generated successfully!`); + console.log(`๐Ÿ“ Output directory: ${path.join(SDK_OUTPUT_DIR, SDK_CONFIGS[language].outputDir)}`); + } else { + console.log(`\nโš ๏ธ Some SDKs failed to generate`); + } +} + +// Main execution +const language = process.argv[2]; + +if (!language || !SDK_CONFIGS[language]) { + console.error('Usage: node generate-sdk.js [typescript|python]'); + console.error('Available languages:', Object.keys(SDK_CONFIGS).join(', ')); + process.exit(1); +} + +console.log('\n๐Ÿš€ MBTQ Universe SDK Generator\n'); + +// Ensure SDK output directory exists +ensureDirectoryExists(SDK_OUTPUT_DIR); + +generateAllSDKs(language); +>>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities diff --git a/scripts/infra.sh b/scripts/infra.sh new file mode 100644 index 0000000..f9d6c76 --- /dev/null +++ b/scripts/infra.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# Infrastructure Readiness Check Script + +echo "๐Ÿ” Starting Infrastructure Readiness Check..." + +# 1. Verify service directories and package.json +SERVICES=("deafauth" "pinksync" "fibonrose") +for service in "${SERVICES[@]}"; do + if [ -f "services/$service/package.json" ]; then + echo "โœ… $service service configured" + else + echo "โŒ $service service NOT configured (missing services/$service/package.json)" + exit 1 + fi +done + +# 2. Verify Terraform files +TF_FILES=("main.tf" "variables.tf" "outputs.tf" "networking.tf" "deafauth.tf" "pinksync.tf" "fibonrose.tf" "monitoring.tf" "cicd.tf" "billing.tf") +for tf_file in "${TF_FILES[@]}"; do + if [ -f "terraform/$tf_file" ]; then + echo "โœ… Terraform file $tf_file present" + else + echo "โŒ Terraform file $tf_file MISSING" + exit 1 + fi +done + +# 3. Verify environment files +ENV_FILES=("dev.tfvars" "staging.tfvars" "production.tfvars") +for env_file in "${ENV_FILES[@]}"; do + if [ -f "environments/$env_file" ]; then + echo "โœ… Environment file $env_file present" + else + echo "โŒ Environment file $env_file MISSING" + exit 1 + fi +done + +echo "โœ… ALL INFRASTRUCTURE CHECKS PASSED" +exit 0 diff --git a/scripts/validate-openapi.js b/scripts/validate-openapi.js index 1706581..951f7e6 100644 --- a/scripts/validate-openapi.js +++ b/scripts/validate-openapi.js @@ -1,4 +1,3 @@ -<<<<<<< HEAD /** * OpenAPI Specification Validator * Validates all OpenAPI specs in the services directory @@ -92,98 +91,98 @@ validateAllSpecs().catch(error => { console.error('Fatal error:', error); process.exit(1); }); -======= -/** - * OpenAPI Specification Validator - * Validates all OpenAPI specs in the services directory - */ - -const fs = require('fs'); -const path = require('path'); -const yaml = require('yaml'); -const SwaggerParser = require('@apidevtools/swagger-parser'); - -const SERVICES_DIR = path.join(__dirname, '..', 'services'); - -async function validateOpenAPISpec(serviceName, specPath) { - try { - console.log(`\n๐Ÿ“‹ Validating ${serviceName}...`); - - // Parse and validate the spec - const api = await SwaggerParser.validate(specPath); - - // Count endpoints - const pathCount = Object.keys(api.paths || {}).length; - let endpointCount = 0; - - for (const path in api.paths) { - const methods = api.paths[path]; - endpointCount += Object.keys(methods).filter(m => - ['get', 'post', 'put', 'patch', 'delete'].includes(m) - ).length; - } - - console.log(` โœ… Valid OpenAPI ${api.openapi} specification`); - console.log(` ๐Ÿ“Š ${pathCount} paths, ${endpointCount} endpoints`); - console.log(` ๐Ÿ“ Title: ${api.info.title}`); - console.log(` ๐Ÿ”ข Version: ${api.info.version}`); - - return { valid: true, serviceName, pathCount, endpointCount }; - } catch (error) { - console.error(` โŒ Validation failed: ${error.message}`); - return { valid: false, serviceName, error: error.message }; - } -} - -async function validateAllSpecs() { - console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - console.log(' OpenAPI Specification Validation'); - console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - - const services = fs.readdirSync(SERVICES_DIR) - .filter(name => { - const servicePath = path.join(SERVICES_DIR, name); - return fs.statSync(servicePath).isDirectory(); - }); - - const results = []; - - for (const service of services) { - const specPath = path.join(SERVICES_DIR, service, 'openapi', 'openapi.yaml'); - - if (fs.existsSync(specPath)) { - const result = await validateOpenAPISpec(service, specPath); - results.push(result); - } else { - console.log(`\nโš ๏ธ ${service}: No OpenAPI spec found`); - results.push({ valid: false, serviceName: service, error: 'Spec file not found' }); - } - } - - // Summary - console.log('\nโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); - const validCount = results.filter(r => r.valid).length; - const totalEndpoints = results - .filter(r => r.valid) - .reduce((sum, r) => sum + r.endpointCount, 0); - - console.log(`\n๐Ÿ“Š Summary:`); - console.log(` Services validated: ${results.length}`); - console.log(` Valid specifications: ${validCount}`); - console.log(` Total endpoints: ${totalEndpoints}`); - - if (validCount === results.length) { - console.log('\nโœ… All OpenAPI specifications are valid!'); - process.exit(0); - } else { - console.log('\nโŒ Some specifications have errors'); - process.exit(1); - } -} - -// Run validation -validateAllSpecs().catch(error => { - console.error('Fatal error:', error); - process.exit(1); -}); ->>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities +======= +/** + * OpenAPI Specification Validator + * Validates all OpenAPI specs in the services directory + */ + +const fs = require('fs'); +const path = require('path'); +const yaml = require('yaml'); +const SwaggerParser = require('@apidevtools/swagger-parser'); + +const SERVICES_DIR = path.join(__dirname, '..', 'services'); + +async function validateOpenAPISpec(serviceName, specPath) { + try { + console.log(`\n๐Ÿ“‹ Validating ${serviceName}...`); + + // Parse and validate the spec + const api = await SwaggerParser.validate(specPath); + + // Count endpoints + const pathCount = Object.keys(api.paths || {}).length; + let endpointCount = 0; + + for (const path in api.paths) { + const methods = api.paths[path]; + endpointCount += Object.keys(methods).filter(m => + ['get', 'post', 'put', 'patch', 'delete'].includes(m) + ).length; + } + + console.log(` โœ… Valid OpenAPI ${api.openapi} specification`); + console.log(` ๐Ÿ“Š ${pathCount} paths, ${endpointCount} endpoints`); + console.log(` ๐Ÿ“ Title: ${api.info.title}`); + console.log(` ๐Ÿ”ข Version: ${api.info.version}`); + + return { valid: true, serviceName, pathCount, endpointCount }; + } catch (error) { + console.error(` โŒ Validation failed: ${error.message}`); + return { valid: false, serviceName, error: error.message }; + } +} + +async function validateAllSpecs() { + console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + console.log(' OpenAPI Specification Validation'); + console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + + const services = fs.readdirSync(SERVICES_DIR) + .filter(name => { + const servicePath = path.join(SERVICES_DIR, name); + return fs.statSync(servicePath).isDirectory(); + }); + + const results = []; + + for (const service of services) { + const specPath = path.join(SERVICES_DIR, service, 'openapi', 'openapi.yaml'); + + if (fs.existsSync(specPath)) { + const result = await validateOpenAPISpec(service, specPath); + results.push(result); + } else { + console.log(`\nโš ๏ธ ${service}: No OpenAPI spec found`); + results.push({ valid: false, serviceName: service, error: 'Spec file not found' }); + } + } + + // Summary + console.log('\nโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•'); + const validCount = results.filter(r => r.valid).length; + const totalEndpoints = results + .filter(r => r.valid) + .reduce((sum, r) => sum + r.endpointCount, 0); + + console.log(`\n๐Ÿ“Š Summary:`); + console.log(` Services validated: ${results.length}`); + console.log(` Valid specifications: ${validCount}`); + console.log(` Total endpoints: ${totalEndpoints}`); + + if (validCount === results.length) { + console.log('\nโœ… All OpenAPI specifications are valid!'); + process.exit(0); + } else { + console.log('\nโŒ Some specifications have errors'); + process.exit(1); + } +} + +// Run validation +validateAllSpecs().catch(error => { + console.error('Fatal error:', error); + process.exit(1); +}); +>>>>>>> e961430... Add Node.js API automated tests and SDK generation capabilities