public synthesizeContent()

in packages/type-safe-api/src/project/model/smithy/components/smithy-aws-pdk-async-prelude.ts [44:157]


  public synthesizeContent(_: IResolver): string | undefined {
    return `// ${this.marker}

$version: "2"

metadata validators = [

    {
        id: "MissingAsyncTrait"
        name: "EmitEachSelector"
        message: "Operation is missing @async trait"
        configuration: {
            selector: """
                operation :not([trait|${this.options.serviceNamespace}#async])
            """
        }
    }

    {
        id: "MissingWebSocketProtocolTrait"
        name: "EmitEachSelector"
        message: "Service is missing @websocketJson trait"
        configuration: {
            selector: """
                service :not([trait|${
                  this.options.serviceNamespace
                }#websocketJson])
            """
        }
    }

    {
        id: "OperationMayNotHaveOutput"
        name: "EmitEachSelector"
        message: "Async operations must have no output"
        configuration: {
            selector: """
                operation -[output]->
            """
        }
    }

    {
        id: "OperationMustHaveInput"
        name: "EmitEachSelector"
        message: "Async operations must define an input"
        configuration: {
            selector: """
                operation :not(-[input]->)
            """
        }
    }

    {
        id: "HandlerTraitNotPermittedForServerToClient"
        name: "EmitEachSelector"
        message: "The @handler trait cannot be applied to an @async operation with direction server_to_client"
        configuration: {
            selector: """
              operation
              [@trait|${
                this.options.serviceNamespace
              }#async: @{direction} = server_to_client]
              [trait|${this.options.serviceNamespace}#handler]
            """
        }
    }

    ${SmithyAwsPdkPrelude.buildHandlerTraitValidators(
      this.options.serviceNamespace,
      "connectHandler",
      this.options.handlerLanguages
    )}
    ${SmithyAwsPdkPrelude.buildHandlerTraitValidators(
      this.options.serviceNamespace,
      "disconnectHandler",
      this.options.handlerLanguages
    )}
]

namespace ${this.options.serviceNamespace}

/// Add this trait to an asynchronous service
@trait(selector: "service")
structure websocketJson {}

enum AsyncDirection {
    CLIENT_TO_SERVER = "client_to_server"
    SERVER_TO_CLIENT = "server_to_client"
    BIDIRECTIONAL = "bidirectional"
}

/// Add this trait to all asynchronous operations
@trait(selector: "operation")
structure async {
    /// The direction this operation will be used in, used to inform the generated client and server sdks.
    @required
    direction: AsyncDirection
}

@trait(selector: "service")
structure connectHandler {
  @required
  language: String
}

@trait(selector: "service")
structure disconnectHandler {
  @required
  language: String
}

`;
  }