@skmtc/core 0.0.829 โ†’ 0.0.831

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.
Files changed (2) hide show
  1. package/README.md +90 -63
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,89 +1,116 @@
1
- [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
2
- [![Deno](https://img.shields.io/badge/Deno-2.5+-green.svg)](https://deno.land/)
3
- [![Discord](https://img.shields.io/badge/Discord-join%20chat-1dce73.svg)](https://discord.com/invite/Mg88C8Xu5Y)
4
-
5
1
  <p align="center">
6
- <img src="https://raw.githubusercontent.com/skmtc/skmtc/refs/heads/main/skmtc.svg" />
2
+ <img src="./skmtc.svg" />
7
3
  </p>
8
4
 
9
- ## Problems We Solve
10
-
11
- **Stop writing the same code over and over.** Generate TypeScript types, API clients, validation schemas, and more directly from your OpenAPI specifications.
5
+ **Skmtc is a declarative code generation framework**. It lets you generate TypeScript code from OpenAPI schemas using string templates.
12
6
 
13
- ### Manual Type Definitions
14
- **Pain:** Hours spent manually writing TypeScript interfaces from OpenAPI docs, fighting typos and sync issues.
15
- **Solution:** Generate accurate types with perfect synchronization.
7
+ ## โœจ Features
16
8
 
17
- ### Schema Evolution Management
18
- **Pain:** API changes break frontend types, validation, mocks, and docs across dozens of files.
19
- **Solution:** Single regeneration command updates all artifacts simultaneously.
9
+ - ๐ŸŽ๏ธ **Fast** - Generates 550k+ tokens per second
10
+ - ๐Ÿงต **Easy to edit code generators** - Outputs specified using string templates, not ASTs
11
+ - ๐Ÿฅž **Stackable generators** - Compose complex functionality by combining generators
12
+ - ๐Ÿ—„๏ธ **Use your own code conventions** - Full control over naming and file structure
20
13
 
21
- ### Type-Unsafe Runtime API Integration
22
- **Pain:** No compile-time guarantees that API calls match backend schemas.
23
- **Solution:** End-to-end type safety from schema through clients to UI components.
14
+ ## ๐Ÿš€ Quick Start
24
15
 
25
- ## Quick Start
16
+ ```bash
17
+ # Run directly with npx
18
+ npx skmtc
26
19
 
27
- **Learning Outcome:** Generate TypeScript types from an OpenAPI schema in 5 minutes.
20
+ ```
28
21
 
29
- ### Install
22
+ ### Running code generators
30
23
 
31
24
  ```bash
32
- # Import in your Deno project
33
- import { toArtifacts } from "jsr:@skmtc/core"
25
+ npx skmtc generate @skmtc/supabase-backend https://petstore3.swagger.io/api/v3/openapi.json
26
+ # Generated 9 files (507 lines, 3,383 tokens) in 9ms
27
+
28
+ npx skmtc generate @skmtc/supabase-react-client https://raw.githubusercontent.com/cloudflare/api-schemas/refs/heads/main/openapi.json
29
+ # Generated 6,797 files (104,752 lines, 1,635,227 tokens) in 2,969ms
34
30
  ```
35
31
 
36
- ### Generate Types
32
+ ### Example generator code
37
33
 
38
34
  ```typescript
39
- import { toArtifacts } from "@skmtc/core"
40
- import typescriptGenerator from "@skmtc/gen-typescript"
41
-
42
- // Your OpenAPI v3 schema
43
- const schema = {
44
- openapi: "3.0.0",
45
- info: { title: "API", version: "1.0.0" },
46
- components: {
47
- schemas: {
48
- User: {
49
- type: "object",
50
- properties: {
51
- id: { type: "string" },
52
- name: { type: "string" }
53
- }
54
- }
55
- }
35
+ import { ZodInsertable } from '@skmtc/gen-zod'
36
+
37
+ class ZodFetch extends BaseTransformer {
38
+ zodName: string;
39
+
40
+ constructor({context, operation, settings}){
41
+ super({context, operation, settings})
42
+
43
+ // Generate Zod schema for API response and insert it into current file
44
+ const response = operation.toSuccessResponse()?.resolve().toSchema()
45
+ const zodResponse = this.insert(ZodInsertable, response)
46
+
47
+ // Grab Zod schema name to use in output code
48
+ this.zodName = zodResponse.identifier.name
56
49
  }
57
- }
58
50
 
59
- // Generate TypeScript types
60
- const artifacts = await toArtifacts({
61
- schema,
62
- generators: [typescriptGenerator]
63
- })
51
+ // Define code output
52
+ toString(){
53
+ return `() => {
54
+ const res = await fetch('${this.operation.path}')
55
+ const data = await res.json()
64
56
 
65
- // Write generated files
66
- for (const [path, content] of artifacts) {
67
- await Deno.writeTextFile(path, content)
57
+ return ${zodName}.parse(data)
58
+ }`
59
+ }
68
60
  }
69
61
  ```
70
62
 
71
- ### Result
63
+ ## ๐Ÿ“ฆ Available Generators
72
64
 
73
- ```typescript
74
- // @/types/user.generated.ts
75
- export interface User {
76
- id?: string
77
- name?: string
78
- }
79
- ```
65
+ Choose from our growing collection of generators, combone them or create your own:
80
66
 
81
- ## What's Next
67
+ - **Tanstack Query** - React Query hooks with Zod validation
68
+ - **MSW** - Mock Service Worker handlers from OpenAPI examples
69
+ - **Zod Schemas** - Runtime validation schemas
70
+ - **TypeScript Types** - Pure type definitions
71
+ - **Supabase/Hono Functions** - Edge function handlers
72
+ - See full list at https://github.com/skmtc/skmtc-generators
82
73
 
83
- - **[Getting Started โ†’](docs/getting-started/installation.md)** - Complete setup guide
84
- - **[How-To Guides โ†’](docs/how-to/)** - Task-oriented tutorials
85
- - **[API Reference โ†’](docs/api/)** - Complete technical documentation
74
+ ## โ“ FAQ
86
75
 
87
- ## License
76
+ ### **What OpenAPI versions are supported?**
77
+ Skmtc supports OpenAPI v3.0. Swagger 2.0 and OpenAPI v3.1 are automatically converted to OpenAPI v3.0.
88
78
 
89
- [Apache-2.0](LICENSE)
79
+ ### **Can I customize the generated code?**
80
+ Yes! Each Transformer specifies its output using plain string templates, which means you can
81
+ edit them as would you edit any other code.
82
+
83
+ ### **Can I use this with my existing React app?**
84
+ Yes! Skmtc generates standalone code that integrates with any React application. The generated components work with your existing setup.
85
+
86
+ ### **How does this compare to OpenAPI Generator?**
87
+ Skmtc is the only code generation framework that provides full control over the generated code. You are not limited by library-specific settings and you do not need to write complex AST code.
88
+
89
+ ### **Does it work with Next.js/Remix/Vite?**
90
+ Yes! The generated code is framework-agnostic TypeScript that works with any build tool or library.
91
+
92
+ ## ๐Ÿค Contributing
93
+
94
+ We welcome contributions! Check out our [Contributing Guide](CONTRIBUTING.md) to get started.
95
+
96
+ <!-- ## ๐Ÿ“š Documentation
97
+
98
+ - [Full Documentation](https://docs.skmtc.dev)
99
+ - [API Reference](https://docs.skmtc.dev/api)
100
+ - [Custom Generators Guide](https://docs.skmtc.dev/generators)
101
+ - [Examples](https://github.com/skmtc/skmtc/tree/main/examples) -->
102
+
103
+ ## ๐Ÿ›Ÿ Support
104
+
105
+ - [GitHub Issues](https://github.com/skmtc/skmtc/issues) - Bug reports and feature requests
106
+ - [Discord Community](https://discord.com/invite/Mg88C8Xu5Y) - Get help and share your experience
107
+
108
+ ## ๐Ÿ“„ License
109
+
110
+ Apache 2.0 ยฉ [Skmtc Contributors](LICENSE.md)
111
+
112
+ ---
113
+
114
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
115
+ [![Deno](https://img.shields.io/badge/Deno-2.5+-green.svg)](https://deno.land/)
116
+ [![Discord](https://img.shields.io/badge/Discord-join%20chat-1dce73.svg)](https://discord.com/invite/Mg88C8Xu5Y)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.829",
3
+ "version": "0.0.831",
4
4
  "description": "Skmtc is a declarative code generation framework",
5
5
  "keywords": [
6
6
  "openapi",