@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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
export function createDocumentationFiles({ meta, groups, schemas, naming, }) {
|
|
3
|
+
return [
|
|
4
|
+
{
|
|
5
|
+
relativePath: 'LICENSE',
|
|
6
|
+
content: renderLicense(meta),
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
relativePath: 'docs/README.md',
|
|
10
|
+
content: renderDocumentationIndex(meta, groups, naming),
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
relativePath: 'docs/types.md',
|
|
14
|
+
content: renderTypesReference(meta, schemas, naming),
|
|
15
|
+
},
|
|
16
|
+
...groups.map((group) => ({
|
|
17
|
+
relativePath: posix.join('docs', 'domains', `${group.fileName}.md`),
|
|
18
|
+
content: renderDomainReference(meta, group, naming),
|
|
19
|
+
})),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
function renderLicense(meta) {
|
|
23
|
+
return `MIT License
|
|
24
|
+
|
|
25
|
+
Copyright (c) ${meta.title} SDK contributors
|
|
26
|
+
|
|
27
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
28
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
29
|
+
in the Software without restriction, including without limitation the rights
|
|
30
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
31
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
32
|
+
furnished to do so, subject to the following conditions:
|
|
33
|
+
|
|
34
|
+
The above copyright notice and this permission notice shall be included in all
|
|
35
|
+
copies or substantial portions of the Software.
|
|
36
|
+
|
|
37
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
38
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
39
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
40
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
41
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
42
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
43
|
+
SOFTWARE.
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
function renderDocumentationIndex(meta, groups, naming) {
|
|
47
|
+
const lines = [
|
|
48
|
+
`# ${meta.title} SDK documentation`,
|
|
49
|
+
'',
|
|
50
|
+
meta.description ?? `Reference documentation for the ${meta.title} SDK.`,
|
|
51
|
+
'',
|
|
52
|
+
'[Back to the SDK overview](../README.md)',
|
|
53
|
+
'',
|
|
54
|
+
'## API domains',
|
|
55
|
+
'',
|
|
56
|
+
'| Domain | Client accessor | Operations | Description |',
|
|
57
|
+
'|---|---|---:|---|',
|
|
58
|
+
];
|
|
59
|
+
if (groups.length === 0) {
|
|
60
|
+
lines.push('| _No public domains_ | — | 0 | This SDK has no exposed operations. |');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
for (const group of groups) {
|
|
64
|
+
lines.push(`| [${escapeMarkdown(group.interfaceName)}](./domains/${group.fileName}.md) | \`${escapeCode(resolveGroupAccessor(group, naming))}\` | ${group.operations.length} | ${escapeTableCell(group.description ?? `${group.name} operations`)} |`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
lines.push('', '## Models and types', '', '- [Generated types reference](./types.md)', '', '## Reliability behavior', '', 'Generated clients use bounded request timeouts, structured SDK errors, request ID propagation, and retry transient failures with exponential backoff. Unsafe requests are not retried unless the generated client can establish idempotency or the caller explicitly enables it.', '');
|
|
68
|
+
return `${lines.join('\n')}\n`;
|
|
69
|
+
}
|
|
70
|
+
function renderDomainReference(meta, group, naming) {
|
|
71
|
+
const accessor = resolveGroupAccessor(group, naming);
|
|
72
|
+
const sourcePath = naming.sourcePath(group).replaceAll('\\', '/');
|
|
73
|
+
const lines = [
|
|
74
|
+
`# ${group.interfaceName}`,
|
|
75
|
+
'',
|
|
76
|
+
group.description ?? `${group.name} API operations.`,
|
|
77
|
+
'',
|
|
78
|
+
`[Documentation index](../README.md) · [SDK overview](../../README.md) · [Generated source](../../${sourcePath})`,
|
|
79
|
+
'',
|
|
80
|
+
`Client accessor: \`${escapeCode(accessor)}\``,
|
|
81
|
+
'',
|
|
82
|
+
'## Operations',
|
|
83
|
+
'',
|
|
84
|
+
'| Method | HTTP | Path | Returns | Description |',
|
|
85
|
+
'|---|---|---|---|---|',
|
|
86
|
+
];
|
|
87
|
+
for (const operation of group.operations) {
|
|
88
|
+
const method = resolveMethodName(operation, naming);
|
|
89
|
+
lines.push(`| [\`${escapeCode(method)}\`](#${markdownAnchor(method)}) | \`${escapeCode(operation.httpMethod.toUpperCase())}\` | \`${escapeCode(documentedPath(operation))}\` | \`${escapeCode(resolveType(operation.responseType, naming))}\` | ${escapeTableCell(operation.summary ?? operation.description ?? '—')} |`);
|
|
90
|
+
}
|
|
91
|
+
for (const operation of group.operations) {
|
|
92
|
+
lines.push('', ...renderOperation(operation, naming));
|
|
93
|
+
}
|
|
94
|
+
lines.push('', '---', '', `Generated from the ${meta.title} manifest by Tesseract.`, '');
|
|
95
|
+
return `${lines.join('\n')}\n`;
|
|
96
|
+
}
|
|
97
|
+
function renderOperation(operation, naming) {
|
|
98
|
+
const method = resolveMethodName(operation, naming);
|
|
99
|
+
const lines = [
|
|
100
|
+
`## ${method}`,
|
|
101
|
+
'',
|
|
102
|
+
`\`${operation.httpMethod.toUpperCase()} ${escapeCode(documentedPath(operation))}\``,
|
|
103
|
+
'',
|
|
104
|
+
];
|
|
105
|
+
if (operation.deprecated) {
|
|
106
|
+
lines.push(`> **Deprecated:** ${operation.deprecationMessage ?? 'This operation may be removed in a future release.'}`, '');
|
|
107
|
+
}
|
|
108
|
+
if (operation.summary)
|
|
109
|
+
lines.push(operation.summary, '');
|
|
110
|
+
if (operation.description && operation.description !== operation.summary) {
|
|
111
|
+
lines.push(operation.description, '');
|
|
112
|
+
}
|
|
113
|
+
if (operation.timeoutMs !== undefined) {
|
|
114
|
+
lines.push(`Default operation timeout: **${operation.timeoutMs} ms**`, '');
|
|
115
|
+
}
|
|
116
|
+
const parameters = collectParameters(operation);
|
|
117
|
+
if (parameters.length) {
|
|
118
|
+
lines.push('### Parameters', '', '| Name | Location | Type | Required | Description |', '|---|---|---|:---:|---|');
|
|
119
|
+
for (const { parameter, location } of parameters) {
|
|
120
|
+
lines.push(`| \`${escapeCode(parameter.originalName)}\` | ${location} | \`${escapeCode(resolveType(parameter.type, naming))}\` | ${parameter.required ? 'Yes' : 'No'} | ${escapeTableCell(parameter.description ?? (parameter.deprecated ? 'Deprecated parameter.' : '—'))} |`);
|
|
121
|
+
}
|
|
122
|
+
lines.push('');
|
|
123
|
+
}
|
|
124
|
+
if (operation.requestBody) {
|
|
125
|
+
lines.push('### Request body', '', `- Type: \`${escapeCode(resolveType(operation.requestBody.type, naming))}\``, `- Required: ${operation.requestBody.required ? 'Yes' : 'No'}`, `- Content type: \`${escapeCode(operation.requestBody.contentType)}\``, '');
|
|
126
|
+
}
|
|
127
|
+
lines.push('### Response', '', `- Success status: \`${operation.statusCode}\``, `- Type: \`${escapeCode(resolveType(operation.responseType, naming))}\``);
|
|
128
|
+
if (operation.isEventStream) {
|
|
129
|
+
lines.push(`- Streaming: Server-Sent Events${operation.eventSchema ? ` with payload \`${escapeCode(resolveType(operation.eventSchema, naming))}\`` : ''}`);
|
|
130
|
+
}
|
|
131
|
+
lines.push('');
|
|
132
|
+
return lines;
|
|
133
|
+
}
|
|
134
|
+
function renderTypesReference(meta, schemas, naming) {
|
|
135
|
+
const lines = [
|
|
136
|
+
`# ${meta.title} generated types`,
|
|
137
|
+
'',
|
|
138
|
+
'[Documentation index](./README.md) · [SDK overview](../README.md)',
|
|
139
|
+
'',
|
|
140
|
+
];
|
|
141
|
+
if (!schemas.length) {
|
|
142
|
+
lines.push('This SDK does not generate local models. Types are supplied by an external schema package.', '');
|
|
143
|
+
return `${lines.join('\n')}\n`;
|
|
144
|
+
}
|
|
145
|
+
lines.push('## Index', '', '| Type | Kind | Description |', '|---|---|---|');
|
|
146
|
+
for (const schema of schemas) {
|
|
147
|
+
lines.push(`| [\`${escapeCode(schema.name)}\`](#${markdownAnchor(schema.name)}) | ${schemaKind(schema)} | ${escapeTableCell(schema.description ?? '—')} |`);
|
|
148
|
+
}
|
|
149
|
+
for (const schema of schemas) {
|
|
150
|
+
lines.push('', `## ${schema.name}`, '');
|
|
151
|
+
if (schema.description)
|
|
152
|
+
lines.push(schema.description, '');
|
|
153
|
+
if (schema.ownership?.kind === 'external') {
|
|
154
|
+
lines.push(`Imported from \`${escapeCode(schema.ownership.externalImport?.importPath ?? schema.ownership.externalImport?.packageName ?? 'external schema package')}\`.`, '');
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (schema.isEnum) {
|
|
158
|
+
lines.push('Allowed values:', '');
|
|
159
|
+
for (const value of schema.enumValues ?? []) {
|
|
160
|
+
lines.push(`- \`${escapeCode(JSON.stringify(value))}\``);
|
|
161
|
+
}
|
|
162
|
+
lines.push('');
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
if (schema.aliasType) {
|
|
166
|
+
lines.push(`Alias of \`${escapeCode(resolveType(schema.aliasType, naming))}\`.`, '');
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (schema.isUnionType) {
|
|
170
|
+
lines.push(`Union of ${formatTypeList(schema.unionMembers ?? [], naming)}.`, '');
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (schema.isIntersectionType) {
|
|
174
|
+
lines.push(`Intersection of ${formatTypeList(schema.intersectionMembers ?? [], naming)}.`, '');
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
if (schema.extends) {
|
|
178
|
+
lines.push(`Extends \`${escapeCode(resolveType(schema.extends, naming))}\`.`, '');
|
|
179
|
+
}
|
|
180
|
+
if (schema.properties.length) {
|
|
181
|
+
lines.push('| Property | Type | Required | Description |', '|---|---|:---:|---|');
|
|
182
|
+
for (const property of schema.properties) {
|
|
183
|
+
const nullable = property.nullable ? ' | null' : '';
|
|
184
|
+
lines.push(`| \`${escapeCode(property.name)}\` | \`${escapeCode(resolveType(property.type, naming))}${nullable}\` | ${property.required ? 'Yes' : 'No'} | ${escapeTableCell(property.description ?? (property.deprecated ? 'Deprecated property.' : '—'))} |`);
|
|
185
|
+
}
|
|
186
|
+
lines.push('');
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
lines.push('This model has no declared properties.', '');
|
|
190
|
+
}
|
|
191
|
+
if (schema.additionalPropertiesType) {
|
|
192
|
+
lines.push(`Additional properties use \`${escapeCode(resolveType(schema.additionalPropertiesType, naming))}\`.`, '');
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return `${lines.join('\n')}\n`;
|
|
196
|
+
}
|
|
197
|
+
function documentedPath(operation) {
|
|
198
|
+
let path = operation.path;
|
|
199
|
+
for (const parameter of operation.pathParams) {
|
|
200
|
+
const replacement = `{${parameter.originalName}}`;
|
|
201
|
+
const placeholders = [
|
|
202
|
+
`\${${parameter.name}}`,
|
|
203
|
+
`:${parameter.name}`,
|
|
204
|
+
`{${parameter.name}}`,
|
|
205
|
+
`\${${parameter.originalName}}`,
|
|
206
|
+
`:${parameter.originalName}`,
|
|
207
|
+
`{${parameter.originalName}}`,
|
|
208
|
+
];
|
|
209
|
+
for (const placeholder of placeholders) {
|
|
210
|
+
path = path.replaceAll(placeholder, replacement);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return path;
|
|
214
|
+
}
|
|
215
|
+
function collectParameters(operation) {
|
|
216
|
+
return [
|
|
217
|
+
...operation.pathParams.map((parameter) => ({ parameter, location: 'Path' })),
|
|
218
|
+
...operation.queryParams.map((parameter) => ({ parameter, location: 'Query' })),
|
|
219
|
+
...operation.headerParams.map((parameter) => ({ parameter, location: 'Header' })),
|
|
220
|
+
...operation.cookieParams.map((parameter) => ({ parameter, location: 'Cookie' })),
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
function resolveGroupAccessor(group, naming) {
|
|
224
|
+
return naming.groupAccessor?.(group) ?? `client.${group.name}`;
|
|
225
|
+
}
|
|
226
|
+
function resolveMethodName(operation, naming) {
|
|
227
|
+
return naming.methodName?.(operation) ?? operation.name;
|
|
228
|
+
}
|
|
229
|
+
function resolveType(type, naming) {
|
|
230
|
+
return naming.typeName?.(type) ?? type;
|
|
231
|
+
}
|
|
232
|
+
function formatTypeList(types, naming) {
|
|
233
|
+
if (!types.length)
|
|
234
|
+
return '`unknown`';
|
|
235
|
+
return types
|
|
236
|
+
.map((type) => `\`${escapeCode(resolveType(type, naming))}\``)
|
|
237
|
+
.join(', ');
|
|
238
|
+
}
|
|
239
|
+
function schemaKind(schema) {
|
|
240
|
+
if (schema.ownership?.kind === 'external')
|
|
241
|
+
return 'External';
|
|
242
|
+
if (schema.isEnum)
|
|
243
|
+
return 'Enum';
|
|
244
|
+
if (schema.aliasType)
|
|
245
|
+
return 'Alias';
|
|
246
|
+
if (schema.isUnionType)
|
|
247
|
+
return 'Union';
|
|
248
|
+
if (schema.isIntersectionType)
|
|
249
|
+
return 'Intersection';
|
|
250
|
+
return 'Model';
|
|
251
|
+
}
|
|
252
|
+
function markdownAnchor(value) {
|
|
253
|
+
return value
|
|
254
|
+
.trim()
|
|
255
|
+
.toLowerCase()
|
|
256
|
+
.replace(/[^a-z0-9 _-]/g, '')
|
|
257
|
+
.replace(/[ _]+/g, '-');
|
|
258
|
+
}
|
|
259
|
+
function escapeCode(value) {
|
|
260
|
+
return value.replaceAll('`', '\\`');
|
|
261
|
+
}
|
|
262
|
+
function escapeMarkdown(value) {
|
|
263
|
+
return value.replace(/([\\*_{}\[\]()#+.!|-])/g, '\\$1');
|
|
264
|
+
}
|
|
265
|
+
function escapeTableCell(value) {
|
|
266
|
+
return value.replaceAll('|', '\\|').replace(/\s+/g, ' ').trim();
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=documentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documentation.js","sourceRoot":"","sources":["../../src/adapters/documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AA0BlC,MAAM,UAAU,wBAAwB,CAAC,EACvC,IAAI,EACJ,MAAM,EACN,OAAO,EACP,MAAM,GACe;IACrB,OAAO;QACL;YACE,YAAY,EAAE,SAAS;YACvB,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC;SAC7B;QACD;YACE,YAAY,EAAE,gBAAgB;YAC9B,OAAO,EAAE,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC;SACxD;QACD;YACE,YAAY,EAAE,eAAe;YAC7B,OAAO,EAAE,oBAAoB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;SACrD;QACD,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACx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AC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK;SACT,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;SAC5B,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC;AAED,SAAS,eAAe,CAAC,KAAa;IACpC,OAAO,KAAK,CAAC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import type { EnrichedSDKIR } from "../../types/ir.js";
|
|
6
|
-
import type { LanguageAdapter, EmitResult } from "../types.js";
|
|
7
|
-
import type { ResolvedConfig } from "../../types/config.js";
|
|
1
|
+
/** Go language adapter. */
|
|
2
|
+
import type { EnrichedSDKIR } from '../../types/ir.js';
|
|
3
|
+
import type { ResolvedConfig } from '../../types/config.js';
|
|
4
|
+
import type { EmitResult, LanguageAdapter } from '../types.js';
|
|
8
5
|
export declare class GoAdapter implements LanguageAdapter {
|
|
9
6
|
readonly language = "go";
|
|
10
|
-
emit(enriched: EnrichedSDKIR,
|
|
7
|
+
emit(enriched: EnrichedSDKIR, _outputDir: string, config?: ResolvedConfig): Promise<EmitResult>;
|
|
11
8
|
}
|
|
12
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/go/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/go/index.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAG3B,OAAO,KAAK,EACV,aAAa,EAGd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AA+I/D,qBAAa,SAAU,YAAW,eAAe;IAC/C,QAAQ,CAAC,QAAQ,QAAQ;IAEnB,IAAI,CACR,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,UAAU,CAAC;CAsIvB"}
|
|
@@ -1,135 +1,231 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
/** Go language adapter. */
|
|
2
|
+
import { pascalCase } from 'change-case';
|
|
3
|
+
import { collectImports, getTemplate, registerHelpers, } from '../../helpers/handlebars.js';
|
|
4
|
+
import { genericArgument, genericArguments, isBooleanLiteral, isInlineObject, isNumberLiteral, isStringLiteral, splitTopLevel, stripOuterParens, unwrapNullable, } from '../type-utils.js';
|
|
5
|
+
import { getPackageVersion, getVisibleGroups, getVisibleSchemas, hasEventStreams, } from '../shared.js';
|
|
6
|
+
import { createDocumentationFiles } from '../documentation.js';
|
|
7
|
+
const GO_PRIMITIVES = {
|
|
8
|
+
string: 'string',
|
|
9
|
+
number: 'float64',
|
|
10
|
+
integer: 'int',
|
|
11
|
+
boolean: 'bool',
|
|
12
|
+
any: 'interface{}',
|
|
13
|
+
unknown: 'interface{}',
|
|
14
|
+
void: 'struct{}',
|
|
15
|
+
never: 'interface{}',
|
|
16
|
+
};
|
|
17
|
+
function goType(value) {
|
|
18
|
+
const { type } = unwrapNullable(value);
|
|
19
|
+
const normalized = stripOuterParens(type);
|
|
20
|
+
const union = splitTopLevel(normalized, '|');
|
|
21
|
+
if (union.length > 1) {
|
|
22
|
+
if (union.every(isStringLiteral))
|
|
23
|
+
return 'string';
|
|
24
|
+
if (union.every(isNumberLiteral))
|
|
25
|
+
return 'float64';
|
|
26
|
+
if (union.every(isBooleanLiteral))
|
|
27
|
+
return 'bool';
|
|
28
|
+
return 'interface{}';
|
|
29
|
+
}
|
|
30
|
+
const intersection = splitTopLevel(normalized, '&');
|
|
31
|
+
if (intersection.length > 1 || isInlineObject(normalized))
|
|
32
|
+
return 'map[string]interface{}';
|
|
33
|
+
if (isStringLiteral(normalized))
|
|
34
|
+
return 'string';
|
|
35
|
+
if (isNumberLiteral(normalized))
|
|
36
|
+
return 'float64';
|
|
37
|
+
if (isBooleanLiteral(normalized))
|
|
38
|
+
return 'bool';
|
|
39
|
+
if (GO_PRIMITIVES[normalized])
|
|
40
|
+
return GO_PRIMITIVES[normalized];
|
|
41
|
+
const array = genericArgument(normalized, 'Array');
|
|
42
|
+
if (array !== undefined)
|
|
43
|
+
return `[]${goType(array)}`;
|
|
44
|
+
const record = genericArguments(normalized, 'Record');
|
|
45
|
+
if (record?.length === 2)
|
|
46
|
+
return `map[string]${goType(record[1])}`;
|
|
47
|
+
const map = genericArgument(normalized, 'Map');
|
|
48
|
+
if (map !== undefined)
|
|
49
|
+
return `map[string]${goType(map)}`;
|
|
50
|
+
return normalized;
|
|
51
|
+
}
|
|
52
|
+
const GO_KEYWORDS = new Set([
|
|
53
|
+
'break',
|
|
54
|
+
'default',
|
|
55
|
+
'func',
|
|
56
|
+
'interface',
|
|
57
|
+
'select',
|
|
58
|
+
'case',
|
|
59
|
+
'defer',
|
|
60
|
+
'go',
|
|
61
|
+
'map',
|
|
62
|
+
'struct',
|
|
63
|
+
'chan',
|
|
64
|
+
'else',
|
|
65
|
+
'goto',
|
|
66
|
+
'package',
|
|
67
|
+
'switch',
|
|
68
|
+
'const',
|
|
69
|
+
'fallthrough',
|
|
70
|
+
'if',
|
|
71
|
+
'range',
|
|
72
|
+
'type',
|
|
73
|
+
'continue',
|
|
74
|
+
'for',
|
|
75
|
+
'import',
|
|
76
|
+
'return',
|
|
77
|
+
'var',
|
|
78
|
+
]);
|
|
79
|
+
function goIdentifier(value) {
|
|
80
|
+
const name = value.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
81
|
+
const valid = /^[A-Za-z_]/.test(name) ? name : `value_${name}`;
|
|
82
|
+
return GO_KEYWORDS.has(valid) ? `${valid}_` : valid;
|
|
15
83
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
any: "interface{}",
|
|
24
|
-
unknown: "interface{}",
|
|
84
|
+
function transformParameter(parameter) {
|
|
85
|
+
const targetType = goType(parameter.type);
|
|
86
|
+
return {
|
|
87
|
+
...parameter,
|
|
88
|
+
name: goIdentifier(parameter.name),
|
|
89
|
+
targetType,
|
|
90
|
+
inputType: parameter.required ? targetType : `*${targetType}`,
|
|
25
91
|
};
|
|
26
|
-
if (MAP[t])
|
|
27
|
-
return MAP[t];
|
|
28
|
-
// Array<T>
|
|
29
|
-
const arr = t.match(/^Array<(.+)>$/);
|
|
30
|
-
if (arr)
|
|
31
|
-
return `[]${goPropertyType(arr[1])}`;
|
|
32
|
-
// Record<K, V>
|
|
33
|
-
const rec = t.match(/^Record<(.+),\s*(.+)>$/);
|
|
34
|
-
if (rec)
|
|
35
|
-
return `map[${goPropertyType(rec[1])}]${goPropertyType(rec[2])}`;
|
|
36
|
-
// TypeScript union literals → string
|
|
37
|
-
if (/^["']/.test(t))
|
|
38
|
-
return "string";
|
|
39
|
-
return t;
|
|
40
92
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
93
|
+
function transformSchema(schema) {
|
|
94
|
+
const enumValues = schema.enumValues ?? [];
|
|
95
|
+
const enumType = enumValues.every((value) => typeof value === 'number')
|
|
96
|
+
? 'float64'
|
|
97
|
+
: 'string';
|
|
98
|
+
return {
|
|
99
|
+
...schema,
|
|
100
|
+
external: schema.ownership?.kind === 'external',
|
|
101
|
+
enumType,
|
|
102
|
+
enumValues: enumValues.map((value, index) => ({
|
|
103
|
+
name: typeof value === 'string' ? value : `Value${index + 1}`,
|
|
104
|
+
value: typeof value === 'string' ? JSON.stringify(value) : String(value),
|
|
105
|
+
})),
|
|
106
|
+
aliasType: schema.aliasType
|
|
107
|
+
? goType(schema.aliasType)
|
|
108
|
+
: schema.additionalPropertiesType
|
|
109
|
+
? goType(`Record<string, ${schema.additionalPropertiesType}>`)
|
|
110
|
+
: 'interface{}',
|
|
111
|
+
properties: schema.properties.map((property) => ({
|
|
112
|
+
...property,
|
|
113
|
+
targetType: property.type === 'string' &&
|
|
114
|
+
(property.format === 'date' || property.format === 'date-time')
|
|
115
|
+
? 'time.Time'
|
|
116
|
+
: goType(property.type),
|
|
117
|
+
optional: !!property.nullable || !property.required,
|
|
118
|
+
})),
|
|
119
|
+
};
|
|
48
120
|
}
|
|
49
121
|
export class GoAdapter {
|
|
50
|
-
language =
|
|
51
|
-
async emit(enriched,
|
|
122
|
+
language = 'go';
|
|
123
|
+
async emit(enriched, _outputDir, config) {
|
|
52
124
|
registerHelpers();
|
|
53
|
-
registerGoHelpers();
|
|
54
125
|
const files = [];
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
try {
|
|
77
|
-
const tpl = getTemplate("go", templateName);
|
|
78
|
-
files.push({ relativePath, content: tpl(ctx) });
|
|
79
|
-
}
|
|
80
|
-
catch (err) {
|
|
81
|
-
warnings.push(`${relativePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
82
|
-
}
|
|
126
|
+
const clientType = config?.clientType ?? 'internal';
|
|
127
|
+
const visibleGroups = getVisibleGroups(enriched, clientType);
|
|
128
|
+
const visibleSchemas = getVisibleSchemas(enriched, visibleGroups, clientType);
|
|
129
|
+
const schemaNames = new Set(visibleSchemas.map((schema) => schema.name));
|
|
130
|
+
const schemas = visibleSchemas.map(transformSchema);
|
|
131
|
+
const packageVersion = getPackageVersion(enriched);
|
|
132
|
+
const hasSSE = hasEventStreams(visibleGroups);
|
|
133
|
+
const moduleName = enriched.meta.packageName
|
|
134
|
+
.replace(/^@/, '')
|
|
135
|
+
.split('/')
|
|
136
|
+
.filter(Boolean)
|
|
137
|
+
.map((part) => part.replace(/[^a-zA-Z0-9._~-]/g, '-'))
|
|
138
|
+
.join('/') || 'sdk';
|
|
139
|
+
const pkgName = (moduleName.split('/').pop() || 'sdk')
|
|
140
|
+
.replace(/[^a-zA-Z0-9_]/g, '_')
|
|
141
|
+
.replace(/^[^a-zA-Z_]/, 'sdk');
|
|
142
|
+
const emit = (relativePath, templateName, context) => {
|
|
143
|
+
files.push({
|
|
144
|
+
relativePath,
|
|
145
|
+
content: getTemplate('go', templateName)(context),
|
|
146
|
+
});
|
|
83
147
|
};
|
|
84
|
-
|
|
85
|
-
emit(
|
|
86
|
-
...enriched.meta,
|
|
87
|
-
pkgName,
|
|
88
|
-
});
|
|
89
|
-
emit("README.md", "readme", {
|
|
148
|
+
emit('go.mod', 'go-mod', { ...enriched.meta, packageVersion, moduleName });
|
|
149
|
+
emit('README.md', 'readme', {
|
|
90
150
|
...enriched.meta,
|
|
151
|
+
packageVersion,
|
|
91
152
|
groups: visibleGroups,
|
|
92
|
-
schemas
|
|
153
|
+
schemas,
|
|
93
154
|
securitySchemes: enriched.securitySchemes,
|
|
94
155
|
hasSSE,
|
|
95
156
|
pkgName,
|
|
96
157
|
});
|
|
97
|
-
|
|
98
|
-
emit("client.go", "client", {
|
|
158
|
+
emit('client.go', 'client', {
|
|
99
159
|
...enriched.meta,
|
|
160
|
+
packageVersion,
|
|
100
161
|
groups: visibleGroups,
|
|
101
162
|
securitySchemes: enriched.securitySchemes,
|
|
102
163
|
hasSSE,
|
|
103
164
|
pkgName,
|
|
104
|
-
clientType,
|
|
165
|
+
clientType: config?.clientType ?? 'internal',
|
|
105
166
|
});
|
|
106
|
-
emit(
|
|
167
|
+
emit('transport.go', 'transport', {
|
|
107
168
|
securitySchemes: enriched.securitySchemes,
|
|
169
|
+
packageVersion,
|
|
108
170
|
pkgName,
|
|
109
171
|
});
|
|
110
|
-
emit(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
emit("types.go", "types", {
|
|
114
|
-
schemas: enriched.schemas,
|
|
172
|
+
emit('errors.go', 'errors', { pkgName });
|
|
173
|
+
emit('types.go', 'types', {
|
|
174
|
+
schemas,
|
|
115
175
|
pkgName,
|
|
176
|
+
needsTime: schemas.some((schema) => schema.properties.some((property) => property.targetType === 'time.Time')),
|
|
116
177
|
});
|
|
117
|
-
emit(
|
|
118
|
-
pkgName,
|
|
119
|
-
});
|
|
120
|
-
// ── Domain files ───────────────────────────────────────────────────────
|
|
178
|
+
emit('utils.go', 'utils', { pkgName });
|
|
121
179
|
for (const group of visibleGroups) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
180
|
+
const operations = group.operations.map((operation) => {
|
|
181
|
+
const pathParams = operation.pathParams.map(transformParameter);
|
|
182
|
+
const queryParams = operation.queryParams.map(transformParameter);
|
|
183
|
+
const headerParams = operation.headerParams.map(transformParameter);
|
|
184
|
+
const requestBody = operation.requestBody
|
|
185
|
+
? {
|
|
186
|
+
...operation.requestBody,
|
|
187
|
+
targetType: goType(operation.requestBody.type),
|
|
188
|
+
inputType: operation.requestBody.required
|
|
189
|
+
? goType(operation.requestBody.type)
|
|
190
|
+
: `*${goType(operation.requestBody.type)}`,
|
|
191
|
+
}
|
|
192
|
+
: undefined;
|
|
193
|
+
return {
|
|
194
|
+
...operation,
|
|
195
|
+
pathParams,
|
|
196
|
+
queryParams,
|
|
197
|
+
headerParams,
|
|
198
|
+
requestBody,
|
|
199
|
+
goResponseType: goType(operation.responseType),
|
|
200
|
+
hasQueryParams: queryParams.length > 0,
|
|
201
|
+
hasHeaderParams: headerParams.length > 0,
|
|
202
|
+
needsFormatting: queryParams.length > 0 || headerParams.length > 0,
|
|
203
|
+
};
|
|
204
|
+
});
|
|
205
|
+
emit(`${group.fileName}.go`, 'domain', {
|
|
125
206
|
...group,
|
|
126
|
-
|
|
127
|
-
|
|
207
|
+
operations,
|
|
208
|
+
imports: collectImports(group.operations, schemaNames),
|
|
209
|
+
hasSSE: operations.some((operation) => operation.isEventStream),
|
|
210
|
+
hasQueryParams: operations.some((operation) => operation.hasQueryParams),
|
|
211
|
+
needsFormatting: operations.some((operation) => operation.needsFormatting),
|
|
128
212
|
securitySchemes: enriched.securitySchemes,
|
|
129
213
|
pkgName,
|
|
130
214
|
});
|
|
131
215
|
}
|
|
132
|
-
|
|
216
|
+
files.push(...createDocumentationFiles({
|
|
217
|
+
meta: enriched.meta,
|
|
218
|
+
groups: visibleGroups,
|
|
219
|
+
schemas: visibleSchemas,
|
|
220
|
+
naming: {
|
|
221
|
+
language: 'Go',
|
|
222
|
+
groupAccessor: (group) => `client.${pascalCase(group.name)}`,
|
|
223
|
+
methodName: (operation) => pascalCase(operation.name),
|
|
224
|
+
typeName: goType,
|
|
225
|
+
sourcePath: (group) => `${group.fileName}.go`,
|
|
226
|
+
},
|
|
227
|
+
}));
|
|
228
|
+
return { files, warnings: [] };
|
|
133
229
|
}
|
|
134
230
|
}
|
|
135
231
|
//# sourceMappingURL=index.js.map
|