@salable/sdk 1.0.41 → 1.0.43

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/dist/index.es.js CHANGED
@@ -407,21 +407,21 @@ const deserializeIntoUntypedNode = (untypedNode = {}) => {
407
407
  * @param node The object to check.
408
408
  * @returns boolean indicating if the node is an UntypedNumber.
409
409
  */
410
- function isUntypedNumber(node) {
410
+ const isUntypedNumber = (node) => {
411
411
  const proposedNode = node;
412
412
  return proposedNode && typeof proposedNode.value === "number";
413
- }
413
+ };
414
414
  /**
415
415
  * Factory to create an UntypedNumber from a number.
416
416
  * @param value The number value to create from.
417
417
  * @returns The created UntypedNumber.
418
418
  */
419
- function createUntypedNumber(value) {
419
+ const createUntypedNumber = (value) => {
420
420
  return {
421
421
  value,
422
422
  getValue: () => value,
423
423
  };
424
- }
424
+ };
425
425
 
426
426
  /**
427
427
  * -------------------------------------------------------------------------------------------
@@ -455,19 +455,19 @@ const createUntypedArray = (value) => {
455
455
  * @param node The object to check.
456
456
  * @returns boolean indicating if the node is an UntypedNull.
457
457
  */
458
- function isUntypedNull(node) {
458
+ const isUntypedNull = (node) => {
459
459
  return node.value === null;
460
- }
460
+ };
461
461
  /**
462
- * Factory to create an UntypedNull from a boolean.
462
+ * Factory to create an UntypedNull.
463
463
  * @returns The created UntypedNull.
464
464
  */
465
- function createUntypedNull() {
465
+ const createUntypedNull = () => {
466
466
  return {
467
467
  value: null,
468
468
  getValue: () => null,
469
469
  };
470
- }
470
+ };
471
471
 
472
472
  /**
473
473
  * -------------------------------------------------------------------------------------------
@@ -501,42 +501,42 @@ const createUntypedObject = (value) => {
501
501
  * @param node The object to check.
502
502
  * @returns boolean indicating if the node is an UntypedString.
503
503
  */
504
- function isUntypedString(node) {
504
+ const isUntypedString = (node) => {
505
505
  const proposedNode = node;
506
506
  return proposedNode && typeof proposedNode.value === "string";
507
- }
507
+ };
508
508
  /**
509
509
  * Factory to create an UntypedString from a string.
510
510
  * @param value The string value to create from.
511
511
  * @returns The created UntypedString.
512
512
  */
513
- function createUntypedString(value) {
513
+ const createUntypedString = (value) => {
514
514
  return {
515
515
  value,
516
516
  getValue: () => value,
517
517
  };
518
- }
518
+ };
519
519
 
520
520
  /**
521
521
  * Type guard to assert that an UntypedNode instance is an UntypedBoolean.
522
522
  * @param node The UntypedNode to check.
523
523
  * @returns boolean indicating if the node is an UntypedBoolean.
524
524
  */
525
- function isUntypedBoolean(node) {
525
+ const isUntypedBoolean = (node) => {
526
526
  const proposedNode = node;
527
527
  return proposedNode && typeof proposedNode.value === "boolean";
528
- }
528
+ };
529
529
  /**
530
530
  * Factory to create an UntypedBoolean from a boolean.
531
531
  * @param value The boolean value to create from.
532
532
  * @returns The created UntypedBoolean.
533
533
  */
534
- function createUntypedBoolean(value) {
534
+ const createUntypedBoolean = (value) => {
535
535
  return {
536
536
  value,
537
537
  getValue: () => value,
538
538
  };
539
- }
539
+ };
540
540
 
541
541
  /**
542
542
  * -------------------------------------------------------------------------------------------
@@ -790,10 +790,10 @@ const BackingStoreKey = "backingStoreEnabled";
790
790
  * @param fields The fields of the object
791
791
  * @returns boolean indicating if the object is a BackedModel
792
792
  */
793
- function isBackingStoreEnabled(fields) {
793
+ const isBackingStoreEnabled = (fields) => {
794
794
  // Check if the fields contain the backing store key
795
795
  return Object.keys(fields).includes(BackingStoreKey);
796
- }
796
+ };
797
797
 
798
798
  /**
799
799
  * -------------------------------------------------------------------------------------------
@@ -808,7 +808,7 @@ function isBackingStoreEnabled(fields) {
808
808
  * @param original The serialization writer to enable the backing store on.
809
809
  * @returns A new serialization writer with the backing store enabled.
810
810
  */
811
- function enableBackingStoreForSerializationWriterFactory(serializationWriterFactoryRegistry, parseNodeFactoryRegistry, original) {
811
+ const enableBackingStoreForSerializationWriterFactory = (serializationWriterFactoryRegistry, parseNodeFactoryRegistry, original) => {
812
812
  if (!original)
813
813
  throw new Error("Original must be specified");
814
814
  let result = original;
@@ -821,14 +821,14 @@ function enableBackingStoreForSerializationWriterFactory(serializationWriterFact
821
821
  enableBackingStoreForSerializationRegistry(serializationWriterFactoryRegistry);
822
822
  enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
823
823
  return result;
824
- }
824
+ };
825
825
  /**
826
826
  * Enables the backing store on default parse node factories and the given parse node factory.
827
827
  * @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on.
828
828
  * @param original The parse node factory to enable the backing store on.
829
829
  * @returns A new parse node factory with the backing store enabled.
830
830
  */
831
- function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry, original) {
831
+ const enableBackingStoreForParseNodeFactory = (parseNodeFactoryRegistry, original) => {
832
832
  if (!original)
833
833
  throw new Error("Original must be specified");
834
834
  let result = original;
@@ -840,29 +840,29 @@ function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry, origina
840
840
  }
841
841
  enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
842
842
  return result;
843
- }
843
+ };
844
844
  /**
845
845
  * Enables the backing store on the given parse node factory registry.
846
846
  * @param registry The parse node factory registry to enable the backing store on.
847
847
  */
848
- function enableBackingStoreForParseNodeRegistry(registry) {
848
+ const enableBackingStoreForParseNodeRegistry = (registry) => {
849
849
  for (const [k, v] of registry.contentTypeAssociatedFactories) {
850
850
  if (!(v instanceof BackingStoreParseNodeFactory || v instanceof ParseNodeFactoryRegistry)) {
851
851
  registry.contentTypeAssociatedFactories.set(k, new BackingStoreParseNodeFactory(v));
852
852
  }
853
853
  }
854
- }
854
+ };
855
855
  /**
856
856
  * Enables the backing store on the given serialization factory registry.
857
857
  * @param registry The serialization factory registry to enable the backing store on.
858
858
  */
859
- function enableBackingStoreForSerializationRegistry(registry) {
859
+ const enableBackingStoreForSerializationRegistry = (registry) => {
860
860
  for (const [k, v] of registry.contentTypeAssociatedFactories) {
861
861
  if (!(v instanceof BackingStoreSerializationWriterProxyFactory || v instanceof SerializationWriterFactoryRegistry)) {
862
862
  registry.contentTypeAssociatedFactories.set(k, new BackingStoreSerializationWriterProxyFactory(v));
863
863
  }
864
864
  }
865
- }
865
+ };
866
866
 
867
867
  /*
868
868
  * Copyright The OpenTelemetry Authors
@@ -2635,9 +2635,9 @@ class DateOnly {
2635
2635
  * @param digits The number of digits to pad
2636
2636
  * @returns The formatted segment
2637
2637
  */
2638
- function formatSegment(segment, digits = 2) {
2638
+ const formatSegment = (segment, digits = 2) => {
2639
2639
  return segment.toString().padStart(digits, "0");
2640
- }
2640
+ };
2641
2641
 
2642
2642
  var dist = {};
2643
2643
 
@@ -2868,7 +2868,7 @@ class Duration {
2868
2868
  * @param canon The function that canonicalizes the property name.
2869
2869
  * @returns A new object that can be used as a dictionary with case-insensitive keys.
2870
2870
  */
2871
- function dictionaryWithCanonicalKeys(canon) {
2871
+ const dictionaryWithCanonicalKeys = (canon) => {
2872
2872
  const keysNormalizationMap = new Map();
2873
2873
  return new Proxy({}, {
2874
2874
  /**
@@ -2877,7 +2877,7 @@ function dictionaryWithCanonicalKeys(canon) {
2877
2877
  * @param prop The property to get.
2878
2878
  * @returns The value of the property.
2879
2879
  */
2880
- get(target, prop) {
2880
+ get: (target, prop) => {
2881
2881
  const normalKey = canon(prop);
2882
2882
  return Reflect.get(target, normalKey);
2883
2883
  },
@@ -2888,7 +2888,7 @@ function dictionaryWithCanonicalKeys(canon) {
2888
2888
  * @param value The value to set.
2889
2889
  * @returns A boolean indicating whether the property was set.
2890
2890
  */
2891
- set(target, prop, value) {
2891
+ set: (target, prop, value) => {
2892
2892
  const nonNormalKey = prop.toString();
2893
2893
  const normalKey = canon(prop);
2894
2894
  keysNormalizationMap.set(normalKey, nonNormalKey);
@@ -2900,7 +2900,7 @@ function dictionaryWithCanonicalKeys(canon) {
2900
2900
  * @param prop The property to check.
2901
2901
  * @returns A boolean indicating whether the property exists.
2902
2902
  */
2903
- has(_, prop) {
2903
+ has: (_, prop) => {
2904
2904
  const normalKey = canon(prop);
2905
2905
  return keysNormalizationMap.has(normalKey);
2906
2906
  },
@@ -2911,7 +2911,7 @@ function dictionaryWithCanonicalKeys(canon) {
2911
2911
  * @param attribs The attributes of the property.
2912
2912
  * @returns A boolean indicating whether the property was defined.
2913
2913
  */
2914
- defineProperty(target, prop, attribs) {
2914
+ defineProperty: (target, prop, attribs) => {
2915
2915
  const nonNormalKey = prop.toString();
2916
2916
  const normalKey = canon(prop);
2917
2917
  keysNormalizationMap.set(normalKey, nonNormalKey);
@@ -2923,7 +2923,7 @@ function dictionaryWithCanonicalKeys(canon) {
2923
2923
  * @param prop The property to delete.
2924
2924
  * @returns A boolean indicating whether the property was deleted.
2925
2925
  */
2926
- deleteProperty(target, prop) {
2926
+ deleteProperty: (target, prop) => {
2927
2927
  const normalKey = canon(prop);
2928
2928
  keysNormalizationMap.delete(normalKey);
2929
2929
  return Reflect.deleteProperty(target, normalKey);
@@ -2934,19 +2934,19 @@ function dictionaryWithCanonicalKeys(canon) {
2934
2934
  * @param prop The property to gets its descriptor.
2935
2935
  * @returns The property descriptor.
2936
2936
  */
2937
- getOwnPropertyDescriptor(target, prop) {
2937
+ getOwnPropertyDescriptor: (target, prop) => {
2938
2938
  return Reflect.getOwnPropertyDescriptor(target, canon(prop));
2939
2939
  },
2940
- ownKeys() {
2940
+ ownKeys: () => {
2941
2941
  return [...keysNormalizationMap.values()];
2942
2942
  },
2943
2943
  });
2944
- }
2944
+ };
2945
2945
  /**
2946
2946
  * A wrapper for type Record that creates a Record with case insensitive keys
2947
2947
  * @returns A new object that can be used as a dictionary with case-insensitive keys.
2948
2948
  */
2949
- function createRecordWithCaseInsensitiveKeys() {
2949
+ const createRecordWithCaseInsensitiveKeys = () => {
2950
2950
  /**
2951
2951
  * A function that takes a property name and returns its canonical form.
2952
2952
  * @param prop The property name to be canonicalized.
@@ -2954,7 +2954,7 @@ function createRecordWithCaseInsensitiveKeys() {
2954
2954
  */
2955
2955
  const record = dictionaryWithCanonicalKeys((p) => (typeof p === "string" ? p.toLowerCase() : p.toString().toLowerCase()));
2956
2956
  return record;
2957
- }
2957
+ };
2958
2958
 
2959
2959
  /**
2960
2960
  * -------------------------------------------------------------------------------------------
@@ -3054,6 +3054,7 @@ class Headers extends Map {
3054
3054
  * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each header in the dictionary.
3055
3055
  * @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
3056
3056
  */
3057
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3057
3058
  forEach(callbackfn, thisArg) {
3058
3059
  for (const header in this.headers) {
3059
3060
  if (Object.prototype.hasOwnProperty.call(this.headers, header)) {
@@ -3335,10 +3336,10 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
3335
3336
  writer.writeStringValue(undefined, part.content);
3336
3337
  }
3337
3338
  else if (part.content instanceof ArrayBuffer) {
3338
- writer.writeByteArrayValue(undefined, new Uint8Array(part.content));
3339
+ writer.writeByteArrayValue(undefined, new Uint8Array(part.content).buffer);
3339
3340
  }
3340
3341
  else if (part.content instanceof Uint8Array) {
3341
- writer.writeByteArrayValue(undefined, part.content);
3342
+ writer.writeByteArrayValue(undefined, part.content.buffer);
3342
3343
  }
3343
3344
  else if (part.serializationCallback) {
3344
3345
  if (!multipartBody.requestAdapter) {
@@ -3354,7 +3355,7 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
3354
3355
  }
3355
3356
  partSerializationWriter.writeObjectValue(undefined, part.content, part.serializationCallback);
3356
3357
  const partContent = partSerializationWriter.getSerializedContent();
3357
- writer.writeByteArrayValue(undefined, new Uint8Array(partContent));
3358
+ writer.writeByteArrayValue(undefined, new Uint8Array(partContent).buffer);
3358
3359
  }
3359
3360
  else {
3360
3361
  throw new Error("unsupported content type for multipart body: " + typeof part.content);
@@ -4018,6 +4019,10 @@ const apiClientProxifier = (requestAdapter, pathParameters, navigationMetadata,
4018
4019
  return apiClientProxifier(requestAdapter, downWardPathParameters, navigationCandidate.navigationMetadata, navigationCandidate.requestsMetadata);
4019
4020
  };
4020
4021
  }
4022
+ if (name === "then") {
4023
+ // handle returning proxy from an async method
4024
+ return undefined;
4025
+ }
4021
4026
  throw new Error(`couldn't find navigation property ${name} data: ${JSON.stringify(navigationMetadata)}`);
4022
4027
  }
4023
4028
  },
@@ -4055,7 +4060,7 @@ class AllowedHostsValidator {
4055
4060
  */
4056
4061
  constructor(allowedHosts = new Set()) {
4057
4062
  this.validateHosts(allowedHosts);
4058
- this.allowedHosts = allowedHosts !== null && allowedHosts !== void 0 ? allowedHosts : new Set();
4063
+ this.allowedHosts = this.normalizeHosts(allowedHosts);
4059
4064
  }
4060
4065
  /**
4061
4066
  * Gets the list of valid hosts. If the list is empty, all hosts are valid.
@@ -4070,7 +4075,7 @@ class AllowedHostsValidator {
4070
4075
  */
4071
4076
  setAllowedHosts(allowedHosts) {
4072
4077
  this.validateHosts(allowedHosts);
4073
- this.allowedHosts = allowedHosts;
4078
+ this.allowedHosts = this.normalizeHosts(allowedHosts);
4074
4079
  }
4075
4080
  /**
4076
4081
  * Checks whether the provided host is valid.
@@ -4078,7 +4083,7 @@ class AllowedHostsValidator {
4078
4083
  * @returns True if the host is valid, false otherwise.
4079
4084
  */
4080
4085
  isUrlHostValid(url) {
4081
- var _a, _b;
4086
+ var _a;
4082
4087
  if (!url)
4083
4088
  return false;
4084
4089
  if (this.allowedHosts.size === 0)
@@ -4095,7 +4100,7 @@ class AllowedHostsValidator {
4095
4100
  return this.isHostAndPathValid(url);
4096
4101
  }
4097
4102
  if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) {
4098
- return this.allowedHosts.has((_b = window.location.host) === null || _b === void 0 ? void 0 : _b.toLowerCase());
4103
+ return this.isHostValid(window.location.host);
4099
4104
  }
4100
4105
  return false;
4101
4106
  }
@@ -4104,11 +4109,21 @@ class AllowedHostsValidator {
4104
4109
  if (hostAndRest.length >= 2) {
4105
4110
  const host = hostAndRest[0];
4106
4111
  if (host) {
4107
- return this.allowedHosts.has(host.toLowerCase());
4112
+ return this.isHostValid(host.split(":")[0]);
4108
4113
  }
4109
4114
  }
4110
4115
  return false;
4111
4116
  }
4117
+ isHostValid(host) {
4118
+ const normalizedHost = host.toLowerCase();
4119
+ if (this.allowedHosts.has(normalizedHost)) {
4120
+ return true;
4121
+ }
4122
+ return Array.from(this.allowedHosts).some((allowedHost) => allowedHost.startsWith(".") && normalizedHost.endsWith(allowedHost));
4123
+ }
4124
+ normalizeHosts(hostsToNormalize) {
4125
+ return new Set(Array.from(hostsToNormalize, (host) => host.toLowerCase()));
4126
+ }
4112
4127
  validateHosts(hostsToValidate) {
4113
4128
  if (!hostsToValidate) {
4114
4129
  throw new Error("hostsToValidate cannot be null");
@@ -4132,27 +4147,27 @@ const localhostStrings = new Set(["localhost", "[::1]", "::1", "127.0.0.1"]);
4132
4147
  * Validates the protocol of the url.
4133
4148
  * @param url - The url to validate.
4134
4149
  */
4135
- function validateProtocol(url) {
4150
+ const validateProtocol = (url) => {
4136
4151
  if (!isLocalhostUrl(url) && !url.toLocaleLowerCase().startsWith("https://") && !windowUrlStartsWithHttps()) {
4137
4152
  throw new Error("Authentication scheme can only be used with https requests");
4138
4153
  }
4139
- }
4154
+ };
4140
4155
  /**
4141
4156
  * Checks if the window url starts with https.
4142
4157
  * @returns True if the window url starts with https, false otherwise.
4143
4158
  */
4144
- function windowUrlStartsWithHttps() {
4159
+ const windowUrlStartsWithHttps = () => {
4145
4160
  if (!inNodeEnv()) {
4146
4161
  return window.location.protocol.toLocaleLowerCase() === "https:";
4147
4162
  }
4148
4163
  return false;
4149
- }
4164
+ };
4150
4165
  /**
4151
4166
  * Checks if the url is a localhost url.
4152
4167
  * @param urlString - The url to check.
4153
4168
  * @returns True if the url is a localhost url, false otherwise.
4154
4169
  */
4155
- function isLocalhostUrl(urlString) {
4170
+ const isLocalhostUrl = (urlString) => {
4156
4171
  try {
4157
4172
  const url = new URL(urlString);
4158
4173
  return localhostStrings.has(url.hostname);
@@ -4160,7 +4175,7 @@ function isLocalhostUrl(urlString) {
4160
4175
  catch (_a) {
4161
4176
  return false;
4162
4177
  }
4163
- }
4178
+ };
4164
4179
 
4165
4180
  /** Authenticate a request by using an API Key */
4166
4181
  class ApiKeyAuthenticationProvider {
@@ -4285,14 +4300,9 @@ class HttpClient {
4285
4300
  middlewares = (middlewares === null || middlewares === void 0 ? void 0 : middlewares.length) && middlewares[0] ? middlewares : MiddlewareFactory.getDefaultMiddlewares(customFetch);
4286
4301
  // If a custom fetch function is provided, add a CustomFetchHandler to the end of the middleware chain
4287
4302
  if (this.customFetch) {
4288
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4289
- middlewares.push(new CustomFetchHandler(customFetch));
4290
- }
4291
- // eslint-disable-next-line no-console
4292
- console.debug("Registered middlewares: " + middlewares.map((m) => m.constructor.name).join(", "));
4293
- // eslint-disable-next-line no-console
4294
- console.debug("Hint: To improve performance, use MiddlewareFactory.getPerformanceMiddlewares(customFetch) instead of MiddlewareFactory.getDefaultMiddlewares(customFetch)");
4295
- // Set the middleware chain
4303
+ middlewares.push(new CustomFetchHandler(this.customFetch));
4304
+ }
4305
+ // Set the middleware handlers chain
4296
4306
  this.setMiddleware(...middlewares);
4297
4307
  }
4298
4308
  /**
@@ -4347,7 +4357,7 @@ class ObservabilityOptionsImpl {
4347
4357
  * @param requestOptions The request options
4348
4358
  * @returns The observability options
4349
4359
  */
4350
- function getObservabilityOptionsFromRequest(requestOptions) {
4360
+ const getObservabilityOptionsFromRequest = (requestOptions) => {
4351
4361
  if (requestOptions) {
4352
4362
  const observabilityOptions = requestOptions[ObservabilityOptionKey];
4353
4363
  if (observabilityOptions instanceof ObservabilityOptionsImpl) {
@@ -4355,7 +4365,7 @@ function getObservabilityOptionsFromRequest(requestOptions) {
4355
4365
  }
4356
4366
  }
4357
4367
  return undefined;
4358
- }
4368
+ };
4359
4369
 
4360
4370
  /**
4361
4371
  * -------------------------------------------------------------------------------------------
@@ -4430,31 +4440,34 @@ class FetchRequestAdapter {
4430
4440
  case "number":
4431
4441
  case "boolean":
4432
4442
  case "Date":
4443
+ case "Duration":
4444
+ case "DateOnly":
4445
+ case "TimeOnly":
4433
4446
  // eslint-disable-next-line no-case-declarations
4434
4447
  const rootNode = await this.getRootParseNode(response);
4435
4448
  return trace.getTracer(this.observabilityOptions.getTracerInstrumentationName()).startActiveSpan(`getCollectionOf${responseType}Value`, (deserializeSpan) => {
4436
4449
  try {
4437
4450
  span.setAttribute(FetchRequestAdapter.responseTypeAttributeKey, responseType);
4438
4451
  if (responseType === "string") {
4439
- return rootNode.getCollectionOfPrimitiveValues();
4452
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4440
4453
  }
4441
4454
  else if (responseType === "number") {
4442
- return rootNode.getCollectionOfPrimitiveValues();
4455
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4443
4456
  }
4444
4457
  else if (responseType === "boolean") {
4445
- return rootNode.getCollectionOfPrimitiveValues();
4458
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4446
4459
  }
4447
4460
  else if (responseType === "Date") {
4448
- return rootNode.getCollectionOfPrimitiveValues();
4461
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4449
4462
  }
4450
4463
  else if (responseType === "Duration") {
4451
- return rootNode.getCollectionOfPrimitiveValues();
4464
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4452
4465
  }
4453
4466
  else if (responseType === "DateOnly") {
4454
- return rootNode.getCollectionOfPrimitiveValues();
4467
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4455
4468
  }
4456
4469
  else if (responseType === "TimeOnly") {
4457
- return rootNode.getCollectionOfPrimitiveValues();
4470
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4458
4471
  }
4459
4472
  else {
4460
4473
  throw new Error("unexpected type to deserialize");
@@ -4985,7 +4998,7 @@ FetchRequestAdapter.authenticateChallengedEventKey = "com.microsoft.kiota.authen
4985
4998
  * @returns A header value for the given key from the request
4986
4999
  */
4987
5000
  const getRequestHeader = (options, key) => {
4988
- if (options && options.headers) {
5001
+ if (options === null || options === void 0 ? void 0 : options.headers) {
4989
5002
  return options.headers[key];
4990
5003
  }
4991
5004
  return undefined;
@@ -5206,7 +5219,7 @@ class CompressionHandler {
5206
5219
  }
5207
5220
  const uint8ArrayToStream = (uint8Array) => {
5208
5221
  return new ReadableStream({
5209
- start(controller) {
5222
+ start: (controller) => {
5210
5223
  controller.enqueue(uint8Array);
5211
5224
  controller.close();
5212
5225
  },
@@ -5463,6 +5476,47 @@ class ParametersNameDecodingHandler {
5463
5476
  * -------------------------------------------------------------------------------------------
5464
5477
  */
5465
5478
  const RedirectHandlerOptionKey = "RedirectHandlerOption";
5479
+ /**
5480
+ * The default implementation for scrubbing sensitive headers during redirects.
5481
+ * This function removes Authorization, Cookie, and Proxy-Authorization headers when the host or scheme changes.
5482
+ *
5483
+ * It is exported so that consumers providing a custom {@link ScrubSensitiveHeaders} callback can call it to
5484
+ * retain the default behavior and then layer additional logic on top (e.g. removing custom headers such as
5485
+ * `X-Api-Key`), matching the composable pattern available in the .NET and Python Kiota SDKs.
5486
+ *
5487
+ * Note: In browser environments, `Proxy-Authorization` is a forbidden header name and typically cannot be set;
5488
+ * it is still removed here if present (e.g. in Node.js or other non-browser runtimes).
5489
+ * @param headers - The headers object to modify
5490
+ * @param originalUrl - The original request URL
5491
+ * @param newUrl - The new redirect URL
5492
+ */
5493
+ const defaultScrubSensitiveHeaders = (headers, originalUrl, newUrl) => {
5494
+ if (!headers || !originalUrl || !newUrl) {
5495
+ return;
5496
+ }
5497
+ try {
5498
+ const originalUri = new URL(originalUrl);
5499
+ const newUri = new URL(newUrl);
5500
+ // Remove Authorization, Cookie, and Proxy-Authorization headers if the request's scheme or host changes.
5501
+ // Header keys must be matched case-insensitively because FetchRequestAdapter.getRequestFromRequestInformation
5502
+ // lower-cases every header key before the headers object reaches this middleware, so PascalCase
5503
+ // property deletes such as `delete headers.Authorization` would otherwise be a no-op.
5504
+ const isDifferentHostOrScheme = originalUri.host.toLowerCase() !== newUri.host.toLowerCase() || originalUri.protocol.toLowerCase() !== newUri.protocol.toLowerCase();
5505
+ if (isDifferentHostOrScheme) {
5506
+ for (const key of Object.keys(headers)) {
5507
+ const lower = key.toLowerCase();
5508
+ if (lower === "authorization" || lower === "cookie" || lower === "proxy-authorization") {
5509
+ delete headers[key];
5510
+ }
5511
+ }
5512
+ }
5513
+ }
5514
+ catch (_a) {
5515
+ // If URL parsing fails, don't modify headers
5516
+ // This handles cases where invalid URLs are passed
5517
+ return;
5518
+ }
5519
+ };
5466
5520
  /**
5467
5521
  * MiddlewareOptions
5468
5522
  * A class representing RedirectHandlerOptions
@@ -5477,7 +5531,7 @@ class RedirectHandlerOptions {
5477
5531
  * @example const options = new RedirectHandlerOptions({ maxRedirects: 5 });
5478
5532
  */
5479
5533
  constructor(options = {}) {
5480
- var _a, _b;
5534
+ var _a, _b, _c;
5481
5535
  if (options.maxRedirects && options.maxRedirects > RedirectHandlerOptions.MAX_MAX_REDIRECTS) {
5482
5536
  const error = new Error(`MaxRedirects should not be more than ${RedirectHandlerOptions.MAX_MAX_REDIRECTS}`);
5483
5537
  error.name = "MaxLimitExceeded";
@@ -5490,6 +5544,7 @@ class RedirectHandlerOptions {
5490
5544
  }
5491
5545
  this.maxRedirects = (_a = options.maxRedirects) !== null && _a !== void 0 ? _a : RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS;
5492
5546
  this.shouldRedirect = (_b = options.shouldRedirect) !== null && _b !== void 0 ? _b : RedirectHandlerOptions.defaultShouldRetry;
5547
+ this.scrubSensitiveHeaders = (_c = options.scrubSensitiveHeaders) !== null && _c !== void 0 ? _c : RedirectHandlerOptions.defaultScrubSensitiveHeaders;
5493
5548
  }
5494
5549
  getKey() {
5495
5550
  return RedirectHandlerOptionKey;
@@ -5509,6 +5564,11 @@ RedirectHandlerOptions.MAX_MAX_REDIRECTS = 20;
5509
5564
  * @returns true
5510
5565
  */
5511
5566
  RedirectHandlerOptions.defaultShouldRetry = () => true;
5567
+ /**
5568
+ * The default {@link ScrubSensitiveHeaders} callback used when none is supplied.
5569
+ * Delegates to the exported {@link defaultScrubSensitiveHeaders} function.
5570
+ */
5571
+ RedirectHandlerOptions.defaultScrubSensitiveHeaders = defaultScrubSensitiveHeaders;
5512
5572
 
5513
5573
  /**
5514
5574
  * -------------------------------------------------------------------------------------------
@@ -5575,27 +5635,6 @@ class RedirectHandler {
5575
5635
  isRelativeURL(url) {
5576
5636
  return !url.includes("://");
5577
5637
  }
5578
- /**
5579
- *
5580
- * To check whether the authorization header in the request should be dropped for consequent redirected requests
5581
- * @param requestUrl - The request url value
5582
- * @param redirectUrl - The redirect url value
5583
- * @returns A boolean representing whether the authorization header in the request should be dropped for consequent redirected requests
5584
- */
5585
- shouldDropAuthorizationHeader(requestUrl, redirectUrl) {
5586
- const schemeHostRegex = /^[A-Za-z].+?:\/\/.+?(?=\/|$)/;
5587
- const requestMatches = schemeHostRegex.exec(requestUrl);
5588
- let requestAuthority;
5589
- let redirectAuthority;
5590
- if (requestMatches !== null) {
5591
- requestAuthority = requestMatches[0];
5592
- }
5593
- const redirectMatches = schemeHostRegex.exec(redirectUrl);
5594
- if (redirectMatches !== null) {
5595
- redirectAuthority = redirectMatches[0];
5596
- }
5597
- return typeof requestAuthority !== "undefined" && typeof redirectAuthority !== "undefined" && requestAuthority !== redirectAuthority;
5598
- }
5599
5638
  /**
5600
5639
  * To execute the next middleware and to handle in case of redirect response returned by the server
5601
5640
  * @param url - The url string value
@@ -5614,19 +5653,22 @@ class RedirectHandler {
5614
5653
  }
5615
5654
  if (redirectCount < currentOptions.maxRedirects && this.isRedirect(response) && this.hasLocationHeader(response) && currentOptions.shouldRedirect(response)) {
5616
5655
  ++redirectCount;
5656
+ const redirectUrl = this.getLocationHeader(response);
5657
+ if (!redirectUrl) {
5658
+ return response;
5659
+ }
5660
+ // Resolve relative URLs
5661
+ const newUrl = this.isRelativeURL(redirectUrl) ? new URL(redirectUrl, url).toString() : redirectUrl;
5662
+ // Scrub sensitive headers before following the redirect
5663
+ if (fetchRequestInit.headers) {
5664
+ currentOptions.scrubSensitiveHeaders(fetchRequestInit.headers, url, newUrl);
5665
+ }
5666
+ // Handle 303 See Other: change POST to GET
5617
5667
  if (response.status === RedirectHandler.STATUS_CODE_SEE_OTHER) {
5618
5668
  fetchRequestInit.method = HttpMethod.GET;
5619
5669
  delete fetchRequestInit.body;
5620
5670
  }
5621
- else {
5622
- const redirectUrl = this.getLocationHeader(response);
5623
- if (redirectUrl) {
5624
- if (fetchRequestInit.headers && !this.isRelativeURL(redirectUrl) && this.shouldDropAuthorizationHeader(url, redirectUrl)) {
5625
- delete fetchRequestInit.headers[RedirectHandler.AUTHORIZATION_HEADER];
5626
- }
5627
- url = redirectUrl;
5628
- }
5629
- }
5671
+ url = newUrl;
5630
5672
  if (tracerName) {
5631
5673
  return trace.getTracer(tracerName).startActiveSpan(`redirectHandler - redirect ${redirectCount}`, (span) => {
5632
5674
  try {
@@ -5692,10 +5734,6 @@ RedirectHandler.STATUS_CODE_SEE_OTHER = 303;
5692
5734
  * A member holding the name of the location header
5693
5735
  */
5694
5736
  RedirectHandler.LOCATION_HEADER = "Location";
5695
- /**
5696
- * A member representing the authorization header name
5697
- */
5698
- RedirectHandler.AUTHORIZATION_HEADER = "Authorization";
5699
5737
  /**
5700
5738
  * A member holding the manual redirect value
5701
5739
  */
@@ -6192,7 +6230,6 @@ class MiddlewareFactory {
6192
6230
  * Returns the default middleware chain an array with the middleware handlers
6193
6231
  * @returns an array of the middleware handlers of the default middleware chain
6194
6232
  */
6195
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
6196
6233
  static getDefaultMiddlewares(customFetch = (...args) => fetch(...args)) {
6197
6234
  return [new RetryHandler(), new RedirectHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new HeadersInspectionHandler(), new UrlReplaceHandler(), new CustomFetchHandler(customFetch)];
6198
6235
  }
@@ -6201,7 +6238,6 @@ class MiddlewareFactory {
6201
6238
  * Returns the default middleware chain + performance middleware
6202
6239
  * @returns an array of the middleware handlers of the default + performance middleware chain
6203
6240
  */
6204
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
6205
6241
  static getPerformanceMiddlewares(customFetch = (...args) => fetch(...args)) {
6206
6242
  const middlewares = MiddlewareFactory.getDefaultMiddlewares(customFetch);
6207
6243
  middlewares.splice(middlewares.length - 3, 0, new CompressionHandler()); // insert CompressionHandler before HeadersInspectionHandler
@@ -6582,6 +6618,24 @@ function createGenerateCheckoutLinkSchema_dataFromDiscriminatorValue(parseNode)
6582
6618
  function createGenerateCheckoutLinkSchemaFromDiscriminatorValue(parseNode) {
6583
6619
  return deserializeIntoGenerateCheckoutLinkSchema;
6584
6620
  }
6621
+ /**
6622
+ * Creates a new instance of the appropriate class based on discriminator value
6623
+ * @param parseNode The parse node to use to read the discriminator value and create the object
6624
+ * @returns {GenerateOnboardingLinkResponseSchema_data}
6625
+ */
6626
+ // @ts-ignore
6627
+ function createGenerateOnboardingLinkResponseSchema_dataFromDiscriminatorValue(parseNode) {
6628
+ return deserializeIntoGenerateOnboardingLinkResponseSchema_data;
6629
+ }
6630
+ /**
6631
+ * Creates a new instance of the appropriate class based on discriminator value
6632
+ * @param parseNode The parse node to use to read the discriminator value and create the object
6633
+ * @returns {GenerateOnboardingLinkResponseSchema}
6634
+ */
6635
+ // @ts-ignore
6636
+ function createGenerateOnboardingLinkResponseSchemaFromDiscriminatorValue(parseNode) {
6637
+ return deserializeIntoGenerateOnboardingLinkResponseSchema;
6638
+ }
6585
6639
  /**
6586
6640
  * Creates a new instance of the appropriate class based on discriminator value
6587
6641
  * @param parseNode The parse node to use to read the discriminator value and create the object
@@ -9691,6 +9745,32 @@ function deserializeIntoGenerateCheckoutLinkSchema_data(generateCheckoutLinkSche
9691
9745
  "url": n => { generateCheckoutLinkSchema_data.url = n.getStringValue(); },
9692
9746
  };
9693
9747
  }
9748
+ /**
9749
+ * The deserialization information for the current model
9750
+ * @param GenerateOnboardingLinkResponseSchema The instance to deserialize into.
9751
+ * @returns {Record<string, (node: ParseNode) => void>}
9752
+ */
9753
+ // @ts-ignore
9754
+ function deserializeIntoGenerateOnboardingLinkResponseSchema(generateOnboardingLinkResponseSchema = {}) {
9755
+ return {
9756
+ "data": n => { generateOnboardingLinkResponseSchema.data = n.getObjectValue(createGenerateOnboardingLinkResponseSchema_dataFromDiscriminatorValue); },
9757
+ "type": n => { generateOnboardingLinkResponseSchema.type = n.getStringValue(); },
9758
+ };
9759
+ }
9760
+ /**
9761
+ * The deserialization information for the current model
9762
+ * @param GenerateOnboardingLinkResponseSchema_data The instance to deserialize into.
9763
+ * @returns {Record<string, (node: ParseNode) => void>}
9764
+ */
9765
+ // @ts-ignore
9766
+ function deserializeIntoGenerateOnboardingLinkResponseSchema_data(generateOnboardingLinkResponseSchema_data = {}) {
9767
+ return {
9768
+ "completionUrl": n => { generateOnboardingLinkResponseSchema_data.completionUrl = n.getStringValue(); },
9769
+ "refreshUrl": n => { generateOnboardingLinkResponseSchema_data.refreshUrl = n.getStringValue(); },
9770
+ "returnUrl": n => { generateOnboardingLinkResponseSchema_data.returnUrl = n.getStringValue(); },
9771
+ "url": n => { generateOnboardingLinkResponseSchema_data.url = n.getStringValue(); },
9772
+ };
9773
+ }
9694
9774
  /**
9695
9775
  * The deserialization information for the current model
9696
9776
  * @param GetAIConversationDetailSchema The instance to deserialize into.
@@ -12272,7 +12352,7 @@ function deserializeIntoGetPlanListSchema_data_tierTag(getPlanListSchema_data_ti
12272
12352
  // @ts-ignore
12273
12353
  function deserializeIntoGetPlanListSchema_filterOptions(getPlanListSchema_filterOptions = {}) {
12274
12354
  return {
12275
- "currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues(); },
12355
+ "currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues("string"); },
12276
12356
  "intervals": n => { getPlanListSchema_filterOptions.intervals = n.getCollectionOfObjectValues(createGetPlanListSchema_filterOptions_intervalsFromDiscriminatorValue); },
12277
12357
  };
12278
12358
  }
@@ -13121,7 +13201,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_sub
13121
13201
  function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items = {}) {
13122
13202
  return {
13123
13203
  "invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoice = n.getStringValue(); },
13124
- "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
13204
+ "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
13125
13205
  };
13126
13206
  }
13127
13207
  /**
@@ -13274,7 +13354,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_
13274
13354
  function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items = {}) {
13275
13355
  return {
13276
13356
  "invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoice = n.getStringValue(); },
13277
- "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
13357
+ "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
13278
13358
  };
13279
13359
  }
13280
13360
  /**
@@ -17164,8 +17244,8 @@ const OnboardingRequestBuilderRequestsMetadata = {
17164
17244
  429: createErrorResponseBodyFromDiscriminatorValue,
17165
17245
  500: createErrorResponseBodyFromDiscriminatorValue,
17166
17246
  },
17167
- adapterMethodName: "sendPrimitive",
17168
- responseBodyFactory: "ArrayBuffer",
17247
+ adapterMethodName: "send",
17248
+ responseBodyFactory: createGenerateOnboardingLinkResponseSchemaFromDiscriminatorValue,
17169
17249
  },
17170
17250
  };
17171
17251
  /* tslint:enable */
@@ -19957,58 +20037,40 @@ class FormParseNode {
19957
20037
  this._rawString = _rawString;
19958
20038
  this.backingStoreFactory = backingStoreFactory;
19959
20039
  this._fields = {};
19960
- this.normalizeKey = (key) => decodeURIComponent(key).trim();
19961
- this.getStringValue = () => decodeURIComponent(this._rawString);
20040
+ this.getStringValue = () => this.getStringValueFromRaw(this._rawString);
19962
20041
  this.getChildNode = (identifier) => {
19963
20042
  if (this._fields[identifier]) {
19964
20043
  return new FormParseNode(this._fields[identifier], this.backingStoreFactory);
19965
20044
  }
19966
20045
  return undefined;
19967
20046
  };
19968
- this.getBooleanValue = () => {
19969
- var _a;
19970
- const value = (_a = this.getStringValue()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
19971
- if (value === "true" || value === "1") {
19972
- return true;
19973
- }
19974
- else if (value === "false" || value === "0") {
19975
- return false;
19976
- }
19977
- return undefined;
19978
- };
19979
- this.getNumberValue = () => parseFloat(this.getStringValue());
19980
- this.getGuidValue = () => parseGuidString(this.getStringValue());
19981
- this.getDateValue = () => new Date(Date.parse(this.getStringValue()));
19982
- this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
19983
- this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
19984
- this.getDurationValue = () => Duration.parse(this.getStringValue());
19985
- this.getCollectionOfPrimitiveValues = () => {
19986
- return this._rawString.split(",").map((x) => {
19987
- const currentParseNode = new FormParseNode(x, this.backingStoreFactory);
19988
- const typeOfX = typeof x;
19989
- if (typeOfX === "boolean") {
19990
- return currentParseNode.getBooleanValue();
19991
- }
19992
- else if (typeOfX === "string") {
19993
- return currentParseNode.getStringValue();
19994
- }
19995
- else if (typeOfX === "number") {
19996
- return currentParseNode.getNumberValue();
19997
- }
19998
- else if (x instanceof Date) {
19999
- return currentParseNode.getDateValue();
20000
- }
20001
- else if (x instanceof DateOnly) {
20002
- return currentParseNode.getDateValue();
20003
- }
20004
- else if (x instanceof TimeOnly) {
20005
- return currentParseNode.getDateValue();
20006
- }
20007
- else if (x instanceof Duration) {
20008
- return currentParseNode.getDateValue();
20009
- }
20010
- else {
20011
- throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
20047
+ this.getBooleanValue = () => this.getBooleanValueFromRaw(this._rawString);
20048
+ this.getNumberValue = () => this.getNumberValueFromRaw(this._rawString);
20049
+ this.getGuidValue = () => this.getGuidValueFromRaw(this._rawString);
20050
+ this.getDateValue = () => this.getDateValueFromRaw(this._rawString);
20051
+ this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._rawString);
20052
+ this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._rawString);
20053
+ this.getDurationValue = () => this.getDurationValueFromRaw(this._rawString);
20054
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
20055
+ const values = this._rawString.split(",");
20056
+ return values.map((x) => {
20057
+ switch (primitiveType) {
20058
+ case "boolean":
20059
+ return this.getBooleanValueFromRaw(x);
20060
+ case "number":
20061
+ return this.getNumberValueFromRaw(x);
20062
+ case "Date":
20063
+ return this.getDateValueFromRaw(x);
20064
+ case "DateOnly":
20065
+ return this.getDateOnlyValueFromRaw(x);
20066
+ case "TimeOnly":
20067
+ return this.getTimeOnlyValueFromRaw(x);
20068
+ case "Duration":
20069
+ return this.getDurationValueFromRaw(x);
20070
+ case "string":
20071
+ return this.getStringValueFromRaw(x);
20072
+ default:
20073
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
20012
20074
  }
20013
20075
  });
20014
20076
  };
@@ -20035,7 +20097,6 @@ class FormParseNode {
20035
20097
  if (!rawValues) {
20036
20098
  return [];
20037
20099
  }
20038
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
20039
20100
  return rawValues.split(",").map((x) => getEnumValueFromStringValue(x, type));
20040
20101
  };
20041
20102
  this.getEnumValue = (type) => {
@@ -20045,20 +20106,6 @@ class FormParseNode {
20045
20106
  }
20046
20107
  return getEnumValueFromStringValue(rawValue, type);
20047
20108
  };
20048
- this.assignFieldValues = (model, parsableFactory) => {
20049
- const fields = parsableFactory(this)(model);
20050
- Object.entries(this._fields)
20051
- .filter((x) => !/^null$/i.test(x[1]))
20052
- .forEach(([k, v]) => {
20053
- const deserializer = fields[k];
20054
- if (deserializer) {
20055
- deserializer(new FormParseNode(v, this.backingStoreFactory));
20056
- }
20057
- else {
20058
- model[k] = v;
20059
- }
20060
- });
20061
- };
20062
20109
  if (!_rawString) {
20063
20110
  throw new Error("rawString cannot be undefined");
20064
20111
  }
@@ -20076,9 +20123,57 @@ class FormParseNode {
20076
20123
  }
20077
20124
  });
20078
20125
  }
20126
+ normalizeKey(key) {
20127
+ return decodeURIComponent(key).trim();
20128
+ }
20129
+ getStringValueFromRaw(value) {
20130
+ return decodeURIComponent(value);
20131
+ }
20132
+ getBooleanValueFromRaw(value) {
20133
+ const decoded = this.getStringValueFromRaw(value).toLowerCase();
20134
+ if (decoded === "true" || decoded === "1") {
20135
+ return true;
20136
+ }
20137
+ else if (decoded === "false" || decoded === "0") {
20138
+ return false;
20139
+ }
20140
+ return undefined;
20141
+ }
20142
+ getNumberValueFromRaw(value) {
20143
+ return parseFloat(this.getStringValueFromRaw(value));
20144
+ }
20145
+ getGuidValueFromRaw(value) {
20146
+ return parseGuidString(this.getStringValueFromRaw(value));
20147
+ }
20148
+ getDateValueFromRaw(value) {
20149
+ return new Date(Date.parse(this.getStringValueFromRaw(value)));
20150
+ }
20151
+ getDateOnlyValueFromRaw(value) {
20152
+ return DateOnly.parse(this.getStringValueFromRaw(value));
20153
+ }
20154
+ getTimeOnlyValueFromRaw(value) {
20155
+ return TimeOnly.parse(this.getStringValueFromRaw(value));
20156
+ }
20157
+ getDurationValueFromRaw(value) {
20158
+ return Duration.parse(this.getStringValueFromRaw(value));
20159
+ }
20079
20160
  getByteArrayValue() {
20080
20161
  throw new Error("serialization of byt arrays is not supported with URI encoding");
20081
20162
  }
20163
+ assignFieldValues(model, parsableFactory) {
20164
+ const fields = parsableFactory(this)(model);
20165
+ Object.entries(this._fields)
20166
+ .filter((x) => !/^null$/i.test(x[1]))
20167
+ .forEach(([k, v]) => {
20168
+ const deserializer = fields[k];
20169
+ if (deserializer) {
20170
+ deserializer(new FormParseNode(v, this.backingStoreFactory));
20171
+ }
20172
+ else {
20173
+ model[k] = v;
20174
+ }
20175
+ });
20176
+ }
20082
20177
  }
20083
20178
 
20084
20179
  /**
@@ -20161,6 +20256,7 @@ class FormSerializationWriter {
20161
20256
  throw new Error(`serialization of collections is not supported with URI encoding`);
20162
20257
  };
20163
20258
  this.writeObjectValue = (key, value, serializerMethod) => {
20259
+ var _a, _b, _c;
20164
20260
  if (++this.depth > 0) {
20165
20261
  throw new Error(`serialization of nested objects is not supported with URI encoding`);
20166
20262
  }
@@ -20171,10 +20267,10 @@ class FormSerializationWriter {
20171
20267
  if (key) {
20172
20268
  this.writePropertyName(key);
20173
20269
  }
20174
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20175
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
20270
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
20271
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20176
20272
  serializerMethod(this, value);
20177
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
20273
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20178
20274
  if (this.writer.length > 0 && this.writer[this.writer.length - 1] === FormSerializationWriter.propertySeparator) {
20179
20275
  // removing the last separator
20180
20276
  this.writer.pop();
@@ -20333,47 +20429,52 @@ class JsonParseNode {
20333
20429
  constructor(_jsonNode, backingStoreFactory) {
20334
20430
  this._jsonNode = _jsonNode;
20335
20431
  this.backingStoreFactory = backingStoreFactory;
20336
- this.getStringValue = () => (typeof this._jsonNode === "string" ? this._jsonNode : undefined);
20432
+ this.getStringValue = () => this.getStringValueFromRaw(this._jsonNode);
20337
20433
  this.getChildNode = (identifier) => (this._jsonNode && typeof this._jsonNode === "object" && this._jsonNode[identifier] !== undefined ? new JsonParseNode(this._jsonNode[identifier], this.backingStoreFactory) : undefined);
20338
20434
  this.getBooleanValue = () => (typeof this._jsonNode === "boolean" ? this._jsonNode : undefined);
20339
20435
  this.getNumberValue = () => (typeof this._jsonNode === "number" ? this._jsonNode : undefined);
20340
- this.getGuidValue = () => parseGuidString(this.getStringValue());
20341
- this.getDateValue = () => (this._jsonNode ? new Date(this._jsonNode) : undefined);
20342
- this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
20343
- this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
20344
- this.getDurationValue = () => Duration.parse(this.getStringValue());
20345
- this.getCollectionOfPrimitiveValues = () => {
20436
+ this.getGuidValue = () => this.getGuidValueFromRaw(this._jsonNode);
20437
+ this.getDateValue = () => this.getDateValueFromRaw(this._jsonNode);
20438
+ this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._jsonNode);
20439
+ this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._jsonNode);
20440
+ this.getDurationValue = () => this.getDurationValueFromRaw(this._jsonNode);
20441
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
20346
20442
  if (!Array.isArray(this._jsonNode)) {
20347
20443
  return undefined;
20348
20444
  }
20349
- return this._jsonNode.map((x) => {
20350
- const currentParseNode = new JsonParseNode(x, this.backingStoreFactory);
20351
- const typeOfX = typeof x;
20352
- if (typeOfX === "boolean") {
20353
- return currentParseNode.getBooleanValue();
20354
- }
20355
- else if (typeOfX === "string") {
20356
- return currentParseNode.getStringValue();
20357
- }
20358
- else if (typeOfX === "number") {
20359
- return currentParseNode.getNumberValue();
20360
- }
20361
- else if (x instanceof Date) {
20362
- return currentParseNode.getDateValue();
20363
- }
20364
- else if (x instanceof DateOnly) {
20365
- return currentParseNode.getDateValue();
20366
- }
20367
- else if (x instanceof TimeOnly) {
20368
- return currentParseNode.getDateValue();
20369
- }
20370
- else if (x instanceof Duration) {
20371
- return currentParseNode.getDateValue();
20372
- }
20373
- else {
20374
- throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
20375
- }
20376
- });
20445
+ return this._jsonNode.map((x) => this.getPrimitiveValue(x, primitiveType));
20446
+ };
20447
+ this.getPrimitiveValue = (value, primitiveType) => {
20448
+ if (value === null) {
20449
+ return null;
20450
+ }
20451
+ switch (primitiveType) {
20452
+ case "boolean":
20453
+ if (typeof value !== "boolean") {
20454
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20455
+ }
20456
+ return value;
20457
+ case "number":
20458
+ if (typeof value !== "number") {
20459
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20460
+ }
20461
+ return value;
20462
+ case "Date":
20463
+ return this.getDateValueFromRaw(value);
20464
+ case "DateOnly":
20465
+ return this.getDateOnlyValueFromRaw(value);
20466
+ case "TimeOnly":
20467
+ return this.getTimeOnlyValueFromRaw(value);
20468
+ case "Duration":
20469
+ return this.getDurationValueFromRaw(value);
20470
+ case "string":
20471
+ if (typeof value !== "string") {
20472
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20473
+ }
20474
+ return value;
20475
+ default:
20476
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
20477
+ }
20377
20478
  };
20378
20479
  this.getCollectionOfObjectValues = (method) => {
20379
20480
  if (!Array.isArray(this._jsonNode)) {
@@ -20448,10 +20549,12 @@ class JsonParseNode {
20448
20549
  if (Array.isArray(this._jsonNode)) {
20449
20550
  return this._jsonNode
20450
20551
  .map((x) => {
20451
- const node = new JsonParseNode(x, this.backingStoreFactory);
20452
- return node.getEnumValue(type);
20552
+ if (typeof x === "string") {
20553
+ return getEnumValueFromStringValue(x, type);
20554
+ }
20555
+ return undefined;
20453
20556
  })
20454
- .filter(Boolean);
20557
+ .filter((value) => value !== undefined);
20455
20558
  }
20456
20559
  return [];
20457
20560
  };
@@ -20463,6 +20566,33 @@ class JsonParseNode {
20463
20566
  return getEnumValueFromStringValue(rawValue, type);
20464
20567
  };
20465
20568
  }
20569
+ getStringValueFromRaw(value) {
20570
+ return typeof value === "string" ? value : undefined;
20571
+ }
20572
+ getGuidValueFromRaw(value) {
20573
+ return parseGuidString(this.getStringValueFromRaw(value));
20574
+ }
20575
+ getDateValueFromRaw(value) {
20576
+ if (value instanceof Date) {
20577
+ return new Date(value.getTime());
20578
+ }
20579
+ if (typeof value === "number") {
20580
+ return new Date(value);
20581
+ }
20582
+ if (typeof value === "string") {
20583
+ return new Date(value);
20584
+ }
20585
+ return undefined;
20586
+ }
20587
+ getDateOnlyValueFromRaw(value) {
20588
+ return value instanceof DateOnly ? value : DateOnly.parse(this.getStringValueFromRaw(value));
20589
+ }
20590
+ getTimeOnlyValueFromRaw(value) {
20591
+ return value instanceof TimeOnly ? value : TimeOnly.parse(this.getStringValueFromRaw(value));
20592
+ }
20593
+ getDurationValueFromRaw(value) {
20594
+ return value instanceof Duration ? value : Duration.parse(this.getStringValueFromRaw(value));
20595
+ }
20466
20596
  getByteArrayValue() {
20467
20597
  const strValue = this.getStringValue();
20468
20598
  if (strValue && strValue.length > 0) {
@@ -20478,7 +20608,7 @@ class JsonParseNode {
20478
20608
  * TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
20479
20609
  * in the future instead of the current environment-specific approach
20480
20610
  */
20481
- return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
20611
+ return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
20482
20612
  }
20483
20613
  return undefined;
20484
20614
  }
@@ -20540,7 +20670,6 @@ class JsonSerializationWriter {
20540
20670
  }
20541
20671
  if (this.shouldWriteValueOrNull(key, value)) {
20542
20672
  key && this.writePropertyName(key);
20543
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
20544
20673
  this.writer.push(`"${value}"`);
20545
20674
  key && this.writer.push(JsonSerializationWriter.propertySeparator);
20546
20675
  }
@@ -20645,10 +20774,9 @@ class JsonSerializationWriter {
20645
20774
  }
20646
20775
  };
20647
20776
  this.writeNonParsableObjectValue = (key, value) => {
20648
- if (key) {
20649
- this.writePropertyName(key);
20650
- }
20651
- this.writer.push(JSON.stringify(value), JsonSerializationWriter.propertySeparator);
20777
+ key && this.writePropertyName(key);
20778
+ this.writer.push(JSON.stringify(value));
20779
+ key && this.writer.push(JsonSerializationWriter.propertySeparator);
20652
20780
  };
20653
20781
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
20654
20782
  this.writeAnyValue = (key, value) => {
@@ -20699,6 +20827,7 @@ class JsonSerializationWriter {
20699
20827
  this.writeStringValue(key, b64);
20700
20828
  }
20701
20829
  writeObjectValue(key, value, serializerMethod) {
20830
+ var _a, _b, _c;
20702
20831
  if (value === undefined) {
20703
20832
  return;
20704
20833
  }
@@ -20757,11 +20886,11 @@ class JsonSerializationWriter {
20757
20886
  }
20758
20887
  if (key)
20759
20888
  this.writePropertyName(key);
20760
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20889
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
20761
20890
  this.startObject();
20762
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
20763
- serializerMethod && serializerMethod(this, value);
20764
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
20891
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20892
+ serializerMethod === null || serializerMethod === void 0 ? void 0 : serializerMethod(this, value);
20893
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20765
20894
  this.removeLastSeparator();
20766
20895
  this.endObject();
20767
20896
  if (key)
@@ -20834,7 +20963,6 @@ class JsonSerializationWriterFactory {
20834
20963
  * See License in the project root for license information.
20835
20964
  * -------------------------------------------------------------------------------------------
20836
20965
  */
20837
- /* eslint-disable @typescript-eslint/no-unused-expressions */
20838
20966
  /** Serialization writer for multipart/form-data */
20839
20967
  class MultipartSerializationWriter {
20840
20968
  constructor() {
@@ -20894,6 +21022,7 @@ class MultipartSerializationWriter {
20894
21022
  throw new Error(`serialization of collections is not supported with multipart`);
20895
21023
  };
20896
21024
  this.writeObjectValue = (key, value, serializerMethod) => {
21025
+ var _a, _b, _c;
20897
21026
  if (!value) {
20898
21027
  throw new Error(`value cannot be undefined`);
20899
21028
  }
@@ -20903,10 +21032,10 @@ class MultipartSerializationWriter {
20903
21032
  if (!serializerMethod) {
20904
21033
  throw new Error(`serializer method cannot be undefined`);
20905
21034
  }
20906
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20907
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
21035
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
21036
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20908
21037
  serializerMethod(this, value);
20909
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
21038
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20910
21039
  };
20911
21040
  this.writeEnumValue = (
20912
21041
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -20998,8 +21127,28 @@ class TextParseNode {
20998
21127
  this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
20999
21128
  this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
21000
21129
  this.getDurationValue = () => Duration.parse(this.getStringValue());
21001
- this.getCollectionOfPrimitiveValues = () => {
21002
- throw new Error(TextParseNode.noStructuredDataMessage);
21130
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
21131
+ return this.text.split(",").map((x) => {
21132
+ const node = new TextParseNode(x);
21133
+ switch (primitiveType) {
21134
+ case "boolean":
21135
+ return node.getBooleanValue();
21136
+ case "number":
21137
+ return node.getNumberValue();
21138
+ case "Date":
21139
+ return node.getDateValue();
21140
+ case "DateOnly":
21141
+ return node.getDateOnlyValue();
21142
+ case "TimeOnly":
21143
+ return node.getTimeOnlyValue();
21144
+ case "Duration":
21145
+ return node.getDurationValue();
21146
+ case "string":
21147
+ return node.getStringValue();
21148
+ default:
21149
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
21150
+ }
21151
+ });
21003
21152
  };
21004
21153
  this.getCollectionOfEnumValues = (type) => {
21005
21154
  throw new Error(TextParseNode.noStructuredDataMessage);
@@ -21030,7 +21179,7 @@ class TextParseNode {
21030
21179
  * TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
21031
21180
  * in the future instead of the current environment-specific approach
21032
21181
  */
21033
- return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
21182
+ return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
21034
21183
  }
21035
21184
  return undefined;
21036
21185
  }
@@ -21087,7 +21236,6 @@ class TextSerializationWriter {
21087
21236
  return this.writeNullValue(key);
21088
21237
  }
21089
21238
  if (value) {
21090
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
21091
21239
  this.writeStringValue(key, `"${value}"`);
21092
21240
  }
21093
21241
  };
@@ -21271,12 +21419,69 @@ const SalableNavigationMetadata = {
21271
21419
  /* tslint:enable */
21272
21420
  /* eslint-enable */
21273
21421
 
21422
+ /**
21423
+ * Kiota's JsonSerializationWriter stringifies null enum values, producing
21424
+ * `"interval": "null"` instead of `"interval": null`, which the API rejects
21425
+ * with an invalid_enum_value error. Unlike every other write method, its
21426
+ * writeEnumValue/writeCollectionOfEnumValues only filter out undefined before
21427
+ * template-stringifying, so null slips through as the string "null".
21428
+ * See https://github.com/microsoft/kiota-typescript — present up to at least
21429
+ * 1.0.0-preview.107. This subclass emits a proper JSON null instead.
21430
+ */
21431
+ class NullSafeJsonSerializationWriter extends JsonSerializationWriter {
21432
+ writeEnumValue = (key, ...values) => {
21433
+ const provided = values.filter((x) => x !== undefined);
21434
+ if (provided.length === 0) {
21435
+ return;
21436
+ }
21437
+ const rawValues = provided.filter((x) => x !== null).map((x) => `${x}`);
21438
+ if (rawValues.length === 0) {
21439
+ this.writeNullValue(key);
21440
+ return;
21441
+ }
21442
+ this.writeStringValue(key, rawValues.join(', '));
21443
+ };
21444
+ writeCollectionOfEnumValues = (key, values) => {
21445
+ if (values === null) {
21446
+ this.writeNullValue(key);
21447
+ return;
21448
+ }
21449
+ if (!values || values.length === 0) {
21450
+ return;
21451
+ }
21452
+ const rawValues = values
21453
+ .filter((x) => x !== undefined)
21454
+ .map((x) => (x === null ? null : `${x}`));
21455
+ if (rawValues.length === 0) {
21456
+ return;
21457
+ }
21458
+ this.writeCollectionOfPrimitiveValues(key, rawValues);
21459
+ };
21460
+ }
21461
+ class NullSafeJsonSerializationWriterFactory extends JsonSerializationWriterFactory {
21462
+ getSerializationWriter(contentType) {
21463
+ if (!contentType) {
21464
+ throw new Error('content type cannot be undefined or empty');
21465
+ }
21466
+ if (this.getValidContentType() !== contentType) {
21467
+ throw new Error(`expected a ${this.getValidContentType()} content type`);
21468
+ }
21469
+ return new NullSafeJsonSerializationWriter();
21470
+ }
21471
+ }
21472
+
21274
21473
  class Salable {
21275
21474
  api;
21276
21475
  constructor(apiKey) {
21277
21476
  const authProvider = new ApiKeyAuthenticationProvider('Bearer ' + apiKey, 'Authorization', ApiKeyLocation.Header);
21278
21477
  const adapter = new FetchRequestAdapter(authProvider);
21279
21478
  this.api = createSalable(adapter).api;
21479
+ // Must run after createSalable, which registers the stock JSON serializer;
21480
+ // re-registering replaces the application/json factory with the null-safe one.
21481
+ const writerRegistry = adapter.getSerializationWriterFactory();
21482
+ if (writerRegistry.registerDefaultSerializer) {
21483
+ writerRegistry.registerDefaultSerializer(NullSafeJsonSerializationWriterFactory);
21484
+ }
21280
21485
  }
21281
21486
  }
21282
21487