@cdk8s/awscdk-resolver 0.0.301 → 0.0.302
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 +2 -2
- package/lib/resolve.js +1 -1
- package/node_modules/@smithy/abort-controller/package.json +2 -2
- package/node_modules/@smithy/config-resolver/package.json +4 -4
- package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +209 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +667 -2
- package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +771 -0
- package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +108 -53
- package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +136 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/SmithyRpcV2CborProtocol.js +74 -0
- package/node_modules/@smithy/core/dist-es/submodules/cbor/index.js +3 -1
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +183 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +164 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +68 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/index.js +7 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +64 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeDeserializer.js +38 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/HttpInterceptingShapeSerializer.js +30 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +87 -0
- package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/determineTimestampFormat.js +20 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/TypeRegistry.js +49 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/deref.js +6 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/index.js +12 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/getSchemaSerdePlugin.js +23 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schema-middleware-types.js +1 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaDeserializationMiddleware.js +60 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/middleware/schemaSerializationMiddleware.js +16 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ErrorSchema.js +17 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/ListSchema.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/MapSchema.js +16 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +291 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/OperationSchema.js +16 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/Schema.js +6 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/SimpleSchema.js +15 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/StructureSchema.js +22 -0
- package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/sentinels.js +16 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/copyDocumentWithTransform.js +53 -0
- package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +4 -3
- package/node_modules/@smithy/core/dist-types/submodules/cbor/CborCodec.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/submodules/cbor/index.d.ts +3 -1
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpBindingProtocol.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/HttpProtocol.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/RpcProtocol.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/index.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/ToStringShapeSerializer.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/submodules/protocols/serde/determineTimestampFormat.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/TypeRegistry.d.ts +55 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/deref.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/index.d.ts +12 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schema-middleware-types.d.ts +8 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/middleware/schemaSerializationMiddleware.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ErrorSchema.d.ts +38 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/ListSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/MapSchema.d.ts +25 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +122 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/OperationSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/Schema.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/SimpleSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/StructureSchema.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/copyDocumentWithTransform.d.ts +5 -0
- package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +4 -3
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/CborCodec.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/SmithyRpcV2CborProtocol.d.ts +22 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/cbor/index.d.ts +3 -1
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpBindingProtocol.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/HttpProtocol.d.ts +29 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/RpcProtocol.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/index.d.ts +7 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/FromStringShapeDeserializer.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeDeserializer.d.ts +18 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/HttpInterceptingShapeSerializer.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/ToStringShapeSerializer.d.ts +15 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/protocols/serde/determineTimestampFormat.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/TypeRegistry.d.ts +55 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/deref.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/index.d.ts +12 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/middleware/getSchemaSerdePlugin.d.ts +14 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/middleware/schema-middleware-types.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/middleware/schemaDeserializationMiddleware.d.ts +9 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/middleware/schemaSerializationMiddleware.d.ts +6 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ErrorSchema.d.ts +38 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/ListSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/MapSchema.d.ts +25 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +125 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/OperationSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/Schema.d.ts +11 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/SimpleSchema.d.ts +20 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/StructureSchema.d.ts +24 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +21 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/copyDocumentWithTransform.d.ts +5 -0
- package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/index.d.ts +4 -3
- package/node_modules/@smithy/core/package.json +17 -7
- package/node_modules/@smithy/core/schema.d.ts +7 -0
- package/node_modules/@smithy/core/schema.js +6 -0
- package/node_modules/@smithy/credential-provider-imds/package.json +5 -5
- package/node_modules/@smithy/fetch-http-handler/package.json +5 -5
- package/node_modules/@smithy/hash-node/package.json +2 -2
- package/node_modules/@smithy/invalid-dependency/package.json +2 -2
- package/node_modules/@smithy/middleware-content-length/package.json +3 -3
- package/node_modules/@smithy/middleware-endpoint/package.json +8 -8
- package/node_modules/@smithy/middleware-retry/package.json +8 -8
- package/node_modules/@smithy/middleware-serde/dist-types/deserializerMiddleware.d.ts +1 -0
- package/node_modules/@smithy/middleware-serde/dist-types/serdePlugin.d.ts +7 -1
- package/node_modules/@smithy/middleware-serde/dist-types/serializerMiddleware.d.ts +1 -0
- package/node_modules/@smithy/middleware-serde/dist-types/ts3.4/deserializerMiddleware.d.ts +1 -0
- package/node_modules/@smithy/middleware-serde/dist-types/ts3.4/serdePlugin.d.ts +7 -1
- package/node_modules/@smithy/middleware-serde/dist-types/ts3.4/serializerMiddleware.d.ts +1 -0
- package/node_modules/@smithy/middleware-serde/package.json +3 -3
- package/node_modules/@smithy/middleware-stack/package.json +2 -2
- package/node_modules/@smithy/node-config-provider/package.json +4 -4
- package/node_modules/@smithy/node-http-handler/package.json +5 -5
- package/node_modules/@smithy/property-provider/package.json +2 -2
- package/node_modules/@smithy/protocol-http/package.json +2 -2
- package/node_modules/@smithy/querystring-builder/package.json +2 -2
- package/node_modules/@smithy/querystring-parser/package.json +2 -2
- package/node_modules/@smithy/service-error-classification/package.json +2 -2
- package/node_modules/@smithy/shared-ini-file-loader/package.json +2 -2
- package/node_modules/@smithy/signature-v4/package.json +4 -4
- package/node_modules/@smithy/smithy-client/dist-cjs/index.js +10 -0
- package/node_modules/@smithy/smithy-client/dist-es/command.js +6 -0
- package/node_modules/@smithy/smithy-client/dist-types/command.d.ts +7 -1
- package/node_modules/@smithy/smithy-client/dist-types/ts3.4/command.d.ts +7 -1
- package/node_modules/@smithy/smithy-client/package.json +7 -7
- package/node_modules/@smithy/types/dist-types/command.d.ts +5 -2
- package/node_modules/@smithy/types/dist-types/schema/schema.d.ts +2 -4
- package/node_modules/@smithy/types/dist-types/ts3.4/command.d.ts +5 -2
- package/node_modules/@smithy/types/dist-types/ts3.4/schema/schema.d.ts +2 -4
- package/node_modules/@smithy/types/package.json +1 -1
- package/node_modules/@smithy/url-parser/package.json +3 -3
- package/node_modules/@smithy/util-defaults-mode-browser/package.json +4 -4
- package/node_modules/@smithy/util-defaults-mode-node/package.json +7 -7
- package/node_modules/@smithy/util-endpoints/package.json +3 -3
- package/node_modules/@smithy/util-middleware/package.json +2 -2
- package/node_modules/@smithy/util-retry/package.json +3 -3
- package/node_modules/@smithy/util-stream/package.json +4 -4
- package/node_modules/@smithy/util-waiter/package.json +3 -3
- package/package.json +5 -5
@@ -0,0 +1,771 @@
|
|
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/schema/index.ts
|
20
|
+
var schema_exports = {};
|
21
|
+
__export(schema_exports, {
|
22
|
+
ErrorSchema: () => ErrorSchema,
|
23
|
+
ListSchema: () => ListSchema,
|
24
|
+
MapSchema: () => MapSchema,
|
25
|
+
NormalizedSchema: () => NormalizedSchema,
|
26
|
+
OperationSchema: () => OperationSchema,
|
27
|
+
SCHEMA: () => SCHEMA,
|
28
|
+
Schema: () => Schema,
|
29
|
+
SimpleSchema: () => SimpleSchema,
|
30
|
+
StructureSchema: () => StructureSchema,
|
31
|
+
TypeRegistry: () => TypeRegistry,
|
32
|
+
deref: () => deref,
|
33
|
+
deserializerMiddlewareOption: () => deserializerMiddlewareOption,
|
34
|
+
error: () => error,
|
35
|
+
getSchemaSerdePlugin: () => getSchemaSerdePlugin,
|
36
|
+
list: () => list,
|
37
|
+
map: () => map,
|
38
|
+
op: () => op,
|
39
|
+
serializerMiddlewareOption: () => serializerMiddlewareOption,
|
40
|
+
sim: () => sim,
|
41
|
+
struct: () => struct
|
42
|
+
});
|
43
|
+
module.exports = __toCommonJS(schema_exports);
|
44
|
+
|
45
|
+
// src/submodules/schema/deref.ts
|
46
|
+
var deref = (schemaRef) => {
|
47
|
+
if (typeof schemaRef === "function") {
|
48
|
+
return schemaRef();
|
49
|
+
}
|
50
|
+
return schemaRef;
|
51
|
+
};
|
52
|
+
|
53
|
+
// src/submodules/schema/middleware/schemaDeserializationMiddleware.ts
|
54
|
+
var import_protocol_http = require("@smithy/protocol-http");
|
55
|
+
var import_util_middleware = require("@smithy/util-middleware");
|
56
|
+
var schemaDeserializationMiddleware = (config) => (next, context) => async (args) => {
|
57
|
+
const { response } = await next(args);
|
58
|
+
const { operationSchema } = (0, import_util_middleware.getSmithyContext)(context);
|
59
|
+
try {
|
60
|
+
const parsed = await config.protocol.deserializeResponse(
|
61
|
+
operationSchema,
|
62
|
+
{
|
63
|
+
...config,
|
64
|
+
...context
|
65
|
+
},
|
66
|
+
response
|
67
|
+
);
|
68
|
+
return {
|
69
|
+
response,
|
70
|
+
output: parsed
|
71
|
+
};
|
72
|
+
} catch (error2) {
|
73
|
+
Object.defineProperty(error2, "$response", {
|
74
|
+
value: response
|
75
|
+
});
|
76
|
+
if (!("$metadata" in error2)) {
|
77
|
+
const hint = `Deserialization error: to see the raw response, inspect the hidden field {error}.$response on this object.`;
|
78
|
+
try {
|
79
|
+
error2.message += "\n " + hint;
|
80
|
+
} catch (e) {
|
81
|
+
if (!context.logger || context.logger?.constructor?.name === "NoOpLogger") {
|
82
|
+
console.warn(hint);
|
83
|
+
} else {
|
84
|
+
context.logger?.warn?.(hint);
|
85
|
+
}
|
86
|
+
}
|
87
|
+
if (typeof error2.$responseBodyText !== "undefined") {
|
88
|
+
if (error2.$response) {
|
89
|
+
error2.$response.body = error2.$responseBodyText;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
try {
|
93
|
+
if (import_protocol_http.HttpResponse.isInstance(response)) {
|
94
|
+
const { headers = {} } = response;
|
95
|
+
const headerEntries = Object.entries(headers);
|
96
|
+
error2.$metadata = {
|
97
|
+
httpStatusCode: response.statusCode,
|
98
|
+
requestId: findHeader(/^x-[\w-]+-request-?id$/, headerEntries),
|
99
|
+
extendedRequestId: findHeader(/^x-[\w-]+-id-2$/, headerEntries),
|
100
|
+
cfId: findHeader(/^x-[\w-]+-cf-id$/, headerEntries)
|
101
|
+
};
|
102
|
+
}
|
103
|
+
} catch (e) {
|
104
|
+
}
|
105
|
+
}
|
106
|
+
throw error2;
|
107
|
+
}
|
108
|
+
};
|
109
|
+
var findHeader = (pattern, headers) => {
|
110
|
+
return (headers.find(([k]) => {
|
111
|
+
return k.match(pattern);
|
112
|
+
}) || [void 0, void 0])[1];
|
113
|
+
};
|
114
|
+
|
115
|
+
// src/submodules/schema/middleware/schemaSerializationMiddleware.ts
|
116
|
+
var import_util_middleware2 = require("@smithy/util-middleware");
|
117
|
+
var schemaSerializationMiddleware = (config) => (next, context) => async (args) => {
|
118
|
+
const { operationSchema } = (0, import_util_middleware2.getSmithyContext)(context);
|
119
|
+
const endpoint = context.endpointV2?.url && config.urlParser ? async () => config.urlParser(context.endpointV2.url) : config.endpoint;
|
120
|
+
const request = await config.protocol.serializeRequest(operationSchema, args.input, {
|
121
|
+
...config,
|
122
|
+
...context,
|
123
|
+
endpoint
|
124
|
+
});
|
125
|
+
return next({
|
126
|
+
...args,
|
127
|
+
request
|
128
|
+
});
|
129
|
+
};
|
130
|
+
|
131
|
+
// src/submodules/schema/middleware/getSchemaSerdePlugin.ts
|
132
|
+
var deserializerMiddlewareOption = {
|
133
|
+
name: "deserializerMiddleware",
|
134
|
+
step: "deserialize",
|
135
|
+
tags: ["DESERIALIZER"],
|
136
|
+
override: true
|
137
|
+
};
|
138
|
+
var serializerMiddlewareOption = {
|
139
|
+
name: "serializerMiddleware",
|
140
|
+
step: "serialize",
|
141
|
+
tags: ["SERIALIZER"],
|
142
|
+
override: true
|
143
|
+
};
|
144
|
+
function getSchemaSerdePlugin(config) {
|
145
|
+
return {
|
146
|
+
applyToStack: (commandStack) => {
|
147
|
+
commandStack.add(schemaSerializationMiddleware(config), serializerMiddlewareOption);
|
148
|
+
commandStack.add(schemaDeserializationMiddleware(config), deserializerMiddlewareOption);
|
149
|
+
config.protocol.setSerdeContext(config);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
}
|
153
|
+
|
154
|
+
// src/submodules/schema/TypeRegistry.ts
|
155
|
+
var TypeRegistry = class _TypeRegistry {
|
156
|
+
constructor(namespace, schemas = /* @__PURE__ */ new Map()) {
|
157
|
+
this.namespace = namespace;
|
158
|
+
this.schemas = schemas;
|
159
|
+
}
|
160
|
+
static {
|
161
|
+
this.registries = /* @__PURE__ */ new Map();
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* @param namespace - specifier.
|
165
|
+
* @returns the schema for that namespace, creating it if necessary.
|
166
|
+
*/
|
167
|
+
static for(namespace) {
|
168
|
+
if (!_TypeRegistry.registries.has(namespace)) {
|
169
|
+
_TypeRegistry.registries.set(namespace, new _TypeRegistry(namespace));
|
170
|
+
}
|
171
|
+
return _TypeRegistry.registries.get(namespace);
|
172
|
+
}
|
173
|
+
/**
|
174
|
+
* Adds the given schema to a type registry with the same namespace.
|
175
|
+
*
|
176
|
+
* @param shapeId - to be registered.
|
177
|
+
* @param schema - to be registered.
|
178
|
+
*/
|
179
|
+
register(shapeId, schema) {
|
180
|
+
const qualifiedName = this.normalizeShapeId(shapeId);
|
181
|
+
const registry = _TypeRegistry.for(this.getNamespace(shapeId));
|
182
|
+
registry.schemas.set(qualifiedName, schema);
|
183
|
+
}
|
184
|
+
/**
|
185
|
+
* @param shapeId - query.
|
186
|
+
* @returns the schema.
|
187
|
+
*/
|
188
|
+
getSchema(shapeId) {
|
189
|
+
const id = this.normalizeShapeId(shapeId);
|
190
|
+
if (!this.schemas.has(id)) {
|
191
|
+
throw new Error(`@smithy/core/schema - schema not found for ${id}`);
|
192
|
+
}
|
193
|
+
return this.schemas.get(id);
|
194
|
+
}
|
195
|
+
/**
|
196
|
+
* The smithy-typescript code generator generates a synthetic (i.e. unmodeled) base exception,
|
197
|
+
* because generated SDKs before the introduction of schemas have the notion of a ServiceBaseException, which
|
198
|
+
* is unique per service/model.
|
199
|
+
*
|
200
|
+
* This is generated under a unique prefix that is combined with the service namespace, and this
|
201
|
+
* method is used to retrieve it.
|
202
|
+
*
|
203
|
+
* The base exception synthetic schema is used when an error is returned by a service, but we cannot
|
204
|
+
* determine what existing schema to use to deserialize it.
|
205
|
+
*
|
206
|
+
* @returns the synthetic base exception of the service namespace associated with this registry instance.
|
207
|
+
*/
|
208
|
+
getBaseException() {
|
209
|
+
for (const [id, schema] of this.schemas.entries()) {
|
210
|
+
if (id.startsWith("smithyts.client.synthetic.") && id.endsWith("ServiceException")) {
|
211
|
+
return schema;
|
212
|
+
}
|
213
|
+
}
|
214
|
+
return void 0;
|
215
|
+
}
|
216
|
+
/**
|
217
|
+
* @param predicate - criterion.
|
218
|
+
* @returns a schema in this registry matching the predicate.
|
219
|
+
*/
|
220
|
+
find(predicate) {
|
221
|
+
return [...this.schemas.values()].find(predicate);
|
222
|
+
}
|
223
|
+
/**
|
224
|
+
* Unloads the current TypeRegistry.
|
225
|
+
*/
|
226
|
+
destroy() {
|
227
|
+
_TypeRegistry.registries.delete(this.namespace);
|
228
|
+
this.schemas.clear();
|
229
|
+
}
|
230
|
+
normalizeShapeId(shapeId) {
|
231
|
+
if (shapeId.includes("#")) {
|
232
|
+
return shapeId;
|
233
|
+
}
|
234
|
+
return this.namespace + "#" + shapeId;
|
235
|
+
}
|
236
|
+
getNamespace(shapeId) {
|
237
|
+
return this.normalizeShapeId(shapeId).split("#")[0];
|
238
|
+
}
|
239
|
+
};
|
240
|
+
|
241
|
+
// src/submodules/schema/schemas/Schema.ts
|
242
|
+
var Schema = class {
|
243
|
+
constructor(name, traits) {
|
244
|
+
this.name = name;
|
245
|
+
this.traits = traits;
|
246
|
+
}
|
247
|
+
};
|
248
|
+
|
249
|
+
// src/submodules/schema/schemas/ListSchema.ts
|
250
|
+
var ListSchema = class extends Schema {
|
251
|
+
constructor(name, traits, valueSchema) {
|
252
|
+
super(name, traits);
|
253
|
+
this.name = name;
|
254
|
+
this.traits = traits;
|
255
|
+
this.valueSchema = valueSchema;
|
256
|
+
}
|
257
|
+
};
|
258
|
+
function list(namespace, name, traits = {}, valueSchema) {
|
259
|
+
const schema = new ListSchema(
|
260
|
+
namespace + "#" + name,
|
261
|
+
traits,
|
262
|
+
typeof valueSchema === "function" ? valueSchema() : valueSchema
|
263
|
+
);
|
264
|
+
TypeRegistry.for(namespace).register(name, schema);
|
265
|
+
return schema;
|
266
|
+
}
|
267
|
+
|
268
|
+
// src/submodules/schema/schemas/MapSchema.ts
|
269
|
+
var MapSchema = class extends Schema {
|
270
|
+
constructor(name, traits, keySchema, valueSchema) {
|
271
|
+
super(name, traits);
|
272
|
+
this.name = name;
|
273
|
+
this.traits = traits;
|
274
|
+
this.keySchema = keySchema;
|
275
|
+
this.valueSchema = valueSchema;
|
276
|
+
}
|
277
|
+
};
|
278
|
+
function map(namespace, name, traits = {}, keySchema, valueSchema) {
|
279
|
+
const schema = new MapSchema(
|
280
|
+
namespace + "#" + name,
|
281
|
+
traits,
|
282
|
+
keySchema,
|
283
|
+
typeof valueSchema === "function" ? valueSchema() : valueSchema
|
284
|
+
);
|
285
|
+
TypeRegistry.for(namespace).register(name, schema);
|
286
|
+
return schema;
|
287
|
+
}
|
288
|
+
|
289
|
+
// src/submodules/schema/schemas/OperationSchema.ts
|
290
|
+
var OperationSchema = class extends Schema {
|
291
|
+
constructor(name, traits, input, output) {
|
292
|
+
super(name, traits);
|
293
|
+
this.name = name;
|
294
|
+
this.traits = traits;
|
295
|
+
this.input = input;
|
296
|
+
this.output = output;
|
297
|
+
}
|
298
|
+
};
|
299
|
+
function op(namespace, name, traits = {}, input, output) {
|
300
|
+
const schema = new OperationSchema(namespace + "#" + name, traits, input, output);
|
301
|
+
TypeRegistry.for(namespace).register(name, schema);
|
302
|
+
return schema;
|
303
|
+
}
|
304
|
+
|
305
|
+
// src/submodules/schema/schemas/StructureSchema.ts
|
306
|
+
var StructureSchema = class extends Schema {
|
307
|
+
constructor(name, traits, memberNames, memberList) {
|
308
|
+
super(name, traits);
|
309
|
+
this.name = name;
|
310
|
+
this.traits = traits;
|
311
|
+
this.memberNames = memberNames;
|
312
|
+
this.memberList = memberList;
|
313
|
+
this.members = {};
|
314
|
+
for (let i = 0; i < memberNames.length; ++i) {
|
315
|
+
this.members[memberNames[i]] = Array.isArray(memberList[i]) ? memberList[i] : [memberList[i], 0];
|
316
|
+
}
|
317
|
+
}
|
318
|
+
};
|
319
|
+
function struct(namespace, name, traits, memberNames, memberList) {
|
320
|
+
const schema = new StructureSchema(namespace + "#" + name, traits, memberNames, memberList);
|
321
|
+
TypeRegistry.for(namespace).register(name, schema);
|
322
|
+
return schema;
|
323
|
+
}
|
324
|
+
|
325
|
+
// src/submodules/schema/schemas/ErrorSchema.ts
|
326
|
+
var ErrorSchema = class extends StructureSchema {
|
327
|
+
constructor(name, traits, memberNames, memberList, ctor) {
|
328
|
+
super(name, traits, memberNames, memberList);
|
329
|
+
this.name = name;
|
330
|
+
this.traits = traits;
|
331
|
+
this.memberNames = memberNames;
|
332
|
+
this.memberList = memberList;
|
333
|
+
this.ctor = ctor;
|
334
|
+
}
|
335
|
+
};
|
336
|
+
function error(namespace, name, traits = {}, memberNames, memberList, ctor) {
|
337
|
+
const schema = new ErrorSchema(namespace + "#" + name, traits, memberNames, memberList, ctor);
|
338
|
+
TypeRegistry.for(namespace).register(name, schema);
|
339
|
+
return schema;
|
340
|
+
}
|
341
|
+
|
342
|
+
// src/submodules/schema/schemas/sentinels.ts
|
343
|
+
var SCHEMA = {
|
344
|
+
BLOB: 21,
|
345
|
+
// 21
|
346
|
+
STREAMING_BLOB: 42,
|
347
|
+
// 42
|
348
|
+
BOOLEAN: 2,
|
349
|
+
// 2
|
350
|
+
STRING: 0,
|
351
|
+
// 0
|
352
|
+
NUMERIC: 1,
|
353
|
+
// 1
|
354
|
+
BIG_INTEGER: 17,
|
355
|
+
// 17
|
356
|
+
BIG_DECIMAL: 19,
|
357
|
+
// 19
|
358
|
+
DOCUMENT: 15,
|
359
|
+
// 15
|
360
|
+
TIMESTAMP_DEFAULT: 4,
|
361
|
+
// 4
|
362
|
+
TIMESTAMP_DATE_TIME: 5,
|
363
|
+
// 5
|
364
|
+
TIMESTAMP_HTTP_DATE: 6,
|
365
|
+
// 6
|
366
|
+
TIMESTAMP_EPOCH_SECONDS: 7,
|
367
|
+
// 7
|
368
|
+
LIST_MODIFIER: 64,
|
369
|
+
// 64
|
370
|
+
MAP_MODIFIER: 128
|
371
|
+
// 128
|
372
|
+
};
|
373
|
+
|
374
|
+
// src/submodules/schema/schemas/SimpleSchema.ts
|
375
|
+
var SimpleSchema = class extends Schema {
|
376
|
+
constructor(name, schemaRef, traits) {
|
377
|
+
super(name, traits);
|
378
|
+
this.name = name;
|
379
|
+
this.schemaRef = schemaRef;
|
380
|
+
this.traits = traits;
|
381
|
+
}
|
382
|
+
};
|
383
|
+
function sim(namespace, name, schemaRef, traits) {
|
384
|
+
const schema = new SimpleSchema(namespace + "#" + name, schemaRef, traits);
|
385
|
+
TypeRegistry.for(namespace).register(name, schema);
|
386
|
+
return schema;
|
387
|
+
}
|
388
|
+
|
389
|
+
// src/submodules/schema/schemas/NormalizedSchema.ts
|
390
|
+
var NormalizedSchema = class _NormalizedSchema {
|
391
|
+
/**
|
392
|
+
* @param ref - a polymorphic SchemaRef to be dereferenced/normalized.
|
393
|
+
* @param memberName - optional memberName if this NormalizedSchema should be considered a member schema.
|
394
|
+
*/
|
395
|
+
constructor(ref, memberName) {
|
396
|
+
this.ref = ref;
|
397
|
+
this.memberName = memberName;
|
398
|
+
const traitStack = [];
|
399
|
+
let _ref = ref;
|
400
|
+
let schema = ref;
|
401
|
+
this._isMemberSchema = false;
|
402
|
+
while (Array.isArray(_ref)) {
|
403
|
+
traitStack.push(_ref[1]);
|
404
|
+
_ref = _ref[0];
|
405
|
+
schema = deref(_ref);
|
406
|
+
this._isMemberSchema = true;
|
407
|
+
}
|
408
|
+
if (traitStack.length > 0) {
|
409
|
+
this.memberTraits = {};
|
410
|
+
for (let i = traitStack.length - 1; i >= 0; --i) {
|
411
|
+
const traitSet = traitStack[i];
|
412
|
+
Object.assign(this.memberTraits, _NormalizedSchema.translateTraits(traitSet));
|
413
|
+
}
|
414
|
+
} else {
|
415
|
+
this.memberTraits = 0;
|
416
|
+
}
|
417
|
+
if (schema instanceof _NormalizedSchema) {
|
418
|
+
this.name = schema.name;
|
419
|
+
this.traits = schema.traits;
|
420
|
+
this._isMemberSchema = schema._isMemberSchema;
|
421
|
+
this.schema = schema.schema;
|
422
|
+
this.memberTraits = Object.assign({}, schema.getMemberTraits(), this.getMemberTraits());
|
423
|
+
this.normalizedTraits = void 0;
|
424
|
+
this.ref = schema.ref;
|
425
|
+
this.memberName = memberName ?? schema.memberName;
|
426
|
+
return;
|
427
|
+
}
|
428
|
+
this.schema = deref(schema);
|
429
|
+
if (this.schema && typeof this.schema === "object") {
|
430
|
+
this.traits = this.schema?.traits ?? {};
|
431
|
+
} else {
|
432
|
+
this.traits = 0;
|
433
|
+
}
|
434
|
+
this.name = (typeof this.schema === "object" ? this.schema?.name : void 0) ?? this.memberName ?? this.getSchemaName();
|
435
|
+
if (this._isMemberSchema && !memberName) {
|
436
|
+
throw new Error(
|
437
|
+
`@smithy/core/schema - NormalizedSchema member schema ${this.getName(true)} must initialize with memberName argument.`
|
438
|
+
);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
/**
|
442
|
+
* Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
|
443
|
+
*/
|
444
|
+
static of(ref, memberName) {
|
445
|
+
if (ref instanceof _NormalizedSchema) {
|
446
|
+
return ref;
|
447
|
+
}
|
448
|
+
return new _NormalizedSchema(ref, memberName);
|
449
|
+
}
|
450
|
+
/**
|
451
|
+
* @param indicator - numeric indicator for preset trait combination.
|
452
|
+
* @returns equivalent trait object.
|
453
|
+
*/
|
454
|
+
static translateTraits(indicator) {
|
455
|
+
if (typeof indicator === "object") {
|
456
|
+
return indicator;
|
457
|
+
}
|
458
|
+
indicator = indicator | 0;
|
459
|
+
const traits = {};
|
460
|
+
if ((indicator & 1) === 1) {
|
461
|
+
traits.httpLabel = 1;
|
462
|
+
}
|
463
|
+
if ((indicator >> 1 & 1) === 1) {
|
464
|
+
traits.idempotent = 1;
|
465
|
+
}
|
466
|
+
if ((indicator >> 2 & 1) === 1) {
|
467
|
+
traits.idempotencyToken = 1;
|
468
|
+
}
|
469
|
+
if ((indicator >> 3 & 1) === 1) {
|
470
|
+
traits.sensitive = 1;
|
471
|
+
}
|
472
|
+
if ((indicator >> 4 & 1) === 1) {
|
473
|
+
traits.httpPayload = 1;
|
474
|
+
}
|
475
|
+
if ((indicator >> 5 & 1) === 1) {
|
476
|
+
traits.httpResponseCode = 1;
|
477
|
+
}
|
478
|
+
if ((indicator >> 6 & 1) === 1) {
|
479
|
+
traits.httpQueryParams = 1;
|
480
|
+
}
|
481
|
+
return traits;
|
482
|
+
}
|
483
|
+
/**
|
484
|
+
* Creates a normalized member schema from the given schema and member name.
|
485
|
+
*/
|
486
|
+
static memberFrom(memberSchema, memberName) {
|
487
|
+
if (memberSchema instanceof _NormalizedSchema) {
|
488
|
+
memberSchema.memberName = memberName;
|
489
|
+
memberSchema._isMemberSchema = true;
|
490
|
+
return memberSchema;
|
491
|
+
}
|
492
|
+
return new _NormalizedSchema(memberSchema, memberName);
|
493
|
+
}
|
494
|
+
/**
|
495
|
+
* @returns the underlying non-normalized schema.
|
496
|
+
*/
|
497
|
+
getSchema() {
|
498
|
+
if (this.schema instanceof _NormalizedSchema) {
|
499
|
+
return this.schema = this.schema.getSchema();
|
500
|
+
}
|
501
|
+
if (this.schema instanceof SimpleSchema) {
|
502
|
+
return deref(this.schema.schemaRef);
|
503
|
+
}
|
504
|
+
return deref(this.schema);
|
505
|
+
}
|
506
|
+
/**
|
507
|
+
* @param withNamespace - qualifies the name.
|
508
|
+
* @returns e.g. `MyShape` or `com.namespace#MyShape`.
|
509
|
+
*/
|
510
|
+
getName(withNamespace = false) {
|
511
|
+
if (!withNamespace) {
|
512
|
+
if (this.name && this.name.includes("#")) {
|
513
|
+
return this.name.split("#")[1];
|
514
|
+
}
|
515
|
+
}
|
516
|
+
return this.name || void 0;
|
517
|
+
}
|
518
|
+
/**
|
519
|
+
* @returns the member name if the schema is a member schema.
|
520
|
+
* @throws Error when the schema isn't a member schema.
|
521
|
+
*/
|
522
|
+
getMemberName() {
|
523
|
+
if (!this.isMemberSchema()) {
|
524
|
+
throw new Error(`@smithy/core/schema - cannot get member name on non-member schema: ${this.getName(true)}`);
|
525
|
+
}
|
526
|
+
return this.memberName;
|
527
|
+
}
|
528
|
+
isMemberSchema() {
|
529
|
+
return this._isMemberSchema;
|
530
|
+
}
|
531
|
+
isUnitSchema() {
|
532
|
+
return this.getSchema() === "unit";
|
533
|
+
}
|
534
|
+
/**
|
535
|
+
* boolean methods on this class help control flow in shape serialization and deserialization.
|
536
|
+
*/
|
537
|
+
isListSchema() {
|
538
|
+
const inner = this.getSchema();
|
539
|
+
if (typeof inner === "number") {
|
540
|
+
return inner >= SCHEMA.LIST_MODIFIER && inner < SCHEMA.MAP_MODIFIER;
|
541
|
+
}
|
542
|
+
return inner instanceof ListSchema;
|
543
|
+
}
|
544
|
+
isMapSchema() {
|
545
|
+
const inner = this.getSchema();
|
546
|
+
if (typeof inner === "number") {
|
547
|
+
return inner >= SCHEMA.MAP_MODIFIER && inner <= 255;
|
548
|
+
}
|
549
|
+
return inner instanceof MapSchema;
|
550
|
+
}
|
551
|
+
isDocumentSchema() {
|
552
|
+
return this.getSchema() === SCHEMA.DOCUMENT;
|
553
|
+
}
|
554
|
+
isStructSchema() {
|
555
|
+
const inner = this.getSchema();
|
556
|
+
return inner !== null && typeof inner === "object" && "members" in inner || inner instanceof StructureSchema;
|
557
|
+
}
|
558
|
+
isBlobSchema() {
|
559
|
+
return this.getSchema() === SCHEMA.BLOB || this.getSchema() === SCHEMA.STREAMING_BLOB;
|
560
|
+
}
|
561
|
+
isTimestampSchema() {
|
562
|
+
const schema = this.getSchema();
|
563
|
+
return typeof schema === "number" && schema >= SCHEMA.TIMESTAMP_DEFAULT && schema <= SCHEMA.TIMESTAMP_EPOCH_SECONDS;
|
564
|
+
}
|
565
|
+
isStringSchema() {
|
566
|
+
return this.getSchema() === SCHEMA.STRING;
|
567
|
+
}
|
568
|
+
isBooleanSchema() {
|
569
|
+
return this.getSchema() === SCHEMA.BOOLEAN;
|
570
|
+
}
|
571
|
+
isNumericSchema() {
|
572
|
+
return this.getSchema() === SCHEMA.NUMERIC;
|
573
|
+
}
|
574
|
+
isBigIntegerSchema() {
|
575
|
+
return this.getSchema() === SCHEMA.BIG_INTEGER;
|
576
|
+
}
|
577
|
+
isBigDecimalSchema() {
|
578
|
+
return this.getSchema() === SCHEMA.BIG_DECIMAL;
|
579
|
+
}
|
580
|
+
isStreaming() {
|
581
|
+
const streaming = !!this.getMergedTraits().streaming;
|
582
|
+
if (streaming) {
|
583
|
+
return true;
|
584
|
+
}
|
585
|
+
return this.getSchema() === SCHEMA.STREAMING_BLOB;
|
586
|
+
}
|
587
|
+
/**
|
588
|
+
* @returns own traits merged with member traits, where member traits of the same trait key take priority.
|
589
|
+
* This method is cached.
|
590
|
+
*/
|
591
|
+
getMergedTraits() {
|
592
|
+
if (this.normalizedTraits) {
|
593
|
+
return this.normalizedTraits;
|
594
|
+
}
|
595
|
+
this.normalizedTraits = {
|
596
|
+
...this.getOwnTraits(),
|
597
|
+
...this.getMemberTraits()
|
598
|
+
};
|
599
|
+
return this.normalizedTraits;
|
600
|
+
}
|
601
|
+
/**
|
602
|
+
* @returns only the member traits. If the schema is not a member, this returns empty.
|
603
|
+
*/
|
604
|
+
getMemberTraits() {
|
605
|
+
return _NormalizedSchema.translateTraits(this.memberTraits);
|
606
|
+
}
|
607
|
+
/**
|
608
|
+
* @returns only the traits inherent to the shape or member target shape if this schema is a member.
|
609
|
+
* If there are any member traits they are excluded.
|
610
|
+
*/
|
611
|
+
getOwnTraits() {
|
612
|
+
return _NormalizedSchema.translateTraits(this.traits);
|
613
|
+
}
|
614
|
+
/**
|
615
|
+
* @returns the map's key's schema. Returns a dummy Document schema if this schema is a Document.
|
616
|
+
*
|
617
|
+
* @throws Error if the schema is not a Map or Document.
|
618
|
+
*/
|
619
|
+
getKeySchema() {
|
620
|
+
if (this.isDocumentSchema()) {
|
621
|
+
return _NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], "key");
|
622
|
+
}
|
623
|
+
if (!this.isMapSchema()) {
|
624
|
+
throw new Error(`@smithy/core/schema - cannot get key schema for non-map schema: ${this.getName(true)}`);
|
625
|
+
}
|
626
|
+
const schema = this.getSchema();
|
627
|
+
if (typeof schema === "number") {
|
628
|
+
return _NormalizedSchema.memberFrom([63 & schema, 0], "key");
|
629
|
+
}
|
630
|
+
return _NormalizedSchema.memberFrom([schema.keySchema, 0], "key");
|
631
|
+
}
|
632
|
+
/**
|
633
|
+
* @returns the schema of the map's value or list's member.
|
634
|
+
* Returns a dummy Document schema if this schema is a Document.
|
635
|
+
*
|
636
|
+
* @throws Error if the schema is not a Map, List, nor Document.
|
637
|
+
*/
|
638
|
+
getValueSchema() {
|
639
|
+
const schema = this.getSchema();
|
640
|
+
if (typeof schema === "number") {
|
641
|
+
if (this.isMapSchema()) {
|
642
|
+
return _NormalizedSchema.memberFrom([63 & schema, 0], "value");
|
643
|
+
} else if (this.isListSchema()) {
|
644
|
+
return _NormalizedSchema.memberFrom([63 & schema, 0], "member");
|
645
|
+
}
|
646
|
+
}
|
647
|
+
if (schema && typeof schema === "object") {
|
648
|
+
if (this.isStructSchema()) {
|
649
|
+
throw new Error(`cannot call getValueSchema() with StructureSchema ${this.getName(true)}`);
|
650
|
+
}
|
651
|
+
const collection = schema;
|
652
|
+
if ("valueSchema" in collection) {
|
653
|
+
if (this.isMapSchema()) {
|
654
|
+
return _NormalizedSchema.memberFrom([collection.valueSchema, 0], "value");
|
655
|
+
} else if (this.isListSchema()) {
|
656
|
+
return _NormalizedSchema.memberFrom([collection.valueSchema, 0], "member");
|
657
|
+
}
|
658
|
+
}
|
659
|
+
}
|
660
|
+
if (this.isDocumentSchema()) {
|
661
|
+
return _NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], "value");
|
662
|
+
}
|
663
|
+
throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have a value member.`);
|
664
|
+
}
|
665
|
+
/**
|
666
|
+
* @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
|
667
|
+
* and will have the member name given.
|
668
|
+
* @param member - which member to retrieve and wrap.
|
669
|
+
*
|
670
|
+
* @throws Error if member does not exist or the schema is neither a document nor structure.
|
671
|
+
* Note that errors are assumed to be structures and unions are considered structures for these purposes.
|
672
|
+
*/
|
673
|
+
getMemberSchema(member) {
|
674
|
+
if (this.isStructSchema()) {
|
675
|
+
const struct2 = this.getSchema();
|
676
|
+
if (!(member in struct2.members)) {
|
677
|
+
throw new Error(
|
678
|
+
`@smithy/core/schema - the schema ${this.getName(true)} does not have a member with name=${member}.`
|
679
|
+
);
|
680
|
+
}
|
681
|
+
return _NormalizedSchema.memberFrom(struct2.members[member], member);
|
682
|
+
}
|
683
|
+
if (this.isDocumentSchema()) {
|
684
|
+
return _NormalizedSchema.memberFrom([SCHEMA.DOCUMENT, 0], member);
|
685
|
+
}
|
686
|
+
throw new Error(`@smithy/core/schema - the schema ${this.getName(true)} does not have members.`);
|
687
|
+
}
|
688
|
+
/**
|
689
|
+
* This can be used for checking the members as a hashmap.
|
690
|
+
* Prefer the structIterator method for iteration.
|
691
|
+
*
|
692
|
+
* This does NOT return list and map members, it is only for structures.
|
693
|
+
*
|
694
|
+
* @returns a map of member names to member schemas (normalized).
|
695
|
+
*/
|
696
|
+
getMemberSchemas() {
|
697
|
+
const { schema } = this;
|
698
|
+
const struct2 = schema;
|
699
|
+
if (!struct2 || typeof struct2 !== "object") {
|
700
|
+
return {};
|
701
|
+
}
|
702
|
+
if ("members" in struct2) {
|
703
|
+
const buffer = {};
|
704
|
+
for (const member of struct2.memberNames) {
|
705
|
+
buffer[member] = this.getMemberSchema(member);
|
706
|
+
}
|
707
|
+
return buffer;
|
708
|
+
}
|
709
|
+
return {};
|
710
|
+
}
|
711
|
+
/**
|
712
|
+
* Allows iteration over members of a structure schema.
|
713
|
+
* Each yield is a pair of the member name and member schema.
|
714
|
+
*
|
715
|
+
* This avoids the overhead of calling Object.entries(ns.getMemberSchemas()).
|
716
|
+
*/
|
717
|
+
*structIterator() {
|
718
|
+
if (!this.isStructSchema()) {
|
719
|
+
throw new Error("@smithy/core/schema - cannot acquire structIterator on non-struct schema.");
|
720
|
+
}
|
721
|
+
const struct2 = this.getSchema();
|
722
|
+
for (let i = 0; i < struct2.memberNames.length; ++i) {
|
723
|
+
yield [struct2.memberNames[i], _NormalizedSchema.memberFrom([struct2.memberList[i], 0], struct2.memberNames[i])];
|
724
|
+
}
|
725
|
+
}
|
726
|
+
/**
|
727
|
+
* @returns a last-resort human-readable name for the schema if it has no other identifiers.
|
728
|
+
*/
|
729
|
+
getSchemaName() {
|
730
|
+
const schema = this.getSchema();
|
731
|
+
if (typeof schema === "number") {
|
732
|
+
const _schema = 63 & schema;
|
733
|
+
const container = 192 & schema;
|
734
|
+
const type = Object.entries(SCHEMA).find(([, value]) => {
|
735
|
+
return value === _schema;
|
736
|
+
})?.[0] ?? "Unknown";
|
737
|
+
switch (container) {
|
738
|
+
case SCHEMA.MAP_MODIFIER:
|
739
|
+
return `${type}Map`;
|
740
|
+
case SCHEMA.LIST_MODIFIER:
|
741
|
+
return `${type}List`;
|
742
|
+
case 0:
|
743
|
+
return type;
|
744
|
+
}
|
745
|
+
}
|
746
|
+
return "Unknown";
|
747
|
+
}
|
748
|
+
};
|
749
|
+
// Annotate the CommonJS export names for ESM import in node:
|
750
|
+
0 && (module.exports = {
|
751
|
+
ErrorSchema,
|
752
|
+
ListSchema,
|
753
|
+
MapSchema,
|
754
|
+
NormalizedSchema,
|
755
|
+
OperationSchema,
|
756
|
+
SCHEMA,
|
757
|
+
Schema,
|
758
|
+
SimpleSchema,
|
759
|
+
StructureSchema,
|
760
|
+
TypeRegistry,
|
761
|
+
deref,
|
762
|
+
deserializerMiddlewareOption,
|
763
|
+
error,
|
764
|
+
getSchemaSerdePlugin,
|
765
|
+
list,
|
766
|
+
map,
|
767
|
+
op,
|
768
|
+
serializerMiddlewareOption,
|
769
|
+
sim,
|
770
|
+
struct
|
771
|
+
});
|