-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b7d2b30
commit e121d63
Showing
26 changed files
with
210 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file renamed
BIN
+104 KB
...del-npm-0.0.212-fba163d6dc-d4753f0308.zip → ...del-npm-0.0.220-f0aa23de2b-34bfbfd1a3.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { FernConstants } from "@fern-fern/ir-model/ir"; | ||
|
||
export const FERN_CONSTANTS: FernConstants = { | ||
errorDiscriminant: "_error", | ||
errorInstanceIdKey: "_errorInstanceId", | ||
unknownErrorDiscriminantValue: "_unknown", | ||
}; |
2 changes: 1 addition & 1 deletion
2
packages/cli/generation/ir-generator/src/__test__/mocks/MockTypeResolver.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/generation/ir-generator/src/converters/convertErrorDeclaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/cli/generation/ir-generator/src/converters/convertId.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
packages/cli/generation/ir-generator/src/converters/services/convertResponseErrorsV2.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { RawPrimitiveType, RawSchemas } from "@fern-api/yaml-schema"; | ||
import { ResponseErrorShape, ResponseErrorsV2, ResponseErrorV2 } from "@fern-fern/ir-model/services/commons"; | ||
import { FernFileContext } from "../../FernFileContext"; | ||
import { ErrorResolver } from "../../resolvers/ErrorResolver"; | ||
import { generateWireStringWithAllCasings } from "../../utils/generateCasings"; | ||
import { parseTypeName } from "../../utils/parseTypeName"; | ||
|
||
const ERROR_DISCRIMINANT = "errorName"; | ||
const ERROR_CONTENT_PROPERTY_NAME = "content"; | ||
|
||
export function convertResponseErrorsV2({ | ||
errors, | ||
file, | ||
errorResolver, | ||
}: { | ||
errors: RawSchemas.ResponseErrorsSchema | undefined; | ||
file: FernFileContext; | ||
errorResolver: ErrorResolver; | ||
}): ResponseErrorsV2 { | ||
const discriminant = generateWireStringWithAllCasings({ | ||
wireValue: ERROR_DISCRIMINANT, | ||
name: ERROR_DISCRIMINANT, | ||
}); | ||
|
||
if (errors == null || errors.length === 0) { | ||
return { | ||
discriminant, | ||
types: [], | ||
}; | ||
} | ||
|
||
return { | ||
discriminant, | ||
types: Object.values(errors).map((errorReference): ResponseErrorV2 => { | ||
const referenceToError = typeof errorReference === "string" ? errorReference : errorReference.error; | ||
|
||
const declaration = errorResolver.getDeclaration(referenceToError, file); | ||
if (declaration == null) { | ||
throw new Error("Cannot locate declaration for error: " + referenceToError); | ||
} | ||
const rawErrorType = typeof declaration === "string" ? declaration : declaration.type; | ||
|
||
const parsedErrorName = parseTypeName({ typeName: referenceToError, file }); | ||
const discriminantValue = parsedErrorName.name; | ||
|
||
return { | ||
docs: typeof errorReference !== "string" ? errorReference.docs : undefined, | ||
discriminantValue: generateWireStringWithAllCasings({ | ||
wireValue: discriminantValue, | ||
name: discriminantValue, | ||
}), | ||
shape: | ||
rawErrorType != null && rawErrorType !== RawPrimitiveType.void | ||
? ResponseErrorShape.singleProperty({ | ||
name: generateWireStringWithAllCasings({ | ||
wireValue: ERROR_CONTENT_PROPERTY_NAME, | ||
name: ERROR_CONTENT_PROPERTY_NAME, | ||
}), | ||
error: parsedErrorName, | ||
}) | ||
: ResponseErrorShape.noProperties(), | ||
}; | ||
}), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...es/cli/generation/ir-generator/src/converters/type-declarations/convertTypeDeclaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...i/generation/ir-generator/src/converters/type-declarations/convertUnionTypeDeclaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ion/ir-generator/src/converters/type-declarations/getReferencedTypesFromRawDeclaration.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.