@fern-api/go-dynamic-snippets 0.0.19 → 1.19.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/dist/index.cjs +32 -0
- package/dist/index.cjs.map +1 -0
- package/{esm/DynamicSnippetsGeneratorContext-X0Mtg6YW.d.ts → dist/index.d.cts} +76 -2
- package/{cjs/DynamicSnippetsGeneratorContext-X0Mtg6YW.d.cts → dist/index.d.ts} +76 -2
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/package.json +9 -10
- package/cjs/DynamicSnippetsGenerator.cjs +0 -37
- package/cjs/DynamicSnippetsGenerator.cjs.map +0 -1
- package/cjs/DynamicSnippetsGenerator.d.cts +0 -20
- package/cjs/EndpointSnippetGenerator.cjs +0 -37
- package/cjs/EndpointSnippetGenerator.cjs.map +0 -1
- package/cjs/EndpointSnippetGenerator.d.cts +0 -66
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +0 -37
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +0 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +0 -4
- package/cjs/context/DynamicTypeInstantiationMapper.cjs +0 -37
- package/cjs/context/DynamicTypeInstantiationMapper.cjs.map +0 -1
- package/cjs/context/DynamicTypeInstantiationMapper.d.cts +0 -4
- package/cjs/context/DynamicTypeMapper.cjs +0 -37
- package/cjs/context/DynamicTypeMapper.cjs.map +0 -1
- package/cjs/context/DynamicTypeMapper.d.cts +0 -4
- package/cjs/context/FilePropertyMapper.cjs +0 -37
- package/cjs/context/FilePropertyMapper.cjs.map +0 -1
- package/cjs/context/FilePropertyMapper.d.cts +0 -4
- package/cjs/index.cjs +0 -37
- package/cjs/index.cjs.map +0 -1
- package/cjs/index.d.cts +0 -6
- package/esm/DynamicSnippetsGenerator.d.ts +0 -20
- package/esm/DynamicSnippetsGenerator.js +0 -2
- package/esm/DynamicSnippetsGenerator.js.map +0 -1
- package/esm/EndpointSnippetGenerator.d.ts +0 -66
- package/esm/EndpointSnippetGenerator.js +0 -2
- package/esm/EndpointSnippetGenerator.js.map +0 -1
- package/esm/chunk-5X6DU53C.js +0 -2
- package/esm/chunk-5X6DU53C.js.map +0 -1
- package/esm/chunk-EUHLPBOB.js +0 -2
- package/esm/chunk-EUHLPBOB.js.map +0 -1
- package/esm/chunk-FVPD7ODP.js +0 -2
- package/esm/chunk-FVPD7ODP.js.map +0 -1
- package/esm/chunk-KGXOPYBU.js +0 -2
- package/esm/chunk-KGXOPYBU.js.map +0 -1
- package/esm/chunk-NY6N4HP7.js +0 -2
- package/esm/chunk-NY6N4HP7.js.map +0 -1
- package/esm/chunk-S5R5YTLQ.js +0 -2
- package/esm/chunk-S5R5YTLQ.js.map +0 -1
- package/esm/chunk-T2DJJZPN.js +0 -2
- package/esm/chunk-T2DJJZPN.js.map +0 -1
- package/esm/chunk-VY2BNRW5.js +0 -37
- package/esm/chunk-VY2BNRW5.js.map +0 -1
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +0 -4
- package/esm/context/DynamicSnippetsGeneratorContext.js +0 -2
- package/esm/context/DynamicSnippetsGeneratorContext.js.map +0 -1
- package/esm/context/DynamicTypeInstantiationMapper.d.ts +0 -4
- package/esm/context/DynamicTypeInstantiationMapper.js +0 -2
- package/esm/context/DynamicTypeInstantiationMapper.js.map +0 -1
- package/esm/context/DynamicTypeMapper.d.ts +0 -4
- package/esm/context/DynamicTypeMapper.js +0 -2
- package/esm/context/DynamicTypeMapper.js.map +0 -1
- package/esm/context/FilePropertyMapper.d.ts +0 -4
- package/esm/context/FilePropertyMapper.js +0 -2
- package/esm/context/FilePropertyMapper.js.map +0 -1
- package/esm/index.d.ts +0 -6
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { AbstractFormatter, Options, Scope, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { go } from \"@fern-api/go-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { FilePropertyInfo } from \"./context/FilePropertyMapper\";\n\nconst SNIPPET_PACKAGE_NAME = \"example\";\nconst SNIPPET_IMPORT_PATH = \"fern\";\nconst SNIPPET_FUNC_NAME = \"do\";\nconst CLIENT_VAR_NAME = \"client\";\nconst TypeInst = go.TypeInstantiation;\nconst WIREMOCK_BASE_URL = \"WireMockBaseURL\";\nconst WIREMOCK_CLIENT_VAR_NAME = \"WireMockClient\";\n\nexport class EndpointSnippetGenerator {\n private context: DynamicSnippetsGeneratorContext;\n private formatter: AbstractFormatter | undefined;\n\n constructor({ context, formatter }: { context: DynamicSnippetsGeneratorContext; formatter?: AbstractFormatter }) {\n this.context = context;\n this.formatter = formatter;\n }\n\n public async generateSnippet({\n endpoint,\n request,\n options\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n options?: Options;\n }): Promise<string> {\n const outputWiremockTests =\n (options?.config as { outputWiremockTests?: boolean })?.outputWiremockTests ?? false;\n if (outputWiremockTests) {\n return this.generateWiremockTest({ endpoint, snippet: request });\n }\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return await code.toStringAsync({\n packageName: SNIPPET_PACKAGE_NAME,\n importPath: SNIPPET_IMPORT_PATH,\n rootImportPath: this.context.rootImportPath,\n customConfig: this.context.customConfig ?? {},\n formatter: this.formatter\n });\n }\n\n public generateSnippetSync({\n endpoint,\n request,\n options\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n options?: Options;\n }): string {\n const outputWiremockTests =\n (options?.config as { outputWiremockTests?: boolean })?.outputWiremockTests ?? false;\n if (outputWiremockTests) {\n return this.generateWiremockTest({ endpoint, snippet: request });\n }\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return code.toString({\n packageName: SNIPPET_PACKAGE_NAME,\n importPath: SNIPPET_IMPORT_PATH,\n rootImportPath: this.context.rootImportPath,\n customConfig: this.context.customConfig ?? {},\n formatter: this.formatter\n });\n }\n\n public async generateSnippetAst({\n endpoint,\n request,\n options\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n options?: Options;\n }): Promise<go.AstNode> {\n throw new Error(\"Unsupported\");\n }\n\n private generateWiremockTest({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): string {\n const code = this.buildWiremockTestCodeBlock({ endpoint, snippet });\n return code.toString({\n packageName: \"wiremock\",\n importPath: SNIPPET_IMPORT_PATH,\n rootImportPath: this.context.rootImportPath,\n customConfig: this.context.customConfig ?? {},\n formatter: this.formatter\n });\n }\n\n private buildCodeBlock({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.AstNode {\n return go.codeblock((writer) => {\n writer.writeNode(\n go.func({\n name: SNIPPET_FUNC_NAME,\n parameters: [],\n return_: [],\n body: go.codeblock((writer) => {\n writer.writeNode(this.constructClient({ endpoint, snippet }));\n writer.writeLine();\n writer.writeNode(this.callMethod({ endpoint, snippet }));\n })\n })\n );\n writer.writeNewLineIfLastLineNot();\n });\n }\n\n private buildWiremockTestCodeBlock({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.AstNode {\n return go.codeblock((writer) => {\n writer.writeNode(\n go.func({\n name: \"Test\" + this.context.getTestMethodName(endpoint) + \"WithWireMock\",\n parameters: [\n go.parameter({\n name: \"t\",\n type: go.Type.pointer(go.Type.reference(this.context.getTestingTypeReference()))\n })\n ],\n return_: [],\n body: go.codeblock((writer) => {\n for (const node of this.buildWiremockTestSetup({ endpoint })) {\n writer.writeNode(node);\n writer.writeLine();\n }\n writer.writeLine();\n writer.writeNode(this.constructWiremockTestClient({ endpoint, snippet }));\n writer.writeLine();\n writer.writeNode(this.callClientMethodAndAssert({ endpoint, snippet }));\n })\n })\n );\n // Not including error case for now until I can figure out why its not matching the wiremock stub\n // writer.writeLine();\n // writer.writeNode(\n // go.func({\n // name: \"Test\" + this.context.getMethodName(endpoint.declaration.name) + \"Error\" + \"WithWireMock\",\n // parameters: [\n // go.parameter({\n // name: \"t\",\n // type: go.Type.pointer(go.Type.reference(this.context.getTestingTypeReference()))\n // })\n // ],\n // return_: [],\n // body: go.codeblock((writer) => {\n // for (const node of this.buildWiremockTestSetup({ endpoint, errorCase: true })) {\n // writer.writeNode(node);\n // writer.writeLine();\n // }\n // writer.writeLine();\n // writer.writeNode(this.constructWiremockTestClient({ endpoint, snippet }));\n // writer.writeLine();\n // writer.writeNode(this.callClientMethodAndAssert({ endpoint, snippet }));\n // })\n // })\n // );\n writer.writeNewLineIfLastLineNot();\n });\n }\n\n private constructClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.CodeBlock {\n return go.codeblock((writer) => {\n writer.write(`${CLIENT_VAR_NAME} := `);\n writer.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({ endpoint, snippet })));\n });\n }\n\n private constructWiremockTestClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.CodeBlock {\n return go.codeblock((writer) => {\n writer.write(`${CLIENT_VAR_NAME} := `);\n writer.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()));\n });\n }\n\n private writeMethodInvocation({\n writer,\n endpoint,\n snippet\n }: {\n writer: go.Writer;\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): void {\n const { otherArgs, requestArg } = this.getMethodArgs({ endpoint, snippet });\n\n if (requestArg != null) {\n if (requestArg instanceof go.TypeInstantiation && go.TypeInstantiation.isNop(requestArg)) {\n writer.writeNode(\n go.invokeMethod({\n on: go.codeblock(CLIENT_VAR_NAME),\n method: this.getMethod({ endpoint }),\n arguments_: [this.context.getContextTodoFunctionInvocation(), ...otherArgs, go.codeblock(\"nil\")]\n })\n );\n } else {\n writer.write(\"request := \");\n writer.writeNode(requestArg);\n writer.writeLine();\n\n const requestRef = go.codeblock(\"request\");\n writer.writeNode(\n go.invokeMethod({\n on: go.codeblock(CLIENT_VAR_NAME),\n method: this.getMethod({ endpoint }),\n arguments_: [this.context.getContextTodoFunctionInvocation(), ...otherArgs, requestRef]\n })\n );\n }\n } else {\n writer.writeNode(\n go.invokeMethod({\n on: go.codeblock(CLIENT_VAR_NAME),\n method: this.getMethod({ endpoint }),\n arguments_: [this.context.getContextTodoFunctionInvocation(), ...otherArgs]\n })\n );\n }\n }\n\n private callMethod({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.CodeBlock {\n return go.codeblock((writer) => {\n this.writeMethodInvocation({ writer, endpoint, snippet });\n });\n }\n\n private getConstructorArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.AstNode[] {\n const args: go.AstNode[] = [];\n const baseUrlArg = this.getConstructorBaseUrlArg({\n baseUrl: snippet.baseURL,\n environment: snippet.environment\n });\n if (baseUrlArg != null) {\n args.push(baseUrlArg);\n }\n if (endpoint.auth != null) {\n if (snippet.auth != null) {\n args.push(this.getConstructorAuthArg({ auth: endpoint.auth, values: snippet.auth }));\n } else {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`\n });\n }\n }\n this.context.errors.scope(Scope.Headers);\n if (this.context.ir.headers != null && snippet.headers != null) {\n args.push(...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers }));\n }\n this.context.errors.unscope();\n return args;\n }\n\n private getWiremockTestConstructorArgs(): go.AstNode[] {\n return [\n go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"WithBaseURL\",\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [go.codeblock(WIREMOCK_BASE_URL)]\n })\n );\n })\n ];\n }\n\n private getConstructorAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): go.AstNode {\n if (values.type !== auth.type) {\n this.addError(this.context.newAuthMismatchError({ auth, values }).message);\n return TypeInst.nop();\n }\n switch (auth.type) {\n case \"basic\":\n return values.type === \"basic\" ? this.getConstructorBasicAuthArg({ auth, values }) : TypeInst.nop();\n case \"bearer\":\n return values.type === \"bearer\" ? this.getConstructorBearerAuthArg({ auth, values }) : TypeInst.nop();\n case \"header\":\n return values.type === \"header\" ? this.getConstructorHeaderAuthArg({ auth, values }) : TypeInst.nop();\n case \"oauth\":\n this.addWarning(\"The Go SDK doesn't support OAuth client credentials yet\");\n return TypeInst.nop();\n case \"inferred\":\n this.addWarning(\"The Go SDK Generator does not support Inferred auth scheme yet\");\n return TypeInst.nop();\n default:\n assertNever(auth);\n }\n }\n\n private addError(message: string): void {\n this.context.errors.add({ severity: Severity.Critical, message });\n }\n\n private addWarning(message: string): void {\n this.context.errors.add({ severity: Severity.Warning, message });\n }\n\n private getConstructorBasicAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BasicAuth;\n values: FernIr.dynamic.BasicAuthValues;\n }): go.AstNode {\n return go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"WithBasicAuth\",\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [\n go.TypeInstantiation.string(values.username),\n go.TypeInstantiation.string(values.password)\n ]\n })\n );\n });\n }\n\n private getConstructorBaseUrlArg({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): go.AstNode | undefined {\n const baseUrlArg = this.getBaseUrlArg({ baseUrl, environment });\n if (baseUrlArg == null) {\n return undefined;\n }\n return go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"WithBaseURL\",\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [baseUrlArg]\n })\n );\n });\n }\n\n private getBaseUrlArg({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): go.AstNode | undefined {\n if (baseUrl != null && environment != null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Cannot specify both baseUrl and environment options\"\n });\n return undefined;\n }\n if (baseUrl != null) {\n return go.TypeInstantiation.string(baseUrl);\n }\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const typeReference = this.context.getEnvironmentTypeReferenceFromID(environment);\n if (typeReference == null) {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Environment ${JSON.stringify(environment)} was not found`\n });\n return undefined;\n }\n return go.TypeInstantiation.reference(typeReference);\n }\n if (this.context.isMultiEnvironmentValues(environment)) {\n this.context.errors.add({\n severity: Severity.Warning,\n message:\n \"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead\"\n });\n }\n }\n return undefined;\n }\n\n private getConstructorBearerAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BearerAuth;\n values: FernIr.dynamic.BearerAuthValues;\n }): go.AstNode {\n return go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: `With${auth.token.pascalCase.unsafeName}`,\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [go.TypeInstantiation.string(values.token)]\n })\n );\n });\n }\n\n private getConstructorHeaderAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.HeaderAuth;\n values: FernIr.dynamic.HeaderAuthValues;\n }): go.AstNode {\n return go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: `With${auth.header.name.name.pascalCase.unsafeName}`,\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [\n this.context.dynamicTypeInstantiationMapper.convert({\n typeReference: auth.header.typeReference,\n value: values.value\n })\n ]\n })\n );\n });\n }\n\n private getConstructorHeaderArgs({\n headers,\n values\n }: {\n headers: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): go.AstNode[] {\n const args: go.AstNode[] = [];\n for (const header of headers) {\n const arg = this.getConstructorHeaderArg({ header, value: values.value });\n if (arg != null) {\n args.push(arg);\n }\n }\n return args;\n }\n\n private getConstructorHeaderArg({\n header,\n value\n }: {\n header: FernIr.dynamic.NamedParameter;\n value: unknown;\n }): go.AstNode | undefined {\n const typeInstantiation = this.context.dynamicTypeInstantiationMapper.convert({\n typeReference: header.typeReference,\n value\n });\n if (go.TypeInstantiation.isNop(typeInstantiation)) {\n // Literal header values (e.g. \"X-API-Version\") should not be included in the\n // client constructor.\n return undefined;\n }\n return go.codeblock((writer) => {\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: `With${header.name.name.pascalCase.unsafeName}`,\n importPath: this.context.getOptionImportPath()\n }),\n arguments_: [typeInstantiation]\n })\n );\n });\n }\n\n private getMethodArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): { otherArgs: go.AstNode[]; requestArg: go.AstNode | undefined } {\n switch (endpoint.request.type) {\n case \"inlined\":\n return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });\n case \"body\":\n return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });\n default:\n assertNever(endpoint.request);\n }\n }\n\n private getMethodArgsForBodyRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.BodyRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): { otherArgs: go.AstNode[]; requestArg: go.AstNode | undefined } {\n const otherArgs: go.AstNode[] = [];\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n otherArgs.push(\n ...this.getPathParameters({ namedParameters: pathParameters, snippet }).map((field) => field.value)\n );\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestArg: go.AstNode | undefined =\n request.body != null\n ? this.getBodyRequestArg({ body: request.body, value: snippet.requestBody })\n : undefined;\n this.context.errors.unscope();\n\n return { otherArgs, requestArg };\n }\n\n private getBodyRequestArg({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): go.TypeInstantiation {\n switch (body.type) {\n case \"bytes\": {\n return this.getBytesBodyRequestArg({ value });\n }\n case \"typeReference\":\n return this.context.dynamicTypeInstantiationMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getBytesBodyRequestArg({ value }: { value: unknown }): go.TypeInstantiation {\n if (typeof value !== \"string\") {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected bytes value to be a string, got ${typeof value}`\n });\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.bytes(value as string);\n }\n\n private getMethodArgsForInlinedRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): { otherArgs: go.AstNode[]; requestArg: go.AstNode | undefined } {\n const otherArgs: go.AstNode[] = [];\n\n const { inlinePathParameters, inlineFileProperties } = {\n inlinePathParameters: this.context.customConfig?.inlinePathParameters ?? true,\n inlineFileProperties: this.context.customConfig?.inlineFileProperties ?? true\n };\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameterFields: go.StructField[] = [];\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n pathParameterFields.push(\n ...this.getPathParameters({\n namedParameters: pathParameters,\n snippet\n })\n );\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });\n this.context.errors.unscope();\n\n if (!this.context.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n otherArgs.push(...pathParameterFields.map((field) => field.value));\n }\n\n if (!inlineFileProperties) {\n otherArgs.push(...filePropertyInfo.fileFields.map((field) => field.value));\n }\n\n const requestArg: go.AstNode | undefined = this.context.needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties\n })\n ? this.getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields: this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ? pathParameterFields\n : [],\n filePropertyInfo\n })\n : undefined;\n return { otherArgs, requestArg };\n }\n\n private getFilePropertyInfo({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): FilePropertyInfo {\n if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {\n return {\n fileFields: [],\n bodyPropertyFields: []\n };\n }\n return this.context.filePropertyMapper.getFilePropertyInfo({\n body: request.body,\n value: snippet.requestBody\n });\n }\n\n private getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields,\n filePropertyInfo\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n pathParameterFields: go.StructField[];\n filePropertyInfo: FilePropertyInfo;\n }): go.TypeInstantiation {\n this.context.errors.scope(Scope.QueryParameters);\n const queryParameters = this.context.associateQueryParametersByWireValue({\n parameters: request.queryParameters ?? [],\n values: snippet.queryParameters ?? {}\n });\n const queryParameterFields = queryParameters.map((queryParameter) => ({\n name: queryParameter.name.name.pascalCase.unsafeName,\n value: this.context.dynamicTypeInstantiationMapper.convert(queryParameter)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n const headers = this.context.associateByWireValue({\n parameters: request.headers ?? [],\n values: snippet.headers ?? {}\n });\n const headerFields = headers.map((header) => ({\n name: header.name.name.pascalCase.unsafeName,\n value: this.context.dynamicTypeInstantiationMapper.convert(header)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestBodyFields =\n request.body != null\n ? this.getInlinedRequestBodyStructFields({\n body: request.body,\n value: snippet.requestBody,\n filePropertyInfo\n })\n : [];\n this.context.errors.unscope();\n\n return go.TypeInstantiation.structPointer({\n typeReference: go.typeReference({\n name: this.context.getMethodName(request.declaration.name),\n importPath: this.context.getImportPathForRequest(request.declaration.fernFilepath)\n }),\n fields: [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields]\n });\n }\n\n private getInlinedRequestBodyStructFields({\n body,\n value,\n filePropertyInfo\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n value: unknown;\n filePropertyInfo: FilePropertyInfo;\n }): go.StructField[] {\n switch (body.type) {\n case \"properties\":\n return this.getInlinedRequestBodyPropertyStructFields({ parameters: body.value, value });\n case \"referenced\":\n return [this.getReferencedRequestBodyPropertyStructField({ body, value })];\n case \"fileUpload\":\n return this.getFileUploadRequestBodyStructFields({ filePropertyInfo });\n default:\n assertNever(body);\n }\n }\n\n private getFileUploadRequestBodyStructFields({\n filePropertyInfo\n }: {\n filePropertyInfo: FilePropertyInfo;\n }): go.StructField[] {\n if (this.context.customConfig?.inlineFileProperties) {\n return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];\n }\n return filePropertyInfo.bodyPropertyFields;\n }\n\n private getReferencedRequestBodyPropertyStructField({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): go.StructField {\n return {\n name: this.context.getTypeName(body.bodyKey),\n value: this.getReferencedRequestBodyPropertyTypeInstantiation({ body: body.bodyType, value })\n };\n }\n\n private getReferencedRequestBodyPropertyTypeInstantiation({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): go.TypeInstantiation {\n switch (body.type) {\n case \"bytes\":\n return this.getBytesBodyRequestArg({ value });\n case \"typeReference\":\n return this.context.dynamicTypeInstantiationMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getInlinedRequestBodyPropertyStructFields({\n parameters,\n value\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n value: unknown;\n }): go.StructField[] {\n const fields: go.StructField[] = [];\n\n const bodyProperties = this.context.associateByWireValue({\n parameters,\n values: this.context.getRecord(value) ?? {}\n });\n for (const parameter of bodyProperties) {\n fields.push({\n name: this.context.getTypeName(parameter.name.name),\n value: this.context.dynamicTypeInstantiationMapper.convert(parameter)\n });\n }\n\n return fields;\n }\n\n private getPathParameters({\n namedParameters,\n snippet\n }: {\n namedParameters: FernIr.dynamic.NamedParameter[];\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.StructField[] {\n const args: go.StructField[] = [];\n\n const pathParameters = this.context.associateByWireValue({\n parameters: namedParameters,\n values: snippet.pathParameters ?? {}\n });\n for (const parameter of pathParameters) {\n args.push({\n name: this.context.getTypeName(parameter.name.name),\n value: this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(parameter)\n });\n }\n\n return args;\n }\n\n private getMethod({ endpoint }: { endpoint: FernIr.dynamic.Endpoint }): string {\n if (endpoint.declaration.fernFilepath.allParts.length > 0) {\n return `${endpoint.declaration.fernFilepath.allParts\n .map((val) => this.context.getMethodName(val))\n .join(\".\")}.${this.context.getMethodName(endpoint.declaration.name)}`;\n }\n return this.context.getMethodName(endpoint.declaration.name);\n }\n\n private getRootClientFuncInvocation(arguments_: go.AstNode[]): go.FuncInvocation {\n return go.invokeFunc({\n func: go.typeReference({\n name: this.context.getClientConstructorName(),\n importPath: this.context.getClientImportPath()\n }),\n arguments_\n });\n }\n\n private buildWiremockTestSetup({\n endpoint,\n errorCase\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n errorCase?: boolean;\n }): go.AstNode[] {\n const ENDPOINT_STUB_NAME = \"stub\";\n const usedSharedMainTest = true;\n return [\n ...(!usedSharedMainTest\n ? [\n // Initialize context\n go.codeblock((writer) => {\n writer.write(\"ctx := \");\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"Background\",\n importPath: \"context\"\n }),\n arguments_: [],\n multiline: false\n })\n );\n }),\n\n // Start WireMock container\n go.codeblock((writer) => {\n writer.write(`container, containerErr := `);\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"RunContainerAndStopOnCleanup\",\n importPath: \"github.com/wiremock/wiremock-testcontainers-go\"\n }),\n arguments_: [\n go.codeblock(\"ctx\"),\n go.codeblock(\"t\"),\n go.invokeFunc({\n func: go.typeReference({\n name: \"WithImage\",\n importPath: \"github.com/wiremock/wiremock-testcontainers-go\"\n }),\n arguments_: [\n go.TypeInstantiation.string(\"docker.io/wiremock/wiremock:3.9.1\")\n ],\n multiline: false\n })\n ],\n multiline: true\n })\n );\n }),\n\n // Check for container error\n go.codeblock((writer) => {\n writer.write(\"if containerErr != nil {\");\n writer.writeLine();\n writer.write(\" t.Fatal(containerErr)\");\n writer.writeLine();\n writer.write(\"}\");\n }),\n\n // Get WireMock URL from container\n go.codeblock((writer) => {\n writer.write(`${WIREMOCK_BASE_URL}, endpointErr := `);\n writer.writeNode(\n go.invokeMethod({\n on: go.codeblock(\"container\"),\n method: \"Endpoint\",\n arguments_: [go.codeblock(\"ctx\"), go.TypeInstantiation.string(\"\")],\n multiline: false\n })\n );\n }),\n\n go.invokeFunc({\n func: go.typeReference({\n name: \"NoError\",\n importPath: \"github.com/stretchr/testify/require\"\n }),\n arguments_: [\n go.codeblock(\"t\"),\n go.codeblock(\"endpointErr\"),\n go.TypeInstantiation.string(\"Failed to get WireMock container endpoint\")\n ],\n multiline: false\n }),\n\n go.codeblock((writer) => {\n writer.write(`${WIREMOCK_BASE_URL} = \"http://\" + ${WIREMOCK_BASE_URL}`);\n }),\n\n // Get WireMock client from container\n go.codeblock((writer) => {\n writer.write(`${WIREMOCK_CLIENT_VAR_NAME} := `);\n writer.writeNode(\n go.selector({\n on: go.codeblock(\"container\"),\n selector: go.codeblock(\"Client\")\n })\n );\n })\n ]\n : [])\n ];\n }\n\n private callClientMethodAndAssert({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): go.CodeBlock {\n return go.codeblock((writer) => {\n // IMPORTANT: currently not capturing the response/error values since its not trivial to determine\n // the number of return values for the method using the dynamic ir\n\n // Call the method and capture response and error\n // writer.write(\"_, invocationErr := \");\n this.writeMethodInvocation({ writer, endpoint, snippet });\n writer.writeLine();\n writer.writeLine();\n\n // Verify WireMock request was matched\n writer.write(\"ok, countErr := \");\n writer.writeNode(\n go.invokeMethod({\n on: go.codeblock(WIREMOCK_CLIENT_VAR_NAME),\n method: \"Verify\",\n arguments_: [\n go.invokeMethod({\n on: go.codeblock(\"stub\"),\n method: \"Request\",\n arguments_: [],\n multiline: false\n }),\n go.codeblock(\"1\")\n ],\n multiline: false\n })\n );\n writer.writeLine();\n\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"NoError\",\n importPath: \"github.com/stretchr/testify/require\"\n }),\n arguments_: [\n go.codeblock(\"t\"),\n go.codeblock(\"countErr\"),\n go.TypeInstantiation.string(\"Failed to verify WireMock request was matched\")\n ],\n multiline: false\n })\n );\n writer.writeLine();\n\n writer.writeNode(\n go.invokeFunc({\n func: go.typeReference({\n name: \"True\",\n importPath: \"github.com/stretchr/testify/require\"\n }),\n arguments_: [\n go.codeblock(\"t\"),\n go.codeblock(\"ok\"),\n go.TypeInstantiation.string(\"WireMock request was not matched\")\n ],\n multiline: false\n })\n );\n writer.writeLine();\n\n // IMPORTANT: currently not asserting that the call succeeded since its not trivial to determine\n // the number of return values for the method using the dynamic ir\n\n // Verify the call succeeded (may not assert this at all and only assert the WireMock request was matched)\n // Since we don't necessarily have valid response bodies in our WireMock stubs (so type casting will fail)\n // writer.writeNode(\n // go.invokeFunc({\n // func: go.typeReference({\n // name: \"NoError\",\n // importPath: \"github.com/stretchr/testify/require\"\n // }),\n // arguments_: [\n // go.codeblock(\"t\"),\n // go.codeblock(\"invocationErr\"),\n // go.TypeInstantiation.string(`${this.getMethod({ endpoint })} call should succeed with WireMock`)\n // ],\n // multiline: false\n // })\n // );\n // writer.writeLine();\n });\n }\n}\n"],"mappings":"8GAAAA,IAAAC,IAQA,IAAMC,EAAuB,UACvBC,EAAsB,OACtBC,EAAoB,KACpBC,EAAkB,SAClBC,EAAWC,EAAG,kBACdC,EAAoB,kBACpBC,EAA2B,iBAEpBC,EAAN,KAA+B,CAIlC,YAAY,CAAE,QAAAC,EAAS,UAAAC,CAAU,EAAgF,CAHjHC,EAAA,KAAQ,WACRA,EAAA,KAAQ,aAGJ,KAAK,QAAUF,EACf,KAAK,UAAYC,CACrB,CAEA,MAAa,gBAAgB,CACzB,SAAAE,EACA,QAAAC,EACA,QAAAC,CACJ,EAIoB,CAjCxB,IAAAC,EAAAC,EAAAC,EAoCQ,QADKD,GAAAD,EAAAD,GAAA,YAAAA,EAAS,SAAT,YAAAC,EAAuD,sBAAvD,KAAAC,EAA8E,IAExE,KAAK,qBAAqB,CAAE,SAAAJ,EAAU,QAASC,CAAQ,CAAC,EAG5D,MADM,KAAK,eAAe,CAAE,SAAAD,EAAU,QAASC,CAAQ,CAAC,EAC7C,cAAc,CAC5B,YAAab,EACb,WAAYC,EACZ,eAAgB,KAAK,QAAQ,eAC7B,cAAcgB,EAAA,KAAK,QAAQ,eAAb,KAAAA,EAA6B,CAAC,EAC5C,UAAW,KAAK,SACpB,CAAC,CACL,CAEO,oBAAoB,CACvB,SAAAL,EACA,QAAAC,EACA,QAAAC,CACJ,EAIW,CAzDf,IAAAC,EAAAC,EAAAC,EA4DQ,QADKD,GAAAD,EAAAD,GAAA,YA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AAY,CACRA,EAAG,UAAU,GAAG,EAChBA,EAAG,UAAU,IAAI,EACjBA,EAAG,kBAAkB,OAAO,kCAAkC,CAClE,EACA,UAAW,EACf,CAAC,CACL,EACAc,EAAO,UAAU,CAsBrB,CAAC,CACL,CACJ","names":["init_process","init_buffer","SNIPPET_PACKAGE_NAME","SNIPPET_IMPORT_PATH","SNIPPET_FUNC_NAME","CLIENT_VAR_NAME","TypeInst","go_exports","WIREMOCK_BASE_URL","WIREMOCK_CLIENT_VAR_NAME","EndpointSnippetGenerator","context","formatter","__publicField","endpoint","request","options","_a","_b","_c","snippet","writer","node","otherArgs","requestArg","requestRef","args","baseUrlArg","Severity","Scope","auth","values","assertNever","message","baseUrl","environment","typeReference","headers","header","arg","value","typeInstantiation","pathParameters","field","body","_d","_e","_f","inlinePathParameters","inlineFileProperties","pathParameterFields","filePropertyInfo","queryParameterFields","queryParameter","headerFields","requestBodyFields","parameters","fields","bodyProperties","parameter","namedParameters","val","arguments_","errorCase","ENDPOINT_STUB_NAME"]}
|
package/esm/chunk-T2DJJZPN.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-NY6N4HP7.js";import{c}from"./chunk-EUHLPBOB.js";import{a as g}from"./chunk-5X6DU53C.js";import{a as h}from"./chunk-FVPD7ODP.js";import{e as r,f as a,g as s,h as p,j as n,k as m,l as u}from"./chunk-VY2BNRW5.js";a();s();var f=class y extends c{constructor({ir:e,config:t}){super({ir:e,config:t});r(this,"ir");r(this,"customConfig");r(this,"dynamicTypeMapper");r(this,"dynamicTypeInstantiationMapper");r(this,"filePropertyMapper");r(this,"rootImportPath");this.ir=e,this.customConfig=t.customConfig!=null?t.customConfig:void 0,this.dynamicTypeMapper=new g({context:this}),this.dynamicTypeInstantiationMapper=new l({context:this}),this.filePropertyMapper=new h({context:this}),this.rootImportPath=u({config:t,customConfig:this.customConfig})}clone(){return new y({ir:this.ir,config:this.config})}isOptional(e){switch(e.type){case"optional":case"map":return!0;case"nullable":case"list":case"set":return this.isOptional(e.value);case"named":case"literal":case"primitive":case"unknown":return!1;default:p(e)}}getMethodName(e){return e.pascalCase.unsafeName}getTestMethodName(e){return e.declaration.fernFilepath.allParts.map(t=>t.pascalCase.unsafeName).join("")+e.declaration.name.pascalCase.unsafeName}getTypeName(e){return e.pascalCase.unsafeName}getFieldName(e){return m(e.pascalCase.unsafeName)}getImportPath(e){let t=e.packagePath.map(i=>i.pascalCase.unsafeName.toLowerCase());return[this.rootImportPath,...t].join("/")}getImportPathForRequest(e){var t;return(t=this.customConfig)!=null&&t.exportAllRequestsAtRoot?this.rootImportPath:this.getImportPath(e)}getContextTypeReference(){return n.typeReference({name:"Context",importPath:"context"})}getContextTodoFunctionInvocation(){return n.invokeFunc({func:n.typeReference({name:"TODO",importPath:"context"}),arguments_:[]})}getIoReaderTypeReference(){return n.typeReference({name:"Reader",importPath:"io"})}getTestingTypeReference(){return n.typeReference({name:"T",importPath:"testing"})}getNewStringsReaderFunctionInvocation(e){return n.invokeFunc({func:n.typeReference({name:"NewReader",importPath:"strings"}),arguments_:[n.TypeInstantiation.string(e)]})}getClientConstructorName(){var e,t;return((e=this.customConfig)==null?void 0:e.clientConstructorName)!=null?this.customConfig.clientConstructorName:((t=this.customConfig)==null?void 0:t.exportedClientName)!=null?`New${this.customConfig.exportedClientName}`:`New${this.getClientName()}`}getClientName(){var e;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:"Client"}getClientImportPath(){return`${this.rootImportPath}/client`}getOptionImportPath(){return`${this.rootImportPath}/option`}getGoTypeReferenceFromDeclaration({declaration:e}){return n.typeReference({name:e.name.pascalCase.unsafeName,importPath:this.getImportPath(e.fernFilepath)})}getEnvironmentTypeReferenceFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return this.getEnvironmentTypeReference(t)}getEnvironmentTypeReference(e){return n.typeReference({name:`Environments.${this.getTypeName(e)}`,importPath:this.rootImportPath})}static chainMethods(e,...t){if(t.length===0)throw new Error("Must have methods to chain");let i=e;for(let o of t)i=n.invokeMethod({on:i,method:o.method,arguments_:o.arguments_,multiline:o.multiline});return i}};export{f as a};
|
|
2
|
-
//# sourceMappingURL=chunk-T2DJJZPN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/context/DynamicSnippetsGeneratorContext.ts"],"sourcesContent":["import {\n AbstractDynamicSnippetsGeneratorContext,\n FernGeneratorExec\n} from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { BaseGoCustomConfigSchema, go, goExportedFieldName, resolveRootImportPath } from \"@fern-api/go-ast\";\n\nimport { DynamicTypeInstantiationMapper } from \"./DynamicTypeInstantiationMapper\";\nimport { DynamicTypeMapper } from \"./DynamicTypeMapper\";\nimport { FilePropertyMapper } from \"./FilePropertyMapper\";\n\nexport class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {\n public ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n public customConfig: BaseGoCustomConfigSchema | undefined;\n public dynamicTypeMapper: DynamicTypeMapper;\n public dynamicTypeInstantiationMapper: DynamicTypeInstantiationMapper;\n public filePropertyMapper: FilePropertyMapper;\n public rootImportPath: string;\n\n constructor({\n ir,\n config\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n }) {\n super({ ir, config });\n this.ir = ir;\n this.customConfig = config.customConfig != null ? (config.customConfig as BaseGoCustomConfigSchema) : undefined;\n this.dynamicTypeMapper = new DynamicTypeMapper({ context: this });\n this.dynamicTypeInstantiationMapper = new DynamicTypeInstantiationMapper({ context: this });\n this.filePropertyMapper = new FilePropertyMapper({ context: this });\n this.rootImportPath = resolveRootImportPath({ config, customConfig: this.customConfig });\n }\n\n public clone(): DynamicSnippetsGeneratorContext {\n return new DynamicSnippetsGeneratorContext({\n ir: this.ir,\n config: this.config\n });\n }\n\n public isOptional(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"optional\":\n case \"map\":\n return true;\n case \"nullable\":\n case \"list\":\n case \"set\":\n return this.isOptional(typeReference.value);\n case \"named\":\n case \"literal\":\n case \"primitive\":\n case \"unknown\":\n return false;\n default:\n assertNever(typeReference);\n }\n }\n\n public getMethodName(name: FernIr.Name): string {\n return name.pascalCase.unsafeName;\n }\n\n public getTestMethodName(endpoint: FernIr.dynamic.Endpoint): string {\n return (\n endpoint.declaration.fernFilepath.allParts.map((name) => name.pascalCase.unsafeName).join(\"\") +\n endpoint.declaration.name.pascalCase.unsafeName\n );\n }\n\n public getTypeName(name: FernIr.Name): string {\n return name.pascalCase.unsafeName;\n }\n\n public getFieldName(name: FernIr.Name): string {\n return goExportedFieldName(name.pascalCase.unsafeName);\n }\n\n public getImportPath(fernFilepath: FernIr.dynamic.FernFilepath): string {\n const parts = fernFilepath.packagePath.map((path) => path.pascalCase.unsafeName.toLowerCase());\n return [this.rootImportPath, ...parts].join(\"/\");\n }\n\n public getImportPathForRequest(fernFilepath: FernIr.dynamic.FernFilepath): string {\n if (this.customConfig?.exportAllRequestsAtRoot) {\n return this.rootImportPath;\n }\n return this.getImportPath(fernFilepath);\n }\n\n public getContextTypeReference(): go.TypeReference {\n return go.typeReference({\n name: \"Context\",\n importPath: \"context\"\n });\n }\n\n public getContextTodoFunctionInvocation(): go.FuncInvocation {\n return go.invokeFunc({\n func: go.typeReference({\n name: \"TODO\",\n importPath: \"context\"\n }),\n arguments_: []\n });\n }\n\n public getIoReaderTypeReference(): go.TypeReference {\n return go.typeReference({\n name: \"Reader\",\n importPath: \"io\"\n });\n }\n\n public getTestingTypeReference(): go.TypeReference {\n return go.typeReference({\n name: \"T\",\n importPath: \"testing\"\n });\n }\n\n public getNewStringsReaderFunctionInvocation(s: string): go.FuncInvocation {\n return go.invokeFunc({\n func: go.typeReference({\n name: \"NewReader\",\n importPath: \"strings\"\n }),\n arguments_: [go.TypeInstantiation.string(s)]\n });\n }\n\n public getClientConstructorName(): string {\n if (this.customConfig?.clientConstructorName != null) {\n return this.customConfig.clientConstructorName;\n }\n if (this.customConfig?.exportedClientName != null) {\n return `New${this.customConfig.exportedClientName}`;\n }\n return `New${this.getClientName()}`;\n }\n\n public getClientName(): string {\n if (this.customConfig?.clientName != null) {\n return this.customConfig.clientName;\n }\n return \"Client\";\n }\n\n public getClientImportPath(): string {\n return `${this.rootImportPath}/client`;\n }\n\n public getOptionImportPath(): string {\n return `${this.rootImportPath}/option`;\n }\n\n public getGoTypeReferenceFromDeclaration({\n declaration\n }: {\n declaration: FernIr.dynamic.Declaration;\n }): go.TypeReference {\n return go.typeReference({\n name: declaration.name.pascalCase.unsafeName,\n importPath: this.getImportPath(declaration.fernFilepath)\n });\n }\n\n public getEnvironmentTypeReferenceFromID(environmentID: string): go.TypeReference | undefined {\n const environmentName = this.resolveEnvironmentName(environmentID);\n if (environmentName == null) {\n return undefined;\n }\n return this.getEnvironmentTypeReference(environmentName);\n }\n\n private getEnvironmentTypeReference(name: FernIr.Name): go.TypeReference {\n return go.typeReference({\n name: `Environments.${this.getTypeName(name)}`,\n importPath: this.rootImportPath\n });\n }\n\n public static chainMethods(\n baseFunc: go.FuncInvocation,\n ...methods: Omit<go.MethodInvocation.Args, \"on\">[]\n ): go.MethodInvocation {\n if (methods.length === 0) {\n throw new Error(\"Must have methods to chain\");\n }\n\n let current: go.AstNode = baseFunc;\n for (const method of methods) {\n current = go.invokeMethod({\n on: current,\n method: method.method,\n arguments_: method.arguments_,\n multiline: method.multiline\n });\n }\n return current as go.MethodInvocation;\n }\n}\n"],"mappings":"6OAAAA,IAAAC,IAYO,IAAMC,EAAN,MAAMC,UAAwCC,CAAwC,CAQzF,YAAY,CACR,GAAAC,EACA,OAAAC,CACJ,EAGG,CACC,MAAM,CAAE,GAAAD,EAAI,OAAAC,CAAO,CAAC,EAdxBC,EAAA,KAAO,MACPA,EAAA,KAAO,gBACPA,EAA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,cAAcA,EAAY,YAAY,CAC3D,CAAC,CACL,CAEO,kCAAkCC,EAAqD,CAC1F,IAAMC,EAAkB,KAAK,uBAAuBD,CAAa,EACjE,GAAIC,GAAmB,KAGvB,OAAO,KAAK,4BAA4BA,CAAe,CAC3D,CAEQ,4BAA4BZ,EAAqC,CACrE,OAAOO,EAAG,cAAc,CACpB,KAAM,gBAAgB,KAAK,YAAYP,CAAI,CAAC,GAC5C,WAAY,KAAK,cACrB,CAAC,CACL,CAEA,OAAc,aACVa,KACGC,EACgB,CACnB,GAAIA,EAAQ,SAAW,EACnB,MAAM,IAAI,MAAM,4BAA4B,EAGhD,IAAIC,EAAsBF,EAC1B,QAAWG,KAAUF,EACjBC,EAAUR,EAAG,aAAa,CACtB,GAAIQ,EACJ,OAAQC,EAAO,OACf,WAAYA,EAAO,WACnB,UAAWA,EAAO,SACtB,CAAC,EAEL,OAAOD,CACX,CACJ","names":["init_process","init_buffer","DynamicSnippetsGeneratorContext","_DynamicSnippetsGeneratorContext","AbstractDynamicSnippetsGeneratorContext","ir","config","__publicField","DynamicTypeMapper","DynamicTypeInstantiationMapper","FilePropertyMapper","resolveRootImportPath","typeReference","assertNever","name","endpoint","goExportedFieldName","fernFilepath","parts","path","_a","go_exports","s","_b","declaration","environmentID","environmentName","baseFunc","methods","current","method"]}
|
package/esm/chunk-VY2BNRW5.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var Oe=Object.defineProperty,It=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var We=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable;var Re=(r,t,e)=>t in r?Oe(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e,_n=(r,t)=>{for(var e in t||(t={}))We.call(t,e)&&Re(r,e,t[e]);if(de)for(var e of de(t))je.call(t,e)&&Re(r,e,t[e]);return r},Ln=(r,t)=>It(r,kt(t));var Pn=r=>typeof r=="symbol"?r:r+"",Bn=(r,t)=>{var e={};for(var n in r)We.call(r,n)&&t.indexOf(n)<0&&(e[n]=r[n]);if(r!=null&&de)for(var n of de(r))t.indexOf(n)<0&&je.call(r,n)&&(e[n]=r[n]);return e};var we=(r,t)=>()=>(r&&(t=r(r=0)),t);var bt=(r,t)=>{for(var e in t)Oe(r,e,{get:t[e],enumerable:!0})};var u=(r,t,e)=>Re(r,typeof t!="symbol"?t+"":t,e);function Ge(){throw new Error("setTimeout has not been defined")}function Je(){throw new Error("clearTimeout has not been defined")}function ze(r){if(D===setTimeout)return setTimeout(r,0);if((D===Ge||!D)&&setTimeout)return D=setTimeout,setTimeout(r,0);try{return D(r,0)}catch(t){try{return D.call(null,r,0)}catch(e){return D.call(this,r,0)}}}function St(r){if(Y===clearTimeout)return clearTimeout(r);if((Y===Je||!Y)&&clearTimeout)return Y=clearTimeout,clearTimeout(r);try{return Y(r)}catch(t){try{return Y.call(null,r)}catch(e){return Y.call(this,r)}}}function Rt(){!ne||!O||(ne=!1,O.length?B=O.concat(B):xe=-1,B.length&&He())}function He(){if(!ne){var r=ze(Rt);ne=!0;for(var t=B.length;t;){for(O=B,B=[];++xe<t;)O&&O[xe].run();xe=-1,t=B.length}O=null,ne=!1,St(r)}}function _t(r){var t=new Array(arguments.length-1);if(arguments.length>1)for(var e=1;e<arguments.length;e++)t[e-1]=arguments[e];B.push(new Ke(r,t)),B.length===1&&!ne&&ze(He)}function Ke(r,t){this.fun=r,this.array=t}function W(){}function zt(r){throw new Error("process.binding is not supported")}function Ht(){return"/"}function Kt(r){throw new Error("process.chdir is not supported")}function Zt(){return 0}function Xt(r){var t=Qt.call(re)*.001,e=Math.floor(t),n=Math.floor(t%1*1e9);return r&&(e=e-r[0],n=n-r[1],n<0&&(e--,n+=1e9)),[e,n]}function er(){var r=new Date,t=r-qt;return t/1e3}var D,Y,B,ne,O,xe,Lt,Pt,Bt,Ut,Ct,Ft,Mt,$t,Dt,Yt,Ot,Wt,jt,Vt,Gt,Jt,re,Qt,qt,w,Ve,f=we(()=>{"use strict";D=Ge,Y=Je;typeof globalThis.setTimeout=="function"&&(D=setTimeout);typeof globalThis.clearTimeout=="function"&&(Y=clearTimeout);B=[],ne=!1,xe=-1;Ke.prototype.run=function(){this.fun.apply(null,this.array)};Lt="browser",Pt="browser",Bt=!0,Ut={},Ct=[],Ft="",Mt={},$t={},Dt={};Yt=W,Ot=W,Wt=W,jt=W,Vt=W,Gt=W,Jt=W;re=globalThis.performance||{},Qt=re.now||re.mozNow||re.msNow||re.oNow||re.webkitNow||function(){return new Date().getTime()};qt=new Date;w={nextTick:_t,title:Lt,browser:Bt,env:Ut,argv:Ct,version:Ft,versions:Mt,on:Yt,addListener:Ot,once:Wt,off:jt,removeListener:Vt,removeAllListeners:Gt,emit:Jt,binding:zt,cwd:Ht,chdir:Kt,umask:Zt,hrtime:Xt,platform:Pt,release:$t,config:Dt,uptime:er},Ve={};Object.keys(Ve).forEach(r=>{let t=r.split("."),e=w;for(let n=0;n<t.length;n++){let i=t[n];n===t.length-1?e[i]=Ve[r]:e=e[i]||(e[i]={})}})});function qe(){Le=!0;for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,e=r.length;t<e;++t)S[t]=r[t],I[r.charCodeAt(t)]=t;I[45]=62,I[95]=63}function rr(r){Le||qe();var t,e,n,i,o,s,l=r.length;if(l%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=r[l-2]==="="?2:r[l-1]==="="?1:0,s=new tr(l*3/4-o),n=o>0?l-4:l;var h=0;for(t=0,e=0;t<n;t+=4,e+=3)i=I[r.charCodeAt(t)]<<18|I[r.charCodeAt(t+1)]<<12|I[r.charCodeAt(t+2)]<<6|I[r.charCodeAt(t+3)],s[h++]=i>>16&255,s[h++]=i>>8&255,s[h++]=i&255;return o===2?(i=I[r.charCodeAt(t)]<<2|I[r.charCodeAt(t+1)]>>4,s[h++]=i&255):o===1&&(i=I[r.charCodeAt(t)]<<10|I[r.charCodeAt(t+1)]<<4|I[r.charCodeAt(t+2)]>>2,s[h++]=i>>8&255,s[h++]=i&255),s}function nr(r){return S[r>>18&63]+S[r>>12&63]+S[r>>6&63]+S[r&63]}function ir(r,t,e){for(var n,i=[],o=t;o<e;o+=3)n=(r[o]<<16)+(r[o+1]<<8)+r[o+2],i.push(nr(n));return i.join("")}function Ze(r){Le||qe();for(var t,e=r.length,n=e%3,i="",o=[],s=16383,l=0,h=e-n;l<h;l+=s)o.push(ir(r,l,l+s>h?h:l+s));return n===1?(t=r[e-1],i+=S[t>>2],i+=S[t<<4&63],i+="=="):n===2&&(t=(r[e-2]<<8)+r[e-1],i+=S[t>>10],i+=S[t>>4&63],i+=S[t<<2&63],i+="="),o.push(i),o.join("")}function ye(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function U(r,t){if(ye()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(r=new Uint8Array(t),r.__proto__=a.prototype):(r===null&&(r=new a(t)),r.length=t),r}function a(r,t,e){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(r,t,e);if(typeof r=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return Pe(this,r)}return et(this,r,t,e)}function et(r,t,e,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?ar(r,t,e,n):typeof t=="string"?sr(r,t,e):ur(r,t)}function tt(r){if(typeof r!="number")throw new TypeError('"size" argument must be a number');if(r<0)throw new RangeError('"size" argument must not be negative')}function or(r,t,e,n){return tt(t),t<=0?U(r,t):e!==void 0?typeof n=="string"?U(r,t).fill(e,n):U(r,t).fill(e):U(r,t)}function Pe(r,t){if(tt(t),r=U(r,t<0?0:Be(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var e=0;e<t;++e)r[e]=0;return r}function sr(r,t,e){if((typeof e!="string"||e==="")&&(e="utf8"),!a.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=rt(t,e)|0;r=U(r,n);var i=r.write(t,e);return i!==n&&(r=r.slice(0,i)),r}function _e(r,t){var e=t.length<0?0:Be(t.length)|0;r=U(r,e);for(var n=0;n<e;n+=1)r[n]=t[n]&255;return r}function ar(r,t,e,n){if(t.byteLength,e<0||t.byteLength<e)throw new RangeError("'offset' is out of bounds");if(t.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");return e===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,e):t=new Uint8Array(t,e,n),a.TYPED_ARRAY_SUPPORT?(r=t,r.__proto__=a.prototype):r=_e(r,t),r}function ur(r,t){if(R(t)){var e=Be(t.length)|0;return r=U(r,e),r.length===0||t.copy(r,0,0,e),r}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||br(t.length)?U(r,0):_e(r,t);if(t.type==="Buffer"&&Array.isArray(t.data))return _e(r,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function Be(r){if(r>=ye())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+ye().toString(16)+" bytes");return r|0}function R(r){return!!(r!=null&&r._isBuffer)}function rt(r,t){if(R(r))return r.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(r)||r instanceof ArrayBuffer))return r.byteLength;typeof r!="string"&&(r=""+r);var e=r.length;if(e===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return ge(r).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return e*2;case"hex":return e>>>1;case"base64":return ft(r).length;default:if(n)return ge(r).length;t=(""+t).toLowerCase(),n=!0}}function fr(r,t,e){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return"";for(r||(r="utf8");;)switch(r){case"hex":return gr(this,t,e);case"utf8":case"utf-8":return ot(this,t,e);case"ascii":return xr(this,t,e);case"latin1":case"binary":return yr(this,t,e);case"base64":return dr(this,t,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Tr(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=!0}}function j(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function nt(r,t,e,n,i){if(r.length===0)return-1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=i?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(i)return-1;e=r.length-1}else if(e<0)if(i)e=0;else return-1;if(typeof t=="string"&&(t=a.from(t,n)),R(t))return t.length===0?-1:Qe(r,t,e,n,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Qe(r,[t],e,n,i);throw new TypeError("val must be string, number or Buffer")}function Qe(r,t,e,n,i){var o=1,s=r.length,l=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return-1;o=2,s/=2,l/=2,e/=2}function h(g,P){return o===1?g[P]:g.readUInt16BE(P*o)}var p;if(i){var m=-1;for(p=e;p<s;p++)if(h(r,p)===h(t,m===-1?0:p-m)){if(m===-1&&(m=p),p-m+1===l)return m*o}else m!==-1&&(p-=p-m),m=-1}else for(e+l>s&&(e=s-l),p=e;p>=0;p--){for(var d=!0,y=0;y<l;y++)if(h(r,p+y)!==h(t,y)){d=!1;break}if(d)return p}return-1}function cr(r,t,e,n){e=Number(e)||0;var i=r.length-e;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var l=parseInt(t.substr(s*2,2),16);if(isNaN(l))return s;r[e+s]=l}return s}function lr(r,t,e,n){return ve(ge(t,r.length-e),r,e,n)}function it(r,t,e,n){return ve(Ir(t),r,e,n)}function hr(r,t,e,n){return it(r,t,e,n)}function pr(r,t,e,n){return ve(ft(t),r,e,n)}function mr(r,t,e,n){return ve(kr(t,r.length-e),r,e,n)}function dr(r,t,e){return t===0&&e===r.length?Ze(r):Ze(r.slice(t,e))}function ot(r,t,e){e=Math.min(r.length,e);for(var n=[],i=t;i<e;){var o=r[i],s=null,l=o>239?4:o>223?3:o>191?2:1;if(i+l<=e){var h,p,m,d;switch(l){case 1:o<128&&(s=o);break;case 2:h=r[i+1],(h&192)===128&&(d=(o&31)<<6|h&63,d>127&&(s=d));break;case 3:h=r[i+1],p=r[i+2],(h&192)===128&&(p&192)===128&&(d=(o&15)<<12|(h&63)<<6|p&63,d>2047&&(d<55296||d>57343)&&(s=d));break;case 4:h=r[i+1],p=r[i+2],m=r[i+3],(h&192)===128&&(p&192)===128&&(m&192)===128&&(d=(o&15)<<18|(h&63)<<12|(p&63)<<6|m&63,d>65535&&d<1114112&&(s=d))}}s===null?(s=65533,l=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=l}return wr(n)}function wr(r){var t=r.length;if(t<=Xe)return String.fromCharCode.apply(String,r);for(var e="",n=0;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Xe));return e}function xr(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]&127);return n}function yr(r,t,e){var n="";e=Math.min(r.length,e);for(var i=t;i<e;++i)n+=String.fromCharCode(r[i]);return n}function gr(r,t,e){var n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);for(var i="",o=t;o<e;++o)i+=Nr(r[o]);return i}function Tr(r,t,e){for(var n=r.slice(t,e),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}function T(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}function N(r,t,e,n,i,o){if(!R(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}function Te(r,t,e,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(r.length-e,2);i<o;++i)r[e+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function Ae(r,t,e,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(r.length-e,4);i<o;++i)r[e+i]=t>>>(n?i:3-i)*8&255}function st(r,t,e,n,i,o){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function at(r,t,e,n,i){return i||st(r,t,e,4,34028234663852886e22,-34028234663852886e22),lt(r,t,e,n,23,4),e+4}function ut(r,t,e,n,i){return i||st(r,t,e,8,17976931348623157e292,-17976931348623157e292),lt(r,t,e,n,52,8),e+8}function vr(r){if(r=Er(r).replace(Ar,""),r.length<2)return"";for(;r.length%4!==0;)r=r+"=";return r}function Er(r){return r.trim?r.trim():r.replace(/^\s+|\s+$/g,"")}function Nr(r){return r<16?"0"+r.toString(16):r.toString(16)}function ge(r,t){t=t||1/0;for(var e,n=r.length,i=null,o=[],s=0;s<n;++s){if(e=r.charCodeAt(s),e>55295&&e<57344){if(!i){if(e>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=e;continue}if(e<56320){(t-=3)>-1&&o.push(239,191,189),i=e;continue}e=(i-55296<<10|e-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,e<128){if((t-=1)<0)break;o.push(e)}else if(e<2048){if((t-=2)<0)break;o.push(e>>6|192,e&63|128)}else if(e<65536){if((t-=3)<0)break;o.push(e>>12|224,e>>6&63|128,e&63|128)}else if(e<1114112){if((t-=4)<0)break;o.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128)}else throw new Error("Invalid code point")}return o}function Ir(r){for(var t=[],e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function kr(r,t){for(var e,n,i,o=[],s=0;s<r.length&&!((t-=2)<0);++s)e=r.charCodeAt(s),n=e>>8,i=e%256,o.push(i),o.push(n);return o}function ft(r){return rr(vr(r))}function ve(r,t,e,n){for(var i=0;i<n&&!(i+e>=t.length||i>=r.length);++i)t[i+e]=r[i];return i}function br(r){return r!==r}function Sr(r){return r!=null&&(!!r._isBuffer||ct(r)||Rr(r))}function ct(r){return!!r.constructor&&typeof r.constructor.isBuffer=="function"&&r.constructor.isBuffer(r)}function Rr(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&ct(r.slice(0,0))}function Ee(r,t,e,n,i){var o,s,l=i*8-n-1,h=(1<<l)-1,p=h>>1,m=-7,d=e?i-1:0,y=e?-1:1,g=r[t+d];for(d+=y,o=g&(1<<-m)-1,g>>=-m,m+=l;m>0;o=o*256+r[t+d],d+=y,m-=8);for(s=o&(1<<-m)-1,o>>=-m,m+=n;m>0;s=s*256+r[t+d],d+=y,m-=8);if(o===0)o=1-p;else{if(o===h)return s?NaN:(g?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-p}return(g?-1:1)*s*Math.pow(2,o-n)}function lt(r,t,e,n,i,o){var s,l,h,p=o*8-i-1,m=(1<<p)-1,d=m>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:o-1,P=n?1:-1,me=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,s=m):(s=Math.floor(Math.log(t)/Math.LN2),t*(h=Math.pow(2,-s))<1&&(s--,h*=2),s+d>=1?t+=y/h:t+=y*Math.pow(2,1-d),t*h>=2&&(s++,h/=2),s+d>=m?(l=0,s=m):s+d>=1?(l=(t*h-1)*Math.pow(2,i),s=s+d):(l=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;r[e+g]=l&255,g+=P,l/=256,i-=8);for(s=s<<i|l,p+=i;p>0;r[e+g]=s&255,g+=P,s/=256,p-=8);r[e+g-P]|=me*128}var S,I,tr,Le,Xe,Ar,ht=we(()=>{"use strict";f();c();S=[],I=[],tr=typeof Uint8Array!="undefined"?Uint8Array:Array,Le=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(r){return r.__proto__=a.prototype,r};a.from=function(r,t,e){return et(null,r,t,e)};a.kMaxLength=ye();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(r,t,e){return or(null,r,t,e)};a.allocUnsafe=function(r){return Pe(null,r)};a.allocUnsafeSlow=function(r){return Pe(null,r)};a.isBuffer=Sr;a.compare=function(t,e){if(!R(t)||!R(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var n=t.length,i=e.length,o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==e[o]){n=t[o],i=e[o];break}return n<i?-1:i<n?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;var i=a.allocUnsafe(e),o=0;for(n=0;n<t.length;++n){var s=t[n];if(!R(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=rt;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)j(this,e,e+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)j(this,e,e+3),j(this,e+1,e+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)j(this,e,e+7),j(this,e+1,e+6),j(this,e+2,e+5),j(this,e+3,e+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?ot(this,0,t):fr.apply(this,arguments)};a.prototype.equals=function(t){if(!R(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,e,n,i,o){if(!R(t))throw new TypeError("Argument must be a Buffer");if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),e<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&e>=n)return 0;if(i>=o)return-1;if(e>=n)return 1;if(e>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,l=n-e,h=Math.min(s,l),p=this.slice(i,o),m=t.slice(e,n),d=0;d<h;++d)if(p[d]!==m[d]){s=p[d],l=m[d];break}return s<l?-1:l<s?1:0};a.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1};a.prototype.indexOf=function(t,e,n){return nt(this,t,e,n,!0)};a.prototype.lastIndexOf=function(t,e,n){return nt(this,t,e,n,!1)};a.prototype.write=function(t,e,n,i){if(e===void 0)i="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")i=e,n=this.length,e=0;else if(isFinite(e))e=e|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-e;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return cr(this,t,e,n);case"utf8":case"utf-8":return lr(this,t,e,n);case"ascii":return it(this,t,e,n);case"latin1":case"binary":return hr(this,t,e,n);case"base64":return pr(this,t,e,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return mr(this,t,e,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};Xe=4096;a.prototype.slice=function(t,e){var n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,e),i.__proto__=a.prototype;else{var o=e-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,e,n){t=t|0,e=e|0,n||T(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,e,n){t=t|0,e=e|0,n||T(t,e,this.length);for(var i=this[t+--e],o=1;e>0&&(o*=256);)i+=this[t+--e]*o;return i};a.prototype.readUInt8=function(t,e){return e||T(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,e){return e||T(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,e){return e||T(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,e){return e||T(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,e){return e||T(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,e,n){t=t|0,e=e|0,n||T(t,e,this.length);for(var i=this[t],o=1,s=0;++s<e&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*e)),i};a.prototype.readIntBE=function(t,e,n){t=t|0,e=e|0,n||T(t,e,this.length);for(var i=e,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*e)),s};a.prototype.readInt8=function(t,e){return e||T(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,e){e||T(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};a.prototype.readInt16BE=function(t,e){e||T(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};a.prototype.readInt32LE=function(t,e){return e||T(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,e){return e||T(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,e){return e||T(t,4,this.length),Ee(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,e){return e||T(t,4,this.length),Ee(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,e){return e||T(t,8,this.length),Ee(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,e){return e||T(t,8,this.length),Ee(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;N(this,t,e,n,o,0)}var s=1,l=0;for(this[e]=t&255;++l<n&&(s*=256);)this[e+l]=t/s&255;return e+n};a.prototype.writeUIntBE=function(t,e,n,i){if(t=+t,e=e|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;N(this,t,e,n,o,0)}var s=n-1,l=1;for(this[e+s]=t&255;--s>=0&&(l*=256);)this[e+s]=t/l&255;return e+n};a.prototype.writeUInt8=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=t&255,e+1};a.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Te(this,t,e,!0),e+2};a.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Te(this,t,e,!1),e+2};a.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255):Ae(this,t,e,!0),e+4};a.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Ae(this,t,e,!1),e+4};a.prototype.writeIntLE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);N(this,t,e,n,o-1,-o)}var s=0,l=1,h=0;for(this[e]=t&255;++s<n&&(l*=256);)t<0&&h===0&&this[e+s-1]!==0&&(h=1),this[e+s]=(t/l>>0)-h&255;return e+n};a.prototype.writeIntBE=function(t,e,n,i){if(t=+t,e=e|0,!i){var o=Math.pow(2,8*n-1);N(this,t,e,n,o-1,-o)}var s=n-1,l=1,h=0;for(this[e+s]=t&255;--s>=0&&(l*=256);)t<0&&h===0&&this[e+s+1]!==0&&(h=1),this[e+s]=(t/l>>0)-h&255;return e+n};a.prototype.writeInt8=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=t&255,e+1};a.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8):Te(this,t,e,!0),e+2};a.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=t&255):Te(this,t,e,!1),e+2};a.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):Ae(this,t,e,!0),e+4};a.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e|0,n||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255):Ae(this,t,e,!1),e+4};a.prototype.writeFloatLE=function(t,e,n){return at(this,t,e,!0,n)};a.prototype.writeFloatBE=function(t,e,n){return at(this,t,e,!1,n)};a.prototype.writeDoubleLE=function(t,e,n){return ut(this,t,e,!0,n)};a.prototype.writeDoubleBE=function(t,e,n){return ut(this,t,e,!1,n)};a.prototype.copy=function(t,e,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),e>=t.length&&(e=t.length),e||(e=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-e<i-n&&(i=t.length-e+n);var o=i-n,s;if(this===t&&n<e&&e<i)for(s=o-1;s>=0;--s)t[s+e]=this[s+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+e]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),e);return o};a.prototype.fill=function(t,e,n,i){if(typeof t=="string"){if(typeof e=="string"?(i=e,e=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var s;if(typeof t=="number")for(s=e;s<n;++s)this[s]=t;else{var l=R(t)?t:ge(new a(t,i).toString()),h=l.length;for(s=0;s<n-e;++s)this[s+e]=l[s%h]}return this};Ar=/[^+\/0-9A-Za-z-_]/g});var c=we(()=>{"use strict";ht()});function gt(r,t){for(var e=0,n=r.length-1;n>=0;n--){var i=r[n];i==="."?r.splice(n,1):i===".."?(r.splice(n,1),e++):e&&(r.splice(n,1),e--)}if(t)for(;e--;e)r.unshift("..");return r}function $e(){for(var r="",t=!1,e=arguments.length-1;e>=-1&&!t;e--){var n=e>=0?arguments[e]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;r=n+"/"+r,t=n.charAt(0)==="/"}return r=gt(Ye(r.split("/"),function(i){return!!i}),!t).join("/"),(t?"/":"")+r||"."}function Tt(r){var t=At(r),e=An(r,-1)==="/";return r=gt(Ye(r.split("/"),function(n){return!!n}),!t).join("/"),!r&&!t&&(r="."),r&&e&&(r+="/"),(t?"/":"")+r}function At(r){return r.charAt(0)==="/"}function mn(){var r=Array.prototype.slice.call(arguments,0);return Tt(Ye(r,function(t,e){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function dn(r,t){r=$e(r).substr(1),t=$e(t).substr(1);function e(p){for(var m=0;m<p.length&&p[m]==="";m++);for(var d=p.length-1;d>=0&&p[d]==="";d--);return m>d?[]:p.slice(m,d-m+1)}for(var n=e(r.split("/")),i=e(t.split("/")),o=Math.min(n.length,i.length),s=o,l=0;l<o;l++)if(n[l]!==i[l]){s=l;break}for(var h=[],l=s;l<n.length;l++)h.push("..");return h=h.concat(i.slice(s)),h.join("/")}function yn(r){var t=De(r),e=t[0],n=t[1];return!e&&!n?".":(n&&(n=n.substr(0,n.length-1)),e+n)}function gn(r,t){var e=De(r)[2];return t&&e.substr(-1*t.length)===t&&(e=e.substr(0,e.length-t.length)),e}function Tn(r){return De(r)[3]}function Ye(r,t){if(r.filter)return r.filter(t);for(var e=[],n=0;n<r.length;n++)t(r[n],n,r)&&e.push(r[n]);return e}var pn,De,wn,xn,vt,An,Et=we(()=>{"use strict";f();c();pn=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,De=function(r){return pn.exec(r).slice(1)};wn="/",xn=":";vt={extname:Tn,basename:gn,dirname:yn,sep:wn,delimiter:xn,relative:dn,join:mn,isAbsolute:At,normalize:Tt,resolve:$e};An="ab".substr(-1)==="b"?function(r,t,e){return r.substr(t,e)}:function(r,t,e){return t<0&&(t=r.length+t),r.substr(t,e)}});f();c();function oe(r){throw new Error("Unexpected value: "+JSON.stringify(r))}f();c();f();c();function _r(r){return Object.keys(r)}var Me={};bt(Me,{Alias:()=>J,AstNode:()=>x,CodeBlock:()=>L,Enum:()=>z,Field:()=>H,File:()=>K,Func:()=>Z,FuncInvocation:()=>b,IoReaderTypeReference:()=>Fe,Method:()=>$,MethodInvocation:()=>M,MultiNode:()=>le,Parameter:()=>Q,Pointer:()=>X,Selector:()=>q,Struct:()=>ee,TimeTypeReference:()=>be,Type:()=>pe,TypeDeclaration:()=>te,TypeInstantiation:()=>v,TypeReference:()=>E,UuidTypeReference:()=>Se,Writer:()=>G,alias:()=>zr,codeblock:()=>Hr,enum_:()=>Kr,field:()=>Zr,file:()=>Qr,func:()=>Xr,identifier:()=>qr,invokeFunc:()=>en,invokeMethod:()=>tn,method:()=>rn,parameter:()=>nn,pointer:()=>on,selector:()=>sn,struct:()=>an,switch_:()=>un,typeDeclaration:()=>fn,typeReference:()=>cn});f();c();f();c();f();c();f();c();f();c();f();c();f();c();f();c();var pt,mt,se=(mt=(pt=w.env.FERN_STACK_TRACK)==null?void 0:pt.toLowerCase())!=null?mt:"",_=se!==""&&se!=="0"&&se!=="false",Ue=["single","multiline","box"].includes(se)?se:"single";_&&(Error.stackTraceLimit=50);var Lr=new Set(["SdkGeneratorCLI","runCli","LoggerImpl","Array.forEach"]),Pr=new Set(["stacktrace"]);function Ie({maxFrames:r=50,skip:t=0,filterPaths:e=[],filterFunctions:n=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,formatFilename:l=h=>h}={}){var p;if(!_)return[];n=[...n,...Lr],e=[...e,...Pr],i=[...i,"runInteractiveTask"];let h=!1;return((p=new Error().stack)!=null?p:"").split(`
|
|
2
|
-
`).map(m=>{let d=m.match(/at\s+(.*)\s+\((.*):(\d+):(\d+)\)/);if(d&&d.length===5){let[,y,g,P,me]=d;if(!y||!g||!P||!me)return;if(h||i.some(Nt=>y==null?void 0:y.includes(Nt))){h=!0;return}switch(y){case"Object.<anonymous>":y="";break;case"Object.object":case"Object.alias":case"Object.union":case"Object.enum":case"Object.undiscriminatedUnion":y=`${y.substring(y.indexOf(".")+1)}()=> { ... }`;break}return{fn:y,path:l(g),position:`${P}:${me}`}}}).filter(m=>{var d,y;return m&&!n.some(g=>m.fn.includes(g))&&!(o&&((d=m.path)!=null&&d.startsWith("node:")))&&!(s&&((y=m.path)!=null&&y.endsWith(".js")))&&!e.some(g=>m.path.includes(g))}).slice(t,t+r)}var Ne=class{constructor({maxFrames:t=50,skip:e=0,filterPaths:n=[],filterFunctions:i=[],stopOn:o=[],filterNode:s=!0,filterJs:l=!0,multiline:h=!1,formatFilename:p=m=>m}={}){u(this,"maxFrames");u(this,"skip");u(this,"filterPaths");u(this,"filterFunctions");u(this,"stopOn");u(this,"filterNode");u(this,"filterJs");u(this,"multiline");u(this,"formatFilename");u(this,"tracking",new WeakMap);this.maxFrames=t,this.skip=e,this.filterPaths=n,this.filterFunctions=i,this.stopOn=o,this.filterNode=s,this.filterJs=l,this.multiline=h,this.formatFilename=p}tag(t){let e=this.tracking.get(t)||new Set;Ie({maxFrames:this.maxFrames,skip:this.skip,filterPaths:this.filterPaths,filterFunctions:this.filterFunctions,stopOn:this.stopOn,filterNode:this.filterNode,filterJs:this.filterJs,formatFilename:this.formatFilename}).forEach(n=>e.add(n)),this.tracking.set(t,e)}trace(t){if(!_)return"";let e=this.tracking.get(t);return e?[...e].map(n=>`${this.multiline?`
|
|
3
|
-
`:""}${n.fn} - ${n.path}:${n.position}`).join(""):""}frames(t){let e=this.tracking.get(t);return e?[...e]:[]}free(t){this.tracking.delete(t)}clear(){this.tracking=new WeakMap}},C;function dt({maxFrames:r=50,skip:t=0,filterPaths:e=[],filterFunctions:n=[],stopOn:i=[],filterNode:o=!0,filterJs:s=!0,multiline:l=!1,formatFilename:h=p=>p}={}){_&&(C!=null||(C=new Ne({maxFrames:r,skip:t,filterPaths:e,filterFunctions:n,stopOn:i,filterNode:o,filterJs:s,multiline:l,formatFilename:h})))}function wt(r){C==null||C.tag(r)}function Ce(r){var t;return(t=C==null?void 0:C.frames(r))!=null?t:[]}var V=class{constructor(){wt(this)}};f();c();var ke=class{formatMultiple(t){return Promise.all(t.map(e=>this.format(e)))}formatMultipleSync(t){return t.map(e=>this.formatSync(e))}},ae=class extends ke{async format(t){return t}formatSync(t){return t}};f();c();f();c();f();c();var k=class extends V{constructor(e){super();u(this,"value");this.value=e}write(e){typeof this.value=="string"?e.write(this.value):typeof this.value=="function"?this.value(e):this.value.write(e)}};var Br=4;dt({skip:0,maxFrames:15,filterFunctions:["Abstract"]});var ue=class{constructor(){u(this,"lineBuffer",[]);u(this,"indentLevel",0);u(this,"hasWrittenAnything",!1);u(this,"lastCharacterIsSemicolon",!1);u(this,"lastCharacterIsNewline",!1);u(this,"nodeStackFrames",[])}get buffer(){return _&&this.nodeStackFrames.length>0&&this.writeInternal(`
|
|
4
|
-
`),this.lineBuffer.join(`
|
|
5
|
-
`)+(this.lastCharacterIsNewline?`
|
|
6
|
-
`:"")}write(...t){for(let e of t)if(e!=null)if(typeof e=="string"){let n=e.length>0&&e.endsWith(`
|
|
7
|
-
`),i=n?e.substring(0,e.length-1):e,o=this.getIndentString(),s=i.replaceAll(`
|
|
8
|
-
`,`
|
|
9
|
-
${o}`);this.isAtStartOfLine()&&(s=o+s),n&&(s+=`
|
|
10
|
-
`),this.writeInternal(s)}else this.writeNode(e)}writeStatement(...t){this.write(...t),this.write(";"),this.writeNewLineIfLastLineNot()}writeNoIndent(t){let e=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=e}writeNode(t){_&&this.nodeStackFrames.push(...Ce(t)),t.write(this),_&&Ue!=="single"&&this.writeInternal(`
|
|
11
|
-
`)}writeNodeOrString(t){if(typeof t=="string"){this.write(t);return}this.writeNode(t)}writeNodeStatement(t){this.writeNode(t),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new k(t).write(this),t.endsWith(";")||this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,e){new k(t).write(this),this.write(" (",e,")"),this.pushScope()}controlFlowWithoutStatement(t){new k(t).write(this),this.pushScope()}endControlFlow(){this.popScope()}contiguousControlFlow(t,e){this.dedent(),this.write("} "),new k(t).write(this),this.write(" (",e,")"),this.pushScope()}alternativeControlFlow(t){this.dedent(),this.write("} "),new k(t).write(this),this.pushScope()}pushScope(){this.writeLine("{"),this.indent()}popScope(t=!0){this.dedent(),this.writeNewLineIfLastLineNot(),t?this.writeLine("}"):this.write("}")}writeLine(...t){this.write(...t.length===0?[""]:t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
12
|
-
`)}writeSemicolonIfLastCharacterIsNot(){this.lastCharacterIsSemicolon||this.writeInternal(";")}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
13
|
-
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:e,writeFunction:n}){if(t.length>0){let i=t[0];i!=null&&n(i);for(let o=1;o<t.length;o++){this.write(e);let s=t[o];s!=null&&n(s)}}}toString(){return this.buffer}writeInternal(t){if(t.length===0)return;let e=!this.lastCharacterIsNewline;this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
14
|
-
`),this.lastCharacterIsSemicolon=t.endsWith(";");let n=t.split(`
|
|
15
|
-
`),i=_&&!this.shouldSkipTracking(n)&&this.lastCharacterIsNewline;e&&(this.lastLine=`${this.lastLine}${n.shift()||""}`),this.lastCharacterIsNewline&&n.pop(),this.lineBuffer.push(...n),i&&this.appendTrackingComment()}set lastLine(t){this.lineBuffer.length>0?this.lineBuffer[this.lineBuffer.length-1]=t:this.lineBuffer.push(t)}get lastLine(){return this.lineBuffer[this.lineBuffer.length-1]||""}shouldSkipTracking(t){return!1}formatStack(t,e=""){return t.map(n=>`${e?`(${e}) `:""} ${n.fn} - ${n.path} : ${n.position}`)}filterStack(t){return t.filter(e=>!e.fn.startsWith(`${this.constructor.name}.`))}appendTrackingComment(){let t=[...this.formatStack(this.filterStack(Ie({maxFrames:15,skip:3}))),...this.formatStack(this.filterStack(this.nodeStackFrames),"node")];switch(this.nodeStackFrames.length=0,Ue){case"single":return this.singleLineTrackingComment(t);case"multiline":return this.multiLineTrackingComment(t);case"box":return this.boxTrackingComment(t)}}singleLineTrackingComment(t){this.lastLine=`${this.lastLine} // ${t.join(" ")}`}multiLineTrackingComment(t){this.lineBuffer.push(...t.map(e=>` // ${e}`))}boxTrackingComment(t){this.lineBuffer.push("/*",...t.map(e=>` ${e}`),"*/")}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*this.getTabSize())}getTabSize(){return Br}};f();c();f();c();function fe(r,t){var n,i;let e=(n=r.split("/").pop())!=null?n:r;return t!=null&&t.stripExtension&&(i=e.split(".")[0])!=null?i:e}f();c();f();c();var Ur=/[^0-9a-zA-Z_]/g,Cr=["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],G=class extends ue{constructor({packageName:e,rootImportPath:n,importPath:i,customConfig:o,formatter:s}){super();u(this,"packageName");u(this,"rootImportPath");u(this,"importPath");u(this,"customConfig");u(this,"formatter");u(this,"imports",{});this.packageName=e,this.rootImportPath=n,this.importPath=i,this.customConfig=o,this.formatter=s!=null?s:new ae}addImport(e){let n=this.imports[e];if(n!=null)return n;if(e===this.rootImportPath&&this.customConfig.packageName!=null)return this.imports[e]=this.customConfig.packageName,this.customConfig.packageName;let i=new Set(Object.values(this.imports)),o=e.split("/");for(let l=1;l<=o.length;l++){let h=o.slice(-l),p=this.getValidAlias(h.join(""));if(!i.has(p))return this.imports[e]=p,p}let s=this.getValidAlias(fe(e));for(;i.has(s);)s="_"+s;return this.imports[e]=s,s}isValidAlias(e){return!Cr.includes(e)}getValidAlias(e){let n=e.split("-");if(n[0]==null)return e;let i=n.map(o=>o.replace(Ur,"")).join("");return this.isValidAlias(i)?i:"_"+i}};var ce=class extends G{constructor({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){super({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
16
|
-
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(e){throw new Error(`Failed to format Go file: ${e}
|
|
17
|
-
${t}`)}return t}getContent(){let t=`package ${this.packageName}
|
|
18
|
-
|
|
19
|
-
`,e=this.stringifyImports();return e.length>0?`${t}${e}
|
|
20
|
-
|
|
21
|
-
${this.buffer}`:t+this.buffer}stringifyImports(){let t=Object.entries(this.imports).filter(([e,n])=>e!==this.importPath).map(([e,n])=>` ${n} "${e}"`).join(`
|
|
22
|
-
`);return t?`import (
|
|
23
|
-
${t}
|
|
24
|
-
)`:""}};var x=class extends V{async toStringAsync({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new ce({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toStringAsync()}toString({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o}){let s=new ce({packageName:t,rootImportPath:e,importPath:n,customConfig:i,formatter:o});return this.write(s),s.toString()}};var A=class extends x{constructor({docs:e}={}){super();u(this,"docs");this.docs=e}write(e){this.docs!=null&&this.docs.split(`
|
|
25
|
-
`).forEach(n=>{e.writeLine(`// ${n}`)})}};var J=class extends x{constructor({name:e,type:n,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" = "),e.writeNode(this.type)}};f();c();var L=class extends x{constructor(e){super();u(this,"arg");this.arg=e}write(e){return new k(this.arg).write(e)}};f();c();f();c();var F=class extends x{constructor(e){super();u(this,"name");this.name=e}write(e){e.write(this.name)}};f();c();f();c();f();c();function ie({writer:r,arguments_:t,multiline:e=!0}){let n=t.map(i=>i instanceof v&&v.isNop(i)?v.nil():i);if(n.length===0){r.write("()");return}if(e){Fr({writer:r,arguments_:n});return}Mr({writer:r,arguments_:n})}function Fr({writer:r,arguments_:t}){r.writeLine("("),r.indent();for(let e of t)e.write(r),r.writeLine(",");r.dedent(),r.write(")")}function Mr({writer:r,arguments_:t}){r.write("("),t.forEach((e,n)=>{n>0&&r.write(", "),e.write(r)}),r.write(")")}var b=class extends x{constructor({func:e,arguments_:n,multiline:i=!0}){super();u(this,"func");u(this,"arguments_");u(this,"multiline");this.func=e,this.arguments_=n,this.multiline=i}write(e){e.writeNode(this.func),ie({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};f();c();f();c();function xt({writer:r,generics:t}){t.length!==0&&(r.write("["),t.forEach((e,n)=>{n>0&&r.write(", "),e!=null&&r.writeNode(e)}),r.write("]"))}var E=class extends x{constructor({name:e,importPath:n,generics:i}){super();u(this,"name");u(this,"importPath");u(this,"generics");this.name=e,this.importPath=n,this.generics=i}write(e){if(this.importPath==null||e.importPath===this.importPath){e.write(this.name);return}let n=e.addImport(this.importPath);e.write(`${n}.${this.name}`),this.generics!=null&&xt({writer:e,generics:this.generics})}};f();c();var M=class extends x{constructor({method:e,arguments_:n,on:i,multiline:o}){super();u(this,"on");u(this,"method");u(this,"arguments_");u(this,"multiline");this.on=i,this.method=e,this.arguments_=n,this.multiline=o}write(e){this.on.write(e),e.write("."),e.write(this.method),ie({writer:e,arguments_:this.arguments_,multiline:this.multiline})}};var $r=new Set(["bool","date","dateTime","float64","int","int64","string","uuid"]),yt=new Set(["any","bytes","map","slice"]),v=class r extends x{constructor(e){super();u(this,"internalType");this.internalType=e}write(e){switch(this.internalType.type){case"any":this.writeAny({writer:e,value:this.internalType.value});break;case"bool":e.write(this.internalType.value.toString());break;case"bytes":e.write(`[]byte("${this.internalType.value}")`);break;case"date":case"dateTime":e.writeNode(Or({writer:e,type:this.internalType}));break;case"enum":e.writeNode(this.internalType.typeReference);break;case"float64":e.write(this.internalType.value.toString());break;case"int":case"int64":e.write(this.internalType.value.toString());break;case"map":this.writeMap({writer:e,map:this.internalType});break;case"nil":e.write("nil");break;case"nop":break;case"optional":this.writeOptional({writer:e,type:this.internalType.value});break;case"reference":e.writeNode(this.internalType.value);break;case"slice":this.writeSlice({writer:e,slice:this.internalType});break;case"string":e.write(this.internalType.value.includes('"')||this.internalType.value.includes(`
|
|
26
|
-
`)?`\`${this.internalType.value}\``:`"${this.internalType.value}"`);break;case"struct":this.writeStruct({writer:e,struct:this.internalType});break;case"uuid":e.writeNode(Wr({value:this.internalType.value}));break;default:oe(this.internalType)}}static any(e){return new this({type:"any",value:e})}static bool(e){return new this({type:"bool",value:e})}static bytes(e){return new this({type:"bytes",value:e})}static date(e){return new this({type:"date",value:e})}static dateTime(e){return new this({type:"dateTime",value:e})}static enum(e){return new this({type:"enum",typeReference:e})}static float64(e){return new this({type:"float64",value:e})}static int(e){return new this({type:"int",value:e})}static int64(e){return new this({type:"int64",value:e})}static map({keyType:e,valueType:n,entries:i}){return new this({type:"map",keyType:e,valueType:n,entries:i})}static nil(){return new this({type:"nil"})}static nop(){return new this({type:"nop"})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static reference(e){return new this({type:"reference",value:e})}static slice({valueType:e,values:n}){return new this({type:"slice",valueType:e,values:n})}static string(e){return new this({type:"string",value:e})}static struct({typeReference:e,fields:n}){return new this({type:"struct",typeReference:e,fields:n})}static structPointer({typeReference:e,fields:n,generics:i}){return new this({type:"optional",value:new this({type:"struct",typeReference:e,fields:n,generics:i})})}static uuid(e){return new this({type:"uuid",value:e})}static isNop(e){return e.internalType.type==="optional"?this.isNop(e.internalType.value):e.internalType.type==="nop"}writeAny({writer:e,value:n}){switch(typeof n){case"boolean":e.write(n.toString());return;case"string":e.write(n.includes('"')?`\`${n}\``:`"${n}"`);return;case"number":e.write(n.toString());return;case"object":if(n==null){e.write("nil");return}if(Array.isArray(n)){this.writeAnyArray({writer:e,value:n});return}this.writeAnyObject({writer:e,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeAnyArray({writer:e,value:n}){if(e.write("[]any"),n.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let i of n)e.writeNode(r.any(i)),e.writeLine(",");e.dedent(),e.write("}")}writeAnyObject({writer:e,value:n}){e.write("map[string]any");let i=Object.entries(n);if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let[o,s]of i)e.write(`"${o}": `),e.writeNode(r.any(s)),e.writeLine(",");e.dedent(),e.write("}")}writeMap({writer:e,map:n}){e.write("map["),e.writeNode(n.keyType),e.write("]"),e.writeNode(n.valueType);let i=jr({entries:n.entries});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.key.write(e),e.write(": "),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeOptional({writer:e,type:n}){if($r.has(n.internalType.type)){e.writeNode(Dr({writer:e,type:n}));return}if(yt.has(n.internalType.type)){n.write(e);return}if(n.internalType.type==="enum"){e.writeNode(new M({on:n.internalType.typeReference,method:"Ptr",arguments_:[]}));return}e.write("&"),n.write(e)}static isAlreadyOptional(e){return e.internalType.type==="optional"||yt.has(e.internalType.type)}writeSlice({writer:e,slice:n}){e.write("[]"),e.writeNode(n.valueType);let i=Gr({values:n.values});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)o.write(e),e.writeLine(",");e.dedent(),e.write("}")}writeStruct({writer:e,struct:n}){e.writeNode(n.typeReference),n.generics!=null&&(e.write("["),n.generics.forEach((o,s)=>{s>0&&e.write(", "),e.writeNode(o)}),e.write("]"));let i=Vr({fields:n.fields});if(i.length===0){e.write("{}");return}e.writeLine("{"),e.indent();for(let o of i)e.write(`${o.name}: `),o.value.write(e),e.writeLine(",");e.dedent(),e.write("}")}};function Dr({writer:r,type:t}){return new b({func:new E({name:Yr({type:t}),importPath:r.rootImportPath}),arguments_:[t]})}function Yr({type:r}){switch(r.internalType.type){case"bool":return"Bool";case"date":case"dateTime":return"Time";case"float64":return"Float64";case"int":return"Int";case"int64":return"Int64";case"string":return"String";case"uuid":return"UUID";default:return""}}function Or({writer:r,type:t}){let e=t.type==="date"?"MustParseDate":"MustParseDateTime";return new b({func:new E({name:e,importPath:r.rootImportPath}),arguments_:[new L(`"${t.value}"`)]})}function Wr({value:r}){return new b({func:new E({name:"MustParse",importPath:"github.com/google/uuid"}),arguments_:[new L(`"${r}"`)]})}function jr({entries:r}){return r.filter(t=>!v.isNop(t.key)&&!v.isNop(t.value))}function Vr({fields:r}){return r.filter(t=>!v.isNop(t.value))}function Gr({values:r}){return r.filter(t=>!v.isNop(t))}var z=class r extends x{constructor({name:e,docs:n}){super();u(this,"name");u(this,"docs");u(this,"members",[]);u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=n}addConstructor(e){this.constructor_=e}addMember(e){this.members.push(e)}addMethod(e){this.methods.push(e)}write(e){this.writeType({writer:e}),this.writeMembers({writer:e}),this.writeConstructor({writer:e}),this.writeMethods({writer:e})}writeType({writer:e}){e.writeNode(new A({docs:this.docs})),e.writeLine(`type ${this.name} string`)}writeMembers({writer:e}){if(this.members.length!==0){e.newLine(),e.writeLine("const ("),e.indent();for(let n of this.members)e.writeNode(new A({docs:n.docs})),e.writeNode(r.getMemberIdentifier({name:this.name,member:n})),e.write(" = "),e.writeNode(v.string(n.value)),e.newLine();e.dedent(),e.write(")")}}writeConstructor({writer:e}){this.constructor_!=null&&(e.newLine(),e.writeNode(this.constructor_))}writeMethods({writer:e}){e.newLine();for(let n of this.methods)e.newLine(),e.writeNode(n),e.newLine()}static getMemberIdentifier({name:e,member:n}){return new F(`${e}${n.name}`)}};f();c();var H=class extends x{constructor({name:e,type:n,docs:i,tags:o}){super();u(this,"name");u(this,"type");u(this,"docs");u(this,"tags",[]);this.name=e,this.type=n,this.docs=i,this.tags=o!=null?o:[]}addTags(...e){this.tags.push(...e)}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e),this.writeTags({writer:e})}writeTags({writer:e}){this.tags.length!==0&&(e.write(" `"),this.tags.forEach((n,i)=>{i>0&&e.write(" "),e.write(`${n.name}:"${n.value}"`)}),e.write("`"))}};f();c();var K=class extends x{constructor({nodes:e}={nodes:[]}){super();u(this,"nodes");this.nodes=e!=null?e:[]}add(...e){this.nodes.push(...e)}write(e){for(let n of this.nodes)n.write(e)}};f();c();f();c();var $=class extends x{constructor({name:e,parameters:n,return_:i,body:o,docs:s,typeReference:l,multiline:h,receiver:p,pointerReceiver:m}){super();u(this,"parameters");u(this,"return_");u(this,"name");u(this,"body");u(this,"docs");u(this,"typeReference");u(this,"multiline");u(this,"receiver");u(this,"pointerReceiver");this.name=e,this.parameters=n,this.return_=i,this.body=o,this.docs=s,this.typeReference=l,this.multiline=h,this.receiver=p,this.pointerReceiver=m}write(e){var n;e.writeNode(new A({docs:this.docs})),e.write("func"),this.typeReference!=null&&this.writeReceiver({writer:e,typeReference:this.typeReference,receiver:this.receiver}),this.name!=null&&e.write(` ${this.name}`),ie({writer:e,arguments_:this.parameters,multiline:this.multiline}),this.return_!=null&&(e.write(" "),this.return_.length>1&&e.write("("),this.return_.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),this.return_.length>1&&e.write(")")),e.writeLine("{"),e.indent(),(n=this.body)==null||n.write(e),e.dedent(),e.writeNewLineIfLastLineNot(),e.write("}")}writeReceiver({writer:e,typeReference:n,receiver:i}){e.write(` (${this.getReceiverName({typeReference:n,receiver:i})} `),this.pointerReceiver&&e.write("*"),n.write(e),e.write(")")}getReceiverName({typeReference:e,receiver:n}){return n!=null?n:e.name.charAt(0).toLowerCase()}};var Z=class extends x{constructor({name:e,parameters:n,return_:i,body:o,docs:s,multiline:l}){super();u(this,"func");this.func=new $({name:e,parameters:n,return_:i,body:o,docs:s,multiline:l})}get parameters(){return this.func.parameters}get return_(){return this.func.return_}get name(){return this.func.name}get body(){return this.func.body}get docs(){return this.func.docs}write(e){e.writeNode(this.func)}};f();c();var le=class extends x{constructor({nodes:e}){super();u(this,"nodes");this.nodes=e}write(e){for(let n of this.nodes)e.newLine(),n.write(e),e.newLine()}};f();c();var Q=class extends x{constructor({name:e,type:n,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write(`${this.name} `),this.type.write(e)}};f();c();var X=class extends x{constructor({node:e}){super();u(this,"node");this.node=e}write(e){e.write("*"),this.node.write(e)}};f();c();var q=class extends x{constructor({on:e,selector:n}){super();u(this,"on");u(this,"selector");this.on=e,this.selector=n}write(e){e.writeNode(this.on),e.write("."),e.writeNode(this.selector)}};f();c();var ee=class extends x{constructor({name:e,embeds:n,fields:i,docs:o}){super();u(this,"name");u(this,"embeds",[]);u(this,"fields",[]);u(this,"docs");u(this,"methods",[]);u(this,"constructor_");this.name=e,this.docs=o,this.embeds=n!=null?n:[],this.fields=i!=null?i:[]}addConstructor(e){this.constructor_=e}addField(...e){this.fields.push(...e)}addMethod(...e){this.methods.push(...e)}write(e){this.writeType({writer:e}),this.constructor_!=null&&(e.newLine(),e.newLine(),this.writeConstructor({writer:e,constructor:this.constructor_})),this.writeMethods({writer:e})}writeType({writer:e}){if(e.writeNode(new A({docs:this.docs})),this.name!=null?e.write(`type ${this.name} struct {`):e.write("struct{"),this.embeds.length===0&&this.fields.length===0){e.writeLine("}");return}e.newLine(),e.indent();for(let o of this.embeds)e.writeNode(o),e.newLine();let n=this.fields.filter(o=>this.isExported(o));for(let o of n)e.writeNode(o),e.newLine();let i=this.fields.filter(o=>!this.isExported(o));n.length>0&&i.length>0&&e.newLine();for(let o of i)e.writeNode(o),e.newLine();e.dedent(),e.write("}")}writeConstructor({writer:e,constructor:n}){n.name!=null?e.write(`func ${n.name}(`):e.write(`func New${this.name}(`),n.parameters.forEach((i,o)=>{o>0&&e.write(", "),e.writeNode(i)}),e.write(`) *${this.name} {`),e.newLine(),e.indent(),e.writeNode(n.body),e.writeNewLineIfLastLineNot(),e.dedent(),e.writeLine("}")}writeMethods({writer:e}){if(this.methods.length!==0){e.writeNewLineIfLastLineNot();for(let n of this.methods)e.newLine(),e.writeNode(n),e.newLine()}}isExported(e){let n=e.name.charAt(0);return n===n.toUpperCase()}};f();c();var he=class extends x{constructor({on:e,cases:n,default:i}){super();u(this,"on");u(this,"cases");u(this,"default");this.on=e,this.cases=n,this.default=i}write(e){let n=this.cases;this.default!=null&&n.push({on:new F("default"),body:this.default}),e.write("switch "),e.writeNode(this.on),e.writeLine("{"),e.indent();for(let i of n)e.write("case "),e.writeNode(i.on),e.writeLine(":"),e.indent(),e.writeNode(i.body),e.dedent(),e.writeNewLineIfLastLineNot();e.dedent(),e.write("}")}};f();c();var Jr=new Set(["any","bytes","map","slice"]),pe=class r extends x{constructor(e){super();u(this,"internalType");this.internalType=e}write(e,{comment:n}={}){switch(this.internalType.type){case"any":e.write("any");break;case"bool":e.write("bool");break;case"bytes":e.write("[]byte");break;case"date":case"dateTime":e.writeNode(be);break;case"error":e.write("error");break;case"float64":e.write("float64");break;case"int":e.write("int");break;case"int64":e.write("int64");break;case"map":{e.write("map["),this.internalType.keyType.write(e),e.write("]"),this.internalType.valueType.write(e);break}case"optional":{e.write("*"),this.internalType.value.write(e);break}case"reference":e.writeNode(this.internalType.value);break;case"slice":e.write("[]"),this.internalType.value.write(e);break;case"string":e.write("string");break;case"uuid":e.writeNode(Se);break;case"variadic":e.write("..."),this.internalType.value.write(e);break;default:oe(this.internalType)}}isOptional(){return this.internalType.type==="optional"}isIterable(){return this.internalType.type==="slice"||this.internalType.type==="variadic"}iterableElement(){if(this.internalType.type==="slice"||this.internalType.type==="variadic")return this.internalType.value}underlying(){return this.internalType.type==="optional"?this.internalType.value:this}static any(){return new this({type:"any"})}static bool(){return new this({type:"bool"})}static bytes(){return new this({type:"bytes"})}static date(){return new this({type:"date"})}static dateTime(){return new this({type:"dateTime"})}static dereference(e){return e.internalType.type==="optional"?e.internalType.value:e}static error(){return new this({type:"error"})}static float64(){return new this({type:"float64"})}static int(){return new this({type:"int"})}static int64(){return new this({type:"int64"})}static map(e,n){return new this({type:"map",keyType:e,valueType:n})}static optional(e){return this.isAlreadyOptional(e)?e:new this({type:"optional",value:e})}static pointer(e){return r.optional(e)}static reference(e){return new this({type:"reference",value:e})}static slice(e){return new this({type:"slice",value:e})}static string(){return new this({type:"string"})}static uuid(){return new this({type:"uuid"})}static variadic(e){return this.isAlreadyVariadic(e)?e:new this({type:"variadic",value:e})}static isAlreadyOptional(e){return e.internalType.type==="optional"||Jr.has(e.internalType.type)}static isAlreadyVariadic(e){return e.internalType.type==="variadic"}},be=new E({importPath:"time",name:"Time"}),Se=new E({importPath:"github.com/google/uuid",name:"UUID"}),Fe=new E({importPath:"io",name:"Reader"});f();c();var te=class extends x{constructor({name:e,type:n,docs:i}){super();u(this,"name");u(this,"type");u(this,"docs");this.name=e,this.type=n,this.docs=i}write(e){e.writeNode(new A({docs:this.docs})),e.write("type "),e.write(this.name),e.write(" "),e.writeNode(this.type)}};function zr(r){return new J(r)}function Hr(r){return new L(r)}function Kr(r){return new z(r)}function Zr(r){return new H(r)}function Qr(r={}){return new K(r)}function Xr(r){return new Z(r)}function qr(r){return new F(r)}function en(r){return new b(r)}function tn(r){return new M(r)}function rn(r){return new $(r)}function nn(r){return new Q(r)}function on(r){return new X(r)}function sn(r){return new q(r)}function an(r={}){return new ee(r)}function un(r){return new he(r)}function fn(r){return new te(r)}function cn(r){return new E(r)}f();c();var ln=new Set(["string"]);function hn(r){if(r==="")return"Underscore";let t=r;for(;t.startsWith("_");)t=t.slice(1);if(t==="")return"Underscore";if(t.length>0&&/^\d/.test(t))return"Field"+t;let e=t,n=t[0];return t.length>0&&n!=null&&n!==n.toUpperCase()&&(e=n.toUpperCase()+t.slice(1)),ln.has(e.toLowerCase())?"Field"+e:e}f();c();Et();var vn="sdk";function En({config:r,customConfig:t}){let e=In({config:r}),n=Nn({config:r,customConfig:t});return e!=null?bn({importPath:n,majorVersion:e}):n}function Nn({config:r,customConfig:t,isModulePath:e=!1}){var i,o,s,l;let n=(s=(o=t==null?void 0:t.importPath)!=null?o:(i=t==null?void 0:t.module)==null?void 0:i.path)!=null?s:r.output.mode.type==="github"?Sn(r.output.mode.repoUrl,"https://"):vn;return e?n:vt.join(n,(l=t==null?void 0:t.packagePath)!=null?l:"")}function In({config:r}){let t=kn({config:r});if(!(t==null||t==="v0"||t==="v1"))return`${t}`}function kn({config:r}){let t=Rn(r);if(t==null)return;let e=t.split(".");if(e[0]==null)return;let n=e[0];return n.startsWith("v")?n:`v${n}`}function bn({importPath:r,majorVersion:t}){return fe(r)===t?r:`${r}/${t}`}function Sn(r,t){return r.startsWith(t)?r.slice(t.length):r}function Rn(r){var e;let t=(e=r==null?void 0:r.output)==null?void 0:e.mode;if(t!=null)return t.type==="github"||t.type==="publish"?t.version:void 0}f();c();export{_n as a,Ln as b,Pn as c,Bn as d,u as e,f,c as g,oe as h,_r as i,Me as j,hn as k,En as l};
|
|
27
|
-
/*! Bundled license information:
|
|
28
|
-
|
|
29
|
-
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
30
|
-
(*!
|
|
31
|
-
* The buffer module from node.js, for the browser.
|
|
32
|
-
*
|
|
33
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
34
|
-
* @license MIT
|
|
35
|
-
*)
|
|
36
|
-
*/
|
|
37
|
-
//# sourceMappingURL=chunk-VY2BNRW5.js.map
|