π¦ Shared types and contracts for LocalStore Platform - TypeScript definitions, GraphQL schemas, and Protobuf specs shared across all repos. Published as @localstore/types npm package for contract-driven development.
This repository contains the shared type definitions and contracts used across all LocalStore Platform services. It serves as the single source of truth for API interfaces, data models, and communication protocols.
Platform: Multi-tenant SaaS for Vietnamese small businesses (restaurants, street vendors)
Primary Market: Vietnam (vi-VN locale, VND currency)
- [Features](# β¨ features)
- [Tech Stack](# π tech-stack)
- [Getting Started](# π getting-started)
- [Usage](# π¦ usage)
- [Development](# π§ development)
- [Contract Change Process](# π contract-change-process)
- [Specifications](# π specifications)
- [Contributing](# π€ contributing)
- [License](# π license)
- TypeScript Type Definitions: Strongly-typed interfaces for all API contracts
- GraphQL Schema: Shared GraphQL type definitions and schema files
- Protobuf Definitions: Protocol buffer messages for inter-service communication
- Vietnamese Localization: Built-in support for vi-VN locale and VND currency
- Multi-Tenant Support: Types designed for multi-tenant architecture
- Semantic Versioning: Strict semver with contract change process
- NPM Package: Published as
@localstore/typesfor easy consumption
- Language: TypeScript 5.x
- Schema Tools:
- GraphQL Code Generator
- Protobuf Compiler (protoc)
- Build Tools: TypeScript Compiler (tsc)
- Testing: Jest with TypeScript support
- Package Manager: npm
- Node.js 20.x or higher
- npm 10.x or higher
Install the package in your project:
npm install @localstore/typesimport { ProductDTO, CreateOrderRequest, OrderStatus } from '@localstore/types';
// Use strongly-typed contracts in your code
const product: ProductDTO = {
id: 'prod_123',
tenantId: 'tenant_456',
name: 'CΓ phΓͺ sα»―a ΔΓ‘',
priceVnd: 25000,
createdAt: new Date().toISOString()
};
// Type-safe API requests
const orderRequest: CreateOrderRequest = {
tenantId: 'tenant_456',
items: [
{ productId: 'prod_123', quantity: 2 }
],
totalVnd: 50000
};All type definitions are exported from the main package:
// API DTOs
import { ProductDTO, OrderDTO, CustomerDTO } from '@localstore/types';
// Request/Response types
import { CreateProductRequest, UpdateOrderRequest } from '@localstore/types';
// Domain enums and constants
import { OrderStatus, PaymentMethod, UserRole } from '@localstore/types';GraphQL schema files are available for code generation:
# Reference in your codegen.yml
schema: './node_modules/@localstore/types/graphql/schema.graphql'Protobuf files for gRPC services:
# Reference in your proto compilation
protoc --proto_path=./node_modules/@localstore/types/proto-
Clone the repository:
git clone https://github.com/localstore-platform/contracts.git cd contracts -
Install dependencies:
npm install
-
Build the project:
npm run build
-
Run tests:
npm test
See Development Guide for detailed setup instructions.
contracts/
βββ types/ # TypeScript type definitions
β βββ api/ # REST API DTOs
β βββ graphql/ # GraphQL-specific types
β βββ domain/ # Domain models
βββ graphql/ # GraphQL schema files
βββ proto/ # Protobuf definitions
βββ dist/ # Compiled output (generated)
βββ docs/ # Documentation
βββ tests/ # Test filesThis repository follows a strict contract change process to maintain stability across all consuming services.
- Major (x.0.0): Breaking changes (removed/renamed fields, changed types)
- Minor (0.x.0): New features (new types, optional fields)
- Patch (0.0.x): Bug fixes (correcting spec mismatches)
- Reference the specification: All changes must align with the specs repository
- Assess impact: Determine if the change is breaking
- Update documentation: Update CHANGELOG.md and migration guides
- Coordinate releases: For breaking changes, coordinate with all consumers
- Follow PR template: Use the provided pull request template
See the Contract Change Process for full details.
This repository implements type definitions based on specifications from the LocalStore Platform Specs Repository.
Spec Version: v1.1-specs
- API Specification - REST API contracts
- GraphQL Schema - GraphQL type system
- Database Schema - Data models and enums
- Contract Change Process - Change management
See docs/SPEC_LINKS.md for a complete list of relevant specifications.
We welcome contributions! Please follow these guidelines:
- Check specifications first: All changes must align with the specs repository
- Use issue templates: Bug reports and feature requests have dedicated templates
- Follow PR template: The pull request template ensures all required information is provided
- Write tests: All new types should have unit tests
- Update documentation: Keep README, CHANGELOG, and inline docs up to date
- Create a feature branch:
git checkout -b feature/my-new-type - Make changes following the Development Guide
- Add tests and ensure all tests pass
- Submit a pull request using the PR template
- Address review feedback
All changes require approval from code owners before merging.
This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0) - see the LICENSE file for details.
- Specifications - Source of truth for all platform specifications
- Backend - Backend API implementation
- Web Dashboard - Web-based management interface
- Issues: Use GitHub Issues with appropriate templates
- Discussions: Join team discussions for general questions
- Specifications: Check the specs repository for detailed requirements
Vietnamese Localization: All types are designed with Vietnamese small businesses in mind, using vi-VN locale and VND currency by default.
Multi-Tenant Architecture: All contracts support multi-tenant isolation and tenant-scoped data access.