@jjrawlins/cdk-iam-policy-builder-helper 0.0.51 → 0.0.53

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.
Files changed (111) hide show
  1. package/.jsii +3 -3
  2. package/cdk-iam-policy-builder-helper/go.mod +1 -1
  3. package/cdk-iam-policy-builder-helper/jsii/jsii.go +2 -2
  4. package/cdk-iam-policy-builder-helper/version +1 -1
  5. package/node_modules/@aws-sdk/client-iam/dist-cjs/index.js +13439 -13574
  6. package/node_modules/@aws-sdk/client-iam/package.json +5 -5
  7. package/node_modules/@aws-sdk/client-sso/dist-cjs/index.js +478 -596
  8. package/node_modules/@aws-sdk/client-sso/package.json +4 -4
  9. package/node_modules/@aws-sdk/core/dist-cjs/index.js +1969 -6
  10. package/node_modules/@aws-sdk/core/dist-cjs/submodules/account-id-endpoint/index.js +48 -88
  11. package/node_modules/@aws-sdk/core/dist-cjs/submodules/client/index.js +35 -74
  12. package/node_modules/@aws-sdk/core/dist-cjs/submodules/httpAuthSchemes/index.js +273 -365
  13. package/node_modules/@aws-sdk/core/dist-cjs/submodules/protocols/index.js +1581 -1863
  14. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsJsonRpcProtocol.js +2 -2
  15. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/AwsRestJsonProtocol.js +2 -2
  16. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeDeserializer.js +4 -4
  17. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/JsonShapeSerializer.js +4 -4
  18. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/AwsQueryProtocol.js +3 -3
  19. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/query/QueryShapeSerializer.js +4 -4
  20. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/AwsRestXmlProtocol.js +2 -2
  21. package/node_modules/@aws-sdk/core/dist-es/submodules/protocols/xml/XmlShapeSerializer.js +4 -4
  22. package/node_modules/@aws-sdk/core/dist-types/submodules/account-id-endpoint/AccountIdEndpointModeConfigResolver.d.ts +1 -1
  23. package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4ASigner.d.ts +1 -1
  24. package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/AwsSdkSigV4Signer.d.ts +1 -1
  25. package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4AConfig.d.ts +1 -1
  26. package/node_modules/@aws-sdk/core/dist-types/submodules/httpAuthSchemes/aws_sdk/resolveAwsSdkSigV4Config.d.ts +1 -1
  27. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/ConfigurableSerdeContext.d.ts +1 -1
  28. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonCodec.d.ts +1 -1
  29. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeDeserializer.d.ts +1 -1
  30. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/json/JsonShapeSerializer.d.ts +2 -2
  31. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/query/QuerySerializerSettings.d.ts +1 -1
  32. package/node_modules/@aws-sdk/core/dist-types/submodules/protocols/xml/XmlCodec.d.ts +1 -1
  33. package/node_modules/@aws-sdk/core/package.json +1 -1
  34. package/node_modules/@aws-sdk/credential-provider-env/dist-cjs/index.js +38 -73
  35. package/node_modules/@aws-sdk/credential-provider-env/package.json +2 -2
  36. package/node_modules/@aws-sdk/credential-provider-http/package.json +2 -2
  37. package/node_modules/@aws-sdk/credential-provider-ini/dist-cjs/index.js +194 -259
  38. package/node_modules/@aws-sdk/credential-provider-ini/package.json +8 -8
  39. package/node_modules/@aws-sdk/credential-provider-node/dist-cjs/index.js +72 -132
  40. package/node_modules/@aws-sdk/credential-provider-node/package.json +7 -7
  41. package/node_modules/@aws-sdk/credential-provider-process/dist-cjs/index.js +71 -107
  42. package/node_modules/@aws-sdk/credential-provider-process/package.json +2 -2
  43. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/index.js +176 -249
  44. package/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/loadSso-CVy8iqsZ.js +14 -0
  45. package/node_modules/@aws-sdk/credential-provider-sso/package.json +4 -4
  46. package/node_modules/@aws-sdk/credential-provider-web-identity/dist-cjs/index.js +16 -25
  47. package/node_modules/@aws-sdk/credential-provider-web-identity/package.json +3 -3
  48. package/node_modules/@aws-sdk/middleware-user-agent/dist-cjs/index.js +170 -203
  49. package/node_modules/@aws-sdk/middleware-user-agent/package.json +2 -2
  50. package/node_modules/@aws-sdk/nested-clients/dist-cjs/index.js +2 -2
  51. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sso-oidc/index.js +583 -858
  52. package/node_modules/@aws-sdk/nested-clients/dist-cjs/submodules/sts/index.js +795 -928
  53. package/node_modules/@aws-sdk/nested-clients/package.json +4 -4
  54. package/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +147 -222
  55. package/node_modules/@aws-sdk/token-providers/package.json +3 -3
  56. package/node_modules/@aws-sdk/util-user-agent-node/dist-cjs/index.js +50 -94
  57. package/node_modules/@aws-sdk/util-user-agent-node/package.json +2 -2
  58. package/node_modules/@smithy/core/dist-cjs/submodules/cbor/index.js +1 -1
  59. package/node_modules/@smithy/core/dist-cjs/submodules/event-streams/index.js +5 -3
  60. package/node_modules/@smithy/core/dist-cjs/submodules/protocols/index.js +32 -30
  61. package/node_modules/@smithy/core/dist-cjs/submodules/schema/index.js +133 -202
  62. package/node_modules/@smithy/core/dist-cjs/submodules/serde/index.js +126 -34
  63. package/node_modules/@smithy/core/dist-es/submodules/cbor/CborCodec.js +2 -2
  64. package/node_modules/@smithy/core/dist-es/submodules/event-streams/EventStreamSerde.js +5 -3
  65. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpBindingProtocol.js +4 -4
  66. package/node_modules/@smithy/core/dist-es/submodules/protocols/HttpProtocol.js +3 -3
  67. package/node_modules/@smithy/core/dist-es/submodules/protocols/RpcProtocol.js +2 -2
  68. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/FromStringShapeDeserializer.js +19 -17
  69. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/ToStringShapeSerializer.js +4 -4
  70. package/node_modules/@smithy/core/dist-es/submodules/protocols/serde/determineTimestampFormat.js +5 -6
  71. package/node_modules/@smithy/core/dist-es/submodules/schema/index.js +1 -0
  72. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/NormalizedSchema.js +82 -176
  73. package/node_modules/@smithy/core/dist-es/submodules/schema/schemas/translateTraits.js +22 -0
  74. package/node_modules/@smithy/core/dist-es/submodules/serde/index.js +1 -0
  75. package/node_modules/@smithy/core/dist-es/submodules/serde/schema-serde-lib/schema-date-utils.js +110 -0
  76. package/node_modules/@smithy/core/dist-es/submodules/serde/value/NumericValue.js +4 -26
  77. package/node_modules/@smithy/core/dist-types/submodules/schema/index.d.ts +1 -0
  78. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
  79. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/sentinels.d.ts +2 -0
  80. package/node_modules/@smithy/core/dist-types/submodules/schema/schemas/translateTraits.d.ts +7 -0
  81. package/node_modules/@smithy/core/dist-types/submodules/serde/index.d.ts +1 -0
  82. package/node_modules/@smithy/core/dist-types/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
  83. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/index.d.ts +1 -0
  84. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/NormalizedSchema.d.ts +5 -24
  85. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/sentinels.d.ts +2 -0
  86. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/schema/schemas/translateTraits.d.ts +7 -0
  87. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/index.d.ts +1 -0
  88. package/node_modules/@smithy/core/dist-types/ts3.4/submodules/serde/schema-serde-lib/schema-date-utils.d.ts +47 -0
  89. package/node_modules/@smithy/core/package.json +3 -3
  90. package/node_modules/@smithy/fetch-http-handler/package.json +2 -2
  91. package/node_modules/@smithy/middleware-endpoint/package.json +2 -2
  92. package/node_modules/@smithy/middleware-retry/package.json +2 -2
  93. package/node_modules/@smithy/smithy-client/package.json +4 -4
  94. package/node_modules/@smithy/util-base64/dist-cjs/constants.browser.js +9 -32
  95. package/node_modules/@smithy/util-base64/dist-es/constants.browser.js +9 -28
  96. package/node_modules/@smithy/util-base64/dist-types/constants.browser.d.ts +5 -6
  97. package/node_modules/@smithy/util-base64/dist-types/ts3.4/constants.browser.d.ts +5 -6
  98. package/node_modules/@smithy/util-base64/package.json +1 -1
  99. package/node_modules/@smithy/util-body-length-node/dist-cjs/index.js +8 -6
  100. package/node_modules/@smithy/util-body-length-node/dist-es/calculateBodyLength.js +8 -6
  101. package/node_modules/@smithy/util-body-length-node/package.json +1 -1
  102. package/node_modules/@smithy/util-defaults-mode-browser/dist-cjs/resolveDefaultsModeConfig.js +11 -9
  103. package/node_modules/@smithy/util-defaults-mode-browser/dist-es/resolveDefaultsModeConfig.js +11 -8
  104. package/node_modules/@smithy/util-defaults-mode-browser/package.json +2 -3
  105. package/node_modules/@smithy/util-defaults-mode-node/package.json +2 -2
  106. package/node_modules/@smithy/util-stream/dist-cjs/index.js +3 -5
  107. package/node_modules/@smithy/util-stream/dist-es/blob/Uint8ArrayBlobAdapter.js +3 -5
  108. package/node_modules/@smithy/util-stream/dist-types/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
  109. package/node_modules/@smithy/util-stream/dist-types/ts3.4/blob/Uint8ArrayBlobAdapter.d.ts +1 -0
  110. package/node_modules/@smithy/util-stream/package.json +3 -3
  111. package/package.json +3 -3
@@ -2,9 +2,8 @@ import { deref } from "../deref";
2
2
  import { ListSchema } from "./ListSchema";
3
3
  import { MapSchema } from "./MapSchema";
4
4
  import { Schema } from "./Schema";
5
- import { SCHEMA } from "./sentinels";
6
- import { SimpleSchema } from "./SimpleSchema";
7
5
  import { StructureSchema } from "./StructureSchema";
6
+ import { translateTraits } from "./translateTraits";
8
7
  export class NormalizedSchema {
9
8
  ref;
10
9
  memberName;
@@ -33,7 +32,7 @@ export class NormalizedSchema {
33
32
  this.memberTraits = {};
34
33
  for (let i = traitStack.length - 1; i >= 0; --i) {
35
34
  const traitSet = traitStack[i];
36
- Object.assign(this.memberTraits, NormalizedSchema.translateTraits(traitSet));
35
+ Object.assign(this.memberTraits, translateTraits(traitSet));
37
36
  }
38
37
  }
39
38
  else {
@@ -54,8 +53,7 @@ export class NormalizedSchema {
54
53
  else {
55
54
  this.traits = 0;
56
55
  }
57
- this.name =
58
- (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? this.getSchemaName();
56
+ this.name = (this.schema instanceof Schema ? this.schema.getName?.() : void 0) ?? this.memberName ?? String(schema);
59
57
  if (this._isMemberSchema && !memberName) {
60
58
  throw new Error(`@smithy/core/schema - NormalizedSchema member init ${this.getName(true)} missing member name.`);
61
59
  }
@@ -64,138 +62,90 @@ export class NormalizedSchema {
64
62
  return Schema[Symbol.hasInstance].bind(this)(lhs);
65
63
  }
66
64
  static of(ref) {
67
- if (ref instanceof NormalizedSchema) {
68
- return ref;
65
+ const sc = deref(ref);
66
+ if (sc instanceof NormalizedSchema) {
67
+ return sc;
69
68
  }
70
- if (Array.isArray(ref)) {
71
- const [ns, traits] = ref;
69
+ if (Array.isArray(sc)) {
70
+ const [ns, traits] = sc;
72
71
  if (ns instanceof NormalizedSchema) {
73
- Object.assign(ns.getMergedTraits(), NormalizedSchema.translateTraits(traits));
72
+ Object.assign(ns.getMergedTraits(), translateTraits(traits));
74
73
  return ns;
75
74
  }
76
75
  throw new Error(`@smithy/core/schema - may not init unwrapped member schema=${JSON.stringify(ref, null, 2)}.`);
77
76
  }
78
- return new NormalizedSchema(ref);
79
- }
80
- static translateTraits(indicator) {
81
- if (typeof indicator === "object") {
82
- return indicator;
83
- }
84
- indicator = indicator | 0;
85
- const traits = {};
86
- let i = 0;
87
- for (const trait of [
88
- "httpLabel",
89
- "idempotent",
90
- "idempotencyToken",
91
- "sensitive",
92
- "httpPayload",
93
- "httpResponseCode",
94
- "httpQueryParams",
95
- ]) {
96
- if (((indicator >> i++) & 1) === 1) {
97
- traits[trait] = 1;
98
- }
99
- }
100
- return traits;
77
+ return new NormalizedSchema(sc);
101
78
  }
102
79
  getSchema() {
103
- if (this.schema instanceof NormalizedSchema) {
104
- Object.assign(this, { schema: this.schema.getSchema() });
105
- return this.schema;
106
- }
107
- if (this.schema instanceof SimpleSchema) {
108
- return deref(this.schema.schemaRef);
109
- }
110
- return deref(this.schema);
80
+ return deref(this.schema?.schemaRef ?? this.schema);
111
81
  }
112
82
  getName(withNamespace = false) {
113
- if (!withNamespace) {
114
- if (this.name && this.name.includes("#")) {
115
- return this.name.split("#")[1];
116
- }
117
- }
118
- return this.name || undefined;
83
+ const { name } = this;
84
+ const short = !withNamespace && name && name.includes("#");
85
+ return short ? name.split("#")[1] : name || undefined;
119
86
  }
120
87
  getMemberName() {
121
- if (!this.isMemberSchema()) {
122
- throw new Error(`@smithy/core/schema - non-member schema: ${this.getName(true)}`);
123
- }
124
88
  return this.memberName;
125
89
  }
126
90
  isMemberSchema() {
127
91
  return this._isMemberSchema;
128
92
  }
129
- isUnitSchema() {
130
- return this.getSchema() === "unit";
131
- }
132
93
  isListSchema() {
133
- const inner = this.getSchema();
134
- if (typeof inner === "number") {
135
- return inner >= SCHEMA.LIST_MODIFIER && inner < SCHEMA.MAP_MODIFIER;
136
- }
137
- return inner instanceof ListSchema;
94
+ const sc = this.getSchema();
95
+ return typeof sc === "number"
96
+ ? sc >= 64 && sc < 128
97
+ : sc instanceof ListSchema;
138
98
  }
139
99
  isMapSchema() {
140
- const inner = this.getSchema();
141
- if (typeof inner === "number") {
142
- return inner >= SCHEMA.MAP_MODIFIER && inner <= 0b1111_1111;
143
- }
144
- return inner instanceof MapSchema;
100
+ const sc = this.getSchema();
101
+ return typeof sc === "number"
102
+ ? sc >= 128 && sc <= 0b1111_1111
103
+ : sc instanceof MapSchema;
145
104
  }
146
105
  isStructSchema() {
147
- const inner = this.getSchema();
148
- return (inner !== null && typeof inner === "object" && "members" in inner) || inner instanceof StructureSchema;
106
+ const sc = this.getSchema();
107
+ return (sc !== null && typeof sc === "object" && "members" in sc) || sc instanceof StructureSchema;
149
108
  }
150
109
  isBlobSchema() {
151
- return this.getSchema() === SCHEMA.BLOB || this.getSchema() === SCHEMA.STREAMING_BLOB;
110
+ const sc = this.getSchema();
111
+ return sc === 21 || sc === 42;
152
112
  }
153
113
  isTimestampSchema() {
154
- const schema = this.getSchema();
155
- return typeof schema === "number" && schema >= SCHEMA.TIMESTAMP_DEFAULT && schema <= SCHEMA.TIMESTAMP_EPOCH_SECONDS;
114
+ const sc = this.getSchema();
115
+ return (typeof sc === "number" &&
116
+ sc >= 4 &&
117
+ sc <= 7);
118
+ }
119
+ isUnitSchema() {
120
+ return this.getSchema() === "unit";
156
121
  }
157
122
  isDocumentSchema() {
158
- return this.getSchema() === SCHEMA.DOCUMENT;
123
+ return this.getSchema() === 15;
159
124
  }
160
125
  isStringSchema() {
161
- return this.getSchema() === SCHEMA.STRING;
126
+ return this.getSchema() === 0;
162
127
  }
163
128
  isBooleanSchema() {
164
- return this.getSchema() === SCHEMA.BOOLEAN;
129
+ return this.getSchema() === 2;
165
130
  }
166
131
  isNumericSchema() {
167
- return this.getSchema() === SCHEMA.NUMERIC;
132
+ return this.getSchema() === 1;
168
133
  }
169
134
  isBigIntegerSchema() {
170
- return this.getSchema() === SCHEMA.BIG_INTEGER;
135
+ return this.getSchema() === 17;
171
136
  }
172
137
  isBigDecimalSchema() {
173
- return this.getSchema() === SCHEMA.BIG_DECIMAL;
138
+ return this.getSchema() === 19;
174
139
  }
175
140
  isStreaming() {
176
- const streaming = !!this.getMergedTraits().streaming;
177
- if (streaming) {
178
- return true;
179
- }
180
- return this.getSchema() === SCHEMA.STREAMING_BLOB;
141
+ const { streaming } = this.getMergedTraits();
142
+ return !!streaming || this.getSchema() === 42;
181
143
  }
182
144
  isIdempotencyToken() {
183
- if (this.normalizedTraits) {
184
- return !!this.normalizedTraits.idempotencyToken;
185
- }
186
- for (const traits of [this.traits, this.memberTraits]) {
187
- if (typeof traits === "number") {
188
- if ((traits & 0b0100) === 0b0100) {
189
- return true;
190
- }
191
- }
192
- else if (typeof traits === "object") {
193
- if (!!traits.idempotencyToken) {
194
- return true;
195
- }
196
- }
197
- }
198
- return false;
145
+ const match = (traits) => (traits & 0b0100) === 0b0100 ||
146
+ !!traits?.idempotencyToken;
147
+ const { normalizedTraits, traits, memberTraits } = this;
148
+ return match(normalizedTraits) || match(traits) || match(memberTraits);
199
149
  }
200
150
  getMergedTraits() {
201
151
  return (this.normalizedTraits ??
@@ -205,74 +155,48 @@ export class NormalizedSchema {
205
155
  }));
206
156
  }
207
157
  getMemberTraits() {
208
- return NormalizedSchema.translateTraits(this.memberTraits);
158
+ return translateTraits(this.memberTraits);
209
159
  }
210
160
  getOwnTraits() {
211
- return NormalizedSchema.translateTraits(this.traits);
161
+ return translateTraits(this.traits);
212
162
  }
213
163
  getKeySchema() {
214
- if (this.isDocumentSchema()) {
215
- return this.memberFrom([SCHEMA.DOCUMENT, 0], "key");
216
- }
217
- if (!this.isMapSchema()) {
164
+ const [isDoc, isMap] = [this.isDocumentSchema(), this.isMapSchema()];
165
+ if (!isDoc && !isMap) {
218
166
  throw new Error(`@smithy/core/schema - cannot get key for non-map: ${this.getName(true)}`);
219
167
  }
220
168
  const schema = this.getSchema();
221
- if (typeof schema === "number") {
222
- return this.memberFrom([0b0011_1111 & schema, 0], "key");
223
- }
224
- return this.memberFrom([schema.keySchema, 0], "key");
169
+ const memberSchema = isDoc
170
+ ? 15
171
+ : schema?.keySchema ?? 0;
172
+ return member([memberSchema, 0], "key");
225
173
  }
226
174
  getValueSchema() {
227
- const schema = this.getSchema();
228
- if (typeof schema === "number") {
229
- if (this.isMapSchema()) {
230
- return this.memberFrom([0b0011_1111 & schema, 0], "value");
231
- }
232
- else if (this.isListSchema()) {
233
- return this.memberFrom([0b0011_1111 & schema, 0], "member");
234
- }
235
- }
236
- if (schema && typeof schema === "object") {
237
- if (this.isStructSchema()) {
238
- throw new Error(`may not getValueSchema() on structure ${this.getName(true)}`);
239
- }
240
- const collection = schema;
241
- if ("valueSchema" in collection) {
242
- if (this.isMapSchema()) {
243
- return this.memberFrom([collection.valueSchema, 0], "value");
244
- }
245
- else if (this.isListSchema()) {
246
- return this.memberFrom([collection.valueSchema, 0], "member");
247
- }
248
- }
249
- }
250
- if (this.isDocumentSchema()) {
251
- return this.memberFrom([SCHEMA.DOCUMENT, 0], "value");
175
+ const sc = this.getSchema();
176
+ const [isDoc, isMap, isList] = [this.isDocumentSchema(), this.isMapSchema(), this.isListSchema()];
177
+ const memberSchema = typeof sc === "number"
178
+ ? 0b0011_1111 & sc
179
+ : sc && typeof sc === "object" && (isMap || isList)
180
+ ? sc.valueSchema
181
+ : isDoc
182
+ ? 15
183
+ : void 0;
184
+ if (memberSchema != null) {
185
+ return member([memberSchema, 0], isMap ? "value" : "member");
252
186
  }
253
187
  throw new Error(`@smithy/core/schema - ${this.getName(true)} has no value member.`);
254
188
  }
255
- hasMemberSchema(member) {
256
- if (this.isStructSchema()) {
257
- const struct = this.getSchema();
258
- return struct.memberNames.includes(member);
259
- }
260
- return false;
261
- }
262
- getMemberSchema(member) {
263
- if (this.isStructSchema()) {
264
- const struct = this.getSchema();
265
- if (!struct.memberNames.includes(member)) {
266
- throw new Error(`@smithy/core/schema - ${this.getName(true)} has no member=${member}.`);
267
- }
268
- const i = struct.memberNames.indexOf(member);
189
+ getMemberSchema(memberName) {
190
+ const struct = this.getSchema();
191
+ if (this.isStructSchema() && struct.memberNames.includes(memberName)) {
192
+ const i = struct.memberNames.indexOf(memberName);
269
193
  const memberSchema = struct.memberList[i];
270
- return this.memberFrom(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], member);
194
+ return member(Array.isArray(memberSchema) ? memberSchema : [memberSchema, 0], memberName);
271
195
  }
272
196
  if (this.isDocumentSchema()) {
273
- return this.memberFrom([SCHEMA.DOCUMENT, 0], member);
197
+ return member([15, 0], memberName);
274
198
  }
275
- throw new Error(`@smithy/core/schema - ${this.getName(true)} has no members.`);
199
+ throw new Error(`@smithy/core/schema - ${this.getName(true)} has no no member=${memberName}.`);
276
200
  }
277
201
  getMemberSchemas() {
278
202
  const buffer = {};
@@ -303,35 +227,17 @@ export class NormalizedSchema {
303
227
  }
304
228
  const struct = this.getSchema();
305
229
  for (let i = 0; i < struct.memberNames.length; ++i) {
306
- yield [struct.memberNames[i], this.memberFrom([struct.memberList[i], 0], struct.memberNames[i])];
307
- }
308
- }
309
- memberFrom(memberSchema, memberName) {
310
- if (memberSchema instanceof NormalizedSchema) {
311
- return Object.assign(memberSchema, {
312
- memberName,
313
- _isMemberSchema: true,
314
- });
315
- }
316
- return new NormalizedSchema(memberSchema, memberName);
317
- }
318
- getSchemaName() {
319
- const schema = this.getSchema();
320
- if (typeof schema === "number") {
321
- const _schema = 0b0011_1111 & schema;
322
- const container = 0b1100_0000 & schema;
323
- const type = Object.entries(SCHEMA).find(([, value]) => {
324
- return value === _schema;
325
- })?.[0] ?? "Unknown";
326
- switch (container) {
327
- case SCHEMA.MAP_MODIFIER:
328
- return `${type}Map`;
329
- case SCHEMA.LIST_MODIFIER:
330
- return `${type}List`;
331
- case 0:
332
- return type;
333
- }
230
+ yield [struct.memberNames[i], member([struct.memberList[i], 0], struct.memberNames[i])];
334
231
  }
335
- return "Unknown";
336
232
  }
337
233
  }
234
+ function member(memberSchema, memberName) {
235
+ if (memberSchema instanceof NormalizedSchema) {
236
+ return Object.assign(memberSchema, {
237
+ memberName,
238
+ _isMemberSchema: true,
239
+ });
240
+ }
241
+ const internalCtorAccess = NormalizedSchema;
242
+ return new internalCtorAccess(memberSchema, memberName);
243
+ }
@@ -0,0 +1,22 @@
1
+ export function translateTraits(indicator) {
2
+ if (typeof indicator === "object") {
3
+ return indicator;
4
+ }
5
+ indicator = indicator | 0;
6
+ const traits = {};
7
+ let i = 0;
8
+ for (const trait of [
9
+ "httpLabel",
10
+ "idempotent",
11
+ "idempotencyToken",
12
+ "sensitive",
13
+ "httpPayload",
14
+ "httpResponseCode",
15
+ "httpQueryParams",
16
+ ]) {
17
+ if (((indicator >> i++) & 1) === 1) {
18
+ traits[trait] = 1;
19
+ }
20
+ }
21
+ return traits;
22
+ }
@@ -4,6 +4,7 @@ export * from "./generateIdempotencyToken";
4
4
  export * from "./lazy-json";
5
5
  export * from "./parse-utils";
6
6
  export * from "./quote-header";
7
+ export * from "./schema-serde-lib/schema-date-utils";
7
8
  export * from "./split-every";
8
9
  export * from "./split-header";
9
10
  export * from "./value/NumericValue";
@@ -0,0 +1,110 @@
1
+ const ddd = `(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)(?:[ne|u?r]?s?day)?`;
2
+ const mmm = `(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)`;
3
+ const time = `(\\d?\\d):(\\d{2}):(\\d{2})(?:\\.(\\d+))?`;
4
+ const date = `(\\d?\\d)`;
5
+ const year = `(\\d{4})`;
6
+ const RFC3339_WITH_OFFSET = new RegExp(/^(\d{4})-(\d\d)-(\d\d)[tT](\d\d):(\d\d):(\d\d)(\.(\d+))?(([-+]\d\d:\d\d)|[zZ])$/);
7
+ const IMF_FIXDATE = new RegExp(`^${ddd}, ${date} ${mmm} ${year} ${time} GMT$`);
8
+ const RFC_850_DATE = new RegExp(`^${ddd}, ${date}-${mmm}-(\\d\\d) ${time} GMT$`);
9
+ const ASC_TIME = new RegExp(`^${ddd} ${mmm} ( [1-9]|\\d\\d) ${time} ${year}$`);
10
+ const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
11
+ export const _parseEpochTimestamp = (value) => {
12
+ if (value == null) {
13
+ return void 0;
14
+ }
15
+ let num = NaN;
16
+ if (typeof value === "number") {
17
+ num = value;
18
+ }
19
+ else if (typeof value === "string") {
20
+ if (!/^-?\d*\.?\d+$/.test(value)) {
21
+ throw new TypeError(`parseEpochTimestamp - numeric string invalid.`);
22
+ }
23
+ num = Number.parseFloat(value);
24
+ }
25
+ else if (typeof value === "object" && value.tag === 1) {
26
+ num = value.value;
27
+ }
28
+ if (isNaN(num) || Math.abs(num) === Infinity) {
29
+ throw new TypeError("Epoch timestamps must be valid finite numbers.");
30
+ }
31
+ return new Date(Math.round(num * 1000));
32
+ };
33
+ export const _parseRfc3339DateTimeWithOffset = (value) => {
34
+ if (value == null) {
35
+ return void 0;
36
+ }
37
+ if (typeof value !== "string") {
38
+ throw new TypeError("RFC3339 timestamps must be strings");
39
+ }
40
+ const matches = RFC3339_WITH_OFFSET.exec(value);
41
+ if (!matches) {
42
+ throw new TypeError(`Invalid RFC3339 timestamp format ${value}`);
43
+ }
44
+ const [, yearStr, monthStr, dayStr, hours, minutes, seconds, , ms, offsetStr] = matches;
45
+ range(monthStr, 1, 12);
46
+ range(dayStr, 1, 31);
47
+ range(hours, 0, 23);
48
+ range(minutes, 0, 59);
49
+ range(seconds, 0, 60);
50
+ const date = new Date();
51
+ date.setUTCFullYear(Number(yearStr), Number(monthStr) - 1, Number(dayStr));
52
+ date.setUTCHours(Number(hours));
53
+ date.setUTCMinutes(Number(minutes));
54
+ date.setUTCSeconds(Number(seconds));
55
+ date.setUTCMilliseconds(Number(ms) ? Math.round(parseFloat(`0.${ms}`) * 1000) : 0);
56
+ if (offsetStr.toUpperCase() != "Z") {
57
+ const [, sign, offsetH, offsetM] = /([+-])(\d\d):(\d\d)/.exec(offsetStr) || [void 0, "+", 0, 0];
58
+ const scalar = sign === "-" ? 1 : -1;
59
+ date.setTime(date.getTime() + scalar * (Number(offsetH) * 60 * 60 * 1000 + Number(offsetM) * 60 * 1000));
60
+ }
61
+ return date;
62
+ };
63
+ export const _parseRfc7231DateTime = (value) => {
64
+ if (value == null) {
65
+ return void 0;
66
+ }
67
+ if (typeof value !== "string") {
68
+ throw new TypeError("RFC7231 timestamps must be strings.");
69
+ }
70
+ let day;
71
+ let month;
72
+ let year;
73
+ let hour;
74
+ let minute;
75
+ let second;
76
+ let fraction;
77
+ let matches;
78
+ if ((matches = IMF_FIXDATE.exec(value))) {
79
+ [, day, month, year, hour, minute, second, fraction] = matches;
80
+ }
81
+ else if ((matches = RFC_850_DATE.exec(value))) {
82
+ [, day, month, year, hour, minute, second, fraction] = matches;
83
+ year = (Number(year) + 1900).toString();
84
+ }
85
+ else if ((matches = ASC_TIME.exec(value))) {
86
+ [, month, day, hour, minute, second, fraction, year] = matches;
87
+ }
88
+ if (year && second) {
89
+ const date = new Date();
90
+ date.setUTCFullYear(Number(year));
91
+ date.setUTCMonth(months.indexOf(month));
92
+ range(day, 1, 31);
93
+ date.setUTCDate(Number(day));
94
+ range(hour, 0, 23);
95
+ date.setUTCHours(Number(hour));
96
+ range(minute, 0, 59);
97
+ date.setUTCMinutes(Number(minute));
98
+ range(second, 0, 60);
99
+ date.setUTCSeconds(Number(second));
100
+ date.setUTCMilliseconds(fraction ? Math.round(parseFloat(`0.${fraction}`) * 1000) : 0);
101
+ return date;
102
+ }
103
+ throw new TypeError(`Invalid RFC7231 date-time value ${value}.`);
104
+ };
105
+ function range(v, min, max) {
106
+ const _v = Number(v);
107
+ if (_v < min || _v > max) {
108
+ throw new Error(`Value ${_v} out of range [${min}, ${max}]`);
109
+ }
110
+ }
@@ -1,25 +1,12 @@
1
+ const format = /^-?\d*(\.\d+)?$/;
1
2
  export class NumericValue {
2
3
  string;
3
4
  type;
4
5
  constructor(string, type) {
5
6
  this.string = string;
6
7
  this.type = type;
7
- let dot = 0;
8
- for (let i = 0; i < string.length; ++i) {
9
- const char = string.charCodeAt(i);
10
- if (i === 0 && char === 45) {
11
- continue;
12
- }
13
- if (char === 46) {
14
- if (dot) {
15
- throw new Error("@smithy/core/serde - NumericValue must contain at most one decimal point.");
16
- }
17
- dot = 1;
18
- continue;
19
- }
20
- if (char < 48 || char > 57) {
21
- throw new Error(`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`);
22
- }
8
+ if (!format.test(string)) {
9
+ throw new Error(`@smithy/core/serde - NumericValue must only contain [0-9], at most one decimal point ".", and an optional negation prefix "-".`);
23
10
  }
24
11
  }
25
12
  toString() {
@@ -30,16 +17,7 @@ export class NumericValue {
30
17
  return false;
31
18
  }
32
19
  const _nv = object;
33
- const prototypeMatch = NumericValue.prototype.isPrototypeOf(object);
34
- if (prototypeMatch) {
35
- return prototypeMatch;
36
- }
37
- if (typeof _nv.string === "string" &&
38
- typeof _nv.type === "string" &&
39
- _nv.constructor?.name?.endsWith("NumericValue")) {
40
- return true;
41
- }
42
- return prototypeMatch;
20
+ return NumericValue.prototype.isPrototypeOf(object) || (_nv.type === "bigDecimal" && format.test(_nv.string));
43
21
  }
44
22
  }
45
23
  export function nv(input) {
@@ -9,4 +9,5 @@ export * from "./schemas/Schema";
9
9
  export * from "./schemas/SimpleSchema";
10
10
  export * from "./schemas/StructureSchema";
11
11
  export * from "./schemas/sentinels";
12
+ export * from "./schemas/translateTraits";
12
13
  export * from "./TypeRegistry";
@@ -1,4 +1,4 @@
1
- import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraits, SchemaTraitsObject } from "@smithy/types";
1
+ import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISchema, SchemaRef, SchemaTraitsObject } from "@smithy/types";
2
2
  /**
3
3
  * Wraps both class instances, numeric sentinel values, and member schema pairs.
4
4
  * Presents a consistent interface for interacting with polymorphic schema representations.
@@ -7,7 +7,7 @@ import type { MemberSchema, NormalizedSchema as INormalizedSchema, Schema as ISc
7
7
  */
8
8
  export declare class NormalizedSchema implements INormalizedSchema {
9
9
  readonly ref: SchemaRef;
10
- private memberName?;
10
+ private readonly memberName?;
11
11
  static readonly symbol: unique symbol;
12
12
  protected readonly symbol: symbol;
13
13
  private readonly name;
@@ -26,11 +26,6 @@ export declare class NormalizedSchema implements INormalizedSchema {
26
26
  * Static constructor that attempts to avoid wrapping a NormalizedSchema within another.
27
27
  */
28
28
  static of(ref: SchemaRef): NormalizedSchema;
29
- /**
30
- * @param indicator - numeric indicator for preset trait combination.
31
- * @returns equivalent trait object.
32
- */
33
- static translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
34
29
  /**
35
30
  * @returns the underlying non-normalized schema.
36
31
  */
@@ -42,11 +37,9 @@ export declare class NormalizedSchema implements INormalizedSchema {
42
37
  getName(withNamespace?: boolean): string | undefined;
43
38
  /**
44
39
  * @returns the member name if the schema is a member schema.
45
- * @throws Error when the schema isn't a member schema.
46
40
  */
47
41
  getMemberName(): string;
48
42
  isMemberSchema(): boolean;
49
- isUnitSchema(): boolean;
50
43
  /**
51
44
  * boolean methods on this class help control flow in shape serialization and deserialization.
52
45
  */
@@ -55,6 +48,7 @@ export declare class NormalizedSchema implements INormalizedSchema {
55
48
  isStructSchema(): boolean;
56
49
  isBlobSchema(): boolean;
57
50
  isTimestampSchema(): boolean;
51
+ isUnitSchema(): boolean;
58
52
  isDocumentSchema(): boolean;
59
53
  isStringSchema(): boolean;
60
54
  isBooleanSchema(): boolean;
@@ -94,20 +88,15 @@ export declare class NormalizedSchema implements INormalizedSchema {
94
88
  * @throws Error if the schema is not a Map, List, nor Document.
95
89
  */
96
90
  getValueSchema(): NormalizedSchema;
97
- /**
98
- * @param member - to query.
99
- * @returns whether there is a memberSchema with the given member name. False if not a structure (or union).
100
- */
101
- hasMemberSchema(member: string): boolean;
102
91
  /**
103
92
  * @returns the NormalizedSchema for the given member name. The returned instance will return true for `isMemberSchema()`
104
93
  * and will have the member name given.
105
- * @param member - which member to retrieve and wrap.
94
+ * @param memberName - which member to retrieve and wrap.
106
95
  *
107
96
  * @throws Error if member does not exist or the schema is neither a document nor structure.
108
97
  * Note that errors are assumed to be structures and unions are considered structures for these purposes.
109
98
  */
110
- getMemberSchema(member: string): NormalizedSchema;
99
+ getMemberSchema(memberName: string): NormalizedSchema;
111
100
  /**
112
101
  * This can be used for checking the members as a hashmap.
113
102
  * Prefer the structIterator method for iteration.
@@ -131,12 +120,4 @@ export declare class NormalizedSchema implements INormalizedSchema {
131
120
  * This avoids the overhead of calling Object.entries(ns.getMemberSchemas()).
132
121
  */
133
122
  structIterator(): Generator<[string, NormalizedSchema], undefined, undefined>;
134
- /**
135
- * Creates a normalized member schema from the given schema and member name.
136
- */
137
- private memberFrom;
138
- /**
139
- * @returns a last-resort human-readable name for the schema if it has no other identifiers.
140
- */
141
- private getSchemaName;
142
123
  }
@@ -2,6 +2,8 @@ import type { BigDecimalSchema, BigIntegerSchema, BlobSchema, BooleanSchema, Doc
2
2
  /**
3
3
  * Schema sentinel runtime values.
4
4
  * @alpha
5
+ *
6
+ * @deprecated use inline numbers with type annotation to save space.
5
7
  */
6
8
  export declare const SCHEMA: {
7
9
  BLOB: BlobSchema;
@@ -0,0 +1,7 @@
1
+ import type { SchemaTraits, SchemaTraitsObject } from "@smithy/types";
2
+ /**
3
+ * @internal
4
+ * @param indicator - numeric indicator for preset trait combination.
5
+ * @returns equivalent trait object.
6
+ */
7
+ export declare function translateTraits(indicator: SchemaTraits): SchemaTraitsObject;
@@ -4,6 +4,7 @@ export * from "./generateIdempotencyToken";
4
4
  export * from "./lazy-json";
5
5
  export * from "./parse-utils";
6
6
  export * from "./quote-header";
7
+ export * from "./schema-serde-lib/schema-date-utils";
7
8
  export * from "./split-every";
8
9
  export * from "./split-header";
9
10
  export * from "./value/NumericValue";