From 4b38080fc7bcf7af4741dd930e855938023c738b Mon Sep 17 00:00:00 2001 From: George Fu Date: Thu, 9 Oct 2025 15:36:52 -0400 Subject: [PATCH] feat: generate static schema --- .changeset/lazy-brooms-sip.md | 7 + .../src/submodules/schema/TypeRegistry.ts | 14 +- .../schemaDeserializationMiddleware.ts | 10 +- .../schemaSerializationMiddleware.ts | 9 +- .../schema/schemas/NormalizedSchema.spec.ts | 31 ++ .../schema/schemas/NormalizedSchema.ts | 69 ++- packages/smithy-client/src/command.ts | 17 +- packages/types/src/index.ts | 1 + packages/types/src/schema/schema.ts | 2 + packages/types/src/schema/static-schemas.ts | 90 ++++ .../src/commands/EmptyInputOutputCommand.ts | 2 +- .../src/commands/Float16Command.ts | 2 +- .../src/commands/FractionalSecondsCommand.ts | 2 +- .../src/commands/GreetingWithErrorsCommand.ts | 2 +- .../src/commands/NoInputOutputCommand.ts | 2 +- .../commands/OperationWithDefaultsCommand.ts | 2 +- .../commands/OptionalInputOutputCommand.ts | 2 +- .../src/commands/RecursiveShapesCommand.ts | 2 +- .../src/commands/RpcV2CborDenseMapsCommand.ts | 2 +- .../src/commands/RpcV2CborListsCommand.ts | 2 +- .../commands/RpcV2CborSparseMapsCommand.ts | 2 +- .../commands/SimpleScalarPropertiesCommand.ts | 2 +- .../commands/SparseNullsOperationCommand.ts | 2 +- .../src/schemas/schemas_0.ts | 369 ++++++++++++++ .../src/schemas/schemas_1_Rpc.ts | 454 ------------------ .../src/schemas/schemas_2_EmptyInputOutput.ts | 14 - .../schemas/schemas_3_FractionalSeconds.ts | 15 - .../src/schemas/schemas_4_.ts | 15 - .../src/schemas/schemas_5_NoInputOutput.ts | 14 - .../codegen/schema/SchemaGenerator.java | 76 +-- .../codegen/schema/ShapeGroupingIndex.java | 9 + 31 files changed, 657 insertions(+), 585 deletions(-) create mode 100644 .changeset/lazy-brooms-sip.md create mode 100644 packages/types/src/schema/static-schemas.ts delete mode 100644 private/smithy-rpcv2-cbor-schema/src/schemas/schemas_1_Rpc.ts delete mode 100644 private/smithy-rpcv2-cbor-schema/src/schemas/schemas_2_EmptyInputOutput.ts delete mode 100644 private/smithy-rpcv2-cbor-schema/src/schemas/schemas_3_FractionalSeconds.ts delete mode 100644 private/smithy-rpcv2-cbor-schema/src/schemas/schemas_4_.ts delete mode 100644 private/smithy-rpcv2-cbor-schema/src/schemas/schemas_5_NoInputOutput.ts diff --git a/.changeset/lazy-brooms-sip.md b/.changeset/lazy-brooms-sip.md new file mode 100644 index 00000000000..03b73bb49ee --- /dev/null +++ b/.changeset/lazy-brooms-sip.md @@ -0,0 +1,7 @@ +--- +"@smithy/smithy-client": minor +"@smithy/types": minor +"@smithy/core": minor +--- + +generation of static schema diff --git a/packages/core/src/submodules/schema/TypeRegistry.ts b/packages/core/src/submodules/schema/TypeRegistry.ts index f6ff1f7eb1c..03c388f011b 100644 --- a/packages/core/src/submodules/schema/TypeRegistry.ts +++ b/packages/core/src/submodules/schema/TypeRegistry.ts @@ -1,4 +1,4 @@ -import type { Schema as ISchema } from "@smithy/types"; +import type { Schema as ISchema, StaticErrorSchema } from "@smithy/types"; import type { ErrorSchema } from "./schemas/ErrorSchema"; @@ -13,7 +13,7 @@ export class TypeRegistry { private constructor( public readonly namespace: string, private schemas: Map = new Map(), - private exceptions: Map = new Map() + private exceptions: Map = new Map() ) {} /** @@ -53,16 +53,16 @@ export class TypeRegistry { /** * Associates an error schema with its constructor. */ - public registerError(errorSchema: ErrorSchema, ctor: any) { - this.exceptions.set(errorSchema, ctor); + public registerError(es: ErrorSchema | StaticErrorSchema, ctor: any) { + this.exceptions.set(es, ctor); } /** - * @param errorSchema - query. + * @param es - query. * @returns Error constructor that extends the service's base exception. */ - public getErrorCtor(errorSchema: ErrorSchema): any { - return this.exceptions.get(errorSchema); + public getErrorCtor(es: ErrorSchema | StaticErrorSchema): any { + return this.exceptions.get(es); } /** diff --git a/packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.ts b/packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.ts index 57032e13edf..1ad63a66738 100644 --- a/packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.ts +++ b/packages/core/src/submodules/schema/middleware/schemaDeserializationMiddleware.ts @@ -5,9 +5,11 @@ import type { HandlerExecutionContext, MetadataBearer, OperationSchema, + StaticOperationSchema, } from "@smithy/types"; import { getSmithyContext } from "@smithy/util-middleware"; +import { hydrate, isStaticSchema } from "../schemas/NormalizedSchema"; import type { PreviouslyResolved } from "./schema-middleware-types"; /** @@ -18,9 +20,13 @@ export const schemaDeserializationMiddleware = (next: DeserializeHandler, context: HandlerExecutionContext) => async (args: DeserializeHandlerArguments) => { const { response } = await next(args); - const { operationSchema } = getSmithyContext(context) as { - operationSchema: OperationSchema; + let { operationSchema } = getSmithyContext(context) as { + operationSchema: OperationSchema | StaticOperationSchema; }; + if (isStaticSchema(operationSchema)) { + operationSchema = hydrate(operationSchema); + } + try { const parsed = await config.protocol.deserializeResponse( operationSchema, diff --git a/packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.ts b/packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.ts index b94000adc61..46cc50e5e0d 100644 --- a/packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.ts +++ b/packages/core/src/submodules/schema/middleware/schemaSerializationMiddleware.ts @@ -6,9 +6,11 @@ import type { Provider, SerializeHandler, SerializeHandlerArguments, + StaticOperationSchema, } from "@smithy/types"; import { getSmithyContext } from "@smithy/util-middleware"; +import { hydrate, isStaticSchema } from "../schemas/NormalizedSchema"; import type { PreviouslyResolved } from "./schema-middleware-types"; /** @@ -18,9 +20,12 @@ export const schemaSerializationMiddleware = (config: PreviouslyResolved) => (next: SerializeHandler, context: HandlerExecutionContext) => async (args: SerializeHandlerArguments) => { - const { operationSchema } = getSmithyContext(context) as { - operationSchema: IOperationSchema; + let { operationSchema } = getSmithyContext(context) as { + operationSchema: IOperationSchema | StaticOperationSchema; }; + if (isStaticSchema(operationSchema)) { + operationSchema = hydrate(operationSchema); + } const endpoint: Provider = context.endpointV2?.url && config.urlParser diff --git a/packages/core/src/submodules/schema/schemas/NormalizedSchema.spec.ts b/packages/core/src/submodules/schema/schemas/NormalizedSchema.spec.ts index ef8251b70d1..c5e130f75d5 100644 --- a/packages/core/src/submodules/schema/schemas/NormalizedSchema.spec.ts +++ b/packages/core/src/submodules/schema/schemas/NormalizedSchema.spec.ts @@ -8,6 +8,9 @@ import type { MapSchemaModifier, MemberSchema, NumericSchema, + StaticListSchema, + StaticMapSchema, + StaticStructureSchema, StreamingBlobSchema, StringSchema, StructureSchema, @@ -313,4 +316,32 @@ describe(NormalizedSchema.name, () => { expect(ns.getEventStreamMember()).toEqual(""); }); }); + + describe("static schema", () => { + it("can normalize static schema indifferently to schema class objects", () => { + const [List, Map, Struct]: [StaticListSchema, StaticMapSchema, () => StaticStructureSchema] = [ + [1, "ack", "List", { sparse: 1 }, 0], + [2, "ack", "Map", 0, 0, 1], + () => schema, + ]; + const schema: StaticStructureSchema = [3, "ack", "Structure", {}, ["list", "map", "struct"], [List, Map, Struct]]; + + const ns = NormalizedSchema.of(schema); + + expect(ns.isStructSchema()).toBe(true); + expect(ns.getMemberSchema("list").isListSchema()).toBe(true); + expect(ns.getMemberSchema("list").getMergedTraits().sparse).toBe(1); + + expect(ns.getMemberSchema("map").isMapSchema()).toBe(true); + expect(ns.getMemberSchema("map").getKeySchema().isStringSchema()).toBe(true); + expect(ns.getMemberSchema("map").getValueSchema().isNumericSchema()).toBe(true); + + expect(ns.getMemberSchema("struct").isStructSchema()).toBe(true); + expect(ns.getMemberSchema("struct").getMemberSchema("list").isListSchema()).toBe(true); + expect(ns.getMemberSchema("struct").getMemberSchema("list").getMergedTraits().sparse).toBe(1); + expect(ns.getMemberSchema("struct").getMemberSchema("map").isMapSchema()).toBe(true); + expect(ns.getMemberSchema("struct").getMemberSchema("map").getKeySchema().isStringSchema()).toBe(true); + expect(ns.getMemberSchema("struct").getMemberSchema("map").getValueSchema().isNumericSchema()).toBe(true); + }); + }); }); diff --git a/packages/core/src/submodules/schema/schemas/NormalizedSchema.ts b/packages/core/src/submodules/schema/schemas/NormalizedSchema.ts index 83b187b931d..2fd34fb2c43 100644 --- a/packages/core/src/submodules/schema/schemas/NormalizedSchema.ts +++ b/packages/core/src/submodules/schema/schemas/NormalizedSchema.ts @@ -13,6 +13,14 @@ import type { SchemaRef, SchemaTraits, SchemaTraitsObject, + StaticErrorSchema, + StaticListSchema, + StaticMapSchema, + StaticOperationSchema, + StaticSchema, + StaticSchemaId, + StaticSimpleSchema, + StaticStructureSchema, StreamingBlobSchema, StringSchema, TimestampDefaultSchema, @@ -22,11 +30,16 @@ import type { import type { IdempotencyTokenBitMask, TraitBitVector } from "@smithy/types/src/schema/traits"; import { deref } from "../deref"; -import { ListSchema } from "./ListSchema"; -import { MapSchema } from "./MapSchema"; +import type { ErrorSchema } from "./ErrorSchema"; +import { error } from "./ErrorSchema"; +import { list, ListSchema } from "./ListSchema"; +import { map, MapSchema } from "./MapSchema"; +import type { OperationSchema } from "./OperationSchema"; +import { op } from "./OperationSchema"; import { Schema } from "./Schema"; import type { SimpleSchema } from "./SimpleSchema"; -import { StructureSchema } from "./StructureSchema"; +import { sim } from "./SimpleSchema"; +import { struct, StructureSchema } from "./StructureSchema"; import { translateTraits } from "./translateTraits"; /** @@ -67,13 +80,15 @@ export class NormalizedSchema implements INormalizedSchema { let schema = ref; this._isMemberSchema = false; - while (Array.isArray(_ref)) { + while (isMemberSchema(_ref)) { traitStack.push(_ref[1]); _ref = _ref[0]; schema = deref(_ref); this._isMemberSchema = true; } + if (isStaticSchema(schema)) schema = hydrate(schema); + if (traitStack.length > 0) { this.memberTraits = {}; for (let i = traitStack.length - 1; i >= 0; --i) { @@ -96,7 +111,8 @@ export class NormalizedSchema implements INormalizedSchema { this.schema = deref(schema) as Exclude; if (this.schema && typeof this.schema === "object") { - this.traits = this.schema?.traits ?? {}; + // excluded by the checked hydrate call above. + this.traits = (this.schema as Exclude)?.traits ?? {}; } else { this.traits = 0; } @@ -120,7 +136,7 @@ export class NormalizedSchema implements INormalizedSchema { if (sc instanceof NormalizedSchema) { return sc; } - if (Array.isArray(sc)) { + if (isMemberSchema(sc)) { const [ns, traits] = sc; if (ns instanceof NormalizedSchema) { Object.assign(ns.getMergedTraits(), translateTraits(traits)); @@ -331,7 +347,7 @@ export class NormalizedSchema implements INormalizedSchema { if (this.isStructSchema() && struct.memberNames.includes(memberName)) { const i = struct.memberNames.indexOf(memberName); const memberSchema = struct.memberList[i]; - return member(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], memberName); + return member(isMemberSchema(memberSchema) ? memberSchema : [memberSchema, 0], memberName); } if (this.isDocumentSchema()) { return member([15 satisfies DocumentSchema, 0], memberName); @@ -409,3 +425,42 @@ function member(memberSchema: NormalizedSchema | [SchemaRef, SchemaTraits], memb const internalCtorAccess = NormalizedSchema as any; return new internalCtorAccess(memberSchema, memberName); } + +/** + * @internal + * @returns a class instance version of a static schema. + */ +export function hydrate(ss: StaticSimpleSchema): SimpleSchema; +export function hydrate(ss: StaticListSchema): ListSchema; +export function hydrate(ss: StaticMapSchema): MapSchema; +export function hydrate(ss: StaticStructureSchema): StructureSchema; +export function hydrate(ss: StaticErrorSchema): ErrorSchema; +export function hydrate(ss: StaticOperationSchema): OperationSchema; +export function hydrate( + ss: StaticSchema +): SimpleSchema | ListSchema | MapSchema | StructureSchema | ErrorSchema | OperationSchema; +export function hydrate( + ss: StaticSchema +): SimpleSchema | ListSchema | MapSchema | StructureSchema | ErrorSchema | OperationSchema { + const [id, ...rest] = ss; + return ( + { + [0 satisfies StaticSchemaId.Simple]: sim, + [1 satisfies StaticSchemaId.List]: list, + [2 satisfies StaticSchemaId.Map]: map, + [3 satisfies StaticSchemaId.Struct]: struct, + [-3 satisfies StaticSchemaId.Error]: error, + [9 satisfies StaticSchemaId.Operation]: op, + }[id] as Function + ).call(null, ...rest); +} + +/** + * @internal + */ +const isMemberSchema = (sc: SchemaRef): sc is MemberSchema => Array.isArray(sc) && sc.length === 2; + +/** + * @internal + */ +export const isStaticSchema = (sc: SchemaRef): sc is StaticSchema => Array.isArray(sc) && sc.length >= 5; diff --git a/packages/smithy-client/src/command.ts b/packages/smithy-client/src/command.ts index 278d6c7e84d..35a4dbda176 100644 --- a/packages/smithy-client/src/command.ts +++ b/packages/smithy-client/src/command.ts @@ -17,6 +17,7 @@ import type { Pluggable, RequestHandler, SerdeContext, + StaticOperationSchema, } from "@smithy/types"; import { SMITHY_CONTEXT_KEY } from "@smithy/types"; @@ -35,7 +36,7 @@ export abstract class Command< { public abstract input: Input; public readonly middlewareStack: IMiddlewareStack = constructStack(); - public readonly schema?: OperationSchema; + public readonly schema?: OperationSchema | StaticOperationSchema; /** * Factory for Command ClassBuilder. @@ -136,7 +137,7 @@ class ClassBuilder< private _outputFilterSensitiveLog: any = undefined; private _serializer: (input: I, context: SerdeContext | any) => Promise = null as any; private _deserializer: (output: IHttpResponse, context: SerdeContext | any) => Promise = null as any; - private _operationSchema?: OperationSchema; + private _operationSchema?: OperationSchema | StaticOperationSchema; /** * Optional init callback. @@ -223,7 +224,7 @@ class ClassBuilder< /** * Sets input/output schema for the operation. */ - public sc(operation: OperationSchema): ClassBuilder { + public sc(operation: OperationSchema | StaticOperationSchema): ClassBuilder { this._operationSchema = operation; this._smithyContext.operationSchema = operation; return this; @@ -265,17 +266,19 @@ class ClassBuilder< * @internal */ public resolveMiddleware(stack: IMiddlewareStack, configuration: C, options: any): Handler { + const op = closure._operationSchema; + const input = (op as StaticOperationSchema)?.[4] ?? (op as OperationSchema)?.input; + const output = (op as StaticOperationSchema)?.[5] ?? (op as OperationSchema)?.output; + return this.resolveMiddlewareWithContext(stack, configuration, options, { CommandCtor: CommandRef, middlewareFn: closure._middlewareFn, clientName: closure._clientName, commandName: closure._commandName, inputFilterSensitiveLog: - closure._inputFilterSensitiveLog ?? - (closure._operationSchema ? schemaLogFilter.bind(null, closure._operationSchema!.input) : (_) => _), + closure._inputFilterSensitiveLog ?? (op ? schemaLogFilter.bind(null, input) : (_) => _), outputFilterSensitiveLog: - closure._outputFilterSensitiveLog ?? - (closure._operationSchema ? schemaLogFilter.bind(null, closure._operationSchema!.output) : (_) => _), + closure._outputFilterSensitiveLog ?? (op ? schemaLogFilter.bind(null, output) : (_) => _), smithyContext: closure._smithyContext, additionalContext: closure._additionalContext, }); diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index b1dfb30b38f..12338d6cdce 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -23,6 +23,7 @@ export * from "./response"; export * from "./retry"; export * from "./schema/schema"; export * from "./schema/sentinels"; +export * from "./schema/static-schemas"; export * from "./serde"; export * from "./shapes"; export * from "./signature"; diff --git a/packages/types/src/schema/schema.ts b/packages/types/src/schema/schema.ts index 108ffefb375..4a53e4b3b58 100644 --- a/packages/types/src/schema/schema.ts +++ b/packages/types/src/schema/schema.ts @@ -16,6 +16,7 @@ import type { TimestampEpochSecondsSchema, TimestampHttpDateSchema, } from "./sentinels"; +import type { StaticSchema } from "./static-schemas"; import type { TraitBitVector } from "./traits"; /** @@ -31,6 +32,7 @@ export type Schema = | StructureSchema | MemberSchema | OperationSchema + | StaticSchema | NormalizedSchema; /** diff --git a/packages/types/src/schema/static-schemas.ts b/packages/types/src/schema/static-schemas.ts new file mode 100644 index 00000000000..77bacf32da1 --- /dev/null +++ b/packages/types/src/schema/static-schemas.ts @@ -0,0 +1,90 @@ +/* +A static schema is a non-function-call object that has no side effects. +Schemas are generated as static objects to improve tree-shaking behavior in downstream applications. + */ + +import type { SchemaRef, SchemaTraits } from "../schema/schema"; + +/** + * @alpha + */ +export namespace StaticSchemaId { + export type Simple = 0; + export type List = 1; + export type Map = 2; + export type Struct = 3; + export type Error = -3; + export type Operation = 9; +} + +/** + * @alpha + */ +export type StaticSchema = + | StaticSimpleSchema + | StaticListSchema + | StaticMapSchema + | StaticStructureSchema + | StaticErrorSchema + | StaticOperationSchema; + +/** + * @alpha + */ +export type ShapeName = string; + +/** + * @alpha + */ +export type ShapeNamespace = string; + +/** + * @alpha + */ +export type StaticSimpleSchema = [StaticSchemaId.Simple, ShapeNamespace, ShapeName, SchemaRef, SchemaTraits]; + +/** + * @alpha + */ +export type StaticListSchema = [StaticSchemaId.List, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef]; + +/** + * @alpha + */ +export type StaticMapSchema = [StaticSchemaId.Map, ShapeNamespace, ShapeName, SchemaTraits, SchemaRef, SchemaRef]; + +/** + * @alpha + */ +export type StaticStructureSchema = [ + StaticSchemaId.Struct, + ShapeNamespace, + ShapeName, + SchemaTraits, + string[], // member name list + SchemaRef[], // member schema list +]; + +/** + * @alpha + */ +export type StaticErrorSchema = [ + StaticSchemaId.Error, + ShapeNamespace, + ShapeName, + SchemaTraits, + string[], // member name list + SchemaRef[], // member schema list +]; + +/** + * @alpha + */ +export type StaticOperationSchema = [ + StaticSchemaId.Operation, + ShapeNamespace, + ShapeName, + SchemaTraits, + SchemaRef, // input schema + SchemaRef, // output schema +]; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/EmptyInputOutputCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/EmptyInputOutputCommand.ts index 433bb6d9d72..c3d41f06cac 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/EmptyInputOutputCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/EmptyInputOutputCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { EmptyStructure } from "../models/models_0"; -import { EmptyInputOutput } from "../schemas/schemas_2_EmptyInputOutput"; +import { EmptyInputOutput } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/Float16Command.ts b/private/smithy-rpcv2-cbor-schema/src/commands/Float16Command.ts index 31663fd18e4..9d59e6e72e3 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/Float16Command.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/Float16Command.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { Float16Output } from "../models/models_0"; -import { Float16 } from "../schemas/schemas_4_"; +import { Float16 } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/FractionalSecondsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/FractionalSecondsCommand.ts index d05f7c00762..28c498feccd 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/FractionalSecondsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/FractionalSecondsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { FractionalSecondsOutput } from "../models/models_0"; -import { FractionalSeconds } from "../schemas/schemas_3_FractionalSeconds"; +import { FractionalSeconds } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/GreetingWithErrorsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/GreetingWithErrorsCommand.ts index 8bb41082673..08e0e78adaf 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/GreetingWithErrorsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/GreetingWithErrorsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { GreetingWithErrorsOutput } from "../models/models_0"; -import { GreetingWithErrors } from "../schemas/schemas_1_Rpc"; +import { GreetingWithErrors } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/NoInputOutputCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/NoInputOutputCommand.ts index 141457db04c..3bb36ad9665 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/NoInputOutputCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/NoInputOutputCommand.ts @@ -1,7 +1,7 @@ // smithy-typescript generated code import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; -import { NoInputOutput } from "../schemas/schemas_5_NoInputOutput"; +import { NoInputOutput } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/OperationWithDefaultsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/OperationWithDefaultsCommand.ts index 8304cd43813..bccb5ba3186 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/OperationWithDefaultsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/OperationWithDefaultsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { OperationWithDefaultsInput, OperationWithDefaultsOutput } from "../models/models_0"; -import { OperationWithDefaults } from "../schemas/schemas_1_Rpc"; +import { OperationWithDefaults } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/OptionalInputOutputCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/OptionalInputOutputCommand.ts index 3c8c89a56f9..5dd233c817e 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/OptionalInputOutputCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/OptionalInputOutputCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { SimpleStructure } from "../models/models_0"; -import { OptionalInputOutput } from "../schemas/schemas_1_Rpc"; +import { OptionalInputOutput } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/RecursiveShapesCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/RecursiveShapesCommand.ts index e099181e657..d72b623f57a 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/RecursiveShapesCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/RecursiveShapesCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { RecursiveShapesInputOutput } from "../models/models_0"; -import { RecursiveShapes } from "../schemas/schemas_1_Rpc"; +import { RecursiveShapes } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborDenseMapsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborDenseMapsCommand.ts index 468cfd2d930..70b0761241e 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborDenseMapsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborDenseMapsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { RpcV2CborDenseMapsInputOutput } from "../models/models_0"; -import { RpcV2CborDenseMaps } from "../schemas/schemas_1_Rpc"; +import { RpcV2CborDenseMaps } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborListsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborListsCommand.ts index faabf08c94a..a9744f5f37c 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborListsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborListsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { RpcV2CborListInputOutput } from "../models/models_0"; -import { RpcV2CborLists } from "../schemas/schemas_1_Rpc"; +import { RpcV2CborLists } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborSparseMapsCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborSparseMapsCommand.ts index f98afd43b48..70bc737cb63 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborSparseMapsCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/RpcV2CborSparseMapsCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { RpcV2CborSparseMapsInputOutput } from "../models/models_0"; -import { RpcV2CborSparseMaps } from "../schemas/schemas_1_Rpc"; +import { RpcV2CborSparseMaps } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/SimpleScalarPropertiesCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/SimpleScalarPropertiesCommand.ts index 70ea70f0e7c..a7570d27547 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/SimpleScalarPropertiesCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/SimpleScalarPropertiesCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { SimpleScalarStructure } from "../models/models_0"; -import { SimpleScalarProperties } from "../schemas/schemas_1_Rpc"; +import { SimpleScalarProperties } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/commands/SparseNullsOperationCommand.ts b/private/smithy-rpcv2-cbor-schema/src/commands/SparseNullsOperationCommand.ts index 794c71810e4..e682281c792 100644 --- a/private/smithy-rpcv2-cbor-schema/src/commands/SparseNullsOperationCommand.ts +++ b/private/smithy-rpcv2-cbor-schema/src/commands/SparseNullsOperationCommand.ts @@ -2,7 +2,7 @@ import { RpcV2ProtocolClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../RpcV2ProtocolClient"; import { commonParams } from "../endpoint/EndpointParameters"; import { SparseNullsOperationInputOutput } from "../models/models_0"; -import { SparseNullsOperation } from "../schemas/schemas_1_Rpc"; +import { SparseNullsOperation } from "../schemas/schemas_0"; import { getEndpointPlugin } from "@smithy/middleware-endpoint"; import { Command as $Command } from "@smithy/smithy-client"; import { MetadataBearer as __MetadataBearer } from "@smithy/types"; diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_0.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_0.ts index 6b2c9ec0c83..d77bd655138 100644 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_0.ts +++ b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_0.ts @@ -132,9 +132,378 @@ export const n2 = "smithy.protocoltests.shared"; // smithy-typescript generated code import { RpcV2ProtocolServiceException as __RpcV2ProtocolServiceException } from "../models/RpcV2ProtocolServiceException"; +import { + ComplexError as __ComplexError, + InvalidGreeting as __InvalidGreeting, + ValidationException as __ValidationException, +} from "../models/index"; import { TypeRegistry, error } from "@smithy/core/schema"; +import { + StaticErrorSchema, + StaticListSchema, + StaticMapSchema, + StaticOperationSchema, + StaticStructureSchema, +} from "@smithy/types"; /* eslint no-var: 0 */ +export var Unit = "unit" as const; + +export var ValidationException: StaticErrorSchema = [ + -3, + n0, + _VE, + { + [_e]: _c, + }, + [_m, _fL], + [0, () => ValidationExceptionFieldList], +]; +TypeRegistry.for(n0).registerError(ValidationException, __ValidationException); + +export var ValidationExceptionField: StaticStructureSchema = [3, n0, _VEF, 0, [_p, _m], [0, 0]]; +export var ClientOptionalDefaults: StaticStructureSchema = [3, n1, _COD, 0, [_me], [1]]; +export var ComplexError: StaticErrorSchema = [ + -3, + n1, + _CE, + { + [_e]: _c, + }, + [_TL, _N], + [0, () => ComplexNestedErrorData], +]; +TypeRegistry.for(n1).registerError(ComplexError, __ComplexError); + +export var ComplexNestedErrorData: StaticStructureSchema = [3, n1, _CNED, 0, [_F], [0]]; +export var Defaults: StaticStructureSchema = [ + 3, + n1, + _D, + 0, + [ + _dS, + _dB, + _dL, + _dT, + _dBe, + _dBef, + _dSe, + _dI, + _dLe, + _dF, + _dD, + _dM, + _dE, + _dIE, + _eS, + _fB, + _eB, + _zB, + _zS, + _zI, + _zL, + _zF, + _zD, + ], + [0, 2, 64 | 0, 4, 21, 1, 1, 1, 1, 1, 1, 128 | 0, 0, 1, 0, 2, 21, 1, 1, 1, 1, 1, 1], +]; +export var EmptyStructure: StaticStructureSchema = [3, n1, _ES, 0, [], []]; +export var Float16Output: StaticStructureSchema = [3, n1, _FO, 0, [_v], [1]]; +export var FractionalSecondsOutput: StaticStructureSchema = [3, n1, _FSO, 0, [_d], [5]]; +export var GreetingWithErrorsOutput: StaticStructureSchema = [3, n1, _GWEO, 0, [_g], [0]]; +export var InvalidGreeting: StaticErrorSchema = [ + -3, + n1, + _IG, + { + [_e]: _c, + }, + [_M], + [0], +]; +TypeRegistry.for(n1).registerError(InvalidGreeting, __InvalidGreeting); + +export var OperationWithDefaultsInput: StaticStructureSchema = [ + 3, + n1, + _OWDI, + 0, + [_de, _cOD, _tLD, _oTLD], + [() => Defaults, () => ClientOptionalDefaults, 0, 1], +]; +export var OperationWithDefaultsOutput: StaticStructureSchema = [ + 3, + n1, + _OWDO, + 0, + [ + _dS, + _dB, + _dL, + _dT, + _dBe, + _dBef, + _dSe, + _dI, + _dLe, + _dF, + _dD, + _dM, + _dE, + _dIE, + _eS, + _fB, + _eB, + _zB, + _zS, + _zI, + _zL, + _zF, + _zD, + ], + [0, 2, 64 | 0, 4, 21, 1, 1, 1, 1, 1, 1, 128 | 0, 0, 1, 0, 2, 21, 1, 1, 1, 1, 1, 1], +]; +export var RecursiveShapesInputOutput: StaticStructureSchema = [ + 3, + n1, + _RSIO, + 0, + [_n], + [() => RecursiveShapesInputOutputNested1], +]; +export var RecursiveShapesInputOutputNested1: StaticStructureSchema = [ + 3, + n1, + _RSION, + 0, + [_f, _n], + [0, () => RecursiveShapesInputOutputNested2], +]; +export var RecursiveShapesInputOutputNested2: StaticStructureSchema = [ + 3, + n1, + _RSIONe, + 0, + [_b, _rM], + [0, () => RecursiveShapesInputOutputNested1], +]; +export var RpcV2CborDenseMapsInputOutput: StaticStructureSchema = [ + 3, + n1, + _RVCDMIO, + 0, + [_dSM, _dNM, _dBM, _dSMe, _dSMen], + [() => DenseStructMap, 128 | 1, 128 | 2, 128 | 0, [2, n1, _DSM, 0, 64 | 0, 64 | 0] as StaticMapSchema], +]; +export var RpcV2CborListInputOutput: StaticStructureSchema = [ + 3, + n1, + _RVCLIO, + 0, + [_sL, _sS, _iL, _bL, _tL, _eL, _iEL, _nSL, _sLt, _bLl], + [ + 64 | 0, + 64 | 0, + 64 | 1, + 64 | 2, + 64 | 4, + 64 | 0, + 64 | 1, + [1, n2, _NSL, 0, 64 | 0] as StaticListSchema, + () => StructureList, + 64 | 21, + ], +]; +export var RpcV2CborSparseMapsInputOutput: StaticStructureSchema = [ + 3, + n1, + _RVCSMIO, + 0, + [_sSM, _sNM, _sBM, _sSMp, _sSMpa], + [ + [() => SparseStructMap, 0], + [() => SparseNumberMap, 0], + [() => SparseBooleanMap, 0], + [() => SparseStringMap, 0], + [() => SparseSetMap, 0], + ], +]; +export var SimpleScalarStructure: StaticStructureSchema = [ + 3, + n1, + _SSS, + 0, + [_tBV, _fBV, _bV, _dV, _fV, _iV, _lV, _sV, _sVt, _bVl], + [2, 2, 1, 1, 1, 1, 1, 1, 0, 21], +]; +export var SimpleStructure: StaticStructureSchema = [3, n1, _SS, 0, [_v], [0]]; +export var SparseNullsOperationInputOutput: StaticStructureSchema = [ + 3, + n1, + _SNOIO, + 0, + [_sSL, _sSMp], + [ + [() => SparseStringList, 0], + [() => SparseStringMap, 0], + ], +]; +export var StructureListMember: StaticStructureSchema = [3, n1, _SLM, 0, [_a, _b_], [0, 0]]; +export var GreetingStruct: StaticStructureSchema = [3, n2, _GS, 0, [_h], [0]]; export var RpcV2ProtocolServiceException = error(_sC, "RpcV2ProtocolServiceException", 0, [], [], null); TypeRegistry.for(_sC).registerError(RpcV2ProtocolServiceException, __RpcV2ProtocolServiceException); + +export var ValidationExceptionFieldList: StaticListSchema = [1, n0, _VEFL, 0, () => ValidationExceptionField]; +export var StructureList: StaticListSchema = [1, n1, _SL, 0, () => StructureListMember]; +export var TestStringList = 64 | 0; + +export var BlobList = 64 | 21; + +export var BooleanList = 64 | 2; + +export var FooEnumList = 64 | 0; + +export var IntegerEnumList = 64 | 1; + +export var IntegerList = 64 | 1; + +export var NestedStringList: StaticListSchema = [1, n2, _NSL, 0, 64 | 0]; +export var SparseStringList: StaticListSchema = [ + 1, + n2, + _SSL, + { + [_s]: 1, + }, + 0, +]; +export var StringList = 64 | 0; + +export var StringSet = 64 | 0; + +export var TimestampList = 64 | 4; + +export var DenseBooleanMap = 128 | 2; + +export var DenseNumberMap = 128 | 1; + +export var DenseSetMap: StaticMapSchema = [2, n1, _DSM, 0, 0, 64 | 0]; +export var DenseStringMap = 128 | 0; + +export var DenseStructMap: StaticMapSchema = [2, n1, _DSMe, 0, 0, () => GreetingStruct]; +export var SparseBooleanMap: StaticMapSchema = [ + 2, + n1, + _SBM, + { + [_s]: 1, + }, + 0, + 2, +]; +export var SparseNumberMap: StaticMapSchema = [ + 2, + n1, + _SNM, + { + [_s]: 1, + }, + 0, + 1, +]; +export var SparseSetMap: StaticMapSchema = [ + 2, + n1, + _SSM, + { + [_s]: 1, + }, + 0, + 64 | 0, +]; +export var SparseStructMap: StaticMapSchema = [ + 2, + n1, + _SSMp, + { + [_s]: 1, + }, + 0, + () => GreetingStruct, +]; +export var TestStringMap = 128 | 0; + +export var SparseStringMap: StaticMapSchema = [ + 2, + n2, + _SSMpa, + { + [_s]: 1, + }, + 0, + 0, +]; +export var EmptyInputOutput: StaticOperationSchema = [9, n1, _EIO, 0, () => EmptyStructure, () => EmptyStructure]; +export var Float16: StaticOperationSchema = [9, n1, _Fl, 0, () => Unit, () => Float16Output]; +export var FractionalSeconds: StaticOperationSchema = [9, n1, _FS, 0, () => Unit, () => FractionalSecondsOutput]; +export var GreetingWithErrors: StaticOperationSchema = [9, n1, _GWE, 2, () => Unit, () => GreetingWithErrorsOutput]; +export var NoInputOutput: StaticOperationSchema = [9, n1, _NIO, 0, () => Unit, () => Unit]; +export var OperationWithDefaults: StaticOperationSchema = [ + 9, + n1, + _OWD, + 0, + () => OperationWithDefaultsInput, + () => OperationWithDefaultsOutput, +]; +export var OptionalInputOutput: StaticOperationSchema = [9, n1, _OIO, 0, () => SimpleStructure, () => SimpleStructure]; +export var RecursiveShapes: StaticOperationSchema = [ + 9, + n1, + _RS, + 0, + () => RecursiveShapesInputOutput, + () => RecursiveShapesInputOutput, +]; +export var RpcV2CborDenseMaps: StaticOperationSchema = [ + 9, + n1, + _RVCDM, + 0, + () => RpcV2CborDenseMapsInputOutput, + () => RpcV2CborDenseMapsInputOutput, +]; +export var RpcV2CborLists: StaticOperationSchema = [ + 9, + n1, + _RVCL, + 2, + () => RpcV2CborListInputOutput, + () => RpcV2CborListInputOutput, +]; +export var RpcV2CborSparseMaps: StaticOperationSchema = [ + 9, + n1, + _RVCSM, + 0, + () => RpcV2CborSparseMapsInputOutput, + () => RpcV2CborSparseMapsInputOutput, +]; +export var SimpleScalarProperties: StaticOperationSchema = [ + 9, + n1, + _SSP, + 0, + () => SimpleScalarStructure, + () => SimpleScalarStructure, +]; +export var SparseNullsOperation: StaticOperationSchema = [ + 9, + n1, + _SNO, + 0, + () => SparseNullsOperationInputOutput, + () => SparseNullsOperationInputOutput, +]; diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_1_Rpc.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_1_Rpc.ts deleted file mode 100644 index d392f856fb8..00000000000 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_1_Rpc.ts +++ /dev/null @@ -1,454 +0,0 @@ -// smithy-typescript generated code -import { - ComplexError as __ComplexError, - InvalidGreeting as __InvalidGreeting, - ValidationException as __ValidationException, -} from "../models/index"; -import { - _CE, - _CNED, - _COD, - _D, - _DSM, - _DSMe, - _F, - _GS, - _GWE, - _GWEO, - _IG, - _M, - _N, - _NSL, - _OIO, - _OWD, - _OWDI, - _OWDO, - _RS, - _RSIO, - _RSION, - _RSIONe, - _RVCDM, - _RVCDMIO, - _RVCL, - _RVCLIO, - _RVCSM, - _RVCSMIO, - _SBM, - _SL, - _SLM, - _SNM, - _SNO, - _SNOIO, - _SS, - _SSL, - _SSM, - _SSMp, - _SSMpa, - _SSP, - _SSS, - _TL, - _VE, - _VEF, - _VEFL, - _a, - _b, - _bL, - _bLl, - _bV, - _bVl, - _b_, - _c, - _cOD, - _dB, - _dBM, - _dBe, - _dBef, - _dD, - _dE, - _dF, - _dI, - _dIE, - _dL, - _dLe, - _dM, - _dNM, - _dS, - _dSM, - _dSMe, - _dSMen, - _dSe, - _dT, - _dV, - _de, - _e, - _eB, - _eL, - _eS, - _f, - _fB, - _fBV, - _fL, - _fV, - _g, - _h, - _iEL, - _iL, - _iV, - _lV, - _m, - _me, - _n, - _nSL, - _oTLD, - _p, - _rM, - _s, - _sBM, - _sL, - _sLt, - _sNM, - _sS, - _sSL, - _sSM, - _sSMp, - _sSMpa, - _sV, - _sVt, - _tBV, - _tL, - _tLD, - _v, - _zB, - _zD, - _zF, - _zI, - _zL, - _zS, - n0, - n1, - n2, -} from "./schemas_0"; -import { TypeRegistry, error, list, map, op, struct } from "@smithy/core/schema"; - -/* eslint no-var: 0 */ - -export var Unit = "unit" as const; - -export var ValidationException = error( - n0, - _VE, - { - [_e]: _c, - }, - [_m, _fL], - [0, () => ValidationExceptionFieldList], - null -); -TypeRegistry.for(n0).registerError(ValidationException, __ValidationException); - -export var ValidationExceptionField = struct(n0, _VEF, 0, [_p, _m], [0, 0]); -export var ClientOptionalDefaults = struct(n1, _COD, 0, [_me], [1]); -export var ComplexError = error( - n1, - _CE, - { - [_e]: _c, - }, - [_TL, _N], - [0, () => ComplexNestedErrorData], - null -); -TypeRegistry.for(n1).registerError(ComplexError, __ComplexError); - -export var ComplexNestedErrorData = struct(n1, _CNED, 0, [_F], [0]); -export var Defaults = struct( - n1, - _D, - 0, - [ - _dS, - _dB, - _dL, - _dT, - _dBe, - _dBef, - _dSe, - _dI, - _dLe, - _dF, - _dD, - _dM, - _dE, - _dIE, - _eS, - _fB, - _eB, - _zB, - _zS, - _zI, - _zL, - _zF, - _zD, - ], - [0, 2, 64 | 0, 4, 21, 1, 1, 1, 1, 1, 1, 128 | 0, 0, 1, 0, 2, 21, 1, 1, 1, 1, 1, 1] -); -export var GreetingWithErrorsOutput = struct(n1, _GWEO, 0, [_g], [0]); -export var InvalidGreeting = error( - n1, - _IG, - { - [_e]: _c, - }, - [_M], - [0], - null -); -TypeRegistry.for(n1).registerError(InvalidGreeting, __InvalidGreeting); - -export var OperationWithDefaultsInput = struct( - n1, - _OWDI, - 0, - [_de, _cOD, _tLD, _oTLD], - [() => Defaults, () => ClientOptionalDefaults, 0, 1] -); -export var OperationWithDefaultsOutput = struct( - n1, - _OWDO, - 0, - [ - _dS, - _dB, - _dL, - _dT, - _dBe, - _dBef, - _dSe, - _dI, - _dLe, - _dF, - _dD, - _dM, - _dE, - _dIE, - _eS, - _fB, - _eB, - _zB, - _zS, - _zI, - _zL, - _zF, - _zD, - ], - [0, 2, 64 | 0, 4, 21, 1, 1, 1, 1, 1, 1, 128 | 0, 0, 1, 0, 2, 21, 1, 1, 1, 1, 1, 1] -); -export var RecursiveShapesInputOutput = struct(n1, _RSIO, 0, [_n], [() => RecursiveShapesInputOutputNested1]); -export var RecursiveShapesInputOutputNested1 = struct( - n1, - _RSION, - 0, - [_f, _n], - [0, () => RecursiveShapesInputOutputNested2] -); -export var RecursiveShapesInputOutputNested2 = struct( - n1, - _RSIONe, - 0, - [_b, _rM], - [0, () => RecursiveShapesInputOutputNested1] -); -export var RpcV2CborDenseMapsInputOutput = struct( - n1, - _RVCDMIO, - 0, - [_dSM, _dNM, _dBM, _dSMe, _dSMen], - [() => DenseStructMap, 128 | 1, 128 | 2, 128 | 0, map(n1, _DSM, 0, 0, 64 | 0)] -); -export var RpcV2CborListInputOutput = struct( - n1, - _RVCLIO, - 0, - [_sL, _sS, _iL, _bL, _tL, _eL, _iEL, _nSL, _sLt, _bLl], - [64 | 0, 64 | 0, 64 | 1, 64 | 2, 64 | 4, 64 | 0, 64 | 1, list(n2, _NSL, 0, 64 | 0), () => StructureList, 64 | 21] -); -export var RpcV2CborSparseMapsInputOutput = struct( - n1, - _RVCSMIO, - 0, - [_sSM, _sNM, _sBM, _sSMp, _sSMpa], - [ - [() => SparseStructMap, 0], - [() => SparseNumberMap, 0], - [() => SparseBooleanMap, 0], - [() => SparseStringMap, 0], - [() => SparseSetMap, 0], - ] -); -export var SimpleScalarStructure = struct( - n1, - _SSS, - 0, - [_tBV, _fBV, _bV, _dV, _fV, _iV, _lV, _sV, _sVt, _bVl], - [2, 2, 1, 1, 1, 1, 1, 1, 0, 21] -); -export var SimpleStructure = struct(n1, _SS, 0, [_v], [0]); -export var SparseNullsOperationInputOutput = struct( - n1, - _SNOIO, - 0, - [_sSL, _sSMp], - [ - [() => SparseStringList, 0], - [() => SparseStringMap, 0], - ] -); -export var StructureListMember = struct(n1, _SLM, 0, [_a, _b_], [0, 0]); -export var GreetingStruct = struct(n2, _GS, 0, [_h], [0]); -export var ValidationExceptionFieldList = list(n0, _VEFL, 0, () => ValidationExceptionField); -export var StructureList = list(n1, _SL, 0, () => StructureListMember); -export var TestStringList = 64 | 0; - -export var BlobList = 64 | 21; - -export var BooleanList = 64 | 2; - -export var FooEnumList = 64 | 0; - -export var IntegerEnumList = 64 | 1; - -export var IntegerList = 64 | 1; - -export var NestedStringList = list(n2, _NSL, 0, 64 | 0); -export var SparseStringList = list( - n2, - _SSL, - { - [_s]: 1, - }, - 0 -); -export var StringList = 64 | 0; - -export var StringSet = 64 | 0; - -export var TimestampList = 64 | 4; - -export var DenseBooleanMap = 128 | 2; - -export var DenseNumberMap = 128 | 1; - -export var DenseSetMap = map(n1, _DSM, 0, 0, 64 | 0); -export var DenseStringMap = 128 | 0; - -export var DenseStructMap = map(n1, _DSMe, 0, 0, () => GreetingStruct); -export var SparseBooleanMap = map( - n1, - _SBM, - { - [_s]: 1, - }, - 0, - 2 -); -export var SparseNumberMap = map( - n1, - _SNM, - { - [_s]: 1, - }, - 0, - 1 -); -export var SparseSetMap = map( - n1, - _SSM, - { - [_s]: 1, - }, - 0, - 64 | 0 -); -export var SparseStructMap = map( - n1, - _SSMp, - { - [_s]: 1, - }, - 0, - () => GreetingStruct -); -export var TestStringMap = 128 | 0; - -export var SparseStringMap = map( - n2, - _SSMpa, - { - [_s]: 1, - }, - 0, - 0 -); -export var GreetingWithErrors = op( - n1, - _GWE, - 2, - () => Unit, - () => GreetingWithErrorsOutput -); -export var OperationWithDefaults = op( - n1, - _OWD, - 0, - () => OperationWithDefaultsInput, - () => OperationWithDefaultsOutput -); -export var OptionalInputOutput = op( - n1, - _OIO, - 0, - () => SimpleStructure, - () => SimpleStructure -); -export var RecursiveShapes = op( - n1, - _RS, - 0, - () => RecursiveShapesInputOutput, - () => RecursiveShapesInputOutput -); -export var RpcV2CborDenseMaps = op( - n1, - _RVCDM, - 0, - () => RpcV2CborDenseMapsInputOutput, - () => RpcV2CborDenseMapsInputOutput -); -export var RpcV2CborLists = op( - n1, - _RVCL, - 2, - () => RpcV2CborListInputOutput, - () => RpcV2CborListInputOutput -); -export var RpcV2CborSparseMaps = op( - n1, - _RVCSM, - 0, - () => RpcV2CborSparseMapsInputOutput, - () => RpcV2CborSparseMapsInputOutput -); -export var SimpleScalarProperties = op( - n1, - _SSP, - 0, - () => SimpleScalarStructure, - () => SimpleScalarStructure -); -export var SparseNullsOperation = op( - n1, - _SNO, - 0, - () => SparseNullsOperationInputOutput, - () => SparseNullsOperationInputOutput -); diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_2_EmptyInputOutput.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_2_EmptyInputOutput.ts deleted file mode 100644 index 6f08d2ec392..00000000000 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_2_EmptyInputOutput.ts +++ /dev/null @@ -1,14 +0,0 @@ -// smithy-typescript generated code -import { _EIO, _ES, n1 } from "./schemas_0"; -import { op, struct } from "@smithy/core/schema"; - -/* eslint no-var: 0 */ - -export var EmptyStructure = struct(n1, _ES, 0, [], []); -export var EmptyInputOutput = op( - n1, - _EIO, - 0, - () => EmptyStructure, - () => EmptyStructure -); diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_3_FractionalSeconds.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_3_FractionalSeconds.ts deleted file mode 100644 index 7f9a11ccc86..00000000000 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_3_FractionalSeconds.ts +++ /dev/null @@ -1,15 +0,0 @@ -// smithy-typescript generated code -import { _FS, _FSO, _d, n1 } from "./schemas_0"; -import { Unit } from "./schemas_1_Rpc"; -import { op, struct } from "@smithy/core/schema"; - -/* eslint no-var: 0 */ - -export var FractionalSecondsOutput = struct(n1, _FSO, 0, [_d], [5]); -export var FractionalSeconds = op( - n1, - _FS, - 0, - () => Unit, - () => FractionalSecondsOutput -); diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_4_.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_4_.ts deleted file mode 100644 index e44a5e80c78..00000000000 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_4_.ts +++ /dev/null @@ -1,15 +0,0 @@ -// smithy-typescript generated code -import { _FO, _Fl, _v, n1 } from "./schemas_0"; -import { Unit } from "./schemas_1_Rpc"; -import { op, struct } from "@smithy/core/schema"; - -/* eslint no-var: 0 */ - -export var Float16Output = struct(n1, _FO, 0, [_v], [1]); -export var Float16 = op( - n1, - _Fl, - 0, - () => Unit, - () => Float16Output -); diff --git a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_5_NoInputOutput.ts b/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_5_NoInputOutput.ts deleted file mode 100644 index d31aec32b48..00000000000 --- a/private/smithy-rpcv2-cbor-schema/src/schemas/schemas_5_NoInputOutput.ts +++ /dev/null @@ -1,14 +0,0 @@ -// smithy-typescript generated code -import { _NIO, n1 } from "./schemas_0"; -import { Unit } from "./schemas_1_Rpc"; -import { op } from "@smithy/core/schema"; - -/* eslint no-var: 0 */ - -export var NoInputOutput = op( - n1, - _NIO, - 0, - () => Unit, - () => Unit -); diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/SchemaGenerator.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/SchemaGenerator.java index cfc1dd1d89b..6329bb04c0e 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/SchemaGenerator.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/SchemaGenerator.java @@ -275,16 +275,16 @@ private String getShapeVariableName(Shape shape) { private void writeSimpleSchema(Shape shape) { TypeScriptWriter writer = getWriter(shape.getId()); if (elision.traits.hasSchemaTraits(shape)) { - writer.addImportSubmodule("sim", "sim", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticSimpleSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.write(""" - export var $L = sim($L, $L, $L,""", + export var $L: StaticSimpleSchema = [0, $L, $L, $L,""", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), resolveSimpleSchema(shape, shape) ); writeTraits(shape); - writer.write(");"); + writer.write("];"); } } @@ -294,15 +294,15 @@ private void writeStructureSchema(StructureShape shape) { String symbolName = reservedWords.escape(shape.getId().getName()); if (shape.hasTrait(ErrorTrait.class)) { String exceptionCtorSymbolName = "__" + symbolName; - writer.addImportSubmodule("error", "error", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticErrorSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.addRelativeImport( symbolName, exceptionCtorSymbolName, Paths.get("..", "models", "index") ); writer.openBlock(""" - export var $L = error($L, $L,""", - ", null);", + export var $L: StaticErrorSchema = [-3, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -317,10 +317,10 @@ private void writeStructureSchema(StructureShape shape) { exceptionCtorSymbolName ); } else { - writer.addImportSubmodule("struct", "struct", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticStructureSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.openBlock(""" - export var $L = struct($L, $L,""", - ");", + export var $L: StaticStructureSchema = [3, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -368,10 +368,10 @@ private void writeBaseError() { private void writeUnionSchema(UnionShape shape) { TypeScriptWriter writer = getWriter(shape.getId()); checkedWriteSchema(shape, () -> { - writer.addImportSubmodule("struct", "uni", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticStructureSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.openBlock(""" - export var $L = uni($L, $L,""", - ");", + export var $L: StaticStructureSchema = [3, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -416,10 +416,10 @@ private void doWithMembers(Shape shape) { private void writeListSchema(CollectionShape shape) { TypeScriptWriter writer = getWriter(shape.getId()); checkedWriteSchema(shape, () -> { - writer.addImportSubmodule("list", "list", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticListSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.openBlock(""" - export var $L = list($L, $L,""", - ");", + export var $L: StaticListSchema = [1, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -434,10 +434,10 @@ private void writeListSchema(CollectionShape shape) { private void writeMapSchema(MapShape shape) { TypeScriptWriter writer = getWriter(shape.getId()); checkedWriteSchema(shape, () -> { - writer.addImportSubmodule("map", "map", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticMapSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.openBlock(""" - export var $L = map($L, $L,""", - ");", + export var $L: StaticMapSchema = [2, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -503,10 +503,10 @@ private void doWithMember(Shape shape, MemberShape keyShape, MemberShape memberS private void writeOperationSchema(OperationShape shape) { TypeScriptWriter writer = getWriter(shape.getId()); - writer.addImportSubmodule("op", "op", TypeScriptDependency.SMITHY_CORE, "/schema"); + writer.addImport("StaticOperationSchema", null, TypeScriptDependency.SMITHY_TYPES); writer.openBlock(""" - export var $L = op($L, $L,""", - ");", + export var $L: StaticOperationSchema = [9, $L, $L,""", + "];", getShapeVariableName(shape), checkImportString(shape, shape.getId().getNamespace(), "n"), checkImportString(shape, shape.getId().getName()), @@ -669,21 +669,28 @@ private String resolveSimpleSchema(Shape context, Shape shape) { */ private String resolveSimpleSchemaNestedContainer(Shape context, Shape shape, TypeScriptWriter writer) { Shape contained; - String factory; + String staticTypePrefix; String sentinel; - String keyMemberSchema; + String keySchema = ""; + String valueSchema; + String as; switch (shape.getType()) { case LIST -> { contained = shape.asListShape().get().getMember(); - factory = "list"; - keyMemberSchema = ""; + staticTypePrefix = "([1, "; + valueSchema = ""; sentinel = "64"; + writer.addImport("StaticListSchema", null, TypeScriptDependency.SMITHY_TYPES); + as = " as StaticListSchema)"; } case MAP -> { contained = shape.asMapShape().get().getValue(); - factory = "map"; - keyMemberSchema = this.resolveSimpleSchema(context, shape.asMapShape().get().getKey()) + ", "; + staticTypePrefix = "([2, "; + keySchema = this.resolveSimpleSchema(context, shape.asMapShape().get().getKey()) + ", "; + valueSchema = this.resolveSimpleSchema(context, shape.asMapShape().get().getValue()) + ", "; sentinel = "128"; + writer.addImport("StaticMapSchema", null, TypeScriptDependency.SMITHY_TYPES); + as = " as StaticMapSchema)"; } default -> { throw new IllegalArgumentException( @@ -696,19 +703,18 @@ private String resolveSimpleSchemaNestedContainer(Shape context, Shape shape, Ty } if (contained.isListShape()) { - writer.addImportSubmodule(factory, factory, TypeScriptDependency.SMITHY_CORE, "/schema"); String schemaVarName = checkImportString(context, shape.getId().getName()); - return factory + "(" + return staticTypePrefix + checkImportString(context, shape.getId().getNamespace(), "n") + ", " + schemaVarName + ", 0, " - + keyMemberSchema - + this.resolveSimpleSchema(context, contained) + ")"; + + valueSchema + + this.resolveSimpleSchema(context, contained) + "]" + as; } else if (contained.isMapShape()) { - writer.addImportSubmodule(factory, factory, TypeScriptDependency.SMITHY_CORE, "/schema"); String schemaVarName = checkImportString(context, shape.getId().getName()); - return factory + "(" + return staticTypePrefix + checkImportString(context, shape.getId().getNamespace(), "n") + ", " + schemaVarName + ", 0, " - + keyMemberSchema - + this.resolveSimpleSchema(context, contained) + ")"; + + keySchema + + valueSchema + + this.resolveSimpleSchema(context, contained) + "]" + as; } else { return sentinel + "|" + this.resolveSimpleSchema(context, contained); } diff --git a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/ShapeGroupingIndex.java b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/ShapeGroupingIndex.java index ba43550fcd0..98d92bee201 100644 --- a/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/ShapeGroupingIndex.java +++ b/smithy-typescript-codegen/src/main/java/software/amazon/smithy/typescript/codegen/schema/ShapeGroupingIndex.java @@ -85,11 +85,20 @@ public static ShapeGroupingIndex of(Model model) { * @return the group name (filename) of the schema group for the given shape. */ public String getGroup(ShapeId id) { + /* + As of the introduction of static schemas, we don't need to bucket schemas into + different files anymore. + todo: remove usage of this class. + */ + return getBaseGroup(); + + /* if (!shapeToOperationalGroup.containsKey(id)) { return getBaseGroup(); } TreeSet operations = shapeToOperationalGroup.get(id); return hashOperationSet(operations); + */ } /**