Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sync:
git fetch --all

generate-protocol-tests:
rm -rf ./smithy-typescript-protocol-test-codegen/build/smithyprojections/smithy-typescript-protocol-test-codegen
./gradlew :smithy-typescript-protocol-test-codegen:build
rm -rf ./private/smithy-rpcv2-cbor
rm -rf ./private/smithy-rpcv2-cbor-schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface GetNumbersCommandOutput extends GetNumbersResponse, __MetadataB
*
* @throws {@link XYZServiceServiceException} (client fault)
*
* @throws {@link MainServiceLinkedError} (client fault)
*
* @throws {@link XYZServiceSyntheticServiceException}
* <p>Base exception class for all service exceptions from XYZService service.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export interface TradeEventStreamCommandOutput extends TradeEventStreamResponse,
* @see {@link TradeEventStreamCommandOutput} for command's `response` shape.
* @see {@link XYZServiceClientResolvedConfig | config} for XYZServiceClient's `config` shape.
*
* @throws {@link MainServiceLinkedError} (client fault)
*
* @throws {@link XYZServiceSyntheticServiceException}
* <p>Base exception class for all service exceptions from XYZService service.</p>
*
Expand Down
19 changes: 19 additions & 0 deletions private/my-local-model-schema/src/models/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ export class HaltError extends __BaseException {
}
}

/**
* @public
*/
export class MainServiceLinkedError extends __BaseException {
readonly name = "MainServiceLinkedError" as const;
readonly $fault = "client" as const;
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<MainServiceLinkedError, __BaseException>) {
super({
name: "MainServiceLinkedError",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, MainServiceLinkedError.prototype);
}
}

/**
* @public
*/
Expand Down
8 changes: 8 additions & 0 deletions private/my-local-model-schema/src/schemas/schemas_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const _GN = "GetNumbers";
const _GNR = "GetNumbersRequest";
const _GNRe = "GetNumbersResponse";
const _HE = "HaltError";
const _MSLE = "MainServiceLinkedError";
const _MTE = "MysteryThrottlingError";
const _RE = "RetryableError";
const _TE = "TradeEvents";
Expand Down Expand Up @@ -35,6 +36,7 @@ import type { StaticErrorSchema, StaticOperationSchema, StaticStructureSchema }
import {
CodedThrottlingError as __CodedThrottlingError,
HaltError as __HaltError,
MainServiceLinkedError as __MainServiceLinkedError,
MysteryThrottlingError as __MysteryThrottlingError,
RetryableError as __RetryableError,
XYZServiceServiceException as __XYZServiceServiceException,
Expand Down Expand Up @@ -71,6 +73,12 @@ export var HaltError: StaticErrorSchema = [-3, n0, _HE,
[]
];
TypeRegistry.for(n0).registerError(HaltError, __HaltError);
export var MainServiceLinkedError: StaticErrorSchema = [-3, n0, _MSLE,
{ [_e]: _c, [_hE]: 400 },
[],
[]
];
TypeRegistry.for(n0).registerError(MainServiceLinkedError, __MainServiceLinkedError);
export var MysteryThrottlingError: StaticErrorSchema = [-3, n0, _MTE,
{ [_e]: _c },
[],
Expand Down
2 changes: 2 additions & 0 deletions private/my-local-model-schema/test/index-objects.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
CodedThrottlingError,
GetNumbersCommand,
HaltError,
MainServiceLinkedError,
MysteryThrottlingError,
RetryableError,
TradeEventStreamCommand,
Expand All @@ -20,6 +21,7 @@ assert(typeof TradeEventStreamCommand === "function");
// errors
assert(CodedThrottlingError.prototype instanceof XYZServiceSyntheticServiceException);
assert(HaltError.prototype instanceof XYZServiceSyntheticServiceException);
assert(MainServiceLinkedError.prototype instanceof XYZServiceSyntheticServiceException);
assert(MysteryThrottlingError.prototype instanceof XYZServiceSyntheticServiceException);
assert(RetryableError.prototype instanceof XYZServiceSyntheticServiceException);
assert(XYZServiceServiceException.prototype instanceof XYZServiceSyntheticServiceException);
Expand Down
1 change: 1 addition & 0 deletions private/my-local-model-schema/test/index-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export type {
TradeEventStreamResponse,
CodedThrottlingError,
HaltError,
MainServiceLinkedError,
MysteryThrottlingError,
RetryableError,
XYZServiceServiceException,
Expand Down
2 changes: 2 additions & 0 deletions private/my-local-model/src/commands/GetNumbersCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export interface GetNumbersCommandOutput extends GetNumbersResponse, __MetadataB
*
* @throws {@link XYZServiceServiceException} (client fault)
*
* @throws {@link MainServiceLinkedError} (client fault)
*
* @throws {@link XYZServiceSyntheticServiceException}
* <p>Base exception class for all service exceptions from XYZService service.</p>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export interface TradeEventStreamCommandOutput extends TradeEventStreamResponse,
* @see {@link TradeEventStreamCommandOutput} for command's `response` shape.
* @see {@link XYZServiceClientResolvedConfig | config} for XYZServiceClient's `config` shape.
*
* @throws {@link MainServiceLinkedError} (client fault)
*
* @throws {@link XYZServiceSyntheticServiceException}
* <p>Base exception class for all service exceptions from XYZService service.</p>
*
Expand Down
19 changes: 19 additions & 0 deletions private/my-local-model/src/models/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ export class HaltError extends __BaseException {
}
}

/**
* @public
*/
export class MainServiceLinkedError extends __BaseException {
readonly name = "MainServiceLinkedError" as const;
readonly $fault = "client" as const;
/**
* @internal
*/
constructor(opts: __ExceptionOptionType<MainServiceLinkedError, __BaseException>) {
super({
name: "MainServiceLinkedError",
$fault: "client",
...opts,
});
Object.setPrototypeOf(this, MainServiceLinkedError.prototype);
}
}

/**
* @public
*/
Expand Down
22 changes: 22 additions & 0 deletions private/my-local-model/src/protocols/Rpcv2cbor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { TradeEventStreamCommandInput, TradeEventStreamCommandOutput } from "../
import {
CodedThrottlingError,
HaltError,
MainServiceLinkedError,
MysteryThrottlingError,
RetryableError,
XYZServiceServiceException,
Expand Down Expand Up @@ -133,6 +134,9 @@ const de_CommandError = async (
case "HaltError":
case "org.xyz.v1#HaltError":
throw await de_HaltErrorRes(parsedOutput, context);
case "MainServiceLinkedError":
case "org.xyz.v1#MainServiceLinkedError":
throw await de_MainServiceLinkedErrorRes(parsedOutput, context);
case "MysteryThrottlingError":
case "org.xyz.v1#MysteryThrottlingError":
throw await de_MysteryThrottlingErrorRes(parsedOutput, context);
Expand Down Expand Up @@ -184,6 +188,22 @@ const de_HaltErrorRes = async (
return __decorateServiceException(exception, body);
};

/**
* deserializeRpcv2cborMainServiceLinkedErrorRes
*/
const de_MainServiceLinkedErrorRes = async (
parsedOutput: any,
context: __SerdeContext
): Promise<MainServiceLinkedError> => {
const body = parsedOutput.body
const deserialized: any = _json(body);
const exception = new MainServiceLinkedError({
$metadata: deserializeMetadata(parsedOutput),
...deserialized
});
return __decorateServiceException(exception, body);
};

/**
* deserializeRpcv2cborMysteryThrottlingErrorRes
*/
Expand Down Expand Up @@ -382,6 +402,8 @@ const se_Alpha_event = (

// de_HaltError omitted.

// de_MainServiceLinkedError omitted.

// de_MysteryThrottlingError omitted.

// de_RetryableError omitted.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private ServiceClosure(
Set<OperationShape> containedOperations = topDown.getContainedOperations(service);
operations.addAll(containedOperations);
scan(containedOperations);
scan(service);
scanned.clear();
deconflictSchemaVarNames();
}
Expand Down Expand Up @@ -271,6 +272,13 @@ private void scan(Collection<Shape> shapes) {
operations.add(operation);
existsAsSchema.add(operation);
}
case SERVICE -> {
ServiceShape serviceShape = (ServiceShape) shape;
serviceShape.getErrorsSet().forEach(errorShapeId -> {
Shape errorShape = model.expectShape(errorShapeId);
scan(errorShape);
});
}
case BYTE, INT_ENUM, SHORT, INTEGER, LONG, FLOAT, DOUBLE, BIG_INTEGER, BIG_DECIMAL, BOOLEAN, STRING,
TIMESTAMP, DOCUMENT, ENUM, BLOB -> {
if (shape.isEnumShape() || shape.isIntEnumShape() || shape.hasTrait(EnumTrait.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ service XYZService {
GetNumbers
TradeEventStream
]
errors: [
MainServiceLinkedError
]
}

@error("client")
@httpError(400)
structure MainServiceLinkedError {}

@readonly
operation GetNumbers {
input: GetNumbersRequest
Expand Down Expand Up @@ -91,3 +98,35 @@ structure Alpha {
id: String
timestamp: Timestamp
}

@rpcv2Cbor
@documentation("a second service in the same model, unused.")
service UnusedService {
version: "1.0"
operations: [
UnusedOperation
]
errors: [
UnusedServiceLinkedError
]
}

operation UnusedOperation {
input: Unit
output: Unit
errors: [
UnusedServiceOperationLinkedError
]
}

@error("client")
@httpError(400)
structure UnusedServiceOperationLinkedError {}

@error("client")
@httpError(400)
structure UnusedServiceLinkedError {}

@error("client")
@httpError(400)
structure CompletelyUnlinkedError {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
$version: "2.0"

namespace org.xyz.secondary

use smithy.protocols#rpcv2Cbor

@rpcv2Cbor
@documentation("a second service in the same model, unused.")
service TertiaryService {
version: "1.0"
operations: [
TertiaryUnusedOperation
]
errors: [
TertiaryUnusedServiceLinkedError
]
}

operation TertiaryUnusedOperation {
input: Unit
output: Unit
errors: [
TertiaryUnusedServiceOperationLinkedError
]
}

@error("client")
@httpError(400)
structure TertiaryUnusedServiceOperationLinkedError {}

@error("client")
@httpError(400)
structure TertiaryUnusedServiceLinkedError {}

@error("client")
@httpError(400)
structure TertiaryCompletelyUnlinkedError {}
4 changes: 2 additions & 2 deletions smithy-typescript-protocol-test-codegen/smithy-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{
"name": "includeServices",
"args": {
"services": ["org.xyz.v1#XYZService"]
"services": ["org.xyz.v1#XYZService", "org.xyz.v1#UnusedService", "org.xyz.secondary#TertiaryService"]
}
}
],
Expand All @@ -83,7 +83,7 @@
{
"name": "includeServices",
"args": {
"services": ["org.xyz.v1#XYZService"]
"services": ["org.xyz.v1#XYZService", "org.xyz.v1#UnusedService", "org.xyz.secondary#TertiaryService"]
}
}
],
Expand Down