@smithy/core 3.20.8 → 3.21.1

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.
@@ -126,6 +126,11 @@ class EventStreamSerde {
126
126
  [unionMember]: out,
127
127
  };
128
128
  }
129
+ if (body.byteLength === 0) {
130
+ return {
131
+ [unionMember]: {},
132
+ };
133
+ }
129
134
  }
130
135
  return {
131
136
  [unionMember]: await this.deserializer.read(eventStreamSchema, body),
@@ -240,6 +240,9 @@ function translateTraits(indicator) {
240
240
  return traits;
241
241
  }
242
242
 
243
+ const anno = {
244
+ it: Symbol.for("@smithy/nor-struct-it"),
245
+ };
243
246
  class NormalizedSchema {
244
247
  ref;
245
248
  memberName;
@@ -395,10 +398,7 @@ class NormalizedSchema {
395
398
  return !!streaming || this.getSchema() === 42;
396
399
  }
397
400
  isIdempotencyToken() {
398
- const match = (traits) => (traits & 0b0100) === 0b0100 ||
399
- !!traits?.idempotencyToken;
400
- const { normalizedTraits, traits, memberTraits } = this;
401
- return match(normalizedTraits) || match(traits) || match(memberTraits);
401
+ return !!this.getMergedTraits().idempotencyToken;
402
402
  }
403
403
  getMergedTraits() {
404
404
  return (this.normalizedTraits ??
@@ -479,9 +479,19 @@ class NormalizedSchema {
479
479
  throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
480
480
  }
481
481
  const struct = this.getSchema();
482
- for (let i = 0; i < struct[4].length; ++i) {
483
- yield [struct[4][i], member([struct[5][i], 0], struct[4][i])];
482
+ const z = struct[4].length;
483
+ let it = struct[anno.it];
484
+ if (it && z === it.length) {
485
+ yield* it;
486
+ return;
487
+ }
488
+ it = Array(z);
489
+ for (let i = 0; i < z; ++i) {
490
+ const k = struct[4][i];
491
+ const v = member([struct[5][i], 0], k);
492
+ yield (it[i] = [k, v]);
484
493
  }
494
+ struct[anno.it] = it;
485
495
  }
486
496
  }
487
497
  function member(memberSchema, memberName) {
@@ -123,6 +123,11 @@ export class EventStreamSerde {
123
123
  [unionMember]: out,
124
124
  };
125
125
  }
126
+ if (body.byteLength === 0) {
127
+ return {
128
+ [unionMember]: {},
129
+ };
130
+ }
126
131
  }
127
132
  return {
128
133
  [unionMember]: await this.deserializer.read(eventStreamSchema, body),
@@ -1,5 +1,8 @@
1
1
  import { deref } from "../deref";
2
2
  import { translateTraits } from "./translateTraits";
3
+ const anno = {
4
+ it: Symbol.for("@smithy/nor-struct-it"),
5
+ };
3
6
  export class NormalizedSchema {
4
7
  ref;
5
8
  memberName;
@@ -155,10 +158,7 @@ export class NormalizedSchema {
155
158
  return !!streaming || this.getSchema() === 42;
156
159
  }
157
160
  isIdempotencyToken() {
158
- const match = (traits) => (traits & 0b0100) === 0b0100 ||
159
- !!traits?.idempotencyToken;
160
- const { normalizedTraits, traits, memberTraits } = this;
161
- return match(normalizedTraits) || match(traits) || match(memberTraits);
161
+ return !!this.getMergedTraits().idempotencyToken;
162
162
  }
163
163
  getMergedTraits() {
164
164
  return (this.normalizedTraits ??
@@ -239,9 +239,19 @@ export class NormalizedSchema {
239
239
  throw new Error("@smithy/core/schema - cannot iterate non-struct schema.");
240
240
  }
241
241
  const struct = this.getSchema();
242
- for (let i = 0; i < struct[4].length; ++i) {
243
- yield [struct[4][i], member([struct[5][i], 0], struct[4][i])];
242
+ const z = struct[4].length;
243
+ let it = struct[anno.it];
244
+ if (it && z === it.length) {
245
+ yield* it;
246
+ return;
247
+ }
248
+ it = Array(z);
249
+ for (let i = 0; i < z; ++i) {
250
+ const k = struct[4][i];
251
+ const v = member([struct[5][i], 0], k);
252
+ yield (it[i] = [k, v]);
244
253
  }
254
+ struct[anno.it] = it;
245
255
  }
246
256
  }
247
257
  function member(memberSchema, memberName) {
@@ -63,7 +63,6 @@ export declare class NormalizedSchema implements INormalizedSchema {
63
63
  isBigDecimalSchema(): boolean;
64
64
  isStreaming(): boolean;
65
65
  /**
66
- * This is a shortcut to avoid calling `getMergedTraits().idempotencyToken` on every string.
67
66
  * @returns whether the schema has the idempotencyToken trait.
68
67
  */
69
68
  isIdempotencyToken(): boolean;
@@ -63,7 +63,6 @@ export declare class NormalizedSchema implements INormalizedSchema {
63
63
  isBigDecimalSchema(): boolean;
64
64
  isStreaming(): boolean;
65
65
  /**
66
- * This is a shortcut to avoid calling `getMergedTraits().idempotencyToken` on every string.
67
66
  * @returns whether the schema has the idempotencyToken trait.
68
67
  */
69
68
  isIdempotencyToken(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smithy/core",
3
- "version": "3.20.8",
3
+ "version": "3.21.1",
4
4
  "scripts": {
5
5
  "build": "yarn lint && concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
6
6
  "build:cjs": "node ../../scripts/inline core",