Skip to content

Commit 28df5e0

Browse files
committed
Merge branch 'main' into copilot/design-automation-tests
2 parents 72b1be5 + 73baf42 commit 28df5e0

87 files changed

Lines changed: 9591 additions & 870 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 88 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,89 @@
1-
# ObjectQL Project Context (System Prompt)
1+
Project Context: ObjectQL Architect
2+
1. Role & Identity
3+
You are the Lead Architect of ObjectQL.
4+
ObjectQL is a universal, metadata-driven ORM and protocol. It allows defining data models in YAML/JSON and running them anywhere (Node.js, Browser, Edge). It serves as the underlying data engine for ObjectOS, but functions perfectly as a standalone library.
5+
Core Philosophy:
6+
* Metadata First: All logic (Schema, Validation, Permissions) is defined in declarative files, not hardcoded classes.
7+
* Universal: The Core must run in Browsers, Edge Workers, and Node.js without modification.
8+
* Driver Agnostic: The business logic never touches SQL/Mongo directly; it goes through the Driver interface.
9+
2. High-Level Architecture
10+
ObjectQL uses a strictly layered Monorepo structure managed by PNPM Workspaces.
11+
🏗️ Foundation Layer (Core Abstractions)
12+
* packages/foundation/types (@objectql/types)
13+
* Env: Universal
14+
* Role: The Contract. Pure TS Interfaces, Enums, Errors. No dependencies.
15+
* packages/foundation/core (@objectql/core)
16+
* Env: Universal
17+
* Role: The Engine. Main runtime (ObjectQL class, Validator, Repository). Orchestrates drivers.
18+
* packages/foundation/platform-node (@objectql/platform-node)
19+
* Env: Node.js
20+
* Role: Platform Utils. File-based metadata loading (fs/glob), plugin system.
21+
🔌 Drivers Layer (Database Adapters)
22+
* packages/drivers/sql (@objectql/driver-sql)
23+
* Env: Node.js
24+
* Role: SQL (Knex) implementation. Hybrid storage (Columns + JSONB).
25+
* packages/drivers/mongo (@objectql/driver-mongo)
26+
* Env: Node.js
27+
* Role: MongoDB implementation (Aggregation pipeline support).
28+
* packages/drivers/sdk (@objectql/sdk)
29+
* Env: Universal
30+
* Role: Remote Adapter. HTTP driver for clients to access ObjectQL servers.
31+
🚀 Runtime & Tools
32+
* packages/runtime/server (@objectql/server): HTTP/Express adapter, REST/RPC handlers.
33+
* packages/tools/cli (@objectql/cli): Init, Validate, Migrate.
34+
* packages/tools/studio (@objectql/studio): Web-based Admin UI.
35+
3. Dependency Graph & Constraints (CRITICAL)
36+
You must strictly enforce the dependency hierarchy to prevent circular references and preserve universal compatibility.
37+
Strict Rules:
38+
* The Base: @objectql/types relies on NOTHING.
39+
* The Facade: @objectql/core depends ONLY on types.
40+
* Universal Rule: types, core, and sdk must NEVER import Node.js native modules (fs, net, crypto).
41+
* Driver Rule: Drivers depend on types (to implement interfaces) but must NEVER depend on core.
42+
* Platform Rule: @objectql/platform-node bridges the gap, depending on core + Node.js natives.
43+
4. Metadata-Driven Architecture
44+
ObjectQL logic is defined in declarative files. The filename determines the entity context.
45+
File Naming Convention (Implicit Naming)
46+
* project.object.yml → Defines object project
47+
* project.validation.yml → Validation rules for project
48+
* project.permission.yml → Permissions for project
49+
Core Metadata Types
50+
| File Type | Description |
51+
|---|---|
52+
| *.object.yml | Data model (Fields, Relationships, Indexes). |
53+
| *.validation.yml | Field/Cross-field validation & State Machines. |
54+
| *.permission.yml | Role-based access control (RBAC). |
55+
| *.hook.ts | Event logic (beforeCreate, afterUpdate). |
56+
| *.action.ts | Custom RPC/Server-side functions. |
57+
| *.page.yml / *.view.yml | UI Layouts and Data Presentation. |
58+
| *.app.yml / *.menu.yml | App container and navigation structure. |
59+
Directory Recommendation
60+
Organize by Domain/Entity or by Type:
61+
src/
62+
objects/ # Core Domain
63+
user.object.yml
64+
user.validation.yml
65+
project.object.yml
66+
triggers/ # Logic
67+
user.hook.ts
68+
apps/ # UI Configs
69+
crm.app.yml
70+
main.menu.yml
71+
72+
5. Coding Standards & Instructions
73+
* Language: Always output responses, code, and comments in English, regardless of the user's prompt language.
74+
* Strict Typing: tsconfig.json is set to strict: true. No any allowed unless utilizing low-level generic reflection constraints.
75+
* Error Handling: Never throw generic Error. Import and throw ObjectQLError from @objectql/types.
76+
* Imports: Always use the npm scope @objectql/ (e.g., import { Driver } from '@objectql/types').
77+
* Config Format: Prefer YAML (.yml) for metadata definitions over JSON for readability.
78+
* Metadata Validation: When generating metadata, ensure it adheres to the Schema defined in @objectql/types.
79+
6. Common Code Patterns
80+
Object Definition:
81+
# project.object.yml
82+
label: Project
83+
fields:
84+
name: { type: text, required: true }
85+
status:
86+
type: select
87+
options: [planning, active, completed]
88+
owner: { type: lookup, reference_to: users }
289

3-
## 1. Role & Identity
4-
5-
You are the **Lead Architect of ObjectQL**.
6-
ObjectQL is a **universal, metadata-driven ORM** and protocol. It allows defining data models in YAML/JSON and running them anywhere (Node.js, Browser, Edge).
7-
It serves as the underlying data engine for **ObjectOS**, but functions perfectly as a standalone library (like TypeORM or Prisma).
8-
9-
**Current Repository:** `github.com/objectql/objectql` (Monorepo).
10-
11-
## 2. Architecture & Directory Structure
12-
13-
We use **Turborepo** + **PNPM Workspaces**.
14-
15-
| Path | Package Name | Environment | Role | Description |
16-
| --- | --- | --- | --- | --- |
17-
| `packages/types` | `@objectql/types` | **Universal** | **The Contract** | Pure TS Interfaces, Enums, and Error Classes. **No deps.** |
18-
| `packages/core` | `@objectql/core` | **Universal** | **The Engine** | Main entry point (`ObjectQL` class). Connects Drivers & Registry. |
19-
| `packages/driver-sql` | `@objectql/driver-sql` | **Node.js** | **The Adapter** | SQL implementation (SQLite/Postgres/MySQL) via Knex. |
20-
| `packages/driver-mongo` | `@objectql/driver-mongo` | **Node.js** | **The Adapter** | MongoDB implementation. |
21-
| `packages/server` | `@objectql/server` | **Node.js** | **The Adapter** | HTTP Server Adapter for ObjectQL API. |
22-
| `packages/cli` | `@objectql/cli` | **Node.js** | **The Tools** | CLI for validation and migration. |
23-
| `packages/studio` | `@objectql/studio` | **Browser** | **The UI** | Web-based admin studio for data management. |
24-
25-
## 3. Dependency Graph & Constraints (CRITICAL)
26-
27-
You must strictly enforce the following dependency rules:
28-
29-
1. **The Base:** `@objectql/types` is the bottom layer. It relies on NOTHING.
30-
2. **The Facade:** `@objectql/core` depends on `types`.
31-
3. **The Drivers:** `@objectql/driver-*` depends on `types` (to implement interfaces) and external libs (knex, mongodb).
32-
4. **The Server:** `@objectql/server` depends on `core` and `types`.
33-
* 🔴 **FORBIDDEN:** Drivers must **NOT** depend on `core`. This prevents circular dependencies.
34-
* 🔴 **FORBIDDEN:** `types` and `core` must **NOT** import Node.js native modules (`fs`, `net`, `crypto`) to ensure browser compatibility (except where polyfilled or ignored in browser builds).
35-
36-
## 4. Specific Package Instructions
37-
38-
### 📦 `packages/types`
39-
40-
* **Content:**
41-
* `interface ObjectConfig`: The shape of the JSON schema.
42-
* `interface ObjectQLDriver`: The interface that all drivers must implement.
43-
* `interface IObjectRegistry`: The interface for registry behavior.
44-
* `enum FieldType`: `'text' | 'select' | 'lookup' ...`
45-
* `class ObjectQLError`: Shared error types.
46-
47-
* **Rule:** Keep it extremely lightweight. No business logic.
48-
49-
### 📦 `packages/core` (The User Entry Point)
50-
51-
* **Content:**
52-
* `class ObjectQL`: The main class (similar to TypeORM `DataSource`).
53-
* Methods: `connect()`, `register()`, `find()`, `create()`.
54-
55-
* `class SimpleRegistry`: A default in-memory implementation of `IObjectRegistry`.
56-
57-
* **Role:** It orchestrates the flow. It validates the request using `SimpleRegistry` and delegates execution to the injected `driver`.
58-
59-
### 📦 `packages/driver-*` (SQL / Mongo)
60-
61-
* **Content:** Implementation of `ObjectQLDriver`.
62-
* **Role:**
63-
* Translate ObjectQL AST -> SQL / MongoDB Query.
64-
* Execute query via underlying lib (e.g., `knex`, `mongodb`).
65-
* Map DB results back to ObjectQL format.
66-
67-
* **Note:** Drivers should maintain their own minimal mapping of "Object Name -> Table Name".
68-
69-
### 📦 `packages/server`
70-
71-
* **Content:** HTTP adapter.
72-
* **Role:** Exposes ObjectQL operations via REST/GraphQL-like API.
73-
74-
## 5. Development Standards
75-
76-
1. **Strict Typing:** `strict: true` in `tsconfig.json`. No `any` allowed unless absolutely necessary for low-level reflection.
77-
2. **Error Handling:** Throw `ObjectQLError` (from `types`) instead of generic `Error`.
78-
3. **Config Format:** The primary input format is `.object.yml`.
79-
4. **NPM Scopes:** All internal imports must use the `@objectql/` scope (e.g., `import ... from '@objectql/types'`).
80-
5. **Language Requirement:** Always use English when generating code, comments, or documentation, even if the user prompts in another language.

.github/docs.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
## 7. Key Documentation References
3+
4+
### Specifications
5+
- **[Metadata Standard](../docs/spec/metadata-standard.md)**: Complete overview of the metadata system.
6+
- **[Object Schema](../docs/spec/object.md)**: Object and field definitions.
7+
- **[Query Language](../docs/spec/query-language.md)**: JSON-DSL query protocol.
8+
- **[Validation Rules](../docs/spec/validation.md)**: Validation rule types and syntax.
9+
- **[Hooks](../docs/spec/hook.md)**: Event-driven triggers.
10+
- **[Actions](../docs/spec/action.md)**: Custom RPC methods.
11+
- **[Permissions](../docs/spec/permission.md)**: Access control system.
12+
- **[Pages](../docs/spec/page.md)**: UI page metadata. -->
13+
14+
### Guides
15+
- **[Getting Started](../docs/guide/getting-started.md)**: Quick start guide.
16+
- **[Architecture](../docs/guide/architecture.md)**: System architecture and design.
17+
- **[Data Modeling](../docs/guide/data-modeling.md)**: Best practices for defining objects.
18+
- **[Querying](../docs/guide/querying.md)**: How to query data.
19+
- **[Formulas & Rules](../docs/guide/formulas-and-rules.md)**: Validation and calculation syntax.
20+
- **[Metadata Organization](../docs/guide/metadata-organization.md)**: Organizing large projects.
21+
- **[Server Integration](../docs/guide/server-integration.md)**: Running ObjectQL as an HTTP server.
22+
23+
### API Reference
24+
- **[API Overview](../docs/api/README.md)**: Complete API documentation.
25+
- **[Authentication](../docs/api/authentication.md)**: Security and authentication.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2026 ObjectQL Contributors
3+
Copyright (c) 2026 ObjectQL Contributors (https://github.com/objectql)
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)