-
Notifications
You must be signed in to change notification settings - Fork 0
Remove flat exports, enforce namespace-only imports (BREAKING CHANGE) #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7cfd9bd
Initial plan
Copilot b67c855
Add namespaced exports to prevent naming conflicts
Copilot cb9b3d4
Add example code demonstrating namespaced imports
Copilot fe6524c
Add comprehensive PR summary document
Copilot 46e16ce
Remove flat exports, enforce namespace-only imports
Copilot fb3126a
Fix documentation examples to be consistent with namespace exports
Copilot 88ea090
删除 EXPORT_ORGANIZATION.md
huangyiirene 89de6e5
删除 PR_SUMMARY.md
huangyiirene 2cfa7e7
Fix imports in packages and examples to use new namespace structure
Copilot b5f1fb1
Fix build-schemas.ts to handle namespace exports
Copilot d7eae3d
Fix unused variable in build-schemas.ts
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { ObjectStackManifest } from '@objectstack/spec'; | ||
| import { ObjectStackManifest } from '@objectstack/spec/system'; | ||
| declare const BiPlugin: ObjectStackManifest; | ||
| export default BiPlugin; | ||
| //# sourceMappingURL=objectstack.config.d.ts.map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import { DriverInterface, DriverOptions, QueryAST, ObjectStackManifest } from '@objectstack/spec'; | ||
| import { QueryAST } from '@objectstack/spec/data'; | ||
| import { DriverInterface, DriverOptions, ObjectStackManifest } from '@objectstack/spec/system'; | ||
| import { SchemaRegistry } from './registry'; | ||
|
|
||
| // Export Registry for consumers | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| import { ServiceObject, App, ObjectStackManifest } from '@objectstack/spec'; | ||
| import { ServiceObject } from '@objectstack/spec/data'; | ||
| import { App } from '@objectstack/spec/ui'; | ||
| import { ObjectStackManifest } from '@objectstack/spec/system'; | ||
|
|
||
| /** | ||
| * Global Schema Registry | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { ServiceObject } from '@objectstack/spec'; | ||
| import { ServiceObject } from '@objectstack/spec/data'; | ||
| import { SchemaRegistry, ObjectQL } from '@objectstack/objectql'; | ||
|
|
||
| /** | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,12 +44,115 @@ The specification is divided into three protocols: | |
|
|
||
| ## 📚 Usage | ||
|
|
||
| ### Import Styles | ||
|
|
||
| **Important:** This package does NOT export types at the root level to prevent naming conflicts. You must use one of the following import styles: | ||
|
|
||
| #### 1. Namespace Imports from Root | ||
|
|
||
| Import protocol namespaces from the package root: | ||
|
|
||
| ```typescript | ||
| import { Data, UI, System, AI, API } from '@objectstack/spec'; | ||
|
|
||
| const field: Data.Field = { | ||
| name: 'task_name', | ||
| type: 'text', | ||
| label: 'Task Name', | ||
| }; | ||
|
|
||
| const user: System.User = { | ||
| id: 'user_123', | ||
| email: 'user@example.com', | ||
| // ... | ||
| }; | ||
|
|
||
| const agent: AI.Agent = { | ||
| name: 'sales_assistant', | ||
| // ... | ||
| }; | ||
| ``` | ||
|
|
||
| **Pros:** | ||
| - Single import line for multiple protocols | ||
| - Clear namespace boundaries | ||
| - No naming conflicts | ||
|
|
||
| #### 2. Namespace Imports via Subpath | ||
|
|
||
| Import protocol domains individually: | ||
|
|
||
| ```typescript | ||
| import * as Data from '@objectstack/spec/data'; | ||
| import * as UI from '@objectstack/spec/ui'; | ||
| import * as System from '@objectstack/spec/system'; | ||
| import * as AI from '@objectstack/spec/ai'; | ||
| import * as API from '@objectstack/spec/api'; | ||
|
|
||
| const field: Data.Field = { | ||
| name: 'task_name', | ||
| type: 'text', | ||
| label: 'Task Name', | ||
| }; | ||
|
|
||
| const user: System.User = { | ||
| id: 'user_123', | ||
| email: 'user@example.com', | ||
| // ... | ||
| }; | ||
| ``` | ||
|
|
||
| **Pros:** | ||
| - Explicit about which protocols are used | ||
| - Better tree-shaking (only imports needed protocols) | ||
| - Clear namespace boundaries | ||
|
|
||
| #### 3. Direct Subpath Imports | ||
|
|
||
| Import specific types from subpaths: | ||
|
|
||
| ```typescript | ||
| import { Field, FieldType, ObjectSchema } from '@objectstack/spec/data'; | ||
| import { User, Session } from '@objectstack/spec/system'; | ||
| import { App, View } from '@objectstack/spec/ui'; | ||
|
|
||
| const field: Field = { | ||
| name: 'task_name', | ||
| type: 'text', | ||
| label: 'Task Name', | ||
| }; | ||
|
|
||
| const user: User = { | ||
| id: 'user_123', | ||
| email: 'user@example.com', | ||
| // ... | ||
| }; | ||
| ``` | ||
|
|
||
| **Pros:** | ||
| - Most concise syntax | ||
| - Good for importing specific types | ||
| - No namespace prefix needed | ||
|
|
||
| **Cons:** | ||
| - Need to know which subpath contains each type | ||
| - Multiple import statements for different protocols | ||
|
|
||
| ### Validation (Runtime) | ||
|
|
||
| ```typescript | ||
| import { ObjectSchema } from '@objectstack/spec'; | ||
| // Style 1: Namespace from root | ||
| import { Data } from '@objectstack/spec'; | ||
| const result = Data.ObjectSchema.safeParse(userConfig); | ||
|
|
||
| // Style 2: Namespace via subpath | ||
| import * as Data from '@objectstack/spec/data'; | ||
| const result = Data.ObjectSchema.safeParse(userConfig); | ||
|
|
||
| // Style 3: Direct subpath import | ||
| import { ObjectSchema } from '@objectstack/spec/data'; | ||
| const result = ObjectSchema.safeParse(userConfig); | ||
|
|
||
| if (!result.success) { | ||
| console.error("Invalid Object definition", result.error); | ||
| } | ||
|
|
@@ -58,14 +161,33 @@ if (!result.success) { | |
| ### Type Definitions (Compile Time) | ||
|
|
||
| ```typescript | ||
| import type { Object, Field } from '@objectstack/spec'; | ||
| // Style 1: Namespace from root | ||
| import type { Data } from '@objectstack/spec'; | ||
| const myField: Data.Field = { | ||
| name: "task_name", | ||
| type: "text", | ||
| label: "Task Name" | ||
| }; | ||
|
|
||
| const myObject: Object = { | ||
| name: "project_task", | ||
| fields: { ... } | ||
| // Style 2: Direct subpath import | ||
| import type { Field } from '@objectstack/spec/data'; | ||
| const myField: Field = { | ||
| name: "task_name", | ||
| type: "text", | ||
| label: "Task Name" | ||
| }; | ||
| ``` | ||
|
|
||
| Using namespace imports for multiple protocols: | ||
|
|
||
| ```typescript | ||
| import type * as Data from '@objectstack/spec/data'; | ||
| import type * as System from '@objectstack/spec/system'; | ||
|
|
||
| const field: Data.Field = { /* ... */ }; | ||
| const user: System.User = { /* ... */ }; | ||
| ``` | ||
|
|
||
| ### JSON Schema (Tooling) | ||
| The package includes valid JSON Schemas in the `/json-schema` directory. | ||
| These can be used with: | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused variable, import, function or class Note
Copilot Autofix
AI 1 day ago
In general, to fix an unused import, either remove it if it's not needed, or start using it in the code if it was meant to be used. Since there is no sign that
WindowFunctionNodeis required for existing functionality and no references to it appear in the snippet, the safest, non-functional change is to delete just that symbol from the import list.Concretely, in
packages/client/src/index.ts, edit the import on line 1 to removeWindowFunctionNodefrom the destructuring while leaving the other imported types intact. No additional imports, methods, or definitions are needed, and this change will not affect runtime behavior because type-only imports are erased at compile time, and this one was unused anyway.