@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.
- package/README.md +218 -110
- package/dist/adapters/csharp/index.d.ts +5 -8
- package/dist/adapters/csharp/index.d.ts.map +1 -1
- package/dist/adapters/csharp/index.js +314 -74
- package/dist/adapters/csharp/index.js.map +1 -1
- package/dist/adapters/documentation.d.ts +17 -0
- package/dist/adapters/documentation.d.ts.map +1 -0
- package/dist/adapters/documentation.js +268 -0
- package/dist/adapters/documentation.js.map +1 -0
- package/dist/adapters/go/index.d.ts +5 -8
- package/dist/adapters/go/index.d.ts.map +1 -1
- package/dist/adapters/go/index.js +197 -101
- package/dist/adapters/go/index.js.map +1 -1
- package/dist/adapters/kotlin/index.d.ts +5 -9
- package/dist/adapters/kotlin/index.d.ts.map +1 -1
- package/dist/adapters/kotlin/index.js +280 -212
- package/dist/adapters/kotlin/index.js.map +1 -1
- package/dist/adapters/php/index.d.ts +5 -15
- package/dist/adapters/php/index.d.ts.map +1 -1
- package/dist/adapters/php/index.js +362 -90
- package/dist/adapters/php/index.js.map +1 -1
- package/dist/adapters/python/index.d.ts +5 -8
- package/dist/adapters/python/index.d.ts.map +1 -1
- package/dist/adapters/python/index.js +240 -109
- package/dist/adapters/python/index.js.map +1 -1
- package/dist/adapters/ruby/index.d.ts +3 -3
- package/dist/adapters/ruby/index.d.ts.map +1 -1
- package/dist/adapters/ruby/index.js +235 -46
- package/dist/adapters/ruby/index.js.map +1 -1
- package/dist/adapters/rust/index.d.ts +5 -9
- package/dist/adapters/rust/index.d.ts.map +1 -1
- package/dist/adapters/rust/index.js +237 -169
- package/dist/adapters/rust/index.js.map +1 -1
- package/dist/adapters/shared.d.ts +7 -0
- package/dist/adapters/shared.d.ts.map +1 -0
- package/dist/adapters/shared.js +68 -0
- package/dist/adapters/shared.js.map +1 -0
- package/dist/adapters/type-utils.d.ts +13 -0
- package/dist/adapters/type-utils.d.ts.map +1 -0
- package/dist/adapters/type-utils.js +105 -0
- package/dist/adapters/type-utils.js.map +1 -0
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/emitSchema.d.ts +2 -2
- package/dist/adapters/typescript/emitter/emitSchema.js +39 -27
- package/dist/adapters/typescript/emitter/emitSchema.js.map +1 -1
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.d.ts +2 -2
- package/dist/adapters/typescript/emitter/emitTypeScriptModels.js +15 -15
- package/dist/adapters/typescript/emitter/importCollector.d.ts +2 -4
- package/dist/adapters/typescript/emitter/importCollector.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/importCollector.js +40 -50
- package/dist/adapters/typescript/emitter/importCollector.js.map +1 -1
- package/dist/adapters/typescript/emitter/parsers.d.ts +1 -1
- package/dist/adapters/typescript/emitter/parsers.js +13 -13
- package/dist/adapters/typescript/emitter/typeHoister.d.ts +1 -1
- package/dist/adapters/typescript/emitter/typeHoister.d.ts.map +1 -1
- package/dist/adapters/typescript/emitter/typeHoister.js +12 -20
- package/dist/adapters/typescript/emitter/typeHoister.js.map +1 -1
- package/dist/adapters/typescript/index.d.ts +3 -3
- package/dist/adapters/typescript/index.d.ts.map +1 -1
- package/dist/adapters/typescript/index.js +148 -166
- package/dist/adapters/typescript/index.js.map +1 -1
- package/dist/adapters/typescript/shared.d.ts +2 -2
- package/dist/adapters/typescript/shared.js +12 -12
- package/dist/cli.js +50 -37
- package/dist/cli.js.map +1 -1
- package/dist/collector.d.ts +13 -3
- package/dist/collector.d.ts.map +1 -1
- package/dist/collector.js +69 -32
- package/dist/collector.js.map +1 -1
- package/dist/elysia.js +2 -2
- package/dist/elysia.js.map +1 -1
- package/dist/express.d.ts.map +1 -1
- package/dist/express.js.map +1 -1
- package/dist/fastify.d.ts +7 -0
- package/dist/fastify.d.ts.map +1 -1
- package/dist/fastify.js +39 -20
- package/dist/fastify.js.map +1 -1
- package/dist/helpers/handlebars.d.ts +7 -16
- package/dist/helpers/handlebars.d.ts.map +1 -1
- package/dist/helpers/handlebars.js +127 -177
- package/dist/helpers/handlebars.js.map +1 -1
- package/dist/hono.d.ts.map +1 -1
- package/dist/hono.js.map +1 -1
- package/dist/index.d.ts +14 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -30
- package/dist/index.js.map +1 -1
- package/dist/koa.d.ts.map +1 -1
- package/dist/koa.js.map +1 -1
- package/dist/nestjs.d.ts.map +1 -1
- package/dist/nestjs.js +41 -14
- package/dist/nestjs.js.map +1 -1
- package/dist/pipeline/enrich.d.ts +2 -13
- package/dist/pipeline/enrich.d.ts.map +1 -1
- package/dist/pipeline/enrich.js +157 -212
- package/dist/pipeline/enrich.js.map +1 -1
- package/dist/pipeline/intake.d.ts +3 -3
- package/dist/pipeline/intake.d.ts.map +1 -1
- package/dist/pipeline/intake.js +342 -238
- package/dist/pipeline/intake.js.map +1 -1
- package/dist/pipeline/write.d.ts +1 -14
- package/dist/pipeline/write.d.ts.map +1 -1
- package/dist/pipeline/write.js +73 -113
- package/dist/pipeline/write.js.map +1 -1
- package/dist/types/config.d.ts +14 -26
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +16 -12
- package/dist/types/config.js.map +1 -1
- package/dist/types/ir.d.ts +12 -8
- package/dist/types/ir.d.ts.map +1 -1
- package/dist/types/manifest.d.ts +10 -11
- package/dist/types/manifest.d.ts.map +1 -1
- package/dist/types/manifest.js +54 -14
- package/dist/types/manifest.js.map +1 -1
- package/dist/types/sdk-module.d.ts +2 -2
- package/dist/types/sdk-module.js +1 -1
- package/dist/utils/format.d.ts +1 -3
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +3 -10
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/naming.d.ts.map +1 -1
- package/dist/utils/naming.js +174 -184
- package/dist/utils/naming.js.map +1 -1
- package/dist/utils/npm-token.d.ts +1 -17
- package/dist/utils/npm-token.d.ts.map +1 -1
- package/dist/utils/npm-token.js +27 -76
- package/dist/utils/npm-token.js.map +1 -1
- package/dist/utils/version.d.ts +14 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +60 -0
- package/dist/utils/version.js.map +1 -0
- package/package.json +4 -3
- package/templates/csharp/client.hbs +26 -49
- package/templates/csharp/csproj.hbs +7 -0
- package/templates/csharp/domain.hbs +48 -130
- package/templates/csharp/errors.hbs +17 -25
- package/templates/csharp/readme.hbs +31 -44
- package/templates/csharp/transport.hbs +238 -136
- package/templates/csharp/types.hbs +30 -76
- package/templates/go/client.hbs +44 -109
- package/templates/go/domain.hbs +83 -25
- package/templates/go/go-mod.hbs +1 -4
- package/templates/go/readme.hbs +32 -29
- package/templates/go/transport.hbs +174 -173
- package/templates/go/types.hbs +17 -53
- package/templates/go/utils.hbs +3 -2
- package/templates/kotlin/build-gradle.hbs +1 -1
- package/templates/kotlin/client.hbs +18 -15
- package/templates/kotlin/domain.hbs +54 -51
- package/templates/kotlin/errors.hbs +1 -1
- package/templates/kotlin/readme.hbs +35 -137
- package/templates/kotlin/transport.hbs +140 -123
- package/templates/kotlin/types.hbs +30 -81
- package/templates/php/client.hbs +8 -46
- package/templates/php/composer.hbs +2 -1
- package/templates/php/domain.hbs +86 -117
- package/templates/php/errors.hbs +1 -1
- package/templates/php/readme.hbs +42 -49
- package/templates/php/transport.hbs +192 -145
- package/templates/php/types.hbs +63 -60
- package/templates/python/client.hbs +15 -2
- package/templates/python/domain.hbs +50 -108
- package/templates/python/pyproject.hbs +5 -0
- package/templates/python/readme.hbs +47 -30
- package/templates/python/resources-init.hbs +1 -1
- package/templates/python/transport.hbs +167 -53
- package/templates/python/types.hbs +22 -58
- package/templates/ruby/client.hbs +10 -6
- package/templates/ruby/domain.hbs +48 -67
- package/templates/ruby/errors.hbs +3 -3
- package/templates/ruby/gemspec.hbs +3 -10
- package/templates/ruby/index.hbs +3 -3
- package/templates/ruby/readme.hbs +33 -70
- package/templates/ruby/transport.hbs +129 -103
- package/templates/ruby/types.hbs +11 -16
- package/templates/ruby/version.hbs +1 -1
- package/templates/rust/cargo.hbs +2 -0
- package/templates/rust/client.hbs +10 -1
- package/templates/rust/domain.hbs +69 -52
- package/templates/rust/error.hbs +3 -1
- package/templates/rust/lib.hbs +4 -5
- package/templates/rust/readme.hbs +33 -46
- package/templates/rust/transport.hbs +170 -159
- package/templates/rust/types.hbs +34 -111
- package/templates/typescript/domain-class.hbs +14 -6
- package/templates/typescript/domain.hbs +13 -5
- package/templates/typescript/package-json.hbs +3 -1
- package/templates/typescript/readme.hbs +42 -42
- package/templates/typescript/transport.hbs +46 -8
- package/templates/typescript/types-errors.hbs +1 -1
- package/dist/adapters/typescript/model-emitter.d.ts +0 -13
- package/dist/adapters/typescript/model-emitter.d.ts.map +0 -1
- package/dist/adapters/typescript/model-emitter.js +0 -415
- package/dist/adapters/typescript/model-emitter.js.map +0 -1
package/templates/php/domain.hbs
CHANGED
|
@@ -1,172 +1,141 @@
|
|
|
1
1
|
<?php
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* @generated
|
|
5
|
-
* This file was automatically generated by Tesseract.
|
|
6
|
-
* DO NOT MODIFY THIS FILE DIRECTLY.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
3
|
declare(strict_types=1);
|
|
10
4
|
|
|
11
5
|
namespace {{namespace}}\Api;
|
|
12
6
|
|
|
7
|
+
use {{namespace}}\SDKError;
|
|
8
|
+
use {{namespace}}\Transport;
|
|
9
|
+
{{#each imports}}
|
|
10
|
+
use {{this}};
|
|
11
|
+
{{/each}}
|
|
13
12
|
use Psr\Http\Message\ResponseInterface;
|
|
14
13
|
|
|
15
|
-
/**
|
|
16
|
-
* {{interfaceName}} domain operations.
|
|
17
|
-
*
|
|
18
|
-
{{#if description}}
|
|
19
|
-
* {{description}}
|
|
20
|
-
*
|
|
21
|
-
{{/if}}
|
|
22
|
-
* @generated
|
|
23
|
-
*/
|
|
14
|
+
/** {{#if description}}{{description}}{{else}}{{interfaceName}} domain operations.{{/if}} */
|
|
24
15
|
class {{className}}
|
|
25
16
|
{
|
|
26
|
-
private Transport $transport
|
|
27
|
-
|
|
28
|
-
public function __construct(Transport $transport)
|
|
17
|
+
public function __construct(private Transport $transport)
|
|
29
18
|
{
|
|
30
|
-
$this->transport = $transport;
|
|
31
19
|
}
|
|
32
20
|
|
|
33
21
|
{{#each operations}}
|
|
34
|
-
{{#if (isEventStream this)}}
|
|
35
|
-
// SSE operations are not yet supported in the PHP adapter — skipping {{name}}
|
|
36
|
-
|
|
37
|
-
{{else}}
|
|
38
22
|
/**
|
|
39
|
-
|
|
23
|
+
{{#if deprecated}}
|
|
40
24
|
* @deprecated{{#if deprecationMessage}} {{deprecationMessage}}{{/if}}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{{#if
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
* @
|
|
49
|
-
|
|
50
|
-
{{#if requestBody}}
|
|
51
|
-
* @param array<string, mixed>{{#unless requestBody.required}}|null{{/unless}} $input Request body
|
|
52
|
-
{{/if}}
|
|
53
|
-
{{#each queryParams}}
|
|
54
|
-
* @param {{type}}|null ${{name}}{{#if description}} {{description}}{{/if}}
|
|
55
|
-
{{/each}}
|
|
56
|
-
{{#each headerParams}}
|
|
57
|
-
* @param {{type}}|null ${{name}}{{#if description}} {{description}}{{/if}}
|
|
58
|
-
{{/each}}
|
|
59
|
-
* @return {{responseType}}
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#each parameters}}
|
|
27
|
+
* @param {{docType}} ${{variableName}}{{#if description}} {{description}}{{/if}}
|
|
28
|
+
{{/each}}
|
|
29
|
+
{{#if isEventStream}}
|
|
30
|
+
* @return \Generator<int, string>
|
|
31
|
+
{{else}}
|
|
32
|
+
* @return {{responseDocType}}
|
|
33
|
+
{{/if}}
|
|
60
34
|
* @throws SDKError
|
|
61
35
|
*/
|
|
62
|
-
public function {{
|
|
63
|
-
|
|
64
|
-
{{
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
{{#unless requestBody.required}}?{{/unless}}array $input{{#unless requestBody.required}} = null{{/unless}},
|
|
68
|
-
{{/if}}
|
|
69
|
-
{{#each queryParams}}
|
|
70
|
-
?{{type}} ${{name}} = null,
|
|
71
|
-
{{/each}}
|
|
72
|
-
{{#each headerParams}}
|
|
73
|
-
?{{type}} ${{name}} = null,
|
|
74
|
-
{{/each}}
|
|
75
|
-
): {{responseType}}
|
|
36
|
+
public function {{methodName}}(
|
|
37
|
+
{{#each parameters}}
|
|
38
|
+
{{targetType}} ${{variableName}}{{#unless required}} = null{{/unless}},
|
|
39
|
+
{{/each}}
|
|
40
|
+
): {{#if isEventStream}}\Generator{{else}}{{targetResponseType}}{{/if}}
|
|
76
41
|
{
|
|
77
|
-
// Build path with parameter substitution
|
|
78
42
|
$path = '{{path}}';
|
|
79
|
-
|
|
80
|
-
$path = str_replace(
|
|
81
|
-
|
|
82
|
-
[{{#each pathParams}}${{name}}{{#unless @last}}, {{/unless}}{{/each}}],
|
|
83
|
-
$path
|
|
84
|
-
);
|
|
85
|
-
{{/if}}
|
|
43
|
+
{{#each pathParams}}
|
|
44
|
+
$path = str_replace('{{placeholder}}', rawurlencode((string) ${{variableName}}), $path);
|
|
45
|
+
{{/each}}
|
|
86
46
|
|
|
87
|
-
// Build query parameters
|
|
88
47
|
$query = [];
|
|
89
|
-
|
|
90
|
-
{{
|
|
91
|
-
|
|
92
|
-
$query['{{originalName}}'] = ${{name}};
|
|
48
|
+
{{#each queryParams}}
|
|
49
|
+
if (${{variableName}} !== null) {
|
|
50
|
+
$query['{{originalName}}'] = ${{variableName}};
|
|
93
51
|
}
|
|
94
|
-
|
|
95
|
-
{{/if}}
|
|
52
|
+
{{/each}}
|
|
96
53
|
|
|
97
|
-
// Build extra headers
|
|
98
54
|
$headers = [];
|
|
99
|
-
|
|
100
|
-
if (${{
|
|
101
|
-
$headers['{{originalName}}'] = (string) ${{
|
|
55
|
+
{{#each headerParams}}
|
|
56
|
+
if (${{variableName}} !== null) {
|
|
57
|
+
$headers['{{originalName}}'] = (string) ${{variableName}};
|
|
58
|
+
}
|
|
59
|
+
{{/each}}
|
|
60
|
+
{{#if cookieParams.length}}
|
|
61
|
+
$cookies = [];
|
|
62
|
+
{{#each cookieParams}}
|
|
63
|
+
if (${{variableName}} !== null) {
|
|
64
|
+
$cookies[] = '{{originalName}}=' . rawurlencode((string) ${{variableName}});
|
|
102
65
|
}
|
|
103
|
-
|
|
66
|
+
{{/each}}
|
|
67
|
+
if ($cookies !== []) {
|
|
68
|
+
$headers['Cookie'] = implode('; ', $cookies);
|
|
69
|
+
}
|
|
70
|
+
{{/if}}
|
|
104
71
|
|
|
105
|
-
|
|
106
|
-
$requestDef = [
|
|
72
|
+
$request = [
|
|
107
73
|
'method' => '{{httpMethod}}',
|
|
108
74
|
'path' => $path,
|
|
109
75
|
'query' => $query,
|
|
110
76
|
'headers' => $headers,
|
|
77
|
+
{{#if isEventStream}}
|
|
78
|
+
'stream' => true,
|
|
79
|
+
{{/if}}
|
|
111
80
|
];
|
|
112
|
-
|
|
113
|
-
{{#if (hasRequestBody this)}}
|
|
81
|
+
{{#if requestBody}}
|
|
114
82
|
if ($input !== null) {
|
|
115
|
-
$
|
|
83
|
+
$request['body'] = $input;
|
|
84
|
+
$request['contentType'] = '{{requestBody.contentType}}';
|
|
116
85
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
$response = $this->transport->executeRequest($requestDef);
|
|
86
|
+
{{/if}}
|
|
120
87
|
|
|
121
|
-
|
|
88
|
+
$response = $this->transport->executeRequest($request);
|
|
89
|
+
{{#if isEventStream}}
|
|
90
|
+
$body = $response->getBody();
|
|
91
|
+
$buffer = '';
|
|
92
|
+
while (!$body->eof()) {
|
|
93
|
+
$buffer .= $body->read(8192);
|
|
94
|
+
while (($lineEnd = strpos($buffer, "\n")) !== false) {
|
|
95
|
+
$line = substr($buffer, 0, $lineEnd);
|
|
96
|
+
$buffer = substr($buffer, $lineEnd + 1);
|
|
97
|
+
yield rtrim($line, "\r");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if ($buffer !== '') {
|
|
101
|
+
yield rtrim($buffer, "\r");
|
|
102
|
+
}
|
|
103
|
+
{{else}}
|
|
122
104
|
$data = $this->decodeResponse($response);
|
|
123
|
-
|
|
124
|
-
{{#if (eq responseType "void")}}
|
|
105
|
+
{{#if isVoid}}
|
|
125
106
|
return;
|
|
126
|
-
|
|
107
|
+
{{else if (eq targetResponseType "string")}}
|
|
127
108
|
return (string) $data;
|
|
128
|
-
|
|
109
|
+
{{else if (eq targetResponseType "int")}}
|
|
129
110
|
return (int) $data;
|
|
130
|
-
|
|
111
|
+
{{else if (eq targetResponseType "float")}}
|
|
131
112
|
return (float) $data;
|
|
132
|
-
|
|
113
|
+
{{else if (eq targetResponseType "bool")}}
|
|
133
114
|
return (bool) $data;
|
|
134
|
-
|
|
115
|
+
{{else if (eq targetResponseType "array")}}
|
|
116
|
+
return is_array($data) ? $data : [];
|
|
117
|
+
{{else if (eq targetResponseType "mixed")}}
|
|
135
118
|
return $data;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
return {{responseType}}::fromArray($data);
|
|
119
|
+
{{else}}
|
|
120
|
+
if (is_array($data) && method_exists({{targetResponseType}}::class, 'fromArray')) {
|
|
121
|
+
return {{targetResponseType}}::fromArray($data);
|
|
140
122
|
}
|
|
141
123
|
return $data;
|
|
142
|
-
|
|
124
|
+
{{/if}}
|
|
125
|
+
{{/if}}
|
|
143
126
|
}
|
|
144
127
|
|
|
145
|
-
{{/if}}
|
|
146
128
|
{{/each}}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Decode a PSR-7 response body to an associative array or raw value.
|
|
150
|
-
*
|
|
151
|
-
* @return array<string, mixed>|string
|
|
152
|
-
*/
|
|
153
|
-
private function decodeResponse(ResponseInterface $response): array|string
|
|
129
|
+
private function decodeResponse(ResponseInterface $response): mixed
|
|
154
130
|
{
|
|
155
131
|
$contents = $response->getBody()->__toString();
|
|
132
|
+
if (trim($contents) === '') {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
156
135
|
|
|
157
136
|
try {
|
|
158
|
-
|
|
159
|
-
if (is_array($decoded)) {
|
|
160
|
-
return $decoded;
|
|
161
|
-
}
|
|
162
|
-
if (is_scalar($decoded)) {
|
|
163
|
-
return (string) $decoded;
|
|
164
|
-
}
|
|
165
|
-
return ['raw' => $decoded];
|
|
137
|
+
return json_decode($contents, true, 512, JSON_THROW_ON_ERROR);
|
|
166
138
|
} catch (\JsonException) {
|
|
167
|
-
if (trim($contents) === '') {
|
|
168
|
-
return [];
|
|
169
|
-
}
|
|
170
139
|
return $contents;
|
|
171
140
|
}
|
|
172
141
|
}
|
package/templates/php/errors.hbs
CHANGED
|
@@ -110,7 +110,7 @@ class SDKError extends \Exception
|
|
|
110
110
|
*/
|
|
111
111
|
public function isRetryable(): bool
|
|
112
112
|
{
|
|
113
|
-
return $this->httpStatus >= 500 || $this->httpStatus
|
|
113
|
+
return $this->httpStatus >= 500 || in_array($this->httpStatus, [408, 425, 429], true);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
package/templates/php/readme.hbs
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
# {{title}} PHP SDK
|
|
2
2
|
|
|
3
|
-
{{#if description}}
|
|
4
|
-
{{description}}
|
|
3
|
+
{{#if description}}{{description}}{{else}}PHP client for the {{title}} API.{{/if}}
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
> This SDK was automatically generated by [Tesseract](https://www.npmjs.com/package/@apollo-deploy/tesseract).
|
|
5
|
+
> Generated by [Tesseract](https://www.npmjs.com/package/@apollo-deploy/tesseract). Generated source files should not be edited manually.
|
|
8
6
|
|
|
9
7
|
## Installation
|
|
10
8
|
|
|
@@ -12,7 +10,7 @@
|
|
|
12
10
|
composer require {{composerName}}
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
## Quick
|
|
13
|
+
## Quick start
|
|
16
14
|
|
|
17
15
|
```php
|
|
18
16
|
<?php
|
|
@@ -24,66 +22,61 @@ use {{namespace}}\Client;
|
|
|
24
22
|
$client = new Client([
|
|
25
23
|
'baseUrl' => '{{baseUrl}}',
|
|
26
24
|
{{#each securitySchemes}}
|
|
27
|
-
'{{configKey}}' => '
|
|
25
|
+
'{{configKey}}' => getenv('{{upperCase (snakeCase configKey)}}'),
|
|
28
26
|
{{/each}}
|
|
27
|
+
'timeoutMs' => 15000,
|
|
29
28
|
]);
|
|
30
29
|
|
|
31
|
-
{{#
|
|
32
|
-
$api = $client->{{
|
|
33
|
-
{{/
|
|
30
|
+
{{#if groups.length}}
|
|
31
|
+
$api = $client->{{groups.[0].accessorName}}();
|
|
32
|
+
{{/if}}
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
## Configuration
|
|
37
|
-
|
|
38
|
-
The `Client` constructor accepts an associative array with the following keys:
|
|
39
|
-
|
|
40
|
-
| Option | Type | Default | Description |
|
|
41
|
-
|--------|------|---------|-------------|
|
|
42
|
-
| `baseUrl` | `string` | `'{{baseUrl}}'` | Base URL for the API |
|
|
43
|
-
{{#each securitySchemes}}
|
|
44
|
-
| `{{configKey}}` | `string` | `null` | {{#if description}}{{description}}{{else}}{{type}} credential for {{name}}{{/if}} |
|
|
45
|
-
{{/each}}
|
|
46
|
-
| `timeoutMs` | `int` | `15000` | Request timeout in milliseconds |
|
|
47
|
-
| `retries` | `array` | `['attempts' => 3, 'backoffMs' => 400, 'jitter' => true]` | Retry configuration |
|
|
48
|
-
| `defaultHeaders` | `array` | `[]` | Default headers sent with every request |
|
|
49
|
-
|
|
50
|
-
## API Reference
|
|
51
|
-
|
|
52
|
-
{{#each groups}}
|
|
53
|
-
### `{{className}}`
|
|
35
|
+
## Configuration and reliability
|
|
54
36
|
|
|
55
|
-
|
|
56
|
-
{{description}}
|
|
37
|
+
The generated Guzzle transport supports bounded timeouts, exponential-backoff retries, rate-limit handling, default headers, and structured `SDKError` exceptions. Unsafe methods are not retried unless the request is idempotent or unsafe retries are explicitly enabled.
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
39
|
+
```php
|
|
40
|
+
$client = new Client([
|
|
41
|
+
'timeoutMs' => 30000,
|
|
42
|
+
'retries' => [
|
|
43
|
+
'attempts' => 3,
|
|
44
|
+
'backoffMs' => 400,
|
|
45
|
+
'jitter' => true,
|
|
46
|
+
'maxBackoffMs' => 30000,
|
|
47
|
+
],
|
|
48
|
+
'defaultHeaders' => ['X-Application' => 'my-service'],
|
|
49
|
+
]);
|
|
50
|
+
```
|
|
64
51
|
|
|
65
|
-
|
|
52
|
+
## Documentation
|
|
66
53
|
|
|
67
|
-
|
|
54
|
+
- [Documentation index](./docs/README.md)
|
|
55
|
+
- [Generated types](./docs/types.md)
|
|
68
56
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{{else}}
|
|
73
|
-
- `{{name}}`{{#if description}} — {{description}}{{/if}}
|
|
74
|
-
{{/if}}
|
|
57
|
+
| Domain | Description |
|
|
58
|
+
|---|---|
|
|
59
|
+
{{#each groups}}
|
|
60
|
+
| [{{className}}](./docs/domains/{{fileName}}.md) | {{#if description}}{{description}}{{else}}{{name}} operations{{/if}} |
|
|
75
61
|
{{/each}}
|
|
76
62
|
|
|
77
|
-
## Error
|
|
63
|
+
## Error handling
|
|
78
64
|
|
|
79
65
|
```php
|
|
80
|
-
<?php
|
|
81
|
-
|
|
82
66
|
use {{namespace}}\SDKError;
|
|
83
67
|
|
|
84
68
|
try {
|
|
85
|
-
|
|
86
|
-
} catch (SDKError $
|
|
87
|
-
|
|
69
|
+
// Call a domain operation.
|
|
70
|
+
} catch (SDKError $error) {
|
|
71
|
+
fprintf(STDERR, "%d %s request=%s\n", $error->getHttpStatus(), $error->getErrorCode(), $error->getRequestId());
|
|
72
|
+
throw $error;
|
|
88
73
|
}
|
|
89
74
|
```
|
|
75
|
+
|
|
76
|
+
## Requirements
|
|
77
|
+
|
|
78
|
+
- PHP 8.2 or later
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT
|