-
Notifications
You must be signed in to change notification settings - Fork 1
[Feature]: Types registry support #117
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
base: main
Are you sure you want to change the base?
Conversation
…y in entities tests
- Introduced `SortField` type for improved sorting parameter handling in list and filter methods. - Updated `importEntities` method to return a structured `ImportResult` type, providing detailed import status and output. - Modified list and filter methods to support generic field selection, enhancing type safety and flexibility.
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportReview Checklist
SummaryThis PR implements a type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The implementation uses TypeScript's declaration merging feature to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation follows excellent TypeScript practices:
Potential Issues 🔍1. Entities Module Type Declaration LocationIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo;
}
}2. Registry Naming ConsistencyThe registries use different value types:
Consider using consistent patterns. Either all map to types or all map to Performance Considerations ⚡The type registry implementation has zero runtime overhead as it's purely a TypeScript compile-time feature. The conditional types are resolved during compilation, resulting in no performance impact. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage 🧪The existing test in
Suggested Test Example:// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
// Test that augmentation works
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// Should have autocomplete for Task
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
// Should have autocomplete for agent names
await client.agents.createConversation({
agent_name: 'support-agent' // ✅ Type-safe
});
// Should have autocomplete for function names
await client.functions.invoke('calculateTotal', {}); // ✅ Type-safeRecommendations 💡
Overall, this is a well-implemented feature that significantly improves the developer experience. The code is clean, follows TypeScript best practices, and maintains backward compatibility. With the minor suggestions above, this will be an excellent addition to the SDK. |
🚀 Package Preview Available!Install this PR's preview build with npm: npm i @base44-preview/sdk@0.8.18-pr.117.353547fPrefer not to change any import paths? Install using npm alias so your code still imports npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.18-pr.117.353547f"Or add it to your {
"dependencies": {
"@base44/sdk": "npm:@base44-preview/sdk@0.8.18-pr.117.353547f"
}
}
Preview published to npm registry — try new features instantly! |
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportI've reviewed the implementation of the type registry system in this PR. Here's my comprehensive feedback: OverviewThis PR implements a clean type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The approach leverages TypeScript's declaration merging to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation demonstrates excellent TypeScript practices:
Potential Issues 🔍1. Test File Module Augmentation PatternIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo; // Just the type, not the handler
}
}The 2. Registry Value Type InconsistencyThe registries use different value patterns:
This inconsistency might be confusing. Consider documenting why agents/functions use boolean markers while entities use full type definitions. Performance Considerations ⚡Zero runtime overhead - The type registry system is purely compile-time TypeScript. The conditional types are resolved during compilation, resulting in no performance impact at runtime. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage Suggestions 🧪The current test demonstrates the concept but could benefit from:
// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// These should have proper type inference
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
await client.agents.createConversation({
agent_name: 'support-agent' // Should autocomplete
});
await client.functions.invoke('calculateTotal', {}); // Should autocomplete
Recommendations 💡
SummaryThis is a well-implemented feature that significantly improves developer experience without breaking changes. The code is clean, follows TypeScript best practices, and maintains backward compatibility. The minor suggestions above would make it even more robust and user-friendly. Great work on this implementation! 🎉 |
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportI've reviewed the implementation of the type registry system in this PR. Here's my comprehensive feedback: OverviewThis PR implements a clean type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The approach leverages TypeScript's declaration merging to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation demonstrates excellent TypeScript practices:
Potential Issues 🔍1. Test File Module Augmentation PatternIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo; // Just the type, not the handler
}
}The 2. Registry Value Type InconsistencyThe registries use different value patterns:
This inconsistency might be confusing. Consider documenting why agents/functions use boolean markers while entities use full type definitions. Performance Considerations ⚡Zero runtime overhead - The type registry system is purely compile-time TypeScript. The conditional types are resolved during compilation, resulting in no performance impact at runtime. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage Suggestions 🧪The current test demonstrates the concept but could benefit from:
// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// These should have proper type inference
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
await client.agents.createConversation({
agent_name: 'support-agent' // Should autocomplete
});
await client.functions.invoke('calculateTotal', {}); // Should autocomplete
Recommendations 💡
SummaryThis is a well-implemented feature that significantly improves developer experience without breaking changes. The code is clean, follows TypeScript best practices, and maintains backward compatibility. The minor suggestions above would make it even more robust and user-friendly. Great work on this implementation! 🎉 |
b8f36bc to
9d980ad
Compare
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportReview Checklist
SummaryThis PR implements a type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The implementation uses TypeScript's declaration merging feature to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation follows excellent TypeScript practices:
Potential Issues 🔍1. Entities Module Type Declaration LocationIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo;
}
}2. Registry Naming ConsistencyThe registries use different value types:
Consider using consistent patterns. Either all map to types or all map to Performance Considerations ⚡The type registry implementation has zero runtime overhead as it's purely a TypeScript compile-time feature. The conditional types are resolved during compilation, resulting in no performance impact. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage 🧪The existing test in
Suggested Test Example:// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
// Test that augmentation works
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// Should have autocomplete for Task
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
// Should have autocomplete for agent names
await client.agents.createConversation({
agent_name: 'support-agent' // ✅ Type-safe
});
// Should have autocomplete for function names
await client.functions.invoke('calculateTotal', {}); // ✅ Type-safeRecommendations 💡
Overall, this is a well-implemented feature that significantly improves the developer experience. The code is clean, follows TypeScript best practices, and maintains backward compatibility. With the minor suggestions above, this will be an excellent addition to the SDK. |
9d980ad to
f22dde7
Compare
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportReview Checklist
SummaryThis PR implements a type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The implementation uses TypeScript's declaration merging feature to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation follows excellent TypeScript practices:
Potential Issues 🔍1. Entities Module Type Declaration LocationIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo;
}
}2. Registry Naming ConsistencyThe registries use different value types:
Consider using consistent patterns. Either all map to types or all map to Performance Considerations ⚡The type registry implementation has zero runtime overhead as it's purely a TypeScript compile-time feature. The conditional types are resolved during compilation, resulting in no performance impact. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage 🧪The existing test in
Suggested Test Example:// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
// Test that augmentation works
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// Should have autocomplete for Task
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
// Should have autocomplete for agent names
await client.agents.createConversation({
agent_name: 'support-agent' // ✅ Type-safe
});
// Should have autocomplete for function names
await client.functions.invoke('calculateTotal', {}); // ✅ Type-safeRecommendations 💡
Overall, this is a well-implemented feature that significantly improves the developer experience. The code is clean, follows TypeScript best practices, and maintains backward compatibility. With the minor suggestions above, this will be an excellent addition to the SDK. |
f22dde7 to
24b39a4
Compare
|
Claude finished @kfirstri's task —— View job PR Review: Types Registry SupportI've reviewed the implementation of the type registry system in this PR. Here's my comprehensive feedback: OverviewThis PR implements a clean type registry system that allows developers to augment the SDK's types with their custom entities, agents, and functions. The approach leverages TypeScript's declaration merging to provide type-safe autocomplete and better developer experience. Code Quality and Best Practices ✅The implementation demonstrates excellent TypeScript practices:
Potential Issues 🔍1. Test File Module Augmentation PatternIn declare module "../../src/modules/entities.types.ts" {
interface EntitiesModule {
Todo: EntityHandler<Todo>;
}
}This augments declare module '@base44/sdk' {
interface EntityTypeRegistry {
Todo: Todo; // Just the type, not the handler
}
}The 2. Registry Value Type InconsistencyThe registries use different value patterns:
This inconsistency might be confusing. Consider documenting why agents/functions use boolean markers while entities use full type definitions. Performance Considerations ⚡Zero runtime overhead - The type registry system is purely compile-time TypeScript. The conditional types are resolved during compilation, resulting in no performance impact at runtime. Security Concerns 🔒No security issues identified. The implementation:
Test Coverage Suggestions 🧪The current test demonstrates the concept but could benefit from:
// types.test-d.ts
import { expectType } from 'tsd';
import { createClient } from '@base44/sdk';
declare module '@base44/sdk' {
interface EntityTypeRegistry {
Task: { id: string; title: string; completed: boolean };
}
interface AgentNameRegistry {
'support-agent': true;
}
interface FunctionNameRegistry {
calculateTotal: true;
}
}
const client = createClient({ appId: 'test', serverUrl: 'test' });
// These should have proper type inference
expectType<{ id: string; title: string; completed: boolean }>(
await client.entities.Task.get('123')
);
await client.agents.createConversation({
agent_name: 'support-agent' // Should autocomplete
});
await client.functions.invoke('calculateTotal', {}); // Should autocomplete
Recommendations 💡
SummaryThis is a well-implemented feature that significantly improves developer experience without breaking changes. The code is clean, follows TypeScript best practices, and maintains backward compatibility. The minor suggestions above would make it even more robust and user-friendly. Great work on this implementation! 🎉 |
Summary
We want to give developers the option to use the entities, agents and functions they've created when calling the sdk.
This PR adds Type Registries and can be augmented from outside of the SDK.
base44/cli#199 This PR in CLI generates types