@apollo-deploy/tesseract 1.9.0 → 2.0.0

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 (194) hide show
  1. package/README.md +218 -110
  2. package/dist/adapters/csharp/index.d.ts +5 -8
  3. package/dist/adapters/csharp/index.d.ts.map +1 -1
  4. package/dist/adapters/csharp/index.js +314 -74
  5. package/dist/adapters/csharp/index.js.map +1 -1
  6. package/dist/adapters/documentation.d.ts +17 -0
  7. package/dist/adapters/documentation.d.ts.map +1 -0
  8. package/dist/adapters/documentation.js +268 -0
  9. package/dist/adapters/documentation.js.map +1 -0
  10. package/dist/adapters/go/index.d.ts +5 -8
  11. package/dist/adapters/go/index.d.ts.map +1 -1
  12. package/dist/adapters/go/index.js +197 -101
  13. package/dist/adapters/go/index.js.map +1 -1
  14. package/dist/adapters/kotlin/index.d.ts +5 -9
  15. package/dist/adapters/kotlin/index.d.ts.map +1 -1
  16. package/dist/adapters/kotlin/index.js +280 -212
  17. package/dist/adapters/kotlin/index.js.map +1 -1
  18. package/dist/adapters/php/index.d.ts +5 -15
  19. package/dist/adapters/php/index.d.ts.map +1 -1
  20. package/dist/adapters/php/index.js +362 -90
  21. package/dist/adapters/php/index.js.map +1 -1
  22. package/dist/adapters/python/index.d.ts +5 -8
  23. package/dist/adapters/python/index.d.ts.map +1 -1
  24. package/dist/adapters/python/index.js +240 -109
  25. package/dist/adapters/python/index.js.map +1 -1
  26. package/dist/adapters/ruby/index.d.ts +3 -3
  27. package/dist/adapters/ruby/index.d.ts.map +1 -1
  28. package/dist/adapters/ruby/index.js +235 -46
  29. package/dist/adapters/ruby/index.js.map +1 -1
  30. package/dist/adapters/rust/index.d.ts +5 -9
  31. package/dist/adapters/rust/index.d.ts.map +1 -1
  32. package/dist/adapters/rust/index.js +237 -169
  33. package/dist/adapters/rust/index.js.map +1 -1
  34. package/dist/adapters/shared.d.ts +7 -0
  35. package/dist/adapters/shared.d.ts.map +1 -0
  36. package/dist/adapters/shared.js +68 -0
  37. package/dist/adapters/shared.js.map +1 -0
  38. package/dist/adapters/type-utils.d.ts +13 -0
  39. package/dist/adapters/type-utils.d.ts.map +1 -0
  40. package/dist/adapters/type-utils.js +105 -0
  41. package/dist/adapters/type-utils.js.map +1 -0
  42. package/dist/adapters/types.d.ts.map +1 -1
  43. package/dist/adapters/typescript/emitter/emitSchema.d.ts +2 -2
  44. package/dist/adapters/typescript/emitter/emitSchema.js +39 -27
  45. package/dist/adapters/typescript/emitter/emitSchema.js.map +1 -1
  46. package/dist/adapters/typescript/emitter/emitTypeScriptModels.d.ts +2 -2
  47. package/dist/adapters/typescript/emitter/emitTypeScriptModels.js +15 -15
  48. package/dist/adapters/typescript/emitter/importCollector.d.ts +2 -4
  49. package/dist/adapters/typescript/emitter/importCollector.d.ts.map +1 -1
  50. package/dist/adapters/typescript/emitter/importCollector.js +40 -50
  51. package/dist/adapters/typescript/emitter/importCollector.js.map +1 -1
  52. package/dist/adapters/typescript/emitter/parsers.d.ts +1 -1
  53. package/dist/adapters/typescript/emitter/parsers.js +13 -13
  54. package/dist/adapters/typescript/emitter/typeHoister.d.ts +1 -1
  55. package/dist/adapters/typescript/emitter/typeHoister.d.ts.map +1 -1
  56. package/dist/adapters/typescript/emitter/typeHoister.js +12 -20
  57. package/dist/adapters/typescript/emitter/typeHoister.js.map +1 -1
  58. package/dist/adapters/typescript/index.d.ts +3 -3
  59. package/dist/adapters/typescript/index.d.ts.map +1 -1
  60. package/dist/adapters/typescript/index.js +148 -166
  61. package/dist/adapters/typescript/index.js.map +1 -1
  62. package/dist/adapters/typescript/shared.d.ts +2 -2
  63. package/dist/adapters/typescript/shared.js +12 -12
  64. package/dist/cli.js +50 -37
  65. package/dist/cli.js.map +1 -1
  66. package/dist/collector.d.ts +13 -3
  67. package/dist/collector.d.ts.map +1 -1
  68. package/dist/collector.js +69 -32
  69. package/dist/collector.js.map +1 -1
  70. package/dist/elysia.js +2 -2
  71. package/dist/elysia.js.map +1 -1
  72. package/dist/express.d.ts.map +1 -1
  73. package/dist/express.js.map +1 -1
  74. package/dist/fastify.d.ts +7 -0
  75. package/dist/fastify.d.ts.map +1 -1
  76. package/dist/fastify.js +39 -20
  77. package/dist/fastify.js.map +1 -1
  78. package/dist/helpers/handlebars.d.ts +7 -16
  79. package/dist/helpers/handlebars.d.ts.map +1 -1
  80. package/dist/helpers/handlebars.js +127 -177
  81. package/dist/helpers/handlebars.js.map +1 -1
  82. package/dist/hono.d.ts.map +1 -1
  83. package/dist/hono.js.map +1 -1
  84. package/dist/index.d.ts +14 -12
  85. package/dist/index.d.ts.map +1 -1
  86. package/dist/index.js +32 -30
  87. package/dist/index.js.map +1 -1
  88. package/dist/koa.d.ts.map +1 -1
  89. package/dist/koa.js.map +1 -1
  90. package/dist/nestjs.d.ts.map +1 -1
  91. package/dist/nestjs.js +41 -14
  92. package/dist/nestjs.js.map +1 -1
  93. package/dist/pipeline/enrich.d.ts +2 -13
  94. package/dist/pipeline/enrich.d.ts.map +1 -1
  95. package/dist/pipeline/enrich.js +157 -212
  96. package/dist/pipeline/enrich.js.map +1 -1
  97. package/dist/pipeline/intake.d.ts +3 -3
  98. package/dist/pipeline/intake.d.ts.map +1 -1
  99. package/dist/pipeline/intake.js +342 -238
  100. package/dist/pipeline/intake.js.map +1 -1
  101. package/dist/pipeline/write.d.ts +1 -14
  102. package/dist/pipeline/write.d.ts.map +1 -1
  103. package/dist/pipeline/write.js +73 -113
  104. package/dist/pipeline/write.js.map +1 -1
  105. package/dist/types/config.d.ts +14 -26
  106. package/dist/types/config.d.ts.map +1 -1
  107. package/dist/types/config.js +16 -12
  108. package/dist/types/config.js.map +1 -1
  109. package/dist/types/ir.d.ts +12 -8
  110. package/dist/types/ir.d.ts.map +1 -1
  111. package/dist/types/manifest.d.ts +10 -11
  112. package/dist/types/manifest.d.ts.map +1 -1
  113. package/dist/types/manifest.js +54 -14
  114. package/dist/types/manifest.js.map +1 -1
  115. package/dist/types/sdk-module.d.ts +2 -2
  116. package/dist/types/sdk-module.js +1 -1
  117. package/dist/utils/format.d.ts +1 -3
  118. package/dist/utils/format.d.ts.map +1 -1
  119. package/dist/utils/format.js +3 -10
  120. package/dist/utils/format.js.map +1 -1
  121. package/dist/utils/naming.d.ts.map +1 -1
  122. package/dist/utils/naming.js +174 -184
  123. package/dist/utils/naming.js.map +1 -1
  124. package/dist/utils/npm-token.d.ts +1 -17
  125. package/dist/utils/npm-token.d.ts.map +1 -1
  126. package/dist/utils/npm-token.js +27 -76
  127. package/dist/utils/npm-token.js.map +1 -1
  128. package/dist/utils/version.d.ts +14 -0
  129. package/dist/utils/version.d.ts.map +1 -0
  130. package/dist/utils/version.js +60 -0
  131. package/dist/utils/version.js.map +1 -0
  132. package/package.json +4 -3
  133. package/templates/csharp/client.hbs +26 -49
  134. package/templates/csharp/csproj.hbs +7 -0
  135. package/templates/csharp/domain.hbs +48 -130
  136. package/templates/csharp/errors.hbs +17 -25
  137. package/templates/csharp/readme.hbs +31 -44
  138. package/templates/csharp/transport.hbs +238 -136
  139. package/templates/csharp/types.hbs +30 -76
  140. package/templates/go/client.hbs +44 -109
  141. package/templates/go/domain.hbs +83 -25
  142. package/templates/go/go-mod.hbs +1 -4
  143. package/templates/go/readme.hbs +32 -29
  144. package/templates/go/transport.hbs +174 -173
  145. package/templates/go/types.hbs +17 -53
  146. package/templates/go/utils.hbs +3 -2
  147. package/templates/kotlin/build-gradle.hbs +1 -1
  148. package/templates/kotlin/client.hbs +18 -15
  149. package/templates/kotlin/domain.hbs +54 -51
  150. package/templates/kotlin/errors.hbs +1 -1
  151. package/templates/kotlin/readme.hbs +35 -137
  152. package/templates/kotlin/transport.hbs +140 -123
  153. package/templates/kotlin/types.hbs +30 -81
  154. package/templates/php/client.hbs +8 -46
  155. package/templates/php/composer.hbs +2 -1
  156. package/templates/php/domain.hbs +86 -117
  157. package/templates/php/errors.hbs +1 -1
  158. package/templates/php/readme.hbs +42 -49
  159. package/templates/php/transport.hbs +192 -145
  160. package/templates/php/types.hbs +63 -60
  161. package/templates/python/client.hbs +15 -2
  162. package/templates/python/domain.hbs +50 -108
  163. package/templates/python/pyproject.hbs +5 -0
  164. package/templates/python/readme.hbs +47 -30
  165. package/templates/python/resources-init.hbs +1 -1
  166. package/templates/python/transport.hbs +167 -53
  167. package/templates/python/types.hbs +22 -58
  168. package/templates/ruby/client.hbs +10 -6
  169. package/templates/ruby/domain.hbs +48 -67
  170. package/templates/ruby/errors.hbs +3 -3
  171. package/templates/ruby/gemspec.hbs +3 -10
  172. package/templates/ruby/index.hbs +3 -3
  173. package/templates/ruby/readme.hbs +33 -70
  174. package/templates/ruby/transport.hbs +129 -103
  175. package/templates/ruby/types.hbs +11 -16
  176. package/templates/ruby/version.hbs +1 -1
  177. package/templates/rust/cargo.hbs +2 -0
  178. package/templates/rust/client.hbs +10 -1
  179. package/templates/rust/domain.hbs +69 -52
  180. package/templates/rust/error.hbs +3 -1
  181. package/templates/rust/lib.hbs +4 -5
  182. package/templates/rust/readme.hbs +33 -46
  183. package/templates/rust/transport.hbs +170 -159
  184. package/templates/rust/types.hbs +34 -111
  185. package/templates/typescript/domain-class.hbs +14 -6
  186. package/templates/typescript/domain.hbs +13 -5
  187. package/templates/typescript/package-json.hbs +3 -1
  188. package/templates/typescript/readme.hbs +42 -42
  189. package/templates/typescript/transport.hbs +46 -8
  190. package/templates/typescript/types-errors.hbs +1 -1
  191. package/dist/adapters/typescript/model-emitter.d.ts +0 -13
  192. package/dist/adapters/typescript/model-emitter.d.ts.map +0 -1
  193. package/dist/adapters/typescript/model-emitter.js +0 -415
  194. package/dist/adapters/typescript/model-emitter.js.map +0 -1
@@ -1,93 +1,75 @@
1
1
  package {{pkgName}}
2
2
 
3
3
  import (
4
+ {{#if hasSSE}}
4
5
  "context"
6
+ {{/if}}
5
7
  "time"
6
8
  )
7
9
 
8
- // ── Client Configuration ──────────────────────────────────────────────────
9
-
10
- // ClientConfig holds all configuration for the API client.
10
+ // ClientConfig configures the API client.
11
11
  type ClientConfig struct {
12
- BaseURL string
13
- Timeout time.Duration
14
- MaxRetries int
15
- DefaultHeaders map[string]string
12
+ BaseURL string
13
+ {{#each securitySchemes}}
14
+ {{pascalCase configKey}} string
15
+ {{/each}}
16
+ Timeout time.Duration
17
+ MaxRetries int
18
+ RetryUnsafeRequests bool
19
+ DefaultHeaders map[string]string
16
20
  }
17
21
 
18
- // ClientOption is a functional option for configuring the client.
19
22
  type ClientOption func(*ClientConfig)
20
23
 
21
- // WithBaseURL sets the base URL for all API requests.
22
- func WithBaseURL(url string) ClientOption {
23
- return func(c *ClientConfig) { c.BaseURL = url }
24
+ func WithBaseURL(url string) ClientOption { return func(c *ClientConfig) { c.BaseURL = url } }
25
+ func WithTimeout(timeout time.Duration) ClientOption { return func(c *ClientConfig) { c.Timeout = timeout } }
26
+ func WithMaxRetries(retries int) ClientOption { return func(c *ClientConfig) { c.MaxRetries = retries } }
27
+ func WithUnsafeRetries(enabled bool) ClientOption {
28
+ return func(c *ClientConfig) { c.RetryUnsafeRequests = enabled }
24
29
  }
25
-
26
- // WithTimeout sets the request timeout.
27
- func WithTimeout(d time.Duration) ClientOption {
28
- return func(c *ClientConfig) { c.Timeout = d }
29
- }
30
-
31
- // WithMaxRetries sets the maximum number of retry attempts.
32
- func WithMaxRetries(n int) ClientOption {
33
- return func(c *ClientConfig) { c.MaxRetries = n }
34
- }
35
-
36
- // WithDefaultHeader adds a default header sent with every request.
37
30
  func WithDefaultHeader(key, value string) ClientOption {
38
31
  return func(c *ClientConfig) {
39
- if c.DefaultHeaders == nil {
40
- c.DefaultHeaders = make(map[string]string)
41
- }
32
+ if c.DefaultHeaders == nil { c.DefaultHeaders = make(map[string]string) }
42
33
  c.DefaultHeaders[key] = value
43
34
  }
44
35
  }
36
+ {{#each securitySchemes}}
37
+ func With{{pascalCase configKey}}(value string) ClientOption {
38
+ return func(c *ClientConfig) { c.{{pascalCase configKey}} = value }
39
+ }
40
+ {{/each}}
45
41
 
46
- // DefaultConfig returns a ClientConfig populated with sensible defaults.
47
42
  func DefaultConfig() ClientConfig {
48
43
  return ClientConfig{
49
- BaseURL: "{{baseUrl}}",
50
- Timeout: 15 * time.Second,
51
- MaxRetries: 3,
44
+ BaseURL: "{{baseUrl}}", Timeout: 15 * time.Second, MaxRetries: 3,
52
45
  }
53
46
  }
54
47
 
55
- // ── Client ────────────────────────────────────────────────────────────────
56
-
57
- // Client is the primary API client for {{title}}.
58
- // It is safe for concurrent use by multiple goroutines.
48
+ // Client is safe for concurrent use by multiple goroutines.
59
49
  type Client struct {
60
- config ClientConfig
50
+ config ClientConfig
61
51
  transport *Transport
62
52
  {{#each groups}}
63
53
  {{pascalCase name}} *{{interfaceName}}
64
54
  {{/each}}
65
55
  }
66
56
 
67
- // NewClient creates a new {{title}} API client with the given options.
68
- //
69
- // Example:
70
- //
71
- // client := petshop.NewClient(
72
- // petshop.WithBaseURL("https://api.example.com"),
73
- // petshop.WithTimeout(30*time.Second),
74
- // )
75
- // pets, err := client.Pets.List(ctx, nil)
76
57
  func NewClient(opts ...ClientOption) *Client {
77
58
  cfg := DefaultConfig()
78
- for _, opt := range opts {
79
- opt(&cfg)
80
- }
81
-
59
+ for _, option := range opts { option(&cfg) }
82
60
  t := NewTransport(TransportConfig{
83
- BaseURL: cfg.BaseURL,
84
- Timeout: cfg.Timeout,
61
+ BaseURL: cfg.BaseURL,
62
+ {{#each securitySchemes}}
63
+ {{pascalCase configKey}}: cfg.{{pascalCase configKey}},
64
+ {{/each}}
65
+ Timeout: cfg.Timeout,
85
66
  MaxRetries: cfg.MaxRetries,
86
- Headers: cfg.DefaultHeaders,
67
+ RetryUnsafeRequests: cfg.RetryUnsafeRequests,
68
+ Headers: cfg.DefaultHeaders,
69
+ UserAgent: "{{pkgName}}-go-sdk/{{packageVersion}}",
87
70
  })
88
-
89
71
  return &Client{
90
- config: cfg,
72
+ config: cfg,
91
73
  transport: t,
92
74
  {{#each groups}}
93
75
  {{pascalCase name}}: &{{interfaceName}}{transport: t},
@@ -95,64 +77,17 @@ func NewClient(opts ...ClientOption) *Client {
95
77
  }
96
78
  }
97
79
 
98
- // Transport returns the underlying HTTP transport for advanced use cases.
99
- func (c *Client) Transport() *Transport {
100
- return c.transport
101
- }
80
+ func (c *Client) Transport() *Transport { return c.transport }
81
+ func (c *Client) CloseIdleConnections() { c.transport.CloseIdleConnections() }
102
82
 
103
- // ── Request / Response types ──────────────────────────────────────────────
104
-
105
- // RequestOptions holds per-request overrides.
106
- type RequestOptions struct {
107
- // Timeout overrides the client-level timeout for this request.
108
- Timeout time.Duration
109
- // Headers are additional headers merged into the request.
110
- Headers map[string]string
111
- }
112
-
113
- // ListParams is embedded by list operation parameter types to provide
114
- // common pagination and filtering fields.
115
- type ListParams struct {
116
- Page *int `json:"page,omitempty"`
117
- Limit *int `json:"limit,omitempty"`
118
- }
119
-
120
- // Int returns a pointer to the given int value. Useful for optional
121
- // parameters in request structs.
122
- func Int(v int) *int { return &v }
123
-
124
- // String returns a pointer to the given string value.
125
- func String(v string) *string { return &v }
126
-
127
- // Bool returns a pointer to the given bool value.
128
- func Bool(v bool) *bool { return &v }
83
+ func Int(value int) *int { return &value }
84
+ func String(value string) *string { return &value }
85
+ func Bool(value bool) *bool { return &value }
129
86
 
130
87
  {{#if hasSSE}}
131
- // ── SSE Types ─────────────────────────────────────────────────────────────
132
-
133
- // SSEEvent represents a parsed Server-Sent Event.
134
- type SSEEvent struct {
135
- Event string
136
- Data string
137
- ID string
138
- Retry int
139
- }
140
-
141
- // SSEOption configures an SSE stream subscription.
88
+ type SSEEvent struct { Event, Data, ID string; Retry int }
142
89
  type SSEOption func(*sseConfig)
143
-
144
- type sseConfig struct {
145
- signal context.Context
146
- eventTypes []string
147
- }
148
-
149
- // WithSSESignal sets a context for cancellation of the SSE stream.
150
- func WithSSESignal(ctx context.Context) SSEOption {
151
- return func(c *sseConfig) { c.signal = ctx }
152
- }
153
-
154
- // WithSSEEventTypes filters the stream to specific event types.
155
- func WithSSEEventTypes(types ...string) SSEOption {
156
- return func(c *sseConfig) { c.eventTypes = types }
157
- }
90
+ type sseConfig struct { signal context.Context; eventTypes []string }
91
+ func WithSSESignal(ctx context.Context) SSEOption { return func(c *sseConfig) { c.signal = ctx } }
92
+ func WithSSEEventTypes(types ...string) SSEOption { return func(c *sseConfig) { c.eventTypes = types } }
158
93
  {{/if}}
@@ -4,6 +4,12 @@ import (
4
4
  {{#if hasSSE}}
5
5
  "bufio"
6
6
  "strings"
7
+ {{/if}}
8
+ {{#if needsFormatting}}
9
+ "fmt"
10
+ {{/if}}
11
+ {{#if hasQueryParams}}
12
+ "net/url"
7
13
  {{/if}}
8
14
  "context"
9
15
  )
@@ -15,22 +21,53 @@ type {{interfaceName}} struct {
15
21
 
16
22
  {{#each operations}}
17
23
  {{#if isEventStream}}
18
- func (api *{{../interfaceName}}) {{pascalCase name}}Stream(
24
+ func (api *{{../interfaceName}}) {{pascalCase name}}(
19
25
  ctx context.Context,
20
26
  {{#each pathParams}}
21
- {{name}} string,
27
+ {{name}} {{targetType}},
22
28
  {{/each}}
23
- {{#if queryType}}
24
- params {{goQueryType queryType}},
29
+ {{#if requestBody}}
30
+ body {{requestBody.inputType}},
25
31
  {{/if}}
32
+ {{#each queryParams}}
33
+ {{name}} {{inputType}},
34
+ {{/each}}
35
+ {{#each headerParams}}
36
+ {{name}} {{inputType}},
37
+ {{/each}}
26
38
  ) (<-chan SSEEvent, <-chan error) {
27
39
  eventCh := make(chan SSEEvent)
28
40
  errCh := make(chan error, 1)
29
41
  go func() {
30
42
  defer close(eventCh)
31
43
  defer close(errCh)
32
- reqPath := buildPath("{{path}}"{{#each pathParams}}, "{{originalName}}", {{name}}{{/each}})
33
- resp, err := api.transport.Stream(ctx, request{Method: "{{httpMethod}}", Path: reqPath})
44
+ reqPath := buildPath("{{path}}"{{#each pathParams}}, "{{name}}", {{name}}{{/each}})
45
+ {{#if hasQueryParams}}
46
+ query := url.Values{}
47
+ {{#each queryParams}}
48
+ {{#if required}}
49
+ query.Set("{{originalName}}", fmt.Sprint({{name}}))
50
+ {{else}}
51
+ if {{name}} != nil { query.Set("{{originalName}}", fmt.Sprint(*{{name}})) }
52
+ {{/if}}
53
+ {{/each}}
54
+ {{/if}}
55
+ {{#if hasHeaderParams}}
56
+ headers := map[string]string{}
57
+ {{#each headerParams}}
58
+ {{#if required}}
59
+ headers["{{originalName}}"] = fmt.Sprint({{name}})
60
+ {{else}}
61
+ if {{name}} != nil { headers["{{originalName}}"] = fmt.Sprint(*{{name}}) }
62
+ {{/if}}
63
+ {{/each}}
64
+ {{/if}}
65
+ resp, err := api.transport.Stream(ctx, request{
66
+ Method: "{{httpMethod}}", Path: reqPath,
67
+ {{#if hasQueryParams}} Query: query,{{/if}}
68
+ {{#if requestBody}} Body: body, ContentType: "{{requestBody.contentType}}",{{/if}}
69
+ {{#if hasHeaderParams}} Headers: headers,{{/if}}
70
+ })
34
71
  if err != nil { errCh <- err; return }
35
72
  defer resp.Body.Close()
36
73
  scanner := bufio.NewScanner(resp.Body)
@@ -49,6 +86,8 @@ func (api *{{../interfaceName}}) {{pascalCase name}}Stream(
49
86
  if strings.HasPrefix(line, "data:") { if current.Data != "" { current.Data += "\n" }; current.Data += strings.TrimSpace(line[5:]) }
50
87
  if strings.HasPrefix(line, "id:") { current.ID = strings.TrimSpace(line[3:]) }
51
88
  }
89
+ if current.Data != "" { eventCh <- current }
90
+ if err := scanner.Err(); err != nil { errCh <- err }
52
91
  }()
53
92
  return eventCh, errCh
54
93
  }
@@ -57,31 +96,50 @@ func (api *{{../interfaceName}}) {{pascalCase name}}Stream(
57
96
  func (api *{{../interfaceName}}) {{pascalCase name}}(
58
97
  ctx context.Context,
59
98
  {{#each pathParams}}
60
- {{name}} string,
99
+ {{name}} {{targetType}},
61
100
  {{/each}}
62
101
  {{#if requestBody}}
63
- body *{{requestBody.type}},
102
+ body {{requestBody.inputType}},
64
103
  {{/if}}
65
- {{#if queryType}}
66
- params {{goQueryType queryType}},
104
+ {{#each queryParams}}
105
+ {{name}} {{inputType}},
106
+ {{/each}}
107
+ {{#each headerParams}}
108
+ {{name}} {{inputType}},
109
+ {{/each}}
110
+ ) {{#if (eq responseType "void")}}error{{else}}(*{{goResponseType}}, error){{/if}} {
111
+ reqPath := buildPath("{{path}}"{{#each pathParams}}, "{{name}}", {{name}}{{/each}})
112
+ {{#if hasQueryParams}}
113
+ query := url.Values{}
114
+ {{#each queryParams}}
115
+ {{#if required}}
116
+ query.Set("{{originalName}}", fmt.Sprint({{name}}))
117
+ {{else}}
118
+ if {{name}} != nil { query.Set("{{originalName}}", fmt.Sprint(*{{name}})) }
67
119
  {{/if}}
68
- ) {{#if (eq responseType "void")}}error{{else}}(*{{responseType}}, error){{/if}} {
69
- reqPath := buildPath("{{path}}"{{#each pathParams}}, "{{originalName}}", {{name}}{{/each}})
70
- {{#if queryType}}q := buildQuery(params){{/if}}
71
- {{#if (eq responseType "void")}}
72
- return api.transport.Execute(ctx, request{
73
- Method: "{{httpMethod}}", Path: reqPath,
74
- {{#if queryType}} Query: q,{{/if}}
75
- {{#if requestBody}} Body: body,{{/if}}
76
- }, nil)
120
+ {{/each}}
121
+ {{/if}}
122
+ {{#if hasHeaderParams}}
123
+ headers := map[string]string{}
124
+ {{#each headerParams}}
125
+ {{#if required}}
126
+ headers["{{originalName}}"] = fmt.Sprint({{name}})
77
127
  {{else}}
78
- var result {{responseType}}
79
- err := api.transport.Execute(ctx, request{
128
+ if {{name}} != nil { headers["{{originalName}}"] = fmt.Sprint(*{{name}}) }
129
+ {{/if}}
130
+ {{/each}}
131
+ {{/if}}
132
+ req := request{
80
133
  Method: "{{httpMethod}}", Path: reqPath,
81
- {{#if queryType}} Query: q,{{/if}}
82
- {{#if requestBody}} Body: body,{{/if}}
83
- }, &result)
84
- if err != nil { return nil, err }
134
+ {{#if hasQueryParams}} Query: query,{{/if}}
135
+ {{#if requestBody}} Body: body, ContentType: "{{requestBody.contentType}}",{{/if}}
136
+ {{#if hasHeaderParams}} Headers: headers,{{/if}}
137
+ }
138
+ {{#if (eq responseType "void")}}
139
+ return api.transport.Execute(ctx, req, nil)
140
+ {{else}}
141
+ var result {{goResponseType}}
142
+ if err := api.transport.Execute(ctx, req, &result); err != nil { return nil, err }
85
143
  return &result, nil
86
144
  {{/if}}
87
145
  }
@@ -1,6 +1,3 @@
1
- module {{packageName}}
1
+ module {{moduleName}}
2
2
 
3
3
  go 1.21
4
-
5
- require (
6
- )
@@ -1,8 +1,8 @@
1
1
  # {{title}} Go SDK
2
2
 
3
- [![Go Reference](https://pkg.go.dev/badge/{{packageName}}.svg)](https://pkg.go.dev/{{packageName}})
3
+ {{#if description}}{{description}}{{else}}Go client for the {{title}} API.{{/if}}
4
4
 
5
- The official Go SDK for {{#if description}}{{description}}{{else}}the {{title}} API{{/if}}.
5
+ > Generated by Tesseract. Generated source files should not be edited manually.
6
6
 
7
7
  ## Installation
8
8
 
@@ -10,57 +10,60 @@ The official Go SDK for {{#if description}}{{description}}{{else}}the {{title}}
10
10
  go get {{packageName}}
11
11
  ```
12
12
 
13
- ## Quick Start
13
+ ## Quick start
14
14
 
15
15
  ```go
16
16
  package main
17
17
 
18
18
  import (
19
19
  "context"
20
- "fmt"
21
- "log"
20
+ "time"
22
21
 
23
22
  "{{packageName}}"
24
23
  )
25
24
 
26
25
  func main() {
27
- client := {{pkgName}}.NewClient({{pkgName}}.DefaultClientConfig(){{#each securitySchemes}}{{#if (eq type "apiKey")}}
28
- {{pascalCase configKey}}: "your-api-key",{{/if}}{{#if (and (eq type "http") (eq scheme "bearer"))}}
29
- {{pascalCase configKey}}: "your-bearer-token",{{/if}}
30
- {{/each}}
26
+ client := {{pkgName}}.NewClient(
27
+ {{pkgName}}.WithTimeout(15*time.Second),
31
28
  )
32
29
 
33
30
  ctx := context.Background()
34
- {{#each groups}}
35
- {{#with operations.[0]}}
36
- // {{../interfaceName}}.{{name}} example
37
- result, err := client.{{pascalCase ../name}}.{{pascalCase name}}(ctx{{#each ../pathParams}}, "{{this}}"{{/each}}{{#if requestBody}}, {{requestBody.type}}{}{{/if}})
38
- if err != nil {
39
- log.Fatal(err)
40
- }
41
- fmt.Printf("%+v\n", result)
42
- {{/with}}
43
- {{/each}}
31
+ _ = ctx
32
+ {{#if groups.length}}
33
+ _ = client.{{pascalCase groups.[0].name}}
34
+ {{/if}}
44
35
  }
45
36
  ```
46
37
 
47
- ## API Reference
38
+ ## Configuration and reliability
39
+
40
+ The client is safe for concurrent use. Requests use contexts for cancellation, bounded timeouts, exponential-backoff retries, `Retry-After` handling, default headers, and structured `SDKError` values. Unsafe requests are not retried unless an idempotency key is present or unsafe retries are explicitly enabled.
41
+
42
+ ```go
43
+ client := {{pkgName}}.NewClient(
44
+ {{pkgName}}.WithTimeout(30*time.Second),
45
+ {{pkgName}}.WithMaxRetries(3),
46
+ {{pkgName}}.WithDefaultHeader("X-Application", "my-service"),
47
+ )
48
+ ```
49
+
50
+ ## Documentation
51
+
52
+ - [Documentation index](./docs/README.md)
53
+ - [Generated types](./docs/types.md)
48
54
 
49
55
  | Domain | Description |
50
- |--------|-------------|
56
+ |---|---|
51
57
  {{#each groups}}
52
- | `{{interfaceName}}` | {{#if description}}{{description}}{{else}}{{name}} operations{{/if}} |
58
+ | [{{interfaceName}}](./docs/domains/{{fileName}}.md) | {{#if description}}{{description}}{{else}}{{name}} operations{{/if}} |
53
59
  {{/each}}
54
60
 
55
- ## Error Handling
56
-
57
- All methods return an `error` as the second return value. Use `errors.As` to inspect SDK-specific errors:
61
+ ## Error handling
58
62
 
59
63
  ```go
60
- var sdkErr *SDKError
64
+ var sdkErr *{{pkgName}}.SDKError
61
65
  if errors.As(err, &sdkErr) {
62
- fmt.Printf("Status: %d, Code: %s, RequestID: %s\n",
63
- sdkErr.Status, sdkErr.Code, sdkErr.RequestID)
66
+ log.Printf("status=%d code=%s request=%s", sdkErr.Status, sdkErr.Code, sdkErr.RequestID)
64
67
  }
65
68
  ```
66
69
 
@@ -70,4 +73,4 @@ if errors.As(err, &sdkErr) {
70
73
 
71
74
  ## License
72
75
 
73
- {{#if license}}{{license}}{{else}}MIT{{/if}}
76
+ MIT