okai 0.0.45 → 0.0.47
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 +499 -1
- package/bin/okai.js +6 -0
- package/dist/client.d.ts +5 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +1 -0
- package/dist/client.js.map +1 -0
- package/dist/cs-apis.d.ts +10 -0
- package/dist/cs-apis.d.ts.map +1 -0
- package/dist/cs-apis.js +2 -1
- package/dist/cs-apis.js.map +1 -0
- package/dist/cs-ast.d.ts +62 -0
- package/dist/cs-ast.d.ts.map +1 -0
- package/dist/cs-ast.js +1 -0
- package/dist/cs-ast.js.map +1 -0
- package/dist/cs-gen.d.ts +29 -0
- package/dist/cs-gen.d.ts.map +1 -0
- package/dist/cs-gen.js +2 -1
- package/dist/cs-gen.js.map +1 -0
- package/dist/cs-migrations.d.ts +9 -0
- package/dist/cs-migrations.d.ts.map +1 -0
- package/dist/cs-migrations.js +1 -0
- package/dist/cs-migrations.js.map +1 -0
- package/dist/icons.d.ts +273 -0
- package/dist/icons.d.ts.map +1 -0
- package/dist/icons.js +46 -18
- package/dist/icons.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -0
- package/dist/info.d.ts +13 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/info.js +3 -2
- package/dist/info.js.map +1 -0
- package/dist/openai.d.ts +165 -0
- package/dist/openai.d.ts.map +1 -0
- package/dist/openai.js +1 -0
- package/dist/openai.js.map +1 -0
- package/dist/ts-ast.d.ts +15 -0
- package/dist/ts-ast.d.ts.map +1 -0
- package/dist/ts-ast.js +1 -0
- package/dist/ts-ast.js.map +1 -0
- package/dist/ts-once.d.ts +9 -0
- package/dist/ts-once.d.ts.map +1 -0
- package/dist/ts-once.js +2 -1
- package/dist/ts-once.js.map +1 -0
- package/dist/ts-parser.d.ts +110 -0
- package/dist/ts-parser.d.ts.map +1 -0
- package/dist/ts-parser.js +46 -4
- package/dist/ts-parser.js.map +1 -0
- package/dist/tsd-gen.d.ts +18 -0
- package/dist/tsd-gen.d.ts.map +1 -0
- package/dist/tsd-gen.js +1 -0
- package/dist/tsd-gen.js.map +1 -0
- package/dist/types.d.ts +759 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/ui-mjs.d.ts +9 -0
- package/dist/ui-mjs.d.ts.map +1 -0
- package/dist/ui-mjs.js +1 -0
- package/dist/ui-mjs.js.map +1 -0
- package/dist/utils.d.ts +60 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +143 -0
- package/dist/utils.js.map +1 -0
- package/package.json +14 -13
- package/dist/okai.js +0 -4
package/README.md
CHANGED
|
@@ -1,2 +1,500 @@
|
|
|
1
1
|
# okai
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
AI-powered code generation tool for ServiceStack Apps. Generate TypeScript data models, C# APIs, migrations, and UI components from natural language prompts using LLMs.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🤖 **AI-Powered Generation** - Generate complete CRUD APIs from natural language prompts
|
|
8
|
+
- 📝 **TypeScript Data Models** - Define your data models in TypeScript with type safety
|
|
9
|
+
- 🔄 **Auto-Generate C# Code** - Automatically generate C# APIs, DTOs, and migrations
|
|
10
|
+
- 🗄️ **Database Migrations** - Create OrmLite migrations for your data models
|
|
11
|
+
- 🎨 **UI Components** - Generate Vue.js admin UI components
|
|
12
|
+
- 👀 **Watch Mode** - Auto-regenerate C# files when TypeScript models change
|
|
13
|
+
- 🔌 **Multiple LLM Support** - Use up to 5 different LLM models simultaneously
|
|
14
|
+
- 🔄 **Schema Conversion** - Convert existing database schemas to TypeScript models
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g okai
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- Node.js >= 24.0.0
|
|
25
|
+
- A ServiceStack application with a `.sln` or `.slnx` file
|
|
26
|
+
- ServiceStack project structure with ServiceModel directory
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
### 1. Navigate to your ServiceStack project
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd /path/to/app
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Generate APIs from a prompt
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
okai "Create a blog system with posts, comments, and tags"
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This will:
|
|
43
|
+
1. Generate TypeScript data models (`.d.ts` file)
|
|
44
|
+
2. Create C# API DTOs and AutoQuery services
|
|
45
|
+
3. Generate database migrations
|
|
46
|
+
4. Create Vue.js admin UI components
|
|
47
|
+
5. Show an interactive preview where you can review and accept the changes
|
|
48
|
+
|
|
49
|
+
### 3. Regenerate C# files from TypeScript models
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
okai Blog.d.ts
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 4. Watch mode for continuous regeneration
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
okai Blog.d.ts --watch
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Usage
|
|
62
|
+
|
|
63
|
+
### Generate from Natural Language Prompt
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
okai <prompt>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**Options:**
|
|
70
|
+
- `-m, --models <model,model,...>` - Specify up to 5 LLM models to use
|
|
71
|
+
- `-l, --license <LC-xxx>` - Provide ServiceStack license for premium models
|
|
72
|
+
- `-v, --verbose` - Display verbose logging
|
|
73
|
+
|
|
74
|
+
**Example:**
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
okai "Create a job board with companies, jobs, and applicants"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
okai "Create an e-commerce system" --models gpt-4,claude-3-opus
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Regenerate C# Files
|
|
85
|
+
|
|
86
|
+
Regenerate C# APIs, migrations, and UI from an existing TypeScript definition file:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
okai <models>.d.ts
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Options:**
|
|
93
|
+
- `-w, --watch` - Watch for changes and auto-regenerate
|
|
94
|
+
|
|
95
|
+
**Example:**
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
okai Blog.d.ts
|
|
99
|
+
okai Blog.d.ts --watch
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Remove Generated Files
|
|
103
|
+
|
|
104
|
+
Remove a TypeScript model file and all its generated C# files:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
okai rm <models>.d.ts
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Example:**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
okai rm Blog.d.ts
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### List Available Models
|
|
117
|
+
|
|
118
|
+
Display available premium LLM models:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
okai ls models
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Initialize Configuration
|
|
125
|
+
|
|
126
|
+
Create an `okai.json` configuration file with your project structure:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
okai init
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
This auto-detects your ServiceStack project structure and creates a config file you can customize.
|
|
133
|
+
|
|
134
|
+
### Create Empty Model File
|
|
135
|
+
|
|
136
|
+
Create an empty TypeScript definition file for a specific model:
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
okai init <model>
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Example:**
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
okai init Blog
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Convert Database Schema
|
|
149
|
+
|
|
150
|
+
Convert .NET RDBMS table definitions to TypeScript data models:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
okai convert <schema.json>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Display Project Info
|
|
157
|
+
|
|
158
|
+
Show detected project information:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
okai info
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Chat with OpenAI
|
|
165
|
+
|
|
166
|
+
Submit a chat request to OpenAI:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
okai chat <prompt>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Options:**
|
|
173
|
+
- `--system <prompt>` - Specify a system prompt
|
|
174
|
+
|
|
175
|
+
**Example:**
|
|
176
|
+
|
|
177
|
+
```bash
|
|
178
|
+
okai chat "Explain AutoQuery" --system "You are a ServiceStack expert"
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## Environment Variables
|
|
182
|
+
|
|
183
|
+
Configure okai behavior using environment variables:
|
|
184
|
+
|
|
185
|
+
- `OKAI_URL` - Base URL for the okai service (default: `https://okai.servicestack.com`)
|
|
186
|
+
- `OKAI_MODELS` - Default LLM models to use (comma-separated)
|
|
187
|
+
- `SERVICESTACK_LICENSE` - Your ServiceStack license key for premium models
|
|
188
|
+
|
|
189
|
+
**Example:**
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
export OKAI_MODELS="gpt-4,claude-3-opus"
|
|
193
|
+
export SERVICESTACK_LICENSE="..."
|
|
194
|
+
okai "Create a booking system"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Configuration File
|
|
198
|
+
|
|
199
|
+
The `okai.json` file allows you to customize project paths:
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{
|
|
203
|
+
"projectName": "MyApp",
|
|
204
|
+
"slnDir": "/path/to/solution",
|
|
205
|
+
"hostDir": "/path/to/MyApp",
|
|
206
|
+
"migrationsDir": "/path/to/MyApp/Migrations",
|
|
207
|
+
"serviceModelDir": "/path/to/MyApp.ServiceModel",
|
|
208
|
+
"serviceInterfaceDir": "/path/to/MyApp.ServiceInterfaces",
|
|
209
|
+
"uiMjsDir": "/path/to/MyApp/wwwroot/admin/sections",
|
|
210
|
+
"userType": "ApplicationUser",
|
|
211
|
+
"userIdType": "string",
|
|
212
|
+
"userLabel": "DisplayName"
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Generate this file automatically with:
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
okai init
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## TypeScript Data Model Format
|
|
223
|
+
|
|
224
|
+
Define your data models in TypeScript with special annotations:
|
|
225
|
+
|
|
226
|
+
```typescript
|
|
227
|
+
/*prompt: Create a blog system
|
|
228
|
+
api: ~/MyApp.ServiceModel/Blog.cs
|
|
229
|
+
migration: ~/MyApp/Migrations/Migration1001.cs
|
|
230
|
+
ui: ~/MyApp/wwwroot/admin/sections/Blog.mjs
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
export enum PostStatus {
|
|
234
|
+
Draft = "Draft",
|
|
235
|
+
Published = "Published",
|
|
236
|
+
Archived = "Archived"
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export class BlogPost {
|
|
240
|
+
id: number
|
|
241
|
+
title: string
|
|
242
|
+
slug: string
|
|
243
|
+
content: string
|
|
244
|
+
status: PostStatus
|
|
245
|
+
authorId: string
|
|
246
|
+
publishedAt?: Date
|
|
247
|
+
createdAt: Date
|
|
248
|
+
updatedAt: Date
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export class Comment {
|
|
252
|
+
id: number
|
|
253
|
+
postId: number
|
|
254
|
+
authorId: string
|
|
255
|
+
content: string
|
|
256
|
+
createdAt: Date
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export class Tag {
|
|
260
|
+
id: number
|
|
261
|
+
name: string
|
|
262
|
+
slug: string
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export class PostTag {
|
|
266
|
+
id: number
|
|
267
|
+
postId: number
|
|
268
|
+
tagId: number
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Header Comments
|
|
273
|
+
|
|
274
|
+
The header comment specifies where generated files should be saved:
|
|
275
|
+
|
|
276
|
+
- `prompt:` - The original prompt used to generate the models
|
|
277
|
+
- `api:` - Path to the generated C# API file
|
|
278
|
+
- `migration:` - Path to the generated migration file
|
|
279
|
+
- `ui:` - Path to the generated UI component file
|
|
280
|
+
|
|
281
|
+
Paths starting with `~/` are relative to the detected project directories.
|
|
282
|
+
|
|
283
|
+
## Generated Files
|
|
284
|
+
|
|
285
|
+
For each TypeScript model file, okai generates:
|
|
286
|
+
|
|
287
|
+
### 1. C# API DTOs and Services
|
|
288
|
+
|
|
289
|
+
AutoQuery CRUD APIs with proper attributes and validation:
|
|
290
|
+
|
|
291
|
+
```csharp
|
|
292
|
+
[Tag("Blog")]
|
|
293
|
+
public class QueryBlogPosts : QueryDb<BlogPost> {}
|
|
294
|
+
|
|
295
|
+
[Tag("Blog")]
|
|
296
|
+
public class CreateBlogPost : ICreateDb<BlogPost>, IReturn<IdResponse>
|
|
297
|
+
{
|
|
298
|
+
public string Title { get; set; }
|
|
299
|
+
public string Content { get; set; }
|
|
300
|
+
// ...
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### 2. Database Migrations
|
|
305
|
+
|
|
306
|
+
OrmLite migrations for creating tables:
|
|
307
|
+
|
|
308
|
+
```csharp
|
|
309
|
+
public class Migration1001 : MigrationBase
|
|
310
|
+
{
|
|
311
|
+
public override void Up()
|
|
312
|
+
{
|
|
313
|
+
Db.CreateTable<BlogPost>();
|
|
314
|
+
Db.CreateTable<Comment>();
|
|
315
|
+
// ...
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
public override void Down()
|
|
319
|
+
{
|
|
320
|
+
Db.DropTable<PostTag>();
|
|
321
|
+
Db.DropTable<Tag>();
|
|
322
|
+
// ...
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### 3. Vue.js Admin UI Components
|
|
328
|
+
|
|
329
|
+
AutoQueryGrid components for admin interface:
|
|
330
|
+
|
|
331
|
+
```javascript
|
|
332
|
+
export default {
|
|
333
|
+
group: "Blog",
|
|
334
|
+
items: {
|
|
335
|
+
BlogPosts: {
|
|
336
|
+
type: 'BlogPost',
|
|
337
|
+
component: {
|
|
338
|
+
template: `
|
|
339
|
+
<AutoQueryGrid :type="type"
|
|
340
|
+
selected-columns="id,title,status,authorId,publishedAt" />
|
|
341
|
+
`,
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
// ...
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Workflow
|
|
350
|
+
|
|
351
|
+
### Typical Development Flow
|
|
352
|
+
|
|
353
|
+
1. **Generate from prompt:**
|
|
354
|
+
```bash
|
|
355
|
+
okai "Create a task management system with projects, tasks, and assignments"
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
2. **Review the generated TypeScript models** in the interactive preview
|
|
359
|
+
|
|
360
|
+
3. **Accept the changes** by pressing `a` in the preview
|
|
361
|
+
|
|
362
|
+
4. **Edit the TypeScript models** if needed (add validations, change types, etc.)
|
|
363
|
+
|
|
364
|
+
5. **Regenerate C# files:**
|
|
365
|
+
```bash
|
|
366
|
+
okai tasks.d.ts
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
6. **Use watch mode during development:**
|
|
370
|
+
```bash
|
|
371
|
+
okai tasks.d.ts --watch
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
7. **Run migrations** in your ServiceStack app to create the database tables
|
|
375
|
+
|
|
376
|
+
8. **Access the admin UI** to manage your data
|
|
377
|
+
|
|
378
|
+
### Iterative Refinement
|
|
379
|
+
|
|
380
|
+
You can edit the `.d.ts` file and regenerate as many times as needed:
|
|
381
|
+
|
|
382
|
+
```bash
|
|
383
|
+
# Edit tasks.d.ts to add new properties or models
|
|
384
|
+
vim tasks.d.ts
|
|
385
|
+
|
|
386
|
+
# Regenerate all C# files
|
|
387
|
+
okai tasks.d.ts
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
## Examples
|
|
391
|
+
|
|
392
|
+
### E-Commerce System
|
|
393
|
+
|
|
394
|
+
```bash
|
|
395
|
+
okai "Create an e-commerce system with products, categories, orders, and customers"
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
### Booking System
|
|
399
|
+
|
|
400
|
+
```bash
|
|
401
|
+
okai "Create a booking system with services, time slots, bookings, and customers"
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Job Board
|
|
405
|
+
|
|
406
|
+
```bash
|
|
407
|
+
okai "Create a job board with companies, job listings, applications, and interviews"
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### CRM System
|
|
411
|
+
|
|
412
|
+
```bash
|
|
413
|
+
okai "Create a CRM with contacts, companies, deals, and activities"
|
|
414
|
+
```
|
|
415
|
+
|
|
416
|
+
### Inventory Management
|
|
417
|
+
|
|
418
|
+
```bash
|
|
419
|
+
okai "Create an inventory system with warehouses, products, stock levels, and transfers"
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
## Tips
|
|
423
|
+
|
|
424
|
+
### Use Specific Prompts
|
|
425
|
+
|
|
426
|
+
The more specific your prompt, the better the results:
|
|
427
|
+
|
|
428
|
+
❌ **Too vague:**
|
|
429
|
+
```bash
|
|
430
|
+
okai "Create a blog"
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
✅ **Better:**
|
|
434
|
+
```bash
|
|
435
|
+
okai "Create a blog system with posts, comments, tags, categories, and authors. Posts should have status (draft/published), featured images, and SEO metadata"
|
|
436
|
+
```
|
|
437
|
+
|
|
438
|
+
### Leverage Multiple Models
|
|
439
|
+
|
|
440
|
+
Use multiple LLM models to get the best results:
|
|
441
|
+
|
|
442
|
+
```bash
|
|
443
|
+
okai "Create a social network" --models gpt-4,claude-3-opus,gemini-pro
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
The tool will use consensus from multiple models to generate better data structures.
|
|
447
|
+
|
|
448
|
+
### Customize Generated Code
|
|
449
|
+
|
|
450
|
+
After generation, you can:
|
|
451
|
+
- Edit the TypeScript models to add custom properties
|
|
452
|
+
- Add TypeScript decorators for validation
|
|
453
|
+
- Modify relationships between models
|
|
454
|
+
- Then regenerate the C# code with `okai <file>.d.ts`
|
|
455
|
+
|
|
456
|
+
### Watch Mode for Rapid Development
|
|
457
|
+
|
|
458
|
+
Use watch mode while developing:
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
okai Blog.d.ts --watch
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Now every time you save `Blog.d.ts`, the C# files are automatically regenerated.
|
|
465
|
+
|
|
466
|
+
## Troubleshooting
|
|
467
|
+
|
|
468
|
+
### "No .sln or .slnx file found"
|
|
469
|
+
|
|
470
|
+
Make sure you're running okai from within a ServiceStack project directory. Alternatively, create an `okai.json` config file:
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
okai init
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
### "Could not find ServiceModel directory"
|
|
477
|
+
|
|
478
|
+
Ensure your ServiceStack project has a `ServiceModel` project. You can override the path in `okai.json`:
|
|
479
|
+
|
|
480
|
+
```json
|
|
481
|
+
{
|
|
482
|
+
"serviceModelDir": "/custom/path/to/ServiceModel"
|
|
483
|
+
}
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### SSL Errors
|
|
487
|
+
|
|
488
|
+
If you encounter SSL certificate errors:
|
|
489
|
+
|
|
490
|
+
```bash
|
|
491
|
+
okai "your prompt" --ignore-ssl-errors
|
|
492
|
+
```
|
|
493
|
+
|
|
494
|
+
## Links
|
|
495
|
+
|
|
496
|
+
- [ServiceStack](https://servicestack.net)
|
|
497
|
+
- [ServiceStack Docs](https://docs.servicestack.net)
|
|
498
|
+
- [Support Forums](https://forums.servicestack.net)
|
|
499
|
+
- [GitHub Repository](https://github.com/ServiceStack/okai)
|
|
500
|
+
|
package/bin/okai.js
ADDED
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { GistFile, TableDefinition } from "./types";
|
|
2
|
+
import { ParseResult } from "./ts-parser.js";
|
|
3
|
+
export declare function getFileContent(file: GistFile): string;
|
|
4
|
+
export declare function convertDefinitionsToAst(definitions: TableDefinition[]): ParseResult;
|
|
5
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAA+B,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAGzE,wBAAgB,cAAc,CAAC,IAAI,EAAC,QAAQ,UAE3C;AA2GD,wBAAgB,uBAAuB,CAAC,WAAW,EAAC,eAAe,EAAE,eAqCpE"}
|
package/dist/client.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE/E,MAAM,UAAU,cAAc,CAAC,IAAa;IACxC,OAAO,IAAI,CAAC,OAAO,CAAA;AACvB,CAAC;AAED,MAAM,SAAS,GAAG;IACd,SAAS,EAAE;QACP,KAAK,EAAO,MAAM;QAClB,KAAK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AK,EAAE,CAAC;oBACV,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;wBACpB,GAAG,CAAC,WAAW,GAAG,CAAC,EAAC,IAAI,EAAC,eAAe,EAAC,CAAC,CAAA;oBAC9C,CAAC;yBAAM,CAAC;wBACJ,GAAG,CAAC,WAAW,GAAG,CAAC,EAAC,IAAI,EAAC,YAAY,EAAC,CAAC,CAAA;oBAC3C,CAAC;gBACL,CAAC;gBACD,OAAO,GAAG,CAAA;YACd,CAAC,CAAC;SACL,CAAA;QACD,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAED,OAAO,CAAC,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MetadataTypes, MetadataOperationType } from "./types";
|
|
2
|
+
import { CSharpGenerator } from "./cs-gen.js";
|
|
3
|
+
export declare class CSharpApiGenerator extends CSharpGenerator {
|
|
4
|
+
toApiClass(op: MetadataOperationType): string;
|
|
5
|
+
generate(ast: MetadataTypes): {
|
|
6
|
+
[x: string]: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export declare function toCSharpApis(csAst: MetadataTypes): string;
|
|
10
|
+
//# sourceMappingURL=cs-apis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cs-apis.d.ts","sourceRoot":"","sources":["../src/cs-apis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAoB,qBAAqB,EAAqB,MAAM,SAAS,CAAA;AAExG,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,qBAAa,kBAAmB,SAAQ,eAAe;IAEnD,UAAU,CAAC,EAAE,EAAC,qBAAqB;IAsFnC,QAAQ,CAAC,GAAG,EAAC,aAAa;;;CA8C7B;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAC,aAAa,UAI/C"}
|
package/dist/cs-apis.js
CHANGED
|
@@ -64,7 +64,7 @@ export class CSharpApiGenerator extends CSharpGenerator {
|
|
|
64
64
|
this.addNamespace(prop.namespace);
|
|
65
65
|
if (prop.description && !hasPropAttr('ApiMember')) {
|
|
66
66
|
if (!prop.description.includes('\n')) {
|
|
67
|
-
attrs.push({ name: 'ApiMember', args: [{ name: 'Description', type: 'string', value: prop.description
|
|
67
|
+
attrs.push({ name: 'ApiMember', args: [{ name: 'Description', type: 'string', value: prop.description }] });
|
|
68
68
|
}
|
|
69
69
|
else {
|
|
70
70
|
sb.push(` [ApiMember(Description=\n` +
|
|
@@ -127,3 +127,4 @@ export function toCSharpApis(csAst) {
|
|
|
127
127
|
const cs = csFiles[Object.keys(csFiles)[0]];
|
|
128
128
|
return cs;
|
|
129
129
|
}
|
|
130
|
+
//# sourceMappingURL=cs-apis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cs-apis.js","sourceRoot":"","sources":["../src/cs-apis.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAa,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,MAAM,OAAO,kBAAmB,SAAQ,eAAe;IAEnD,UAAU,CAAC,EAAwB;QAC/B,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAA;QACtB,MAAM,EAAE,GAAY,EAAE,CAAA;QACtB,IAAI,MAAM,GAAG,gBAAgB,GAAG,CAAC,IAAI,EAAE,CAAA;QACvC,IAAI,UAAU,GAAG,KAAK,CAAA;QACtB,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;YACf,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YACzC,MAAM,IAAI,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAA;YAC9C,UAAU,GAAG,IAAI,CAAA;QACrB,CAAC;QACD,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,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ataType, MetadataTypes, MetadataAttribute, MetadataTypeName } from "./types";
|
|
2
|
+
import { ParsedAnnotation, ParsedClass, ParsedEnum, ParseResult } from "./ts-parser.js";
|
|
3
|
+
export declare class CSharpAst {
|
|
4
|
+
typeMap: {
|
|
5
|
+
[js: string]: MetadataTypeName;
|
|
6
|
+
};
|
|
7
|
+
decimalTypeProps: string[];
|
|
8
|
+
valueTypes: string[];
|
|
9
|
+
integerTypes: string[];
|
|
10
|
+
commonValueTypes: string[];
|
|
11
|
+
requestAttrs: string[];
|
|
12
|
+
modelAttrs: string[];
|
|
13
|
+
requestPropAttrs: string[];
|
|
14
|
+
get requestPropAttrsWithoutValidators(): string[];
|
|
15
|
+
modelPropAttrs: string[];
|
|
16
|
+
targetOnlyAttrs: string[];
|
|
17
|
+
ignoreCreateProps: string[];
|
|
18
|
+
ignoreUpdateProps: string[];
|
|
19
|
+
ignoreUpdateValidators: string[];
|
|
20
|
+
ignoreReadValidators: string[];
|
|
21
|
+
ignoreDeleteValidators: string[];
|
|
22
|
+
ignoreApisFor: string[];
|
|
23
|
+
isEnum(type: string): true | MetadataType;
|
|
24
|
+
isValueType(type: string): true | MetadataType;
|
|
25
|
+
ast: ParseResult;
|
|
26
|
+
result: MetadataTypes;
|
|
27
|
+
toCsName(tsName: string): string;
|
|
28
|
+
csharpType(type: string, propName?: string): MetadataTypeName;
|
|
29
|
+
csharpAttribute(attr: ParsedAnnotation): MetadataAttribute;
|
|
30
|
+
addMetadataType(cls: ParsedClass): MetadataType;
|
|
31
|
+
addMetadataEnum(e: ParsedEnum): MetadataType;
|
|
32
|
+
get classes(): MetadataType[];
|
|
33
|
+
get typesWithPrimaryKeys(): MetadataType[];
|
|
34
|
+
get typesWithReferences(): MetadataType[];
|
|
35
|
+
onlyAttrs(attrs: MetadataAttribute[] | null | undefined, only: string[]): MetadataAttribute[];
|
|
36
|
+
attrsFor(dtoType: "Read" | "Create" | "Update" | "Delete" | "Model", attrType: "Type" | "Prop", attrs?: MetadataAttribute[]): MetadataAttribute[];
|
|
37
|
+
createAutoCrudApis(): MetadataTypes;
|
|
38
|
+
filterModelAttributes(): void;
|
|
39
|
+
parseTypes(): void;
|
|
40
|
+
parse(ast: ParseResult): MetadataTypes;
|
|
41
|
+
}
|
|
42
|
+
export type Transform = (gen: CSharpAst) => void;
|
|
43
|
+
export declare const Transforms: {
|
|
44
|
+
Default: (typeof convertReferenceTypes)[];
|
|
45
|
+
};
|
|
46
|
+
export declare function toMetadataTypes(ast: ParseResult, transforms?: Transform[]): MetadataTypes;
|
|
47
|
+
export declare function unwrap(type: string): string;
|
|
48
|
+
export declare function nullable(type: string): string;
|
|
49
|
+
export declare function replaceReference(gen: CSharpAst, fromType: string, toType: string): void;
|
|
50
|
+
export declare function replaceReferences(gen: CSharpAst, references: string[]): void;
|
|
51
|
+
export declare function replaceIds(gen: CSharpAst): void;
|
|
52
|
+
export declare function removeEmptyAttributes(gen: CSharpAst): void;
|
|
53
|
+
export declare function convertReferenceTypes(gen: CSharpAst): void;
|
|
54
|
+
export declare function convertArrayReferenceTypes(gen: CSharpAst): void;
|
|
55
|
+
export declare function convertArraysToLists(gen: CSharpAst): void;
|
|
56
|
+
export declare function addMissingReferencesToForeignKeyProps(gen: CSharpAst): void;
|
|
57
|
+
export declare function addAutoIncrementAttrs(gen: CSharpAst): void;
|
|
58
|
+
export declare function addIconsToKnownTypes(gen: CSharpAst): void;
|
|
59
|
+
export declare function hideReferenceProperties(gen: CSharpAst): void;
|
|
60
|
+
export declare function replaceUserReferencesWithAuditTables(gen: CSharpAst): void;
|
|
61
|
+
export declare function isDataModel(type: MetadataType): boolean;
|
|
62
|
+
//# sourceMappingURL=cs-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cs-ast.d.ts","sourceRoot":"","sources":["../src/cs-ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACc,YAAY,EAAE,aAAa,EACjD,iBAAiB,EAAE,gBAAgB,EACtC,MAAM,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@@ -1143,3 +1143,4 @@ export function isDataModel(type) {
|
|
|
1143
1143
|
return (!type.inherits || !type.inherits.name.startsWith("Query"))
|
|
1144
1144
|
&& (!type.implements || !type.implements.some(x => apiInterfacePrefixes.some(prefix => x.name.startsWith(prefix))));
|
|
1145
1145
|
}
|
|
1146
|
+
//# sourceMappingURL=cs-ast.js.map
|