@base44-preview/cli 0.0.15-pr.100.7c491cf → 0.0.15-pr.102.d2fdfed
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -1
- package/dist/cli/index.js +562 -546
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,93 @@ base44 deploy
|
|
|
70
70
|
|---------|-------------|
|
|
71
71
|
| `base44 site deploy` | Deploy built site files to Base44 hosting |
|
|
72
72
|
|
|
73
|
+
### Types
|
|
74
|
+
|
|
75
|
+
| Command | Description |
|
|
76
|
+
|---------|-------------|
|
|
77
|
+
| `base44 types` | Generate TypeScript types from entity schemas |
|
|
78
|
+
|
|
79
|
+
**Options:**
|
|
80
|
+
- `-o, --output <dir>` - Output directory (default: `src/base44`)
|
|
81
|
+
- `--entities-only` - Only generate entity types, skip client types
|
|
82
|
+
|
|
83
|
+
## TypeScript Type Generation
|
|
84
|
+
|
|
85
|
+
Generate fully-typed interfaces from your entity schemas for type-safe SDK usage.
|
|
86
|
+
|
|
87
|
+
### Usage
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Generate types (outputs to src/base44/)
|
|
91
|
+
base44 types
|
|
92
|
+
|
|
93
|
+
# Custom output directory
|
|
94
|
+
base44 types --output ./types
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Generated Files
|
|
98
|
+
|
|
99
|
+
| File | Contents |
|
|
100
|
+
|------|----------|
|
|
101
|
+
| `entities.ts` | Entity interfaces, CreateInput, UpdateInput, Filter types |
|
|
102
|
+
| `client.ts` | Typed SDK client interface |
|
|
103
|
+
| `index.ts` | Barrel exports |
|
|
104
|
+
|
|
105
|
+
### Setup with @base44/sdk
|
|
106
|
+
|
|
107
|
+
1. Generate types:
|
|
108
|
+
```bash
|
|
109
|
+
base44 types
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
2. Add to `tsconfig.json`:
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"include": ["src", "src/base44/entities.ts"]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
3. Use in your code:
|
|
120
|
+
```typescript
|
|
121
|
+
import { createClient } from '@base44/sdk';
|
|
122
|
+
import type { TypedBase44Client } from './base44/client';
|
|
123
|
+
|
|
124
|
+
const base44 = createClient({ appId: 'my-app' }) as TypedBase44Client;
|
|
125
|
+
|
|
126
|
+
// Fully typed!
|
|
127
|
+
const { items: tasks } = await base44.entities.Task.list();
|
|
128
|
+
await base44.entities.Task.create({ title: 'Buy milk' });
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Example
|
|
132
|
+
|
|
133
|
+
Given an entity schema:
|
|
134
|
+
```jsonc
|
|
135
|
+
// base44/entities/task.jsonc
|
|
136
|
+
{
|
|
137
|
+
"name": "Task",
|
|
138
|
+
"type": "object",
|
|
139
|
+
"properties": {
|
|
140
|
+
"title": { "type": "string", "description": "Task title" },
|
|
141
|
+
"completed": { "type": "boolean", "default": false }
|
|
142
|
+
},
|
|
143
|
+
"required": ["title"]
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Generated types:
|
|
148
|
+
```typescript
|
|
149
|
+
export interface Task extends BaseEntity {
|
|
150
|
+
title: string;
|
|
151
|
+
completed?: boolean;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface TaskCreateInput {
|
|
155
|
+
title: string;
|
|
156
|
+
completed?: boolean;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
73
160
|
## Configuration
|
|
74
161
|
|
|
75
162
|
### Project Configuration
|
|
@@ -115,7 +202,12 @@ my-project/
|
|
|
115
202
|
│ └── my-function/
|
|
116
203
|
│ ├── config.jsonc
|
|
117
204
|
│ └── index.js
|
|
118
|
-
├── src/
|
|
205
|
+
├── src/
|
|
206
|
+
│ ├── base44/ # Generated types (from `base44 types`)
|
|
207
|
+
│ │ ├── entities.ts
|
|
208
|
+
│ │ ├── client.ts
|
|
209
|
+
│ │ └── index.ts
|
|
210
|
+
│ └── ... # Your frontend code
|
|
119
211
|
├── dist/ # Built site files (for deployment)
|
|
120
212
|
└── package.json
|
|
121
213
|
```
|