@cdk8s/awscdk-resolver 0.0.347 → 0.0.349
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/.jsii +3 -3
- package/lib/resolve.js +1 -1
- package/node_modules/@aws-sdk/client-cloudformation/package.json +6 -6
- package/node_modules/@aws-sdk/client-sso/package.json +5 -5
- package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +81 -48
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +12 -8
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +12 -8
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +14 -10
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +12 -15
- package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +3 -3
- package/node_modules/@aws-sdk/core/package.json +1 -1
- package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
- package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
- package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
- package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
- package/node_modules/@aws-sdk/middleware-logger/dist-types/loggerMiddleware.d.ts +1 -1
- package/node_modules/@aws-sdk/middleware-logger/package.json +1 -1
- package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
- package/node_modules/@aws-sdk/nested-clients/package.json +5 -5
- package/node_modules/@aws-sdk/token-providers/package.json +3 -3
- package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +44 -15
- package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +261 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +129 -39
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +25 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +36 -15
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +200 -0
- package/node_modules/@smithy/core/dist-es/submodules/event-streams/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +11 -26
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +36 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +36 -10
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +17 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +6 -2
- package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/parseCborBody.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/event-streams/EventStreamSerde.d.ts +60 -0
- package/node_modules/@smithy/core/dist-types/submodules/event-streams/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +39 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/RpcProtocol.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +5 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/EventStreamSerde.d.ts +60 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/event-streams/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +39 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +1 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +1 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +10 -0
- package/node_modules/@smithy/core/event-streams.d.ts +7 -0
- package/node_modules/@smithy/core/event-streams.js +6 -0
- package/node_modules/@smithy/core/package.json +11 -1
- package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
- package/node_modules/@smithy/middleware-retry/package.json +4 -4
- package/node_modules/@smithy/smithy-client/dist-cjs/index.js +43 -6
- package/node_modules/@smithy/smithy-client/dist-cjs/schemaLogFilter.js +1 -0
- package/node_modules/@smithy/smithy-client/dist-es/command.js +7 -4
- package/node_modules/@smithy/smithy-client/dist-es/schemaLogFilter.js +34 -0
- package/node_modules/@smithy/smithy-client/dist-types/schemaLogFilter.d.ts +9 -0
- package/node_modules/@smithy/smithy-client/dist-types/ts3.4/schemaLogFilter.d.ts +9 -0
- package/node_modules/@smithy/smithy-client/package.json +3 -3
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -2
- package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
- package/package.json +5 -5
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/credential-provider-node",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "AWS credential provider that sources credentials from a Node.JS environment. ",
|
5
5
|
"engines": {
|
6
6
|
"node": ">=18.0.0"
|
@@ -29,12 +29,12 @@
|
|
29
29
|
},
|
30
30
|
"license": "Apache-2.0",
|
31
31
|
"dependencies": {
|
32
|
-
"@aws-sdk/credential-provider-env": "3.
|
33
|
-
"@aws-sdk/credential-provider-http": "3.
|
34
|
-
"@aws-sdk/credential-provider-ini": "3.
|
35
|
-
"@aws-sdk/credential-provider-process": "3.
|
36
|
-
"@aws-sdk/credential-provider-sso": "3.
|
37
|
-
"@aws-sdk/credential-provider-web-identity": "3.
|
32
|
+
"@aws-sdk/credential-provider-env": "3.876.0",
|
33
|
+
"@aws-sdk/credential-provider-http": "3.876.0",
|
34
|
+
"@aws-sdk/credential-provider-ini": "3.876.0",
|
35
|
+
"@aws-sdk/credential-provider-process": "3.876.0",
|
36
|
+
"@aws-sdk/credential-provider-sso": "3.876.0",
|
37
|
+
"@aws-sdk/credential-provider-web-identity": "3.876.0",
|
38
38
|
"@aws-sdk/types": "3.862.0",
|
39
39
|
"@smithy/credential-provider-imds": "^4.0.7",
|
40
40
|
"@smithy/property-provider": "^4.0.5",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/credential-provider-process",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "AWS credential provider that sources credential_process from ~/.aws/credentials and ~/.aws/config",
|
5
5
|
"main": "./dist-cjs/index.js",
|
6
6
|
"module": "./dist-es/index.js",
|
@@ -25,7 +25,7 @@
|
|
25
25
|
},
|
26
26
|
"license": "Apache-2.0",
|
27
27
|
"dependencies": {
|
28
|
-
"@aws-sdk/core": "3.
|
28
|
+
"@aws-sdk/core": "3.876.0",
|
29
29
|
"@aws-sdk/types": "3.862.0",
|
30
30
|
"@smithy/property-provider": "^4.0.5",
|
31
31
|
"@smithy/shared-ini-file-loader": "^4.0.5",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/credential-provider-sso",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "AWS credential provider that exchanges a resolved SSO login token file for temporary AWS credentials",
|
5
5
|
"main": "./dist-cjs/index.js",
|
6
6
|
"module": "./dist-es/index.js",
|
@@ -25,9 +25,9 @@
|
|
25
25
|
},
|
26
26
|
"license": "Apache-2.0",
|
27
27
|
"dependencies": {
|
28
|
-
"@aws-sdk/client-sso": "3.
|
29
|
-
"@aws-sdk/core": "3.
|
30
|
-
"@aws-sdk/token-providers": "3.
|
28
|
+
"@aws-sdk/client-sso": "3.876.0",
|
29
|
+
"@aws-sdk/core": "3.876.0",
|
30
|
+
"@aws-sdk/token-providers": "3.876.0",
|
31
31
|
"@aws-sdk/types": "3.862.0",
|
32
32
|
"@smithy/property-provider": "^4.0.5",
|
33
33
|
"@smithy/shared-ini-file-loader": "^4.0.5",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/credential-provider-web-identity",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "AWS credential provider that calls STS assumeRole for temporary AWS credentials",
|
5
5
|
"main": "./dist-cjs/index.js",
|
6
6
|
"module": "./dist-es/index.js",
|
@@ -33,8 +33,8 @@
|
|
33
33
|
},
|
34
34
|
"license": "Apache-2.0",
|
35
35
|
"dependencies": {
|
36
|
-
"@aws-sdk/core": "3.
|
37
|
-
"@aws-sdk/nested-clients": "3.
|
36
|
+
"@aws-sdk/core": "3.876.0",
|
37
|
+
"@aws-sdk/nested-clients": "3.876.0",
|
38
38
|
"@aws-sdk/types": "3.862.0",
|
39
39
|
"@smithy/property-provider": "^4.0.5",
|
40
40
|
"@smithy/types": "^4.3.2",
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AbsoluteLocation, HandlerExecutionContext, InitializeHandler, InitializeHandlerOptions, MetadataBearer, Pluggable } from "@smithy/types";
|
1
|
+
import type { AbsoluteLocation, HandlerExecutionContext, InitializeHandler, InitializeHandlerOptions, MetadataBearer, Pluggable } from "@smithy/types";
|
2
2
|
export declare const loggerMiddleware: () => <Output extends MetadataBearer = MetadataBearer>(next: InitializeHandler<any, Output>, context: HandlerExecutionContext) => InitializeHandler<any, Output>;
|
3
3
|
export declare const loggerMiddlewareOptions: InitializeHandlerOptions & AbsoluteLocation;
|
4
4
|
export declare const getLoggerPlugin: (options: any) => Pluggable<any, any>;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/middleware-user-agent",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"scripts": {
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline middleware-user-agent",
|
@@ -24,7 +24,7 @@
|
|
24
24
|
},
|
25
25
|
"license": "Apache-2.0",
|
26
26
|
"dependencies": {
|
27
|
-
"@aws-sdk/core": "3.
|
27
|
+
"@aws-sdk/core": "3.876.0",
|
28
28
|
"@aws-sdk/types": "3.862.0",
|
29
29
|
"@aws-sdk/util-endpoints": "3.873.0",
|
30
30
|
"@smithy/core": "^3.8.0",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/nested-clients",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "Nested clients for AWS SDK packages.",
|
5
5
|
"main": "./dist-cjs/index.js",
|
6
6
|
"module": "./dist-es/index.js",
|
@@ -28,16 +28,16 @@
|
|
28
28
|
"dependencies": {
|
29
29
|
"@aws-crypto/sha256-browser": "5.2.0",
|
30
30
|
"@aws-crypto/sha256-js": "5.2.0",
|
31
|
-
"@aws-sdk/core": "3.
|
31
|
+
"@aws-sdk/core": "3.876.0",
|
32
32
|
"@aws-sdk/middleware-host-header": "3.873.0",
|
33
|
-
"@aws-sdk/middleware-logger": "3.
|
33
|
+
"@aws-sdk/middleware-logger": "3.876.0",
|
34
34
|
"@aws-sdk/middleware-recursion-detection": "3.873.0",
|
35
|
-
"@aws-sdk/middleware-user-agent": "3.
|
35
|
+
"@aws-sdk/middleware-user-agent": "3.876.0",
|
36
36
|
"@aws-sdk/region-config-resolver": "3.873.0",
|
37
37
|
"@aws-sdk/types": "3.862.0",
|
38
38
|
"@aws-sdk/util-endpoints": "3.873.0",
|
39
39
|
"@aws-sdk/util-user-agent-browser": "3.873.0",
|
40
|
-
"@aws-sdk/util-user-agent-node": "3.
|
40
|
+
"@aws-sdk/util-user-agent-node": "3.876.0",
|
41
41
|
"@smithy/config-resolver": "^4.1.5",
|
42
42
|
"@smithy/core": "^3.8.0",
|
43
43
|
"@smithy/fetch-http-handler": "^5.1.1",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/token-providers",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"description": "A collection of token providers",
|
5
5
|
"main": "./dist-cjs/index.js",
|
6
6
|
"module": "./dist-es/index.js",
|
@@ -29,8 +29,8 @@
|
|
29
29
|
},
|
30
30
|
"license": "Apache-2.0",
|
31
31
|
"dependencies": {
|
32
|
-
"@aws-sdk/core": "3.
|
33
|
-
"@aws-sdk/nested-clients": "3.
|
32
|
+
"@aws-sdk/core": "3.876.0",
|
33
|
+
"@aws-sdk/nested-clients": "3.876.0",
|
34
34
|
"@aws-sdk/types": "3.862.0",
|
35
35
|
"@smithy/property-provider": "^4.0.5",
|
36
36
|
"@smithy/shared-ini-file-loader": "^4.0.5",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@aws-sdk/util-user-agent-node",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.876.0",
|
4
4
|
"scripts": {
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",
|
6
6
|
"build:cjs": "node ../../scripts/compilation/inline util-user-agent-node",
|
@@ -21,7 +21,7 @@
|
|
21
21
|
},
|
22
22
|
"license": "Apache-2.0",
|
23
23
|
"dependencies": {
|
24
|
-
"@aws-sdk/middleware-user-agent": "3.
|
24
|
+
"@aws-sdk/middleware-user-agent": "3.876.0",
|
25
25
|
"@aws-sdk/types": "3.862.0",
|
26
26
|
"@smithy/node-config-provider": "^4.1.4",
|
27
27
|
"@smithy/types": "^4.3.2",
|
@@ -895,6 +895,10 @@ var CborShapeDeserializer = class {
|
|
895
895
|
const data2 = cbor.deserialize(bytes);
|
896
896
|
return this.readValue(schema, data2);
|
897
897
|
}
|
898
|
+
/**
|
899
|
+
* Public because it's called by the protocol implementation to deserialize errors.
|
900
|
+
* @internal
|
901
|
+
*/
|
898
902
|
readValue(_schema, value) {
|
899
903
|
const ns = import_schema.NormalizedSchema.of(_schema);
|
900
904
|
if (ns.isTimestampSchema() && typeof value === "number") {
|
@@ -972,9 +976,9 @@ var SmithyRpcV2CborProtocol = class extends import_protocols2.RpcProtocol {
|
|
972
976
|
async serializeRequest(operationSchema, input, context) {
|
973
977
|
const request = await super.serializeRequest(operationSchema, input, context);
|
974
978
|
Object.assign(request.headers, {
|
975
|
-
"content-type":
|
979
|
+
"content-type": this.getDefaultContentType(),
|
976
980
|
"smithy-protocol": "rpc-v2-cbor",
|
977
|
-
accept:
|
981
|
+
accept: this.getDefaultContentType()
|
978
982
|
});
|
979
983
|
if ((0, import_schema2.deref)(operationSchema.input) === "unit") {
|
980
984
|
delete request.body;
|
@@ -1002,25 +1006,50 @@ var SmithyRpcV2CborProtocol = class extends import_protocols2.RpcProtocol {
|
|
1002
1006
|
return super.deserializeResponse(operationSchema, context, response);
|
1003
1007
|
}
|
1004
1008
|
async handleError(operationSchema, context, response, dataObject, metadata) {
|
1005
|
-
const
|
1009
|
+
const errorName = loadSmithyRpcV2CborErrorCode(response, dataObject) ?? "Unknown";
|
1006
1010
|
let namespace = this.options.defaultNamespace;
|
1007
|
-
if (
|
1008
|
-
[namespace] =
|
1011
|
+
if (errorName.includes("#")) {
|
1012
|
+
[namespace] = errorName.split("#");
|
1009
1013
|
}
|
1014
|
+
const errorMetadata = {
|
1015
|
+
$metadata: metadata,
|
1016
|
+
$response: response,
|
1017
|
+
$fault: response.statusCode <= 500 ? "client" : "server"
|
1018
|
+
};
|
1010
1019
|
const registry = import_schema2.TypeRegistry.for(namespace);
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1020
|
+
let errorSchema;
|
1021
|
+
try {
|
1022
|
+
errorSchema = registry.getSchema(errorName);
|
1023
|
+
} catch (e) {
|
1024
|
+
if (dataObject.Message) {
|
1025
|
+
dataObject.message = dataObject.Message;
|
1026
|
+
}
|
1027
|
+
const baseExceptionSchema = import_schema2.TypeRegistry.for("smithy.ts.sdk.synthetic." + namespace).getBaseException();
|
1028
|
+
if (baseExceptionSchema) {
|
1029
|
+
const ErrorCtor = baseExceptionSchema.ctor;
|
1030
|
+
throw Object.assign(new ErrorCtor({ name: errorName }), errorMetadata, dataObject);
|
1031
|
+
}
|
1032
|
+
throw Object.assign(new Error(errorName), errorMetadata, dataObject);
|
1014
1033
|
}
|
1034
|
+
const ns = import_schema2.NormalizedSchema.of(errorSchema);
|
1015
1035
|
const message = dataObject.message ?? dataObject.Message ?? "Unknown";
|
1016
1036
|
const exception = new errorSchema.ctor(message);
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1037
|
+
const output = {};
|
1038
|
+
for (const [name, member] of ns.structIterator()) {
|
1039
|
+
output[name] = this.deserializer.readValue(member, dataObject[name]);
|
1040
|
+
}
|
1041
|
+
throw Object.assign(
|
1042
|
+
exception,
|
1043
|
+
errorMetadata,
|
1044
|
+
{
|
1045
|
+
$fault: ns.getMergedTraits().error,
|
1046
|
+
message
|
1047
|
+
},
|
1048
|
+
output
|
1049
|
+
);
|
1050
|
+
}
|
1051
|
+
getDefaultContentType() {
|
1052
|
+
return "application/cbor";
|
1024
1053
|
}
|
1025
1054
|
};
|
1026
1055
|
// Annotate the CommonJS export names for ESM import in node:
|
@@ -0,0 +1,261 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
|
19
|
+
// src/submodules/event-streams/index.ts
|
20
|
+
var event_streams_exports = {};
|
21
|
+
__export(event_streams_exports, {
|
22
|
+
EventStreamSerde: () => EventStreamSerde
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(event_streams_exports);
|
25
|
+
|
26
|
+
// src/submodules/event-streams/EventStreamSerde.ts
|
27
|
+
var import_schema = require("@smithy/core/schema");
|
28
|
+
var import_util_utf8 = require("@smithy/util-utf8");
|
29
|
+
var EventStreamSerde = class {
|
30
|
+
/**
|
31
|
+
* Properties are injected by the HttpProtocol.
|
32
|
+
*/
|
33
|
+
constructor({
|
34
|
+
marshaller,
|
35
|
+
serializer,
|
36
|
+
deserializer,
|
37
|
+
serdeContext,
|
38
|
+
defaultContentType
|
39
|
+
}) {
|
40
|
+
this.marshaller = marshaller;
|
41
|
+
this.serializer = serializer;
|
42
|
+
this.deserializer = deserializer;
|
43
|
+
this.serdeContext = serdeContext;
|
44
|
+
this.defaultContentType = defaultContentType;
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* @param eventStream - the iterable provided by the caller.
|
48
|
+
* @param requestSchema - the schema of the event stream container (struct).
|
49
|
+
* @param [initialRequest] - only provided if the initial-request is part of the event stream (RPC).
|
50
|
+
*
|
51
|
+
* @returns a stream suitable for the HTTP body of a request.
|
52
|
+
*/
|
53
|
+
async serializeEventStream({
|
54
|
+
eventStream,
|
55
|
+
requestSchema,
|
56
|
+
initialRequest
|
57
|
+
}) {
|
58
|
+
const marshaller = this.marshaller;
|
59
|
+
const eventStreamMember = requestSchema.getEventStreamMember();
|
60
|
+
const unionSchema = requestSchema.getMemberSchema(eventStreamMember);
|
61
|
+
const memberSchemas = unionSchema.getMemberSchemas();
|
62
|
+
const serializer = this.serializer;
|
63
|
+
const defaultContentType = this.defaultContentType;
|
64
|
+
const initialRequestMarker = Symbol("initialRequestMarker");
|
65
|
+
const eventStreamIterable = {
|
66
|
+
async *[Symbol.asyncIterator]() {
|
67
|
+
if (initialRequest) {
|
68
|
+
const headers = {
|
69
|
+
":event-type": { type: "string", value: "initial-request" },
|
70
|
+
":message-type": { type: "string", value: "event" },
|
71
|
+
":content-type": { type: "string", value: defaultContentType }
|
72
|
+
};
|
73
|
+
serializer.write(requestSchema, initialRequest);
|
74
|
+
const body = serializer.flush();
|
75
|
+
yield {
|
76
|
+
[initialRequestMarker]: true,
|
77
|
+
headers,
|
78
|
+
body
|
79
|
+
};
|
80
|
+
}
|
81
|
+
for await (const page of eventStream) {
|
82
|
+
yield page;
|
83
|
+
}
|
84
|
+
}
|
85
|
+
};
|
86
|
+
return marshaller.serialize(eventStreamIterable, (event) => {
|
87
|
+
if (event[initialRequestMarker]) {
|
88
|
+
return {
|
89
|
+
headers: event.headers,
|
90
|
+
body: event.body
|
91
|
+
};
|
92
|
+
}
|
93
|
+
const unionMember = Object.keys(event).find((key) => {
|
94
|
+
return key !== "__type";
|
95
|
+
}) ?? "";
|
96
|
+
const { additionalHeaders, body, eventType, explicitPayloadContentType } = this.writeEventBody(
|
97
|
+
unionMember,
|
98
|
+
unionSchema,
|
99
|
+
event
|
100
|
+
);
|
101
|
+
const headers = {
|
102
|
+
":event-type": { type: "string", value: eventType },
|
103
|
+
":message-type": { type: "string", value: "event" },
|
104
|
+
":content-type": { type: "string", value: explicitPayloadContentType ?? defaultContentType },
|
105
|
+
...additionalHeaders
|
106
|
+
};
|
107
|
+
return {
|
108
|
+
headers,
|
109
|
+
body
|
110
|
+
};
|
111
|
+
});
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* @param response - http response from which to read the event stream.
|
115
|
+
* @param unionSchema - schema of the event stream container (struct).
|
116
|
+
* @param [initialResponseContainer] - provided and written to only if the initial response is part of the event stream (RPC).
|
117
|
+
*
|
118
|
+
* @returns the asyncIterable of the event stream for the end-user.
|
119
|
+
*/
|
120
|
+
async deserializeEventStream({
|
121
|
+
response,
|
122
|
+
responseSchema,
|
123
|
+
initialResponseContainer
|
124
|
+
}) {
|
125
|
+
const marshaller = this.marshaller;
|
126
|
+
const eventStreamMember = responseSchema.getEventStreamMember();
|
127
|
+
const unionSchema = responseSchema.getMemberSchema(eventStreamMember);
|
128
|
+
const memberSchemas = unionSchema.getMemberSchemas();
|
129
|
+
const initialResponseMarker = Symbol("initialResponseMarker");
|
130
|
+
const asyncIterable = marshaller.deserialize(response.body, async (event) => {
|
131
|
+
const unionMember = Object.keys(event).find((key) => {
|
132
|
+
return key !== "__type";
|
133
|
+
}) ?? "";
|
134
|
+
if (unionMember === "initial-response") {
|
135
|
+
const dataObject = await this.deserializer.read(responseSchema, event[unionMember].body);
|
136
|
+
delete dataObject[eventStreamMember];
|
137
|
+
return {
|
138
|
+
[initialResponseMarker]: true,
|
139
|
+
...dataObject
|
140
|
+
};
|
141
|
+
} else if (unionMember in memberSchemas) {
|
142
|
+
const eventStreamSchema = memberSchemas[unionMember];
|
143
|
+
return {
|
144
|
+
[unionMember]: await this.deserializer.read(eventStreamSchema, event[unionMember].body)
|
145
|
+
};
|
146
|
+
} else {
|
147
|
+
return {
|
148
|
+
$unknown: event
|
149
|
+
};
|
150
|
+
}
|
151
|
+
});
|
152
|
+
const asyncIterator = asyncIterable[Symbol.asyncIterator]();
|
153
|
+
const firstEvent = await asyncIterator.next();
|
154
|
+
if (firstEvent.done) {
|
155
|
+
return asyncIterable;
|
156
|
+
}
|
157
|
+
if (firstEvent.value?.[initialResponseMarker]) {
|
158
|
+
if (!responseSchema) {
|
159
|
+
throw new Error(
|
160
|
+
"@smithy::core/protocols - initial-response event encountered in event stream but no response schema given."
|
161
|
+
);
|
162
|
+
}
|
163
|
+
for (const [key, value] of Object.entries(firstEvent.value)) {
|
164
|
+
initialResponseContainer[key] = value;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return {
|
168
|
+
async *[Symbol.asyncIterator]() {
|
169
|
+
if (!firstEvent?.value?.[initialResponseMarker]) {
|
170
|
+
yield firstEvent.value;
|
171
|
+
}
|
172
|
+
while (true) {
|
173
|
+
const { done, value } = await asyncIterator.next();
|
174
|
+
if (done) {
|
175
|
+
break;
|
176
|
+
}
|
177
|
+
yield value;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
};
|
181
|
+
}
|
182
|
+
/**
|
183
|
+
* @param unionMember - member name within the structure that contains an event stream union.
|
184
|
+
* @param unionSchema - schema of the union.
|
185
|
+
* @param event
|
186
|
+
*
|
187
|
+
* @returns the event body (bytes) and event type (string).
|
188
|
+
*/
|
189
|
+
writeEventBody(unionMember, unionSchema, event) {
|
190
|
+
const serializer = this.serializer;
|
191
|
+
let eventType = unionMember;
|
192
|
+
let explicitPayloadMember = null;
|
193
|
+
let explicitPayloadContentType;
|
194
|
+
const isKnownSchema = unionSchema.hasMemberSchema(unionMember);
|
195
|
+
const additionalHeaders = {};
|
196
|
+
if (!isKnownSchema) {
|
197
|
+
const [type, value] = event[unionMember];
|
198
|
+
eventType = type;
|
199
|
+
serializer.write(import_schema.SCHEMA.DOCUMENT, value);
|
200
|
+
} else {
|
201
|
+
const eventSchema = unionSchema.getMemberSchema(unionMember);
|
202
|
+
if (eventSchema.isStructSchema()) {
|
203
|
+
for (const [memberName, memberSchema] of eventSchema.structIterator()) {
|
204
|
+
const { eventHeader, eventPayload } = memberSchema.getMergedTraits();
|
205
|
+
if (eventPayload) {
|
206
|
+
explicitPayloadMember = memberName;
|
207
|
+
break;
|
208
|
+
} else if (eventHeader) {
|
209
|
+
const value = event[unionMember][memberName];
|
210
|
+
let type = "binary";
|
211
|
+
if (memberSchema.isNumericSchema()) {
|
212
|
+
if ((-2) ** 31 <= value && value <= 2 ** 31 - 1) {
|
213
|
+
type = "integer";
|
214
|
+
} else {
|
215
|
+
type = "long";
|
216
|
+
}
|
217
|
+
} else if (memberSchema.isTimestampSchema()) {
|
218
|
+
type = "timestamp";
|
219
|
+
} else if (memberSchema.isStringSchema()) {
|
220
|
+
type = "string";
|
221
|
+
} else if (memberSchema.isBooleanSchema()) {
|
222
|
+
type = "boolean";
|
223
|
+
}
|
224
|
+
if (value != null) {
|
225
|
+
additionalHeaders[memberName] = {
|
226
|
+
type,
|
227
|
+
value
|
228
|
+
};
|
229
|
+
delete event[unionMember][memberName];
|
230
|
+
}
|
231
|
+
}
|
232
|
+
}
|
233
|
+
if (explicitPayloadMember !== null) {
|
234
|
+
const payloadSchema = eventSchema.getMemberSchema(explicitPayloadMember);
|
235
|
+
if (payloadSchema.isBlobSchema()) {
|
236
|
+
explicitPayloadContentType = "application/octet-stream";
|
237
|
+
} else if (payloadSchema.isStringSchema()) {
|
238
|
+
explicitPayloadContentType = "text/plain";
|
239
|
+
}
|
240
|
+
serializer.write(payloadSchema, event[unionMember][explicitPayloadMember]);
|
241
|
+
} else {
|
242
|
+
serializer.write(eventSchema, event[unionMember]);
|
243
|
+
}
|
244
|
+
} else {
|
245
|
+
throw new Error("@smithy/core/event-streams - non-struct member not supported in event stream union.");
|
246
|
+
}
|
247
|
+
}
|
248
|
+
const messageSerialization = serializer.flush();
|
249
|
+
const body = typeof messageSerialization === "string" ? (this.serdeContext?.utf8Decoder ?? import_util_utf8.fromUtf8)(messageSerialization) : messageSerialization;
|
250
|
+
return {
|
251
|
+
body,
|
252
|
+
eventType,
|
253
|
+
explicitPayloadContentType,
|
254
|
+
additionalHeaders
|
255
|
+
};
|
256
|
+
}
|
257
|
+
};
|
258
|
+
// Annotate the CommonJS export names for ESM import in node:
|
259
|
+
0 && (module.exports = {
|
260
|
+
EventStreamSerde
|
261
|
+
});
|