aws-cdk 2.1135.1 → 2.1136.0

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/lib/index.js CHANGED
@@ -3695,7 +3695,7 @@ var require_semver2 = __commonJS({
3695
3695
  // ../@aws-cdk/cloud-assembly-schema/cli-version.json
3696
3696
  var require_cli_version = __commonJS({
3697
3697
  "../@aws-cdk/cloud-assembly-schema/cli-version.json"(exports2, module2) {
3698
- module2.exports = { version: "2.1135.1" };
3698
+ module2.exports = { version: "2.1136.0" };
3699
3699
  }
3700
3700
  });
3701
3701
 
@@ -35739,7 +35739,7 @@ var init_package = __esm({
35739
35739
  "../../node_modules/@aws-sdk/nested-clients/package.json"() {
35740
35740
  package_default = {
35741
35741
  name: "@aws-sdk/nested-clients",
35742
- version: "3.997.38",
35742
+ version: "3.997.41",
35743
35743
  description: "Nested clients for AWS SDK packages.",
35744
35744
  homepage: "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/nested-clients",
35745
35745
  license: "Apache-2.0",
@@ -35839,7 +35839,7 @@ var init_package = __esm({
35839
35839
  "test:watch": "yarn g:vitest watch"
35840
35840
  },
35841
35841
  dependencies: {
35842
- "@aws-sdk/core": "^3.977.3",
35842
+ "@aws-sdk/core": "^3.977.6",
35843
35843
  "@aws-sdk/signature-v4-multi-region": "^3.996.43",
35844
35844
  "@aws-sdk/types": "^3.974.2",
35845
35845
  "@smithy/core": "^3.31.1",
@@ -37558,30 +37558,54 @@ var init_UnionSerde = __esm({
37558
37558
  }
37559
37559
  });
37560
37560
 
37561
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js
37562
+ function detectBufferParsing() {
37563
+ if (canParseBuffer === void 0) {
37564
+ try {
37565
+ if (typeof Buffer !== "function") {
37566
+ canParseBuffer = false;
37567
+ } else {
37568
+ const result2 = JSON.parse(Buffer.from([123, 125]));
37569
+ canParseBuffer = result2 !== null && typeof result2 === "object";
37570
+ }
37571
+ } catch {
37572
+ canParseBuffer = false;
37573
+ }
37574
+ }
37575
+ return canParseBuffer;
37576
+ }
37577
+ var canParseBuffer;
37578
+ var init_detectBufferParsing = __esm({
37579
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js"() {
37580
+ __name(detectBufferParsing, "detectBufferParsing");
37581
+ }
37582
+ });
37583
+
37561
37584
  // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js
37562
37585
  function jsonReviver(key, value2, context) {
37563
37586
  if (context?.source) {
37564
37587
  const numericString = context.source;
37565
37588
  if (typeof value2 === "number") {
37566
37589
  const inSafeRange = value2 <= Number.MAX_SAFE_INTEGER && value2 >= Number.MIN_SAFE_INTEGER;
37567
- if (!inSafeRange || numericString !== String(value2)) {
37568
- if (inSafeRange && /[eE]/.test(numericString) && String(Number(numericString)) === String(value2)) {
37590
+ if (inSafeRange) {
37591
+ if (isRepresentable(numericString, value2)) {
37569
37592
  return value2;
37570
37593
  }
37571
- if (isFractionalNumeric(numericString)) {
37594
+ return new NumericValue(numericString, "bigDecimal");
37595
+ } else {
37596
+ if (isFractionalBigNumeric(numericString)) {
37572
37597
  return new NumericValue(numericString, "bigDecimal");
37573
- } else {
37574
- if (/[eE]/.test(numericString)) {
37575
- return BigInt(Number(numericString));
37576
- }
37577
- return BigInt(numericString);
37578
37598
  }
37599
+ if (/[eE]/.test(numericString)) {
37600
+ return expandExponentToBigInt(numericString);
37601
+ }
37602
+ return BigInt(numericString);
37579
37603
  }
37580
37604
  }
37581
37605
  }
37582
37606
  return value2;
37583
37607
  }
37584
- function isFractionalNumeric(s2) {
37608
+ function isFractionalBigNumeric(s2) {
37585
37609
  const dotIndex = s2.indexOf(".");
37586
37610
  if (dotIndex === -1) {
37587
37611
  return false;
@@ -37594,11 +37618,91 @@ function isFractionalNumeric(s2) {
37594
37618
  const exp = parseInt(s2.slice(eIndex + 1), 10);
37595
37619
  return exp < fracDigits;
37596
37620
  }
37621
+ function isRepresentable(numericString, value2) {
37622
+ if (numericString === String(value2)) {
37623
+ return true;
37624
+ }
37625
+ if (Object.is(value2, -0)) {
37626
+ return true;
37627
+ }
37628
+ if (/[eE]/.test(numericString)) {
37629
+ return expandToDecimal(numericString) === expandToDecimal(String(value2));
37630
+ }
37631
+ const normalized = numericString.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
37632
+ const canonical = String(value2);
37633
+ if (normalized === canonical) {
37634
+ return true;
37635
+ }
37636
+ if (/[eE]/.test(canonical)) {
37637
+ return normalized === expandToDecimal(canonical);
37638
+ }
37639
+ return false;
37640
+ }
37641
+ function expandToDecimal(s2) {
37642
+ const negative = s2.startsWith("-");
37643
+ const abs = negative ? s2.slice(1) : s2;
37644
+ const eIndex = abs.search(/[eE]/);
37645
+ let result2;
37646
+ if (eIndex === -1) {
37647
+ result2 = abs;
37648
+ } else {
37649
+ const exp = parseInt(abs.slice(eIndex + 1), 10);
37650
+ const mantissa = abs.slice(0, eIndex);
37651
+ const dotIndex = mantissa.indexOf(".");
37652
+ let digits;
37653
+ let intLen;
37654
+ if (dotIndex === -1) {
37655
+ digits = mantissa;
37656
+ intLen = mantissa.length;
37657
+ } else {
37658
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
37659
+ intLen = dotIndex;
37660
+ }
37661
+ digits = digits.replace(/0+$/, "") || "0";
37662
+ const newDotPos = intLen + exp;
37663
+ if (digits === "0") {
37664
+ result2 = "0";
37665
+ } else if (newDotPos <= 0) {
37666
+ result2 = "0." + "0".repeat(-newDotPos) + digits;
37667
+ } else if (newDotPos >= digits.length) {
37668
+ result2 = digits + "0".repeat(newDotPos - digits.length);
37669
+ } else {
37670
+ result2 = digits.slice(0, newDotPos) + "." + digits.slice(newDotPos);
37671
+ }
37672
+ }
37673
+ if (result2.includes(".")) {
37674
+ result2 = result2.replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
37675
+ }
37676
+ return (negative ? "-" : "") + result2;
37677
+ }
37678
+ function expandExponentToBigInt(s2) {
37679
+ const eIndex = s2.search(/[eE]/);
37680
+ const exp = parseInt(s2.slice(eIndex + 1), 10);
37681
+ const negative = s2.startsWith("-");
37682
+ const mantissa = s2.slice(negative ? 1 : 0, eIndex);
37683
+ const dotIndex = mantissa.indexOf(".");
37684
+ let digits;
37685
+ let shift;
37686
+ if (dotIndex === -1) {
37687
+ digits = mantissa;
37688
+ shift = exp;
37689
+ } else {
37690
+ digits = mantissa.slice(0, dotIndex) + mantissa.slice(dotIndex + 1);
37691
+ const fracDigits = mantissa.length - dotIndex - 1;
37692
+ shift = exp - fracDigits;
37693
+ }
37694
+ digits = digits.replace(/0+$/, "") || "0";
37695
+ const result2 = BigInt(digits) * 10n ** BigInt(shift + (mantissa.replace(".", "").length - digits.length));
37696
+ return negative ? -result2 : result2;
37697
+ }
37597
37698
  var init_jsonReviver = __esm({
37598
37699
  "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReviver.js"() {
37599
37700
  init_serde();
37600
37701
  __name(jsonReviver, "jsonReviver");
37601
- __name(isFractionalNumeric, "isFractionalNumeric");
37702
+ __name(isFractionalBigNumeric, "isFractionalBigNumeric");
37703
+ __name(isRepresentable, "isRepresentable");
37704
+ __name(expandToDecimal, "expandToDecimal");
37705
+ __name(expandExponentToBigInt, "expandExponentToBigInt");
37602
37706
  }
37603
37707
  });
37604
37708
 
@@ -37660,29 +37764,6 @@ var init_common2 = __esm({
37660
37764
  }
37661
37765
  });
37662
37766
 
37663
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js
37664
- function detectBufferParsing() {
37665
- if (canParseBuffer === void 0) {
37666
- try {
37667
- if (typeof Buffer !== "function") {
37668
- canParseBuffer = false;
37669
- } else {
37670
- const result2 = JSON.parse(Buffer.from([123, 125]));
37671
- canParseBuffer = result2 !== null && typeof result2 === "object";
37672
- }
37673
- } catch {
37674
- canParseBuffer = false;
37675
- }
37676
- }
37677
- return canParseBuffer;
37678
- }
37679
- var canParseBuffer;
37680
- var init_detectBufferParsing = __esm({
37681
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/detectBufferParsing.js"() {
37682
- __name(detectBufferParsing, "detectBufferParsing");
37683
- }
37684
- });
37685
-
37686
37767
  // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/parseJsonBody.js
37687
37768
  async function parseJsonBody(streamBody, context, schema) {
37688
37769
  let parsingInput;
@@ -37788,23 +37869,23 @@ var init_writeKey = __esm({
37788
37869
  }
37789
37870
  });
37790
37871
 
37791
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js
37792
- var JsonShapeDeserializer;
37793
- var init_JsonShapeDeserializer = __esm({
37794
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js"() {
37872
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js
37873
+ var JsonShapeDeserializer2;
37874
+ var init_JsonShapeDeserializer2 = __esm({
37875
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js"() {
37795
37876
  init_protocols();
37796
37877
  init_schema4();
37797
37878
  init_serde();
37798
- init_serde();
37799
37879
  init_ConfigurableSerdeContext();
37800
37880
  init_UnionSerde();
37881
+ init_detectBufferParsing();
37801
37882
  init_jsonReviver();
37802
37883
  init_needsReviver();
37803
37884
  init_parseJsonBody();
37804
37885
  init_writeKey();
37805
- JsonShapeDeserializer = class extends SerdeContextConfig {
37886
+ JsonShapeDeserializer2 = class extends SerdeContextConfig {
37806
37887
  static {
37807
- __name(this, "JsonShapeDeserializer");
37888
+ __name(this, "JsonShapeDeserializer2");
37808
37889
  }
37809
37890
  settings;
37810
37891
  constructor(settings) {
@@ -37813,7 +37894,22 @@ var init_JsonShapeDeserializer = __esm({
37813
37894
  }
37814
37895
  async read(schema, data) {
37815
37896
  const reviver = needsReviver(schema) ? jsonReviver : void 0;
37816
- return this._read(schema, typeof data === "string" ? JSON.parse(data, reviver) : await parseJsonBody(data, this.serdeContext, schema));
37897
+ let parsed;
37898
+ if (typeof data === "string") {
37899
+ if (data.length === 0) {
37900
+ return {};
37901
+ }
37902
+ parsed = JSON.parse(data, reviver);
37903
+ } else if (data instanceof Uint8Array && detectBufferParsing()) {
37904
+ if (data.byteLength === 0) {
37905
+ return {};
37906
+ }
37907
+ const buf2 = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
37908
+ parsed = JSON.parse(buf2, reviver);
37909
+ } else {
37910
+ parsed = await parseJsonBody(data, this.serdeContext, schema);
37911
+ }
37912
+ return this._read(schema, parsed);
37817
37913
  }
37818
37914
  readObject(schema, data) {
37819
37915
  return this._read(schema, data);
@@ -37823,62 +37919,29 @@ var init_JsonShapeDeserializer = __esm({
37823
37919
  const ns = NormalizedSchema.of(schema);
37824
37920
  if (isObject3) {
37825
37921
  if (ns.isStructSchema()) {
37826
- const record = value2;
37827
- const union = ns.isUnionSchema();
37828
- const out = {};
37829
- let nameMap = void 0;
37830
- const { jsonName } = this.settings;
37831
- if (jsonName) {
37832
- nameMap = {};
37833
- }
37834
- let unionSerde;
37835
- if (union) {
37836
- unionSerde = new UnionSerde(record, out);
37837
- }
37838
- for (const [memberName, memberSchema] of ns.structIterator()) {
37839
- let fromKey = memberName;
37840
- if (jsonName) {
37841
- fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
37842
- nameMap[fromKey] = memberName;
37843
- }
37844
- if (union) {
37845
- unionSerde.mark(fromKey);
37846
- }
37847
- if (record[fromKey] != null) {
37848
- out[memberName] = this._read(memberSchema, record[fromKey]);
37849
- }
37850
- }
37851
- if (union) {
37852
- unionSerde.writeUnknown();
37853
- } else if (typeof record.__type === "string") {
37854
- for (const k6 in record) {
37855
- const v = record[k6];
37856
- const t = jsonName ? nameMap[k6] ?? k6 : k6;
37857
- if (!(t in out)) {
37858
- out[t] = v;
37859
- }
37860
- }
37861
- }
37862
- return out;
37922
+ return this._readStruct(ns, value2);
37863
37923
  }
37864
37924
  if (Array.isArray(value2) && ns.isListSchema()) {
37865
37925
  const listMember = ns.getValueSchema();
37866
- const out = [];
37867
- for (const item of value2) {
37868
- out.push(this._read(listMember, item));
37926
+ if (this.needsTransform(listMember)) {
37927
+ for (let i6 = 0; i6 < value2.length; ++i6) {
37928
+ value2[i6] = this._read(listMember, value2[i6]);
37929
+ }
37869
37930
  }
37870
- return out;
37931
+ return value2;
37871
37932
  }
37872
37933
  if (ns.isMapSchema()) {
37873
37934
  const mapMember = ns.getValueSchema();
37874
- const out = {};
37875
- for (const _k in value2) {
37876
- if (_k === "__proto__") {
37877
- writeKey(out);
37935
+ const map3 = value2;
37936
+ if (this.needsTransform(mapMember)) {
37937
+ for (const k6 in map3) {
37938
+ if (k6 === "__proto__") {
37939
+ writeKey(map3);
37940
+ }
37941
+ map3[k6] = this._read(mapMember, map3[k6]);
37878
37942
  }
37879
- out[_k] = this._read(mapMember, value2[_k]);
37880
37943
  }
37881
- return out;
37944
+ return map3;
37882
37945
  }
37883
37946
  }
37884
37947
  if (ns.isBlobSchema() && typeof value2 === "string") {
@@ -37932,292 +37995,723 @@ var init_JsonShapeDeserializer = __esm({
37932
37995
  }
37933
37996
  if (ns.isDocumentSchema()) {
37934
37997
  if (isObject3) {
37935
- const out = Array.isArray(value2) ? [] : {};
37936
- for (const k6 in value2) {
37937
- if (k6 === "__proto__") {
37938
- writeKey(out);
37998
+ if (Array.isArray(value2)) {
37999
+ for (let i6 = 0; i6 < value2.length; ++i6) {
38000
+ const v = value2[i6];
38001
+ if (!(v instanceof NumericValue)) {
38002
+ value2[i6] = this._read(ns, v);
38003
+ }
37939
38004
  }
37940
- const v = value2[k6];
37941
- if (v instanceof NumericValue) {
37942
- out[k6] = v;
37943
- } else {
37944
- out[k6] = this._read(ns, v);
38005
+ } else {
38006
+ const doc = value2;
38007
+ for (const k6 in doc) {
38008
+ if (k6 === "__proto__") {
38009
+ writeKey(doc);
38010
+ }
38011
+ const v = doc[k6];
38012
+ if (!(v instanceof NumericValue)) {
38013
+ doc[k6] = this._read(ns, v);
38014
+ }
37945
38015
  }
37946
38016
  }
37947
- return out;
37948
- } else {
37949
- return structuredClone(value2);
37950
38017
  }
37951
38018
  }
37952
38019
  return value2;
37953
38020
  }
38021
+ _readStruct(ns, record) {
38022
+ const union = ns.isUnionSchema();
38023
+ const out = {};
38024
+ let nameMap;
38025
+ const hasType = typeof record.__type === "string";
38026
+ const { jsonName } = this.settings;
38027
+ if (jsonName && hasType) {
38028
+ nameMap = {};
38029
+ }
38030
+ let unionSerde;
38031
+ if (union) {
38032
+ unionSerde = new UnionSerde(record, out);
38033
+ }
38034
+ for (const [memberName, memberSchema] of ns.structIterator()) {
38035
+ let fromKey = memberName;
38036
+ if (jsonName) {
38037
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
38038
+ if (hasType) {
38039
+ nameMap[fromKey] = memberName;
38040
+ }
38041
+ }
38042
+ if (union) {
38043
+ unionSerde.mark(fromKey);
38044
+ }
38045
+ if (record[fromKey] != null) {
38046
+ out[memberName] = this._read(memberSchema, record[fromKey]);
38047
+ }
38048
+ }
38049
+ if (union) {
38050
+ unionSerde.writeUnknown();
38051
+ } else if (hasType) {
38052
+ for (const k6 in record) {
38053
+ const v = record[k6];
38054
+ const t = jsonName ? nameMap[k6] ?? k6 : k6;
38055
+ if (!(t in out)) {
38056
+ out[t] = v;
38057
+ }
38058
+ }
38059
+ }
38060
+ return out;
38061
+ }
38062
+ needsTransform(ns) {
38063
+ if (ns.isBlobSchema() || ns.isTimestampSchema() || ns.isBigIntegerSchema() || ns.isBigDecimalSchema()) {
38064
+ return true;
38065
+ }
38066
+ if (ns.isDocumentSchema() || ns.isStructSchema() || ns.isListSchema() || ns.isMapSchema()) {
38067
+ return true;
38068
+ }
38069
+ if (ns.isStringSchema() && ns.getMergedTraits().mediaType) {
38070
+ return true;
38071
+ }
38072
+ return false;
38073
+ }
37954
38074
  };
37955
38075
  }
37956
38076
  });
37957
38077
 
37958
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js
37959
- var NUMERIC_CONTROL_CHAR, JsonReplacer;
37960
- var init_jsonReplacer = __esm({
37961
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js"() {
38078
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js
38079
+ var JsonBytesStringAdapter, warned;
38080
+ var init_JsonBytesStringAdapter = __esm({
38081
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonBytesStringAdapter.js"() {
37962
38082
  init_serde();
37963
- NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
37964
- JsonReplacer = class {
38083
+ JsonBytesStringAdapter = class _JsonBytesStringAdapter extends Uint8Array {
37965
38084
  static {
37966
- __name(this, "JsonReplacer");
38085
+ __name(this, "JsonBytesStringAdapter");
37967
38086
  }
37968
- values = /* @__PURE__ */ new Map();
37969
- counter = 0;
37970
- stage = 0;
37971
- createReplacer() {
37972
- if (this.stage === 1) {
37973
- throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
38087
+ string = null;
38088
+ static allocUnsafe(bytes) {
38089
+ if (typeof Buffer === "function") {
38090
+ const buffer = Buffer.allocUnsafe(bytes);
38091
+ return new _JsonBytesStringAdapter(buffer.buffer, buffer.byteOffset, buffer.byteLength);
37974
38092
  }
37975
- if (this.stage === 2) {
37976
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
38093
+ return new _JsonBytesStringAdapter(bytes);
38094
+ }
38095
+ toString() {
38096
+ return this.s();
38097
+ }
38098
+ valueOf() {
38099
+ return this.s();
38100
+ }
38101
+ includes(searchString, position) {
38102
+ if (typeof searchString === "string") {
38103
+ return this.s().includes(searchString, position);
37977
38104
  }
37978
- this.stage = 1;
37979
- return (key, value2) => {
37980
- if (value2 instanceof NumericValue) {
37981
- const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value2.string;
37982
- this.values.set(`"${v}"`, value2.string);
37983
- return v;
37984
- }
37985
- if (typeof value2 === "bigint") {
37986
- const s2 = value2.toString();
37987
- const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s2;
37988
- this.values.set(`"${v}"`, s2);
37989
- return v;
37990
- }
37991
- return value2;
37992
- };
38105
+ return Uint8Array.prototype.includes.call(this, searchString, position);
37993
38106
  }
37994
- replaceInJson(json) {
37995
- if (this.stage === 0) {
37996
- throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
38107
+ indexOf(searchString, position) {
38108
+ if (typeof searchString === "string") {
38109
+ return this.s().indexOf(searchString, position);
37997
38110
  }
37998
- if (this.stage === 2) {
37999
- throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
38111
+ return Uint8Array.prototype.indexOf.call(this, searchString, position);
38112
+ }
38113
+ lastIndexOf(searchString, position) {
38114
+ if (typeof searchString === "string") {
38115
+ return this.s().lastIndexOf(searchString, position);
38000
38116
  }
38001
- this.stage = 2;
38002
- if (this.counter === 0) {
38003
- return json;
38117
+ const fn = Uint8Array.prototype.lastIndexOf;
38118
+ if (position !== void 0) {
38119
+ return fn.call(this, searchString, position);
38004
38120
  }
38005
- for (const [key, value2] of this.values) {
38006
- json = json.replace(key, value2);
38121
+ return fn.call(this, searchString);
38122
+ }
38123
+ startsWith(searchString, position) {
38124
+ return this.s().startsWith(searchString, position);
38125
+ }
38126
+ endsWith(searchString, endPosition) {
38127
+ return this.s().endsWith(searchString, endPosition);
38128
+ }
38129
+ match(regexp) {
38130
+ return this.s().match(regexp);
38131
+ }
38132
+ replace(searchValue, replaceValue) {
38133
+ return this.s().replace(searchValue, replaceValue);
38134
+ }
38135
+ search(regexp) {
38136
+ return this.s().search(regexp);
38137
+ }
38138
+ split(separator, limit) {
38139
+ return this.s().split(separator, limit);
38140
+ }
38141
+ substring(start, end2) {
38142
+ return this.s().substring(start, end2);
38143
+ }
38144
+ trim() {
38145
+ return this.s().trim();
38146
+ }
38147
+ trimStart() {
38148
+ return this.s().trimStart();
38149
+ }
38150
+ trimEnd() {
38151
+ return this.s().trimEnd();
38152
+ }
38153
+ charAt(pos2) {
38154
+ return this.s().charAt(pos2);
38155
+ }
38156
+ charCodeAt(index) {
38157
+ return this.s().charCodeAt(index);
38158
+ }
38159
+ padStart(maxLength, fillString) {
38160
+ return this.s().padStart(maxLength, fillString);
38161
+ }
38162
+ padEnd(maxLength, fillString) {
38163
+ return this.s().padEnd(maxLength, fillString);
38164
+ }
38165
+ repeat(count) {
38166
+ return this.s().repeat(count);
38167
+ }
38168
+ toUpperCase() {
38169
+ return this.s().toUpperCase();
38170
+ }
38171
+ toLowerCase() {
38172
+ return this.s().toLowerCase();
38173
+ }
38174
+ s() {
38175
+ if (this.string == null) {
38176
+ const n3 = Date.now();
38177
+ if (n3 > warned + 6e4) {
38178
+ console.warn("@aws-sdk/core/protocols - WARN - JsonCodec2: you have called a string method on a Uint8Array request body. It has been automatically converted to string. In a future version this will throw an error.");
38179
+ warned = n3;
38180
+ }
38181
+ this.string = toUtf8(this);
38007
38182
  }
38008
- return json;
38183
+ return this.string;
38009
38184
  }
38010
38185
  };
38186
+ warned = 0;
38011
38187
  }
38012
38188
  });
38013
38189
 
38014
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js
38015
- var JsonShapeSerializer;
38016
- var init_JsonShapeSerializer = __esm({
38017
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js"() {
38190
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js
38191
+ function alloc(size) {
38192
+ return JsonBytesStringAdapter.allocUnsafe(size);
38193
+ }
38194
+ var encoder, OPEN_BRACE, CLOSE_BRACE, OPEN_BRACKET, CLOSE_BRACKET, QUOTE, COLON, COMMA, BACKSLASH, TRUE, FALSE, NULL, ESCAPE_TABLE, INITIAL_BUFFER_SIZE2, JsonShapeSerializer2;
38195
+ var init_JsonShapeSerializer2 = __esm({
38196
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js"() {
38018
38197
  init_protocols();
38019
38198
  init_schema4();
38020
38199
  init_serde();
38021
38200
  init_ConfigurableSerdeContext();
38022
- init_jsonReplacer();
38023
- init_writeKey();
38024
- JsonShapeSerializer = class extends SerdeContextConfig {
38201
+ init_JsonBytesStringAdapter();
38202
+ encoder = new TextEncoder();
38203
+ OPEN_BRACE = 123;
38204
+ CLOSE_BRACE = 125;
38205
+ OPEN_BRACKET = 91;
38206
+ CLOSE_BRACKET = 93;
38207
+ QUOTE = 34;
38208
+ COLON = 58;
38209
+ COMMA = 44;
38210
+ BACKSLASH = 92;
38211
+ TRUE = new Uint8Array([116, 114, 117, 101]);
38212
+ FALSE = new Uint8Array([102, 97, 108, 115, 101]);
38213
+ NULL = new Uint8Array([110, 117, 108, 108]);
38214
+ ESCAPE_TABLE = new Array(128).fill(null);
38215
+ ESCAPE_TABLE[8] = "b";
38216
+ ESCAPE_TABLE[9] = "t";
38217
+ ESCAPE_TABLE[10] = "n";
38218
+ ESCAPE_TABLE[12] = "f";
38219
+ ESCAPE_TABLE[13] = "r";
38220
+ ESCAPE_TABLE[34] = '"';
38221
+ ESCAPE_TABLE[92] = "\\";
38222
+ for (let i6 = 0; i6 < 32; i6++) {
38223
+ if (ESCAPE_TABLE[i6] === null) {
38224
+ ESCAPE_TABLE[i6] = "u00" + i6.toString(16).padStart(2, "0");
38225
+ }
38226
+ }
38227
+ INITIAL_BUFFER_SIZE2 = 2048;
38228
+ __name(alloc, "alloc");
38229
+ JsonShapeSerializer2 = class _JsonShapeSerializer2 extends SerdeContextConfig {
38025
38230
  static {
38026
- __name(this, "JsonShapeSerializer");
38231
+ __name(this, "JsonShapeSerializer2");
38027
38232
  }
38028
38233
  settings;
38029
- buffer;
38030
- useReplacer = false;
38234
+ json;
38235
+ i = 0;
38031
38236
  rootSchema;
38237
+ rawValue;
38238
+ passthrough = false;
38032
38239
  constructor(settings) {
38033
38240
  super();
38034
38241
  this.settings = settings;
38242
+ this.json = alloc(INITIAL_BUFFER_SIZE2);
38035
38243
  }
38036
38244
  write(schema, value2) {
38245
+ this.i = 0;
38246
+ this.rawValue = value2;
38037
38247
  this.rootSchema = NormalizedSchema.of(schema);
38038
- this.buffer = this._write(this.rootSchema, value2);
38248
+ this.passthrough = this.rootSchema.isBlobSchema() || this.rootSchema.isStringSchema();
38249
+ if (!this.passthrough) {
38250
+ this.writeValue(this.rootSchema, value2, void 0);
38251
+ }
38252
+ }
38253
+ writeDiscriminatedDocument(schema, value2) {
38254
+ this.i = 0;
38255
+ this.rootSchema = NormalizedSchema.of(schema);
38256
+ const ns = this.rootSchema;
38257
+ if (ns.isStructSchema() && value2 != null && typeof value2 === "object") {
38258
+ this.writeValue(ns, value2, void 0);
38259
+ const prefix = `"__type":"${ns.getName(true) ?? "Unknown"}",`;
38260
+ const z = prefix.length;
38261
+ this.ensure(z);
38262
+ this.json.copyWithin(1 + z, 1, this.i);
38263
+ encoder.encodeInto(prefix, this.json.subarray(1));
38264
+ this.i += z;
38265
+ } else {
38266
+ this.writeValue(ns, value2, void 0);
38267
+ }
38039
38268
  }
38040
38269
  flush() {
38041
- const { rootSchema, useReplacer } = this;
38042
38270
  this.rootSchema = void 0;
38043
- this.useReplacer = false;
38044
- if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
38045
- if (!useReplacer) {
38046
- return JSON.stringify(this.buffer);
38271
+ const finalPosition = this.i;
38272
+ this.i = 0;
38273
+ const raw = this.rawValue;
38274
+ this.rawValue = void 0;
38275
+ if (finalPosition === 0) {
38276
+ return raw;
38277
+ }
38278
+ const result2 = this.json.subarray(0, finalPosition);
38279
+ this.json = alloc(INITIAL_BUFFER_SIZE2);
38280
+ return result2;
38281
+ }
38282
+ ensure(byteCount) {
38283
+ const { i: i6, json } = this;
38284
+ if (i6 + byteCount > json.length) {
38285
+ let newSize = json.length * 2;
38286
+ while (newSize < i6 + byteCount) {
38287
+ newSize *= 2;
38047
38288
  }
38048
- const replacer = new JsonReplacer();
38049
- return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
38289
+ const next = alloc(newSize);
38290
+ next.set(this.json);
38291
+ this.json = next;
38050
38292
  }
38051
- return this.buffer;
38052
38293
  }
38053
- writeDiscriminatedDocument(schema, value2) {
38054
- this.write(schema, value2);
38055
- if (typeof this.buffer === "object") {
38056
- this.buffer.__type = NormalizedSchema.of(schema).getName(true);
38294
+ writeAscii(s2) {
38295
+ const z = s2.length;
38296
+ this.ensure(z);
38297
+ let { i: i6, json } = this;
38298
+ for (let j6 = 0; j6 < z; ++j6) {
38299
+ json[i6] = s2.charCodeAt(j6);
38300
+ i6 += 1;
38057
38301
  }
38302
+ this.i = i6;
38058
38303
  }
38059
- _write(schema, value2, container) {
38060
- const isObject3 = value2 !== null && typeof value2 === "object";
38061
- const ns = NormalizedSchema.of(schema);
38062
- if (isObject3) {
38063
- if (ns.isStructSchema()) {
38064
- const record = value2;
38065
- const out = {};
38066
- const { jsonName } = this.settings;
38067
- let nameMap = void 0;
38068
- if (jsonName) {
38069
- nameMap = {};
38070
- }
38071
- let outCount = 0;
38072
- for (const [memberName, memberSchema] of ns.structIterator()) {
38073
- const serializableValue = this._write(memberSchema, record[memberName], ns);
38074
- if (serializableValue !== void 0) {
38075
- let targetKey = memberName;
38076
- if (jsonName) {
38077
- targetKey = memberSchema.getMergedTraits().jsonName ?? memberName;
38078
- nameMap[memberName] = targetKey;
38079
- }
38080
- out[targetKey] = serializableValue;
38081
- outCount++;
38304
+ writeAsciiQuoted(s2) {
38305
+ const z = s2.length;
38306
+ this.ensure(z + 4);
38307
+ let { json, i: i6 } = this;
38308
+ json[i6++] = QUOTE;
38309
+ for (let j6 = 0; j6 < z; ++j6) {
38310
+ json[i6++] = s2.charCodeAt(j6);
38311
+ }
38312
+ json[i6++] = QUOTE;
38313
+ this.i = i6;
38314
+ }
38315
+ writeJsonString(s2) {
38316
+ this.ensure(s2.length * 3 + 2);
38317
+ this.json[this.i++] = QUOTE;
38318
+ const z = s2.length;
38319
+ for (let j6 = 0; j6 < z; ++j6) {
38320
+ const c6 = s2.charCodeAt(j6);
38321
+ if (c6 > 34 && c6 < 92) {
38322
+ this.json[this.i++] = c6;
38323
+ } else if (c6 < 128) {
38324
+ const esc = ESCAPE_TABLE[c6];
38325
+ if (esc !== null) {
38326
+ this.ensure(esc.length + 1);
38327
+ this.json[this.i++] = BACKSLASH;
38328
+ for (let k6 = 0; k6 < esc.length; k6++) {
38329
+ this.json[this.i++] = esc.charCodeAt(k6);
38082
38330
  }
38331
+ } else {
38332
+ this.json[this.i++] = c6;
38083
38333
  }
38084
- if (ns.isUnionSchema() && outCount === 0) {
38085
- const { $unknown } = record;
38086
- if (Array.isArray($unknown)) {
38087
- const [k6, v] = $unknown;
38088
- if (k6 === "__proto__") {
38089
- writeKey(out);
38090
- }
38091
- out[k6] = this._write(15, v);
38092
- }
38093
- } else if (typeof record.__type === "string") {
38094
- for (const k6 in record) {
38095
- const v = record[k6];
38096
- const targetKey = jsonName ? nameMap[k6] ?? k6 : k6;
38097
- if (!(targetKey in out)) {
38098
- out[targetKey] = this._write(15, v);
38099
- }
38100
- }
38334
+ } else if (c6 >= 55296 && c6 <= 56319) {
38335
+ const next = j6 + 1 < z ? s2.charCodeAt(j6 + 1) : 0;
38336
+ if (next >= 56320 && next <= 57343) {
38337
+ this.ensure(4);
38338
+ const { written } = encoder.encodeInto(s2.substring(j6, j6 + 2), this.json.subarray(this.i));
38339
+ this.i += written;
38340
+ ++j6;
38341
+ } else {
38342
+ this.ensure(6);
38343
+ this.writeUnicodeEscape(c6);
38101
38344
  }
38102
- return out;
38345
+ } else if (c6 >= 56320 && c6 <= 57343) {
38346
+ this.ensure(6);
38347
+ this.writeUnicodeEscape(c6);
38348
+ } else {
38349
+ let { i: i6, json } = this;
38350
+ if (c6 < 2048) {
38351
+ json[i6++] = 192 | c6 >> 6;
38352
+ json[i6++] = 128 | c6 & 63;
38353
+ } else {
38354
+ json[i6++] = 224 | c6 >> 12;
38355
+ json[i6++] = 128 | c6 >> 6 & 63;
38356
+ json[i6++] = 128 | c6 & 63;
38357
+ }
38358
+ this.i = i6;
38103
38359
  }
38104
- if (Array.isArray(value2) && ns.isListSchema()) {
38105
- const listMember = ns.getValueSchema();
38106
- const out = [];
38107
- const sparse = !!ns.getMergedTraits().sparse;
38108
- for (const item of value2) {
38109
- if (sparse || item != null) {
38110
- out.push(this._write(listMember, item));
38360
+ }
38361
+ this.json[this.i++] = QUOTE;
38362
+ }
38363
+ writeUnicodeEscape(code) {
38364
+ let { json, i: i6 } = this;
38365
+ json[i6++] = BACKSLASH;
38366
+ json[i6++] = 117;
38367
+ const hex = code.toString(16).padStart(4, "0");
38368
+ for (let j6 = 0; j6 < 4; ++j6) {
38369
+ json[i6++] = hex.charCodeAt(j6);
38370
+ }
38371
+ this.i = i6;
38372
+ }
38373
+ static B64 = (() => {
38374
+ const chars3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
38375
+ const table3 = new Uint8Array(64);
38376
+ for (let i6 = 0; i6 < 64; ++i6) {
38377
+ table3[i6] = chars3.charCodeAt(i6);
38378
+ }
38379
+ return table3;
38380
+ })();
38381
+ writeBase64(data) {
38382
+ const b64Len = Math.ceil(data.length / 3) * 4;
38383
+ this.ensure(b64Len + 2);
38384
+ const json = this.json;
38385
+ const B64 = _JsonShapeSerializer2.B64;
38386
+ let i6 = this.i;
38387
+ json[i6++] = QUOTE;
38388
+ const len = data.length;
38389
+ const remainder = len % 3;
38390
+ const mainLen = len - remainder;
38391
+ for (let j6 = 0; j6 < mainLen; j6 += 3) {
38392
+ const a6 = data[j6];
38393
+ const b6 = data[j6 + 1];
38394
+ const c6 = data[j6 + 2];
38395
+ json[i6++] = B64[a6 >> 2];
38396
+ json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
38397
+ json[i6++] = B64[(b6 & 15) << 2 | c6 >> 6];
38398
+ json[i6++] = B64[c6 & 63];
38399
+ }
38400
+ if (remainder === 2) {
38401
+ const a6 = data[mainLen];
38402
+ const b6 = data[mainLen + 1];
38403
+ json[i6++] = B64[a6 >> 2];
38404
+ json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
38405
+ json[i6++] = B64[(b6 & 15) << 2];
38406
+ json[i6++] = 61;
38407
+ } else if (remainder === 1) {
38408
+ const a6 = data[mainLen];
38409
+ json[i6++] = B64[a6 >> 2];
38410
+ json[i6++] = B64[(a6 & 3) << 4];
38411
+ json[i6++] = 61;
38412
+ json[i6++] = 61;
38413
+ }
38414
+ json[i6++] = QUOTE;
38415
+ this.i = i6;
38416
+ }
38417
+ writeValue(schema, value2, container) {
38418
+ if (value2 == null) {
38419
+ if (container?.isStructSchema()) {
38420
+ if (value2 === void 0) {
38421
+ const ns2 = NormalizedSchema.of(schema);
38422
+ if (ns2.isIdempotencyToken()) {
38423
+ this.writeAsciiQuoted(generateIdempotencyToken());
38424
+ return;
38111
38425
  }
38112
38426
  }
38113
- return out;
38427
+ return;
38114
38428
  }
38115
- if (ns.isMapSchema()) {
38116
- const mapMember = ns.getValueSchema();
38117
- const out = {};
38118
- const sparse = !!ns.getMergedTraits().sparse;
38119
- for (const _k in value2) {
38120
- const _v = value2[_k];
38121
- if (sparse || _v != null) {
38122
- if (_k === "__proto__") {
38123
- writeKey(out);
38124
- }
38125
- out[_k] = this._write(mapMember, _v);
38126
- }
38429
+ this.ensure(4);
38430
+ this.json.set(NULL, this.i);
38431
+ this.i += 4;
38432
+ return;
38433
+ }
38434
+ const ns = NormalizedSchema.of(schema);
38435
+ const isObject3 = typeof value2 === "object";
38436
+ if (ns.isStringSchema()) {
38437
+ const mediaType = ns.getMergedTraits().mediaType;
38438
+ if (mediaType) {
38439
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
38440
+ if (isJson) {
38441
+ this.writeJsonString(LazyJsonString.from(value2).toString());
38442
+ return;
38127
38443
  }
38128
- return out;
38444
+ }
38445
+ }
38446
+ if (isObject3) {
38447
+ if (ns.isStructSchema()) {
38448
+ this.writeStruct(ns, value2);
38449
+ return;
38450
+ }
38451
+ if (Array.isArray(value2) && (ns.isListSchema() || ns.isDocumentSchema())) {
38452
+ this.writeList(ns, value2, ns.isDocumentSchema());
38453
+ return;
38454
+ }
38455
+ if (ns.isMapSchema()) {
38456
+ this.writeMap(ns, value2, false);
38457
+ return;
38129
38458
  }
38130
38459
  if (value2 instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
38131
- if (ns === this.rootSchema) {
38132
- return value2;
38133
- }
38134
- return (this.serdeContext?.base64Encoder ?? toBase64)(value2);
38460
+ this.writeBase64(value2);
38461
+ return;
38135
38462
  }
38136
38463
  if (value2 instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
38137
- const format30 = determineTimestampFormat(ns, this.settings);
38138
- switch (format30) {
38139
- case 5:
38140
- return value2.toISOString().replace(".000Z", "Z");
38141
- case 6:
38142
- return dateToUtcString(value2);
38143
- case 7:
38144
- return value2.getTime() / 1e3;
38145
- default:
38146
- console.warn("Missing timestamp format, using epoch seconds", value2);
38147
- return value2.getTime() / 1e3;
38148
- }
38464
+ this.writeTimestamp(ns, value2);
38465
+ return;
38149
38466
  }
38150
38467
  if (value2 instanceof NumericValue) {
38151
- this.useReplacer = true;
38468
+ this.writeAscii(value2.string);
38469
+ return;
38152
38470
  }
38471
+ if (ns.isDocumentSchema()) {
38472
+ if (Array.isArray(value2)) {
38473
+ this.writeList(ns, value2, true);
38474
+ } else {
38475
+ this.writeMap(ns, value2, true);
38476
+ }
38477
+ return;
38478
+ }
38479
+ const json = JSON.stringify(value2);
38480
+ this.writeAscii(json);
38481
+ return;
38153
38482
  }
38154
- if (value2 === null && container?.isStructSchema()) {
38155
- return void 0;
38483
+ if (typeof value2 === "string") {
38484
+ if (ns.isBlobSchema()) {
38485
+ const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value2);
38486
+ this.writeAsciiQuoted(b64);
38487
+ return;
38488
+ }
38489
+ this.writeJsonString(value2);
38490
+ return;
38156
38491
  }
38157
- if (ns.isStringSchema()) {
38158
- if (typeof value2 === "undefined" && ns.isIdempotencyToken()) {
38159
- return generateIdempotencyToken();
38492
+ if (typeof value2 === "number") {
38493
+ if (Math.abs(value2) === Infinity || Number.isNaN(value2)) {
38494
+ this.writeAsciiQuoted(String(value2));
38495
+ return;
38160
38496
  }
38161
- const mediaType = ns.getMergedTraits().mediaType;
38162
- if (value2 != null && mediaType) {
38163
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
38164
- if (isJson) {
38165
- return LazyJsonString.from(value2);
38166
- }
38497
+ const numStr = String(value2);
38498
+ this.writeAscii(numStr);
38499
+ return;
38500
+ }
38501
+ if (typeof value2 === "boolean") {
38502
+ this.ensure(5);
38503
+ let { i: i6, json } = this;
38504
+ if (value2) {
38505
+ json.set(TRUE, i6);
38506
+ i6 += 4;
38507
+ } else {
38508
+ json.set(FALSE, i6);
38509
+ i6 += 5;
38167
38510
  }
38168
- return value2;
38511
+ this.i = i6;
38512
+ return;
38169
38513
  }
38170
- if (typeof value2 === "number" && ns.isNumericSchema()) {
38171
- if (Math.abs(value2) === Infinity || isNaN(value2)) {
38172
- return String(value2);
38514
+ if (typeof value2 === "bigint") {
38515
+ this.writeAscii(value2.toString());
38516
+ return;
38517
+ }
38518
+ this.writeAscii(String(value2));
38519
+ }
38520
+ writeStruct(ns, value2) {
38521
+ this.ensure(2);
38522
+ this.json[this.i++] = OPEN_BRACE;
38523
+ let wroteAny = false;
38524
+ const hasType = typeof value2.__type === "string";
38525
+ let writtenKeys;
38526
+ if (hasType) {
38527
+ writtenKeys = /* @__PURE__ */ new Set();
38528
+ }
38529
+ for (const [memberName, memberSchema] of ns.structIterator()) {
38530
+ const item = value2[memberName];
38531
+ if (item == null && !memberSchema.isIdempotencyToken()) {
38532
+ continue;
38173
38533
  }
38174
- return value2;
38534
+ if (wroteAny) {
38535
+ this.ensure(1);
38536
+ this.json[this.i++] = COMMA;
38537
+ }
38538
+ wroteAny = true;
38539
+ const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
38540
+ if (writtenKeys) {
38541
+ writtenKeys.add(memberName);
38542
+ writtenKeys.add(targetKey);
38543
+ }
38544
+ this.writeAsciiQuoted(targetKey);
38545
+ this.json[this.i++] = COLON;
38546
+ this.writeValue(memberSchema, item, ns);
38175
38547
  }
38176
- if (typeof value2 === "string" && ns.isBlobSchema()) {
38177
- if (ns === this.rootSchema) {
38178
- return value2;
38548
+ if (!wroteAny && ns.isUnionSchema()) {
38549
+ const { $unknown } = value2;
38550
+ if (Array.isArray($unknown)) {
38551
+ const [k6, v] = $unknown;
38552
+ this.writeAsciiQuoted(k6);
38553
+ this.ensure(1);
38554
+ this.json[this.i++] = COLON;
38555
+ this.writeValue(15, v, ns);
38556
+ }
38557
+ } else if (hasType) {
38558
+ for (const k6 in value2) {
38559
+ if (writtenKeys.has(k6)) {
38560
+ continue;
38561
+ }
38562
+ writtenKeys.add(k6);
38563
+ const v = value2[k6];
38564
+ if (wroteAny) {
38565
+ this.ensure(1);
38566
+ this.json[this.i++] = COMMA;
38567
+ }
38568
+ wroteAny = true;
38569
+ this.writeAsciiQuoted(k6);
38570
+ this.ensure(1);
38571
+ this.json[this.i++] = COLON;
38572
+ this.writeValue(15, v, void 0);
38179
38573
  }
38180
- return (this.serdeContext?.base64Encoder ?? toBase64)(value2);
38181
38574
  }
38182
- if (typeof value2 === "bigint") {
38183
- this.useReplacer = true;
38575
+ this.ensure(1);
38576
+ this.json[this.i++] = CLOSE_BRACE;
38577
+ }
38578
+ writeList(ns, value2, isDocument) {
38579
+ const sparse = !!ns.getMergedTraits().sparse;
38580
+ const valueSchema = ns.getValueSchema();
38581
+ if (!isDocument) {
38582
+ if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
38583
+ let hasSpecials = false;
38584
+ for (let i6 = 0; i6 < value2.length; ++i6) {
38585
+ const v = value2[i6];
38586
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity || v == null && !sparse) {
38587
+ hasSpecials = true;
38588
+ break;
38589
+ }
38590
+ }
38591
+ let json;
38592
+ if (!hasSpecials) {
38593
+ json = JSON.stringify(value2);
38594
+ } else {
38595
+ const out = [];
38596
+ for (let i6 = 0; i6 < value2.length; ++i6) {
38597
+ const v = value2[i6];
38598
+ if (v == null && !sparse)
38599
+ continue;
38600
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
38601
+ out.push(String(v));
38602
+ } else {
38603
+ out.push(v);
38604
+ }
38605
+ }
38606
+ json = JSON.stringify(out);
38607
+ }
38608
+ this.ensure(json.length * 3);
38609
+ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
38610
+ return;
38611
+ }
38184
38612
  }
38185
- if (ns.isDocumentSchema()) {
38186
- if (isObject3) {
38187
- const out = Array.isArray(value2) ? [] : {};
38613
+ this.ensure(2);
38614
+ this.json[this.i++] = OPEN_BRACKET;
38615
+ let wroteFirstItem = false;
38616
+ for (let i6 = 0; i6 < value2.length; ++i6) {
38617
+ const item = value2[i6];
38618
+ if (isDocument ? item === void 0 : item == null && !sparse) {
38619
+ continue;
38620
+ }
38621
+ if (wroteFirstItem) {
38622
+ this.ensure(1);
38623
+ this.json[this.i++] = COMMA;
38624
+ }
38625
+ this.writeValue(valueSchema, item, void 0);
38626
+ wroteFirstItem = true;
38627
+ }
38628
+ this.ensure(1);
38629
+ this.json[this.i++] = CLOSE_BRACKET;
38630
+ }
38631
+ writeMap(ns, value2, isDocument) {
38632
+ const sparse = !!ns.getMergedTraits().sparse;
38633
+ const valueSchema = ns.getValueSchema();
38634
+ if (!isDocument) {
38635
+ if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
38636
+ let modifications;
38188
38637
  for (const k6 in value2) {
38189
38638
  const v = value2[k6];
38190
- if (k6 === "__proto__") {
38191
- writeKey(out);
38192
- }
38193
- if (v instanceof NumericValue) {
38194
- this.useReplacer = true;
38195
- out[k6] = v;
38196
- } else {
38197
- out[k6] = this._write(ns, v);
38639
+ if (Number.isNaN(v) || v === Infinity || v === -Infinity) {
38640
+ (modifications ??= {})[k6] = v;
38641
+ value2[k6] = String(v);
38642
+ } else if (v === null && !sparse) {
38643
+ (modifications ??= {})[k6] = null;
38644
+ value2[k6] = void 0;
38198
38645
  }
38199
38646
  }
38200
- return out;
38201
- } else {
38202
- return structuredClone(value2);
38647
+ const json = JSON.stringify(value2);
38648
+ if (modifications) {
38649
+ Object.assign(value2, modifications);
38650
+ }
38651
+ this.ensure(json.length * 3);
38652
+ this.i += encoder.encodeInto(json, this.json.subarray(this.i)).written;
38653
+ return;
38654
+ }
38655
+ }
38656
+ this.ensure(2);
38657
+ this.json[this.i++] = OPEN_BRACE;
38658
+ let first = true;
38659
+ for (const k6 in value2) {
38660
+ const v = value2[k6];
38661
+ if (isDocument ? v === void 0 : v == null && !sparse) {
38662
+ continue;
38663
+ }
38664
+ if (!first) {
38665
+ this.ensure(1);
38666
+ this.json[this.i++] = COMMA;
38667
+ }
38668
+ first = false;
38669
+ this.writeJsonString(k6);
38670
+ this.ensure(1);
38671
+ this.json[this.i++] = COLON;
38672
+ this.writeValue(valueSchema, v, void 0);
38673
+ }
38674
+ this.ensure(1);
38675
+ this.json[this.i++] = CLOSE_BRACE;
38676
+ }
38677
+ writeTimestamp(ns, value2) {
38678
+ const format30 = determineTimestampFormat(ns, this.settings);
38679
+ switch (format30) {
38680
+ case 5: {
38681
+ const iso = value2.toISOString().replace(".000Z", "Z");
38682
+ this.writeAsciiQuoted(iso);
38683
+ return;
38684
+ }
38685
+ case 6: {
38686
+ this.writeAsciiQuoted(dateToUtcString(value2));
38687
+ return;
38688
+ }
38689
+ case 7: {
38690
+ const epochSecs = String(value2.getTime() / 1e3);
38691
+ this.writeAscii(epochSecs);
38692
+ return;
38693
+ }
38694
+ default: {
38695
+ const epochSecs = String(value2.getTime() / 1e3);
38696
+ this.writeAscii(epochSecs);
38697
+ return;
38203
38698
  }
38204
38699
  }
38205
- return value2;
38206
38700
  }
38207
38701
  };
38208
38702
  }
38209
38703
  });
38210
38704
 
38211
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js
38212
- var JsonCodec;
38213
- var init_JsonCodec = __esm({
38214
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js"() {
38705
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js
38706
+ var JsonCodec2;
38707
+ var init_JsonCodec2 = __esm({
38708
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js"() {
38215
38709
  init_ConfigurableSerdeContext();
38216
- init_JsonShapeDeserializer();
38217
- init_JsonShapeSerializer();
38218
- JsonCodec = class extends SerdeContextConfig {
38710
+ init_JsonShapeDeserializer2();
38711
+ init_JsonShapeSerializer2();
38712
+ JsonCodec2 = class extends SerdeContextConfig {
38219
38713
  static {
38220
- __name(this, "JsonCodec");
38714
+ __name(this, "JsonCodec2");
38221
38715
  }
38222
38716
  settings;
38223
38717
  constructor(settings) {
@@ -38225,12 +38719,12 @@ var init_JsonCodec = __esm({
38225
38719
  this.settings = settings;
38226
38720
  }
38227
38721
  createSerializer() {
38228
- const serializer = new JsonShapeSerializer(this.settings);
38722
+ const serializer = new JsonShapeSerializer2(this.settings);
38229
38723
  serializer.setSerdeContext(this.serdeContext);
38230
38724
  return serializer;
38231
38725
  }
38232
38726
  createDeserializer() {
38233
- const deserializer = new JsonShapeDeserializer(this.settings);
38727
+ const deserializer = new JsonShapeDeserializer2(this.settings);
38234
38728
  deserializer.setSerdeContext(this.serdeContext);
38235
38729
  return deserializer;
38236
38730
  }
@@ -38245,7 +38739,7 @@ var init_AwsJsonRpcProtocol = __esm({
38245
38739
  init_protocols();
38246
38740
  init_schema4();
38247
38741
  init_ProtocolLib();
38248
- init_JsonCodec();
38742
+ init_JsonCodec2();
38249
38743
  init_parseJsonBody();
38250
38744
  AwsJsonRpcProtocol = class extends RpcProtocol {
38251
38745
  static {
@@ -38263,7 +38757,7 @@ var init_AwsJsonRpcProtocol = __esm({
38263
38757
  errorTypeRegistries: errorTypeRegistries6
38264
38758
  });
38265
38759
  this.serviceTarget = serviceTarget;
38266
- this.codec = jsonCodec ?? new JsonCodec({
38760
+ this.codec = jsonCodec ?? new JsonCodec2({
38267
38761
  timestampFormat: {
38268
38762
  useTrait: true,
38269
38763
  default: 7
@@ -38393,7 +38887,7 @@ var init_AwsRestJsonProtocol = __esm({
38393
38887
  init_protocols();
38394
38888
  init_schema4();
38395
38889
  init_ProtocolLib();
38396
- init_JsonCodec();
38890
+ init_JsonCodec2();
38397
38891
  init_parseJsonBody();
38398
38892
  AwsRestJsonProtocol = class extends HttpBindingProtocol {
38399
38893
  static {
@@ -38403,7 +38897,7 @@ var init_AwsRestJsonProtocol = __esm({
38403
38897
  deserializer;
38404
38898
  codec;
38405
38899
  mixin = new ProtocolLib();
38406
- constructor({ defaultNamespace, errorTypeRegistries: errorTypeRegistries6 }) {
38900
+ constructor({ defaultNamespace, errorTypeRegistries: errorTypeRegistries6, jsonCodec }) {
38407
38901
  super({
38408
38902
  defaultNamespace,
38409
38903
  errorTypeRegistries: errorTypeRegistries6
@@ -38416,7 +38910,7 @@ var init_AwsRestJsonProtocol = __esm({
38416
38910
  httpBindings: true,
38417
38911
  jsonName: true
38418
38912
  };
38419
- this.codec = new JsonCodec(settings);
38913
+ this.codec = jsonCodec ?? new JsonCodec2(settings);
38420
38914
  this.serializer = new HttpInterceptingShapeSerializer(this.codec.createSerializer(), settings);
38421
38915
  this.deserializer = new HttpInterceptingShapeDeserializer(this.codec.createDeserializer(), settings);
38422
38916
  }
@@ -38481,24 +38975,23 @@ var init_AwsRestJsonProtocol = __esm({
38481
38975
  }
38482
38976
  });
38483
38977
 
38484
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js
38485
- var JsonShapeDeserializer2;
38486
- var init_JsonShapeDeserializer2 = __esm({
38487
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeDeserializer2.js"() {
38978
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js
38979
+ var JsonShapeDeserializer;
38980
+ var init_JsonShapeDeserializer = __esm({
38981
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeDeserializer.js"() {
38488
38982
  init_protocols();
38489
38983
  init_schema4();
38490
38984
  init_serde();
38491
38985
  init_serde();
38492
38986
  init_ConfigurableSerdeContext();
38493
38987
  init_UnionSerde();
38494
- init_detectBufferParsing();
38495
38988
  init_jsonReviver();
38496
38989
  init_needsReviver();
38497
38990
  init_parseJsonBody();
38498
38991
  init_writeKey();
38499
- JsonShapeDeserializer2 = class extends SerdeContextConfig {
38992
+ JsonShapeDeserializer = class extends SerdeContextConfig {
38500
38993
  static {
38501
- __name(this, "JsonShapeDeserializer2");
38994
+ __name(this, "JsonShapeDeserializer");
38502
38995
  }
38503
38996
  settings;
38504
38997
  constructor(settings) {
@@ -38507,16 +39000,7 @@ var init_JsonShapeDeserializer2 = __esm({
38507
39000
  }
38508
39001
  async read(schema, data) {
38509
39002
  const reviver = needsReviver(schema) ? jsonReviver : void 0;
38510
- let parsed;
38511
- if (typeof data === "string") {
38512
- parsed = JSON.parse(data, reviver);
38513
- } else if (data instanceof Uint8Array && detectBufferParsing()) {
38514
- const buf2 = Buffer.isBuffer(data) ? data : Buffer.from(data.buffer, data.byteOffset, data.byteLength);
38515
- parsed = JSON.parse(buf2, reviver);
38516
- } else {
38517
- parsed = await parseJsonBody(data, this.serdeContext);
38518
- }
38519
- return this._read(schema, parsed);
39003
+ return this._read(schema, typeof data === "string" ? JSON.parse(data, reviver) : await parseJsonBody(data, this.serdeContext, schema));
38520
39004
  }
38521
39005
  readObject(schema, data) {
38522
39006
  return this._read(schema, data);
@@ -38526,25 +39010,62 @@ var init_JsonShapeDeserializer2 = __esm({
38526
39010
  const ns = NormalizedSchema.of(schema);
38527
39011
  if (isObject3) {
38528
39012
  if (ns.isStructSchema()) {
38529
- return this._readStruct(ns, value2);
39013
+ const record = value2;
39014
+ const union = ns.isUnionSchema();
39015
+ const out = {};
39016
+ let nameMap = void 0;
39017
+ const { jsonName } = this.settings;
39018
+ if (jsonName) {
39019
+ nameMap = {};
39020
+ }
39021
+ let unionSerde;
39022
+ if (union) {
39023
+ unionSerde = new UnionSerde(record, out);
39024
+ }
39025
+ for (const [memberName, memberSchema] of ns.structIterator()) {
39026
+ let fromKey = memberName;
39027
+ if (jsonName) {
39028
+ fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
39029
+ nameMap[fromKey] = memberName;
39030
+ }
39031
+ if (union) {
39032
+ unionSerde.mark(fromKey);
39033
+ }
39034
+ if (record[fromKey] != null) {
39035
+ out[memberName] = this._read(memberSchema, record[fromKey]);
39036
+ }
39037
+ }
39038
+ if (union) {
39039
+ unionSerde.writeUnknown();
39040
+ } else if (typeof record.__type === "string") {
39041
+ for (const k6 in record) {
39042
+ const v = record[k6];
39043
+ const t = jsonName ? nameMap[k6] ?? k6 : k6;
39044
+ if (!(t in out)) {
39045
+ out[t] = v;
39046
+ }
39047
+ }
39048
+ }
39049
+ return out;
38530
39050
  }
38531
39051
  if (Array.isArray(value2) && ns.isListSchema()) {
38532
39052
  const listMember = ns.getValueSchema();
38533
- for (let i6 = 0; i6 < value2.length; ++i6) {
38534
- value2[i6] = this._read(listMember, value2[i6]);
39053
+ const out = [];
39054
+ for (const item of value2) {
39055
+ out.push(this._read(listMember, item));
38535
39056
  }
38536
- return value2;
39057
+ return out;
38537
39058
  }
38538
39059
  if (ns.isMapSchema()) {
38539
39060
  const mapMember = ns.getValueSchema();
38540
- const map3 = value2;
38541
- for (const k6 in map3) {
38542
- if (k6 === "__proto__") {
38543
- writeKey(map3);
39061
+ const out = {};
39062
+ for (const _k in value2) {
39063
+ if (_k === "__proto__") {
39064
+ writeKey(out);
38544
39065
  }
38545
- map3[k6] = this._read(mapMember, map3[k6]);
39066
+ out[_k] = this._read(mapMember, value2[_k]);
38546
39067
  }
38547
- return map3;
39068
+ return out;
38548
39069
  }
38549
39070
  }
38550
39071
  if (ns.isBlobSchema() && typeof value2 === "string") {
@@ -38598,577 +39119,295 @@ var init_JsonShapeDeserializer2 = __esm({
38598
39119
  }
38599
39120
  if (ns.isDocumentSchema()) {
38600
39121
  if (isObject3) {
38601
- if (Array.isArray(value2)) {
38602
- for (let i6 = 0; i6 < value2.length; ++i6) {
38603
- const v = value2[i6];
38604
- if (!(v instanceof NumericValue)) {
38605
- value2[i6] = this._read(ns, v);
38606
- }
39122
+ const out = Array.isArray(value2) ? [] : {};
39123
+ for (const k6 in value2) {
39124
+ if (k6 === "__proto__") {
39125
+ writeKey(out);
38607
39126
  }
38608
- } else {
38609
- const doc = value2;
38610
- for (const k6 in doc) {
38611
- if (k6 === "__proto__") {
38612
- writeKey(doc);
38613
- }
38614
- const v = doc[k6];
38615
- if (!(v instanceof NumericValue)) {
38616
- doc[k6] = this._read(ns, v);
38617
- }
39127
+ const v = value2[k6];
39128
+ if (v instanceof NumericValue) {
39129
+ out[k6] = v;
39130
+ } else {
39131
+ out[k6] = this._read(ns, v);
38618
39132
  }
38619
39133
  }
38620
- return value2;
39134
+ return out;
38621
39135
  } else {
38622
- return value2;
39136
+ return structuredClone(value2);
38623
39137
  }
38624
39138
  }
38625
39139
  return value2;
38626
39140
  }
38627
- _readStruct(ns, record) {
38628
- const union = ns.isUnionSchema();
38629
- const out = {};
38630
- let nameMap = void 0;
38631
- const { jsonName } = this.settings;
38632
- if (jsonName) {
38633
- nameMap = {};
39141
+ };
39142
+ }
39143
+ });
39144
+
39145
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js
39146
+ var NUMERIC_CONTROL_CHAR, JsonReplacer;
39147
+ var init_jsonReplacer = __esm({
39148
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/jsonReplacer.js"() {
39149
+ init_serde();
39150
+ NUMERIC_CONTROL_CHAR = String.fromCharCode(925);
39151
+ JsonReplacer = class {
39152
+ static {
39153
+ __name(this, "JsonReplacer");
39154
+ }
39155
+ values = /* @__PURE__ */ new Map();
39156
+ counter = 0;
39157
+ stage = 0;
39158
+ createReplacer() {
39159
+ if (this.stage === 1) {
39160
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer already created.");
38634
39161
  }
38635
- let unionSerde;
38636
- if (union) {
38637
- unionSerde = new UnionSerde(record, out);
39162
+ if (this.stage === 2) {
39163
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
38638
39164
  }
38639
- for (const [memberName, memberSchema] of ns.structIterator()) {
38640
- let fromKey = memberName;
38641
- if (jsonName) {
38642
- fromKey = memberSchema.getMergedTraits().jsonName ?? fromKey;
38643
- nameMap[fromKey] = memberName;
38644
- }
38645
- if (union) {
38646
- unionSerde.mark(fromKey);
39165
+ this.stage = 1;
39166
+ return (key, value2) => {
39167
+ if (value2 instanceof NumericValue) {
39168
+ const v = `${NUMERIC_CONTROL_CHAR + "nv" + this.counter++}_` + value2.string;
39169
+ this.values.set(`"${v}"`, value2.string);
39170
+ return v;
38647
39171
  }
38648
- if (record[fromKey] != null) {
38649
- out[memberName] = this._read(memberSchema, record[fromKey]);
39172
+ if (typeof value2 === "bigint") {
39173
+ const s2 = value2.toString();
39174
+ const v = `${NUMERIC_CONTROL_CHAR + "b" + this.counter++}_` + s2;
39175
+ this.values.set(`"${v}"`, s2);
39176
+ return v;
38650
39177
  }
39178
+ return value2;
39179
+ };
39180
+ }
39181
+ replaceInJson(json) {
39182
+ if (this.stage === 0) {
39183
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer not created yet.");
38651
39184
  }
38652
- if (union) {
38653
- unionSerde.writeUnknown();
38654
- } else if (typeof record.__type === "string") {
38655
- for (const k6 in record) {
38656
- const v = record[k6];
38657
- const t = jsonName ? nameMap[k6] ?? k6 : k6;
38658
- if (!(t in out)) {
38659
- out[t] = v;
38660
- }
38661
- }
39185
+ if (this.stage === 2) {
39186
+ throw new Error("@aws-sdk/core/protocols - JsonReplacer exhausted.");
38662
39187
  }
38663
- return out;
39188
+ this.stage = 2;
39189
+ if (this.counter === 0) {
39190
+ return json;
39191
+ }
39192
+ for (const [key, value2] of this.values) {
39193
+ json = json.replace(key, value2);
39194
+ }
39195
+ return json;
38664
39196
  }
38665
39197
  };
38666
39198
  }
38667
39199
  });
38668
39200
 
38669
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js
38670
- function alloc(size) {
38671
- return typeof Buffer !== "undefined" ? Buffer.allocUnsafe(size) : new Uint8Array(size);
38672
- }
38673
- var encoder, OPEN_BRACE, CLOSE_BRACE, OPEN_BRACKET, CLOSE_BRACKET, QUOTE, COLON, COMMA, BACKSLASH, TRUE, FALSE, NULL, ESCAPE_TABLE, INITIAL_BUFFER_SIZE2, JsonShapeSerializer2;
38674
- var init_JsonShapeSerializer2 = __esm({
38675
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonShapeSerializer2.js"() {
39201
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js
39202
+ var JsonShapeSerializer;
39203
+ var init_JsonShapeSerializer = __esm({
39204
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonShapeSerializer.js"() {
38676
39205
  init_protocols();
38677
39206
  init_schema4();
38678
39207
  init_serde();
38679
39208
  init_ConfigurableSerdeContext();
39209
+ init_jsonReplacer();
38680
39210
  init_writeKey();
38681
- encoder = new TextEncoder();
38682
- OPEN_BRACE = 123;
38683
- CLOSE_BRACE = 125;
38684
- OPEN_BRACKET = 91;
38685
- CLOSE_BRACKET = 93;
38686
- QUOTE = 34;
38687
- COLON = 58;
38688
- COMMA = 44;
38689
- BACKSLASH = 92;
38690
- TRUE = new Uint8Array([116, 114, 117, 101]);
38691
- FALSE = new Uint8Array([102, 97, 108, 115, 101]);
38692
- NULL = new Uint8Array([110, 117, 108, 108]);
38693
- ESCAPE_TABLE = new Array(128).fill(null);
38694
- ESCAPE_TABLE[8] = "b";
38695
- ESCAPE_TABLE[9] = "t";
38696
- ESCAPE_TABLE[10] = "n";
38697
- ESCAPE_TABLE[12] = "f";
38698
- ESCAPE_TABLE[13] = "r";
38699
- ESCAPE_TABLE[34] = '"';
38700
- ESCAPE_TABLE[92] = "\\";
38701
- for (let i6 = 0; i6 < 32; i6++) {
38702
- if (ESCAPE_TABLE[i6] === null) {
38703
- ESCAPE_TABLE[i6] = "u00" + i6.toString(16).padStart(2, "0");
38704
- }
38705
- }
38706
- INITIAL_BUFFER_SIZE2 = 2048;
38707
- __name(alloc, "alloc");
38708
- JsonShapeSerializer2 = class _JsonShapeSerializer2 extends SerdeContextConfig {
39211
+ JsonShapeSerializer = class extends SerdeContextConfig {
38709
39212
  static {
38710
- __name(this, "JsonShapeSerializer2");
39213
+ __name(this, "JsonShapeSerializer");
38711
39214
  }
38712
39215
  settings;
38713
- json;
38714
- i = 0;
39216
+ buffer;
39217
+ useReplacer = false;
38715
39218
  rootSchema;
38716
- rawValue;
38717
- passthrough = false;
38718
39219
  constructor(settings) {
38719
39220
  super();
38720
39221
  this.settings = settings;
38721
- this.json = alloc(INITIAL_BUFFER_SIZE2);
38722
39222
  }
38723
39223
  write(schema, value2) {
38724
- this.i = 0;
38725
- this.rawValue = value2;
38726
39224
  this.rootSchema = NormalizedSchema.of(schema);
38727
- this.passthrough = !this.rootSchema.isStructSchema() && !this.rootSchema.isDocumentSchema() && (this.rootSchema.isBlobSchema() || this.rootSchema.isStringSchema());
38728
- if (!this.passthrough) {
38729
- this.writeValue(this.rootSchema, value2, void 0);
38730
- }
38731
- }
38732
- writeDiscriminatedDocument(schema, value2) {
38733
- this.i = 0;
38734
- this.rootSchema = NormalizedSchema.of(schema);
38735
- const ns = this.rootSchema;
38736
- if (ns.isStructSchema() && value2 != null && typeof value2 === "object") {
38737
- this.ensure(2);
38738
- this.json[this.i++] = OPEN_BRACE;
38739
- this.writeAsciiQuoted("__type");
38740
- this.json[this.i++] = COLON;
38741
- this.writeAsciiQuoted(ns.getName(true) ?? "Unknown");
38742
- let wroteAny = true;
38743
- const { jsonName } = this.settings;
38744
- for (const [memberName, memberSchema] of ns.structIterator()) {
38745
- const item = value2[memberName];
38746
- if (item == null && !memberSchema.isIdempotencyToken()) {
38747
- continue;
38748
- }
38749
- if (wroteAny) {
38750
- this.ensure(1);
38751
- this.json[this.i++] = COMMA;
38752
- }
38753
- const targetKey = jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
38754
- this.writeAsciiQuoted(targetKey);
38755
- this.json[this.i++] = COLON;
38756
- this.writeValue(memberSchema, item, ns);
38757
- wroteAny = true;
38758
- }
38759
- this.ensure(1);
38760
- this.json[this.i++] = CLOSE_BRACE;
38761
- } else {
38762
- this.writeValue(ns, value2, void 0);
38763
- }
39225
+ this.buffer = this._write(this.rootSchema, value2);
38764
39226
  }
38765
39227
  flush() {
39228
+ const { rootSchema, useReplacer } = this;
38766
39229
  this.rootSchema = void 0;
38767
- const finalPosition = this.i;
38768
- this.i = 0;
38769
- const raw = this.rawValue;
38770
- this.rawValue = void 0;
38771
- if (finalPosition === 0) {
38772
- return raw;
38773
- }
38774
- const result2 = this.json.subarray(0, finalPosition);
38775
- this.json = alloc(INITIAL_BUFFER_SIZE2);
38776
- return result2;
38777
- }
38778
- ensure(byteCount) {
38779
- const { i: i6, json } = this;
38780
- if (i6 + byteCount > json.length) {
38781
- let newSize = json.length * 2;
38782
- while (newSize < i6 + byteCount) {
38783
- newSize *= 2;
39230
+ this.useReplacer = false;
39231
+ if (rootSchema?.isStructSchema() || rootSchema?.isDocumentSchema()) {
39232
+ if (!useReplacer) {
39233
+ return JSON.stringify(this.buffer);
38784
39234
  }
38785
- const next = alloc(newSize);
38786
- next.set(this.json);
38787
- this.json = next;
38788
- }
38789
- }
38790
- writeAscii(s2) {
38791
- const z = s2.length;
38792
- this.ensure(z);
38793
- let { i: i6, json } = this;
38794
- for (let j6 = 0; j6 < z; ++j6) {
38795
- json[i6] = s2.charCodeAt(j6);
38796
- i6 += 1;
39235
+ const replacer = new JsonReplacer();
39236
+ return replacer.replaceInJson(JSON.stringify(this.buffer, replacer.createReplacer(), 0));
38797
39237
  }
38798
- this.i = i6;
39238
+ return this.buffer;
38799
39239
  }
38800
- writeAsciiQuoted(s2) {
38801
- const z = s2.length;
38802
- this.ensure(z + 4);
38803
- let { json, i: i6 } = this;
38804
- json[i6++] = QUOTE;
38805
- for (let j6 = 0; j6 < z; ++j6) {
38806
- json[i6++] = s2.charCodeAt(j6);
39240
+ writeDiscriminatedDocument(schema, value2) {
39241
+ this.write(schema, value2);
39242
+ if (typeof this.buffer === "object") {
39243
+ this.buffer.__type = NormalizedSchema.of(schema).getName(true);
38807
39244
  }
38808
- json[i6++] = QUOTE;
38809
- this.i = i6;
38810
39245
  }
38811
- writeJsonString(s2) {
38812
- this.ensure(s2.length * 2 + 2);
38813
- this.json[this.i++] = QUOTE;
38814
- const z = s2.length;
38815
- for (let j6 = 0; j6 < z; ++j6) {
38816
- const c6 = s2.charCodeAt(j6);
38817
- if (c6 > 34 && c6 < 92) {
38818
- this.json[this.i++] = c6;
38819
- } else if (c6 < 128) {
38820
- const esc = ESCAPE_TABLE[c6];
38821
- if (esc !== null) {
38822
- this.ensure(esc.length + 1);
38823
- this.json[this.i++] = BACKSLASH;
38824
- for (let k6 = 0; k6 < esc.length; k6++) {
38825
- this.json[this.i++] = esc.charCodeAt(k6);
38826
- }
38827
- } else {
38828
- this.json[this.i++] = c6;
38829
- }
38830
- } else if (c6 >= 55296 && c6 <= 56319) {
38831
- const next = j6 + 1 < z ? s2.charCodeAt(j6 + 1) : 0;
38832
- if (next >= 56320 && next <= 57343) {
38833
- this.ensure(4);
38834
- const { written } = encoder.encodeInto(s2.substring(j6, j6 + 2), this.json.subarray(this.i));
38835
- this.i += written;
38836
- j6++;
38837
- } else {
38838
- this.ensure(6);
38839
- this.writeUnicodeEscape(c6);
39246
+ _write(schema, value2, container) {
39247
+ const isObject3 = value2 !== null && typeof value2 === "object";
39248
+ const ns = NormalizedSchema.of(schema);
39249
+ if (isObject3) {
39250
+ if (ns.isStructSchema()) {
39251
+ const record = value2;
39252
+ const out = {};
39253
+ const { jsonName } = this.settings;
39254
+ let nameMap = void 0;
39255
+ if (jsonName) {
39256
+ nameMap = {};
38840
39257
  }
38841
- } else if (c6 >= 56320 && c6 <= 57343) {
38842
- this.ensure(6);
38843
- this.writeUnicodeEscape(c6);
38844
- } else {
38845
- let { i: i6, json } = this;
38846
- if (c6 < 2048) {
38847
- json[i6++] = 192 | c6 >> 6;
38848
- json[i6++] = 128 | c6 & 63;
38849
- } else {
38850
- json[i6++] = 224 | c6 >> 12;
38851
- json[i6++] = 128 | c6 >> 6 & 63;
38852
- json[i6++] = 128 | c6 & 63;
39258
+ let outCount = 0;
39259
+ for (const [memberName, memberSchema] of ns.structIterator()) {
39260
+ const serializableValue = this._write(memberSchema, record[memberName], ns);
39261
+ if (serializableValue !== void 0) {
39262
+ let targetKey = memberName;
39263
+ if (jsonName) {
39264
+ targetKey = memberSchema.getMergedTraits().jsonName ?? memberName;
39265
+ nameMap[memberName] = targetKey;
39266
+ }
39267
+ out[targetKey] = serializableValue;
39268
+ outCount++;
39269
+ }
38853
39270
  }
38854
- this.i = i6;
38855
- }
38856
- }
38857
- this.json[this.i++] = QUOTE;
38858
- }
38859
- writeUnicodeEscape(code) {
38860
- let { json, i: i6 } = this;
38861
- json[i6++] = BACKSLASH;
38862
- json[i6++] = 117;
38863
- const hex = code.toString(16).padStart(4, "0");
38864
- for (let j6 = 0; j6 < 4; ++j6) {
38865
- json[i6++] = hex.charCodeAt(j6);
38866
- }
38867
- this.i = i6;
38868
- }
38869
- static B64 = (() => {
38870
- const chars3 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
38871
- const table3 = new Uint8Array(64);
38872
- for (let i6 = 0; i6 < 64; i6++)
38873
- table3[i6] = chars3.charCodeAt(i6);
38874
- return table3;
38875
- })();
38876
- writeBase64(data) {
38877
- const b64Len = Math.ceil(data.length / 3) * 4;
38878
- this.ensure(b64Len + 2);
38879
- const json = this.json;
38880
- const B64 = _JsonShapeSerializer2.B64;
38881
- let i6 = this.i;
38882
- json[i6++] = QUOTE;
38883
- const len = data.length;
38884
- const remainder = len % 3;
38885
- const mainLen = len - remainder;
38886
- for (let j6 = 0; j6 < mainLen; j6 += 3) {
38887
- const a6 = data[j6];
38888
- const b6 = data[j6 + 1];
38889
- const c6 = data[j6 + 2];
38890
- json[i6++] = B64[a6 >> 2];
38891
- json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
38892
- json[i6++] = B64[(b6 & 15) << 2 | c6 >> 6];
38893
- json[i6++] = B64[c6 & 63];
38894
- }
38895
- if (remainder === 2) {
38896
- const a6 = data[mainLen];
38897
- const b6 = data[mainLen + 1];
38898
- json[i6++] = B64[a6 >> 2];
38899
- json[i6++] = B64[(a6 & 3) << 4 | b6 >> 4];
38900
- json[i6++] = B64[(b6 & 15) << 2];
38901
- json[i6++] = 61;
38902
- } else if (remainder === 1) {
38903
- const a6 = data[mainLen];
38904
- json[i6++] = B64[a6 >> 2];
38905
- json[i6++] = B64[(a6 & 3) << 4];
38906
- json[i6++] = 61;
38907
- json[i6++] = 61;
38908
- }
38909
- json[i6++] = QUOTE;
38910
- this.i = i6;
38911
- }
38912
- writeValue(schema, value2, container) {
38913
- if (value2 == null) {
38914
- if (container?.isStructSchema()) {
38915
- if (value2 === void 0) {
38916
- const ns2 = NormalizedSchema.of(schema);
38917
- if (ns2.isIdempotencyToken()) {
38918
- this.writeAsciiQuoted(generateIdempotencyToken());
38919
- return;
39271
+ if (ns.isUnionSchema() && outCount === 0) {
39272
+ const { $unknown } = record;
39273
+ if (Array.isArray($unknown)) {
39274
+ const [k6, v] = $unknown;
39275
+ if (k6 === "__proto__") {
39276
+ writeKey(out);
39277
+ }
39278
+ out[k6] = this._write(15, v);
39279
+ }
39280
+ } else if (typeof record.__type === "string") {
39281
+ for (const k6 in record) {
39282
+ const v = record[k6];
39283
+ const targetKey = jsonName ? nameMap[k6] ?? k6 : k6;
39284
+ if (!(targetKey in out)) {
39285
+ out[targetKey] = this._write(15, v);
39286
+ }
38920
39287
  }
38921
39288
  }
38922
- return;
39289
+ return out;
38923
39290
  }
38924
- this.ensure(4);
38925
- this.json.set(NULL, this.i);
38926
- this.i += 4;
38927
- return;
38928
- }
38929
- const ns = NormalizedSchema.of(schema);
38930
- const isObject3 = typeof value2 === "object";
38931
- if (ns.isStringSchema()) {
38932
- const mediaType = ns.getMergedTraits().mediaType;
38933
- if (mediaType) {
38934
- const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
38935
- if (isJson) {
38936
- this.writeJsonString(LazyJsonString.from(value2).toString());
38937
- return;
39291
+ if (Array.isArray(value2) && ns.isListSchema()) {
39292
+ const listMember = ns.getValueSchema();
39293
+ const out = [];
39294
+ const sparse = !!ns.getMergedTraits().sparse;
39295
+ for (const item of value2) {
39296
+ if (sparse || item != null) {
39297
+ out.push(this._write(listMember, item));
39298
+ }
38938
39299
  }
38939
- }
38940
- }
38941
- if (isObject3) {
38942
- if (ns.isStructSchema()) {
38943
- this.writeStruct(ns, value2);
38944
- return;
38945
- }
38946
- if (Array.isArray(value2) && (ns.isListSchema() || ns.isDocumentSchema())) {
38947
- this.writeList(ns, value2, ns.isDocumentSchema());
38948
- return;
39300
+ return out;
38949
39301
  }
38950
39302
  if (ns.isMapSchema()) {
38951
- this.writeMap(ns, value2, false);
38952
- return;
39303
+ const mapMember = ns.getValueSchema();
39304
+ const out = {};
39305
+ const sparse = !!ns.getMergedTraits().sparse;
39306
+ for (const _k in value2) {
39307
+ const _v = value2[_k];
39308
+ if (sparse || _v != null) {
39309
+ if (_k === "__proto__") {
39310
+ writeKey(out);
39311
+ }
39312
+ out[_k] = this._write(mapMember, _v);
39313
+ }
39314
+ }
39315
+ return out;
38953
39316
  }
38954
- if (value2 instanceof Uint8Array && (ns.isBlobSchema() || ns.isDocumentSchema())) {
38955
- this.writeBase64(value2);
38956
- return;
39317
+ if (value2 instanceof Uint8Array && ns.isBlobSchema()) {
39318
+ if (ns === this.rootSchema) {
39319
+ return value2;
39320
+ }
39321
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value2);
38957
39322
  }
38958
39323
  if (value2 instanceof Date && (ns.isTimestampSchema() || ns.isDocumentSchema())) {
38959
- this.writeTimestamp(ns, value2);
38960
- return;
39324
+ const format30 = determineTimestampFormat(ns, this.settings);
39325
+ switch (format30) {
39326
+ case 5:
39327
+ return value2.toISOString().replace(".000Z", "Z");
39328
+ case 6:
39329
+ return dateToUtcString(value2);
39330
+ case 7:
39331
+ return value2.getTime() / 1e3;
39332
+ default:
39333
+ console.warn("Missing timestamp format, using epoch seconds", value2);
39334
+ return value2.getTime() / 1e3;
39335
+ }
38961
39336
  }
38962
39337
  if (value2 instanceof NumericValue) {
38963
- this.writeAscii(value2.string);
38964
- return;
38965
- }
38966
- if (ns.isDocumentSchema()) {
38967
- if (Array.isArray(value2)) {
38968
- this.writeList(ns, value2, true);
38969
- } else {
38970
- this.writeMap(ns, value2, true);
38971
- }
38972
- return;
39338
+ this.useReplacer = true;
38973
39339
  }
38974
- const json = JSON.stringify(value2);
38975
- this.writeAscii(json);
38976
- return;
38977
39340
  }
38978
- if (typeof value2 === "string") {
38979
- if (ns.isBlobSchema()) {
38980
- const b64 = (this.serdeContext?.base64Encoder ?? toBase64)(value2);
38981
- this.writeAsciiQuoted(b64);
38982
- return;
39341
+ if (value2 === null && container?.isStructSchema()) {
39342
+ return void 0;
39343
+ }
39344
+ if (ns.isStringSchema()) {
39345
+ if (typeof value2 === "undefined" && ns.isIdempotencyToken()) {
39346
+ return generateIdempotencyToken();
38983
39347
  }
38984
- this.writeJsonString(value2);
38985
- return;
39348
+ const mediaType = ns.getMergedTraits().mediaType;
39349
+ if (value2 != null && mediaType) {
39350
+ const isJson = mediaType === "application/json" || mediaType.endsWith("+json");
39351
+ if (isJson) {
39352
+ return LazyJsonString.from(value2);
39353
+ }
39354
+ }
39355
+ return value2;
38986
39356
  }
38987
39357
  if (typeof value2 === "number") {
38988
- if (ns.isNumericSchema() && (Math.abs(value2) === Infinity || isNaN(value2))) {
38989
- this.writeAsciiQuoted(String(value2));
38990
- return;
39358
+ if (Math.abs(value2) === Infinity || isNaN(value2)) {
39359
+ return String(value2);
38991
39360
  }
38992
- const numStr = String(value2);
38993
- this.writeAscii(numStr);
38994
- return;
39361
+ return value2;
38995
39362
  }
38996
- if (typeof value2 === "boolean") {
38997
- this.ensure(5);
38998
- if (value2) {
38999
- this.json.set(TRUE, this.i);
39000
- this.i += 4;
39001
- } else {
39002
- this.json.set(FALSE, this.i);
39003
- this.i += 5;
39363
+ if (typeof value2 === "string" && ns.isBlobSchema()) {
39364
+ if (ns === this.rootSchema) {
39365
+ return value2;
39004
39366
  }
39005
- return;
39367
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value2);
39006
39368
  }
39007
39369
  if (typeof value2 === "bigint") {
39008
- this.writeAscii(value2.toString());
39009
- return;
39010
- }
39011
- this.writeAscii(String(value2));
39012
- }
39013
- writeStruct(ns, value2) {
39014
- this.ensure(2);
39015
- this.json[this.i++] = OPEN_BRACE;
39016
- let first = true;
39017
- let wroteAny = false;
39018
- const hasType = typeof value2.__type === "string";
39019
- let writtenKeys;
39020
- if (hasType) {
39021
- writtenKeys = /* @__PURE__ */ new Set();
39022
- }
39023
- for (const [memberName, memberSchema] of ns.structIterator()) {
39024
- const item = value2[memberName];
39025
- if (item == null && !memberSchema.isIdempotencyToken())
39026
- continue;
39027
- if (!first) {
39028
- this.ensure(1);
39029
- this.json[this.i++] = COMMA;
39030
- }
39031
- first = false;
39032
- wroteAny = true;
39033
- const targetKey = this.settings.jsonName ? memberSchema.getMergedTraits().jsonName ?? memberName : memberName;
39034
- if (writtenKeys) {
39035
- writtenKeys.add(memberName);
39036
- writtenKeys.add(targetKey);
39037
- }
39038
- this.writeAsciiQuoted(targetKey);
39039
- this.json[this.i++] = COLON;
39040
- this.writeValue(memberSchema, item, ns);
39370
+ this.useReplacer = true;
39041
39371
  }
39042
- if (!wroteAny && ns.isUnionSchema()) {
39043
- const { $unknown } = value2;
39044
- if (Array.isArray($unknown)) {
39045
- const [k6, v] = $unknown;
39046
- this.writeAsciiQuoted(k6);
39047
- this.ensure(1);
39048
- this.json[this.i++] = COLON;
39049
- this.writeValue(15, v, ns);
39050
- }
39051
- } else if (hasType) {
39052
- for (const k6 in value2) {
39053
- const targetKey = this.settings.jsonName ? writtenKeys.has(k6) ? k6 : k6 : k6;
39054
- if (writtenKeys.has(targetKey))
39055
- continue;
39056
- writtenKeys.add(targetKey);
39057
- const v = value2[k6];
39058
- if (!first) {
39059
- this.ensure(1);
39060
- this.json[this.i++] = COMMA;
39372
+ if (ns.isDocumentSchema()) {
39373
+ if (isObject3) {
39374
+ if (value2 instanceof Uint8Array) {
39375
+ return (this.serdeContext?.base64Encoder ?? toBase64)(value2);
39061
39376
  }
39062
- first = false;
39063
- this.writeAsciiQuoted(targetKey);
39064
- this.ensure(1);
39065
- this.json[this.i++] = COLON;
39066
- this.writeValue(15, v, void 0);
39067
- }
39068
- }
39069
- this.ensure(1);
39070
- this.json[this.i++] = CLOSE_BRACE;
39071
- }
39072
- writeList(ns, value2, isDocument) {
39073
- this.ensure(2);
39074
- this.json[this.i++] = OPEN_BRACKET;
39075
- const sparse = !!ns.getMergedTraits().sparse;
39076
- const valueSchema = ns.getValueSchema();
39077
- for (let i6 = 0; i6 < value2.length; ++i6) {
39078
- const item = value2[i6];
39079
- if (isDocument ? item === void 0 : item == null && !sparse) {
39080
- continue;
39081
- }
39082
- if (i6 !== 0) {
39083
- this.ensure(1);
39084
- this.json[this.i++] = COMMA;
39085
- }
39086
- this.writeValue(valueSchema, item, void 0);
39087
- }
39088
- this.ensure(1);
39089
- this.json[this.i++] = CLOSE_BRACKET;
39090
- }
39091
- writeMap(ns, value2, isDocument) {
39092
- const sparse = !!ns.getMergedTraits().sparse;
39093
- const valueSchema = ns.getValueSchema();
39094
- if (!isDocument) {
39095
- if (valueSchema.isStringSchema() || valueSchema.isNumericSchema() || valueSchema.isBooleanSchema()) {
39096
- let input = value2;
39097
- if (sparse) {
39098
- input = {};
39099
- for (const k6 in value2) {
39100
- if (k6 === "__proto__") {
39101
- writeKey(input);
39102
- }
39103
- input[k6] = value2[k6] ?? null;
39377
+ const out = Array.isArray(value2) ? [] : {};
39378
+ for (const k6 in value2) {
39379
+ const v = value2[k6];
39380
+ if (k6 === "__proto__") {
39381
+ writeKey(out);
39382
+ }
39383
+ if (v instanceof NumericValue) {
39384
+ this.useReplacer = true;
39385
+ out[k6] = v;
39386
+ } else {
39387
+ out[k6] = this._write(ns, v);
39104
39388
  }
39105
39389
  }
39106
- const json = JSON.stringify(input);
39107
- this.ensure(json.length * 3);
39108
- const { written } = encoder.encodeInto(json, this.json.subarray(this.i));
39109
- this.i += written;
39110
- return;
39111
- }
39112
- }
39113
- this.ensure(2);
39114
- this.json[this.i++] = OPEN_BRACE;
39115
- let first = true;
39116
- for (const k6 in value2) {
39117
- const v = value2[k6];
39118
- if (isDocument ? v === void 0 : v == null && !sparse) {
39119
- continue;
39120
- }
39121
- if (!first) {
39122
- this.ensure(1);
39123
- this.json[this.i++] = COMMA;
39124
- }
39125
- first = false;
39126
- this.writeJsonString(k6);
39127
- this.ensure(1);
39128
- this.json[this.i++] = COLON;
39129
- this.writeValue(valueSchema, v, void 0);
39130
- }
39131
- this.ensure(1);
39132
- this.json[this.i++] = CLOSE_BRACE;
39133
- }
39134
- writeTimestamp(ns, value2) {
39135
- const format30 = determineTimestampFormat(ns, this.settings);
39136
- switch (format30) {
39137
- case 5: {
39138
- const iso = value2.toISOString().replace(".000Z", "Z");
39139
- this.writeAsciiQuoted(iso);
39140
- return;
39141
- }
39142
- case 6: {
39143
- this.writeAsciiQuoted(dateToUtcString(value2));
39144
- return;
39145
- }
39146
- case 7: {
39147
- const epochSecs = String(value2.getTime() / 1e3);
39148
- this.writeAscii(epochSecs);
39149
- return;
39150
- }
39151
- default: {
39152
- const epochSecs = String(value2.getTime() / 1e3);
39153
- this.writeAscii(epochSecs);
39154
- return;
39390
+ return out;
39391
+ } else {
39392
+ return structuredClone(value2);
39155
39393
  }
39156
39394
  }
39395
+ return value2;
39157
39396
  }
39158
39397
  };
39159
39398
  }
39160
39399
  });
39161
39400
 
39162
- // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js
39163
- var JsonCodec2;
39164
- var init_JsonCodec2 = __esm({
39165
- "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v2/JsonCodec2.js"() {
39401
+ // ../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js
39402
+ var JsonCodec;
39403
+ var init_JsonCodec = __esm({
39404
+ "../../node_modules/@aws-sdk/core/dist-es/submodules/protocols/json/codec-v1/JsonCodec.js"() {
39166
39405
  init_ConfigurableSerdeContext();
39167
- init_JsonShapeDeserializer2();
39168
- init_JsonShapeSerializer2();
39169
- JsonCodec2 = class extends SerdeContextConfig {
39406
+ init_JsonShapeDeserializer();
39407
+ init_JsonShapeSerializer();
39408
+ JsonCodec = class extends SerdeContextConfig {
39170
39409
  static {
39171
- __name(this, "JsonCodec2");
39410
+ __name(this, "JsonCodec");
39172
39411
  }
39173
39412
  settings;
39174
39413
  constructor(settings) {
@@ -39176,12 +39415,12 @@ var init_JsonCodec2 = __esm({
39176
39415
  this.settings = settings;
39177
39416
  }
39178
39417
  createSerializer() {
39179
- const serializer = new JsonShapeSerializer2(this.settings);
39418
+ const serializer = new JsonShapeSerializer(this.settings);
39180
39419
  serializer.setSerdeContext(this.serdeContext);
39181
39420
  return serializer;
39182
39421
  }
39183
39422
  createDeserializer() {
39184
- const deserializer = new JsonShapeDeserializer2(this.settings);
39423
+ const deserializer = new JsonShapeDeserializer(this.settings);
39185
39424
  deserializer.setSerdeContext(this.serdeContext);
39186
39425
  return deserializer;
39187
39426
  }
@@ -44951,7 +45190,7 @@ var init_signin = __esm({
44951
45190
  var require_dist_cjs11 = __commonJS({
44952
45191
  "../../node_modules/@aws-sdk/credential-provider-login/dist-cjs/index.js"(exports2) {
44953
45192
  var { setCredentialFeature: setCredentialFeature2 } = (init_client3(), __toCommonJS(client_exports2));
44954
- var { CredentialsProviderError: CredentialsProviderError2, readFile: readFile11, parseKnownFiles: parseKnownFiles2, getProfileName: getProfileName2 } = (init_config2(), __toCommonJS(config_exports));
45193
+ var { CredentialsProviderError: CredentialsProviderError2, parseKnownFiles: parseKnownFiles2, getProfileName: getProfileName2 } = (init_config2(), __toCommonJS(config_exports));
44955
45194
  var { HttpRequest: HttpRequest2 } = (init_protocols(), __toCommonJS(protocols_exports));
44956
45195
  var { createHash: createHash8, createPrivateKey, createPublicKey, sign: sign3 } = require("node:crypto");
44957
45196
  var { promises: promises8 } = require("node:fs");
@@ -44982,13 +45221,7 @@ var require_dist_cjs11 = __commonJS({
44982
45221
  if (timeUntilExpiry <= _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
44983
45222
  return this.refresh(token);
44984
45223
  }
44985
- return {
44986
- accessKeyId: accessToken.accessKeyId,
44987
- secretAccessKey: accessToken.secretAccessKey,
44988
- sessionToken: accessToken.sessionToken,
44989
- accountId: accessToken.accountId,
44990
- expiration: new Date(accessToken.expiresAt)
44991
- };
45224
+ return this.toCredentials(token.accessToken);
44992
45225
  }
44993
45226
  get logger() {
44994
45227
  return this.init?.logger;
@@ -44996,7 +45229,25 @@ var require_dist_cjs11 = __commonJS({
44996
45229
  get loginSession() {
44997
45230
  return this.profileData.login_session;
44998
45231
  }
45232
+ toCredentials(token) {
45233
+ return {
45234
+ accessKeyId: token.accessKeyId,
45235
+ secretAccessKey: token.secretAccessKey,
45236
+ sessionToken: token.sessionToken,
45237
+ accountId: token.accountId,
45238
+ expiration: new Date(token.expiresAt)
45239
+ };
45240
+ }
44999
45241
  async refresh(token) {
45242
+ const diskToken = await this.loadToken().catch(() => token);
45243
+ const now = Date.now();
45244
+ const diskExpiry = new Date(diskToken.accessToken.expiresAt).getTime();
45245
+ const tokenExpiry = new Date(token.accessToken.expiresAt).getTime();
45246
+ const freshToken = diskExpiry <= now && tokenExpiry > now ? token : diskToken;
45247
+ const freshExpiry = new Date(freshToken.accessToken.expiresAt).getTime();
45248
+ if (freshExpiry - Date.now() > _LoginCredentialsFetcher.REFRESH_THRESHOLD) {
45249
+ return this.toCredentials(freshToken.accessToken);
45250
+ }
45000
45251
  const { SigninClient: SigninClient2, CreateOAuth2TokenCommand: CreateOAuth2TokenCommand2 } = (init_signin(), __toCommonJS(signin_exports));
45001
45252
  const { logger: logger2, userAgentAppId } = this.callerClientConfig ?? {};
45002
45253
  const isH22 = /* @__PURE__ */ __name((requestHandler2) => {
@@ -45018,8 +45269,8 @@ var require_dist_cjs11 = __commonJS({
45018
45269
  this.createDPoPInterceptor(client.middlewareStack);
45019
45270
  const commandInput = {
45020
45271
  tokenInput: {
45021
- clientId: token.clientId,
45022
- refreshToken: token.refreshToken,
45272
+ clientId: freshToken.clientId,
45273
+ refreshToken: freshToken.refreshToken,
45023
45274
  grantType: "refresh_token"
45024
45275
  }
45025
45276
  };
@@ -45036,9 +45287,9 @@ var require_dist_cjs11 = __commonJS({
45036
45287
  const expiresInMs = (expiresIn ?? 900) * 1e3;
45037
45288
  const expiration = new Date(Date.now() + expiresInMs);
45038
45289
  const updatedToken = {
45039
- ...token,
45290
+ ...freshToken,
45040
45291
  accessToken: {
45041
- ...token.accessToken,
45292
+ ...freshToken.accessToken,
45042
45293
  accessKeyId,
45043
45294
  secretAccessKey,
45044
45295
  sessionToken,
@@ -45047,14 +45298,7 @@ var require_dist_cjs11 = __commonJS({
45047
45298
  refreshToken
45048
45299
  };
45049
45300
  await this.saveToken(updatedToken);
45050
- const newAccessToken = updatedToken.accessToken;
45051
- return {
45052
- accessKeyId: newAccessToken.accessKeyId,
45053
- secretAccessKey: newAccessToken.secretAccessKey,
45054
- sessionToken: newAccessToken.sessionToken,
45055
- accountId: newAccessToken.accountId,
45056
- expiration
45057
- };
45301
+ return this.toCredentials(updatedToken.accessToken);
45058
45302
  } catch (error3) {
45059
45303
  if (error3.name === "AccessDeniedException") {
45060
45304
  const errorType = error3.error;
@@ -45072,7 +45316,15 @@ var require_dist_cjs11 = __commonJS({
45072
45316
  default:
45073
45317
  message2 = `Failed to refresh token: ${String(error3)}. Please re-authenticate using \`aws login\``;
45074
45318
  }
45075
- throw new CredentialsProviderError2(message2, { logger: this.logger, tryNextLink: false });
45319
+ throw new CredentialsProviderError2(message2, {
45320
+ logger: this.logger,
45321
+ tryNextLink: false
45322
+ });
45323
+ }
45324
+ const tokenExpiry2 = new Date(freshToken.accessToken.expiresAt).getTime();
45325
+ if (tokenExpiry2 > Date.now()) {
45326
+ this.logger?.warn?.(`Failed to refresh token: ${String(error3)}. Using existing token until expiry.`);
45327
+ return this.toCredentials(freshToken.accessToken);
45076
45328
  }
45077
45329
  throw new CredentialsProviderError2(`Failed to refresh token: ${String(error3)}. Please re-authenticate using aws login`, { logger: this.logger });
45078
45330
  }
@@ -45080,12 +45332,7 @@ var require_dist_cjs11 = __commonJS({
45080
45332
  async loadToken() {
45081
45333
  const tokenFilePath = this.getTokenFilePath();
45082
45334
  try {
45083
- let tokenData;
45084
- try {
45085
- tokenData = await readFile11(tokenFilePath, { ignoreCache: this.init?.ignoreCache });
45086
- } catch {
45087
- tokenData = await promises8.readFile(tokenFilePath, "utf8");
45088
- }
45335
+ const tokenData = await promises8.readFile(tokenFilePath, "utf8");
45089
45336
  const token = JSON.parse(tokenData);
45090
45337
  const missingFields = ["accessToken", "clientId", "refreshToken", "dpopKey"].filter((k6) => !token[k6]);
45091
45338
  if (!token.accessToken?.accountId) {
@@ -78038,10 +78285,10 @@ ${pair.comment}` : item.comment;
78038
78285
  }
78039
78286
  }
78040
78287
  __name(warnFileDeprecation, "warnFileDeprecation");
78041
- var warned = {};
78288
+ var warned2 = {};
78042
78289
  function warnOptionDeprecation(name, alternative) {
78043
- if (!warned[name] && shouldWarn(true)) {
78044
- warned[name] = true;
78290
+ if (!warned2[name] && shouldWarn(true)) {
78291
+ warned2[name] = true;
78045
78292
  let msg = `The option '${name}' will be removed in a future release`;
78046
78293
  msg += alternative ? `, use '${alternative}' instead.` : ".";
78047
78294
  warn2(msg, "DeprecationWarning");
@@ -296825,9 +297072,6 @@ function stripReferences(value2, exports2) {
296825
297072
  if ("Fn::GetAtt" in value2) {
296826
297073
  return { __cloud_ref__: "Fn::GetAtt" };
296827
297074
  }
296828
- if ("DependsOn" in value2) {
296829
- return { __cloud_ref__: "DependsOn" };
296830
- }
296831
297075
  if ("Fn::ImportValue" in value2) {
296832
297076
  const exp = exports2[value2["Fn::ImportValue"]];
296833
297077
  if (exp != null) {
@@ -296845,6 +297089,9 @@ function stripReferences(value2, exports2) {
296845
297089
  }
296846
297090
  const result2 = {};
296847
297091
  for (const [k6, v] of Object.entries(value2)) {
297092
+ if (k6 === "DependsOn") {
297093
+ continue;
297094
+ }
296848
297095
  result2[k6] = stripReferences(v, exports2);
296849
297096
  }
296850
297097
  return result2;
@@ -316740,7 +316987,7 @@ var require_lru_cache = __commonJS({
316740
316987
  }
316741
316988
  }
316742
316989
  };
316743
- var warned = /* @__PURE__ */ new Set();
316990
+ var warned2 = /* @__PURE__ */ new Set();
316744
316991
  var deprecatedOption = /* @__PURE__ */ __name((opt, instead) => {
316745
316992
  const code = `LRU_CACHE_OPTION_${opt}`;
316746
316993
  if (shouldWarn(code)) {
@@ -316766,9 +317013,9 @@ var require_lru_cache = __commonJS({
316766
317013
  var emitWarning = /* @__PURE__ */ __name((...a6) => {
316767
317014
  typeof process === "object" && process && typeof process.emitWarning === "function" ? process.emitWarning(...a6) : console.error(...a6);
316768
317015
  }, "emitWarning");
316769
- var shouldWarn = /* @__PURE__ */ __name((code) => !warned.has(code), "shouldWarn");
317016
+ var shouldWarn = /* @__PURE__ */ __name((code) => !warned2.has(code), "shouldWarn");
316770
317017
  var warn2 = /* @__PURE__ */ __name((code, what, instead, fn) => {
316771
- warned.add(code);
317018
+ warned2.add(code);
316772
317019
  const msg = `The ${what} is deprecated. Please use ${instead} instead.`;
316773
317020
  emitWarning(msg, "DeprecationWarning", code, fn);
316774
317021
  }, "warn");
@@ -316928,7 +317175,7 @@ var require_lru_cache = __commonJS({
316928
317175
  if (!this.ttlAutopurge && !this.max && !this.maxSize) {
316929
317176
  const code = "LRU_CACHE_UNBOUNDED";
316930
317177
  if (shouldWarn(code)) {
316931
- warned.add(code);
317178
+ warned2.add(code);
316932
317179
  const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
316933
317180
  emitWarning(msg, "UnboundedCacheWarning", code, _LRUCache);
316934
317181
  }
@@ -318252,10 +318499,10 @@ var require_browser = __commonJS({
318252
318499
  exports2.useColors = useColors;
318253
318500
  exports2.storage = localstorage();
318254
318501
  exports2.destroy = /* @__PURE__ */ (() => {
318255
- let warned = false;
318502
+ let warned2 = false;
318256
318503
  return () => {
318257
- if (!warned) {
318258
- warned = true;
318504
+ if (!warned2) {
318505
+ warned2 = true;
318259
318506
  console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
318260
318507
  }
318261
318508
  };