s4kit 0.1.10 → 0.1.11

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 +56 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -64,28 +64,78 @@ The platform handles CSRF tokens, authentication, and connection pooling — you
64
64
 
65
65
  ---
66
66
 
67
- ## Type Generation
67
+ ## Type Generation (Recommended)
68
68
 
69
- Generate TypeScript types from your SAP system for full autocomplete and type safety:
69
+ > **This is the key feature of S4Kit.** Generate TypeScript types directly from your SAP system's OData metadata for full autocomplete and compile-time type safety.
70
+
71
+ ### Why Generate Types?
72
+
73
+ Without types, the SDK works but you lose the main benefit - type safety:
74
+ ```typescript
75
+ // Without types - works but no autocomplete, no type checking
76
+ const partners = await client.A_BusinessPartner.list(); // partners is any[]
77
+ ```
78
+
79
+ With generated types:
80
+ ```typescript
81
+ // With types - full IDE support and compile-time validation
82
+ const partners = await client.A_BusinessPartner.list({
83
+ select: ['BusinessPartner', 'BusinessPartnerName'], // ← Autocomplete!
84
+ });
85
+ partners.forEach(p => console.log(p.BusinessPartnerName)); // ← Type-safe!
86
+ ```
87
+
88
+ ### Generating Types
70
89
 
71
90
  ```bash
72
- npx s4kit generate-types --api-key sk_live_... --base-url https://staging.proxy.s4kit.com/api/proxy --output ./types
91
+ # Basic usage
92
+ npx s4kit generate-types --api-key sk_live_... --output ./types
93
+
94
+ # With all options
95
+ npx s4kit generate-types \
96
+ --api-key sk_live_... # Required
97
+ --output ./types # Output directory (default: ./s4kit-types)
98
+ --base-url https://staging.proxy.s4kit.com/api/proxy # Custom proxy URL
99
+ --connection my-sap-system # Specific connection only
73
100
  ```
74
101
 
102
+ ### Using Generated Types
103
+
75
104
  ```typescript
76
105
  import { S4Kit } from 's4kit';
77
- import './types'; // Enable type inference
106
+ import './types'; // This enables type inference
78
107
 
79
108
  const client = S4Kit({ apiKey: 'sk_live_...' });
80
109
 
81
110
  // Full autocomplete on entity names and fields
82
111
  const partners = await client.A_BusinessPartner.list({
83
- select: ['BusinessPartner', 'BusinessPartnerName'], // ← Type-safe!
112
+ select: ['BusinessPartner', 'BusinessPartnerName'],
84
113
  filter: { BusinessPartnerCategory: '1' }
85
114
  });
86
115
 
87
116
  // partners is A_BusinessPartner[], not any[]
88
- partners.forEach(p => console.log(p.BusinessPartnerName)); // ← Autocomplete works!
117
+ partners.forEach(p => console.log(p.BusinessPartnerName));
118
+ ```
119
+
120
+ ### What You Get
121
+
122
+ - **Entity autocomplete** - `client.` shows all available entities
123
+ - **Field autocomplete** - `select`, `filter`, `orderBy` show valid fields
124
+ - **Type-safe filters** - operators match field types (string fields get `contains`, number fields get `gt`/`lt`)
125
+ - **Proper return types** - query results are typed, not `any[]`
126
+ - **Navigation properties** - `expand` options show available relations
127
+ - **Compile-time errors** - typos in field names caught before runtime
128
+
129
+ ### Regenerating Types
130
+
131
+ Regenerate types when:
132
+ - You connect a new SAP service
133
+ - The SAP system's schema changes
134
+ - You add new services to your API key
135
+
136
+ ```bash
137
+ # Regenerate all types
138
+ npx s4kit generate-types --api-key sk_live_... --output ./types
89
139
  ```
90
140
 
91
141
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "s4kit",
3
- "version": "0.1.10",
3
+ "version": "0.1.11",
4
4
  "description": "The lightweight, type-safe SDK for SAP S/4HANA",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",