@salable/sdk 1.0.42 → 1.0.44

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.js CHANGED
@@ -409,21 +409,21 @@ const deserializeIntoUntypedNode = (untypedNode = {}) => {
409
409
  * @param node The object to check.
410
410
  * @returns boolean indicating if the node is an UntypedNumber.
411
411
  */
412
- function isUntypedNumber(node) {
412
+ const isUntypedNumber = (node) => {
413
413
  const proposedNode = node;
414
414
  return proposedNode && typeof proposedNode.value === "number";
415
- }
415
+ };
416
416
  /**
417
417
  * Factory to create an UntypedNumber from a number.
418
418
  * @param value The number value to create from.
419
419
  * @returns The created UntypedNumber.
420
420
  */
421
- function createUntypedNumber(value) {
421
+ const createUntypedNumber = (value) => {
422
422
  return {
423
423
  value,
424
424
  getValue: () => value,
425
425
  };
426
- }
426
+ };
427
427
 
428
428
  /**
429
429
  * -------------------------------------------------------------------------------------------
@@ -457,19 +457,19 @@ const createUntypedArray = (value) => {
457
457
  * @param node The object to check.
458
458
  * @returns boolean indicating if the node is an UntypedNull.
459
459
  */
460
- function isUntypedNull(node) {
460
+ const isUntypedNull = (node) => {
461
461
  return node.value === null;
462
- }
462
+ };
463
463
  /**
464
- * Factory to create an UntypedNull from a boolean.
464
+ * Factory to create an UntypedNull.
465
465
  * @returns The created UntypedNull.
466
466
  */
467
- function createUntypedNull() {
467
+ const createUntypedNull = () => {
468
468
  return {
469
469
  value: null,
470
470
  getValue: () => null,
471
471
  };
472
- }
472
+ };
473
473
 
474
474
  /**
475
475
  * -------------------------------------------------------------------------------------------
@@ -503,42 +503,42 @@ const createUntypedObject = (value) => {
503
503
  * @param node The object to check.
504
504
  * @returns boolean indicating if the node is an UntypedString.
505
505
  */
506
- function isUntypedString(node) {
506
+ const isUntypedString = (node) => {
507
507
  const proposedNode = node;
508
508
  return proposedNode && typeof proposedNode.value === "string";
509
- }
509
+ };
510
510
  /**
511
511
  * Factory to create an UntypedString from a string.
512
512
  * @param value The string value to create from.
513
513
  * @returns The created UntypedString.
514
514
  */
515
- function createUntypedString(value) {
515
+ const createUntypedString = (value) => {
516
516
  return {
517
517
  value,
518
518
  getValue: () => value,
519
519
  };
520
- }
520
+ };
521
521
 
522
522
  /**
523
523
  * Type guard to assert that an UntypedNode instance is an UntypedBoolean.
524
524
  * @param node The UntypedNode to check.
525
525
  * @returns boolean indicating if the node is an UntypedBoolean.
526
526
  */
527
- function isUntypedBoolean(node) {
527
+ const isUntypedBoolean = (node) => {
528
528
  const proposedNode = node;
529
529
  return proposedNode && typeof proposedNode.value === "boolean";
530
- }
530
+ };
531
531
  /**
532
532
  * Factory to create an UntypedBoolean from a boolean.
533
533
  * @param value The boolean value to create from.
534
534
  * @returns The created UntypedBoolean.
535
535
  */
536
- function createUntypedBoolean(value) {
536
+ const createUntypedBoolean = (value) => {
537
537
  return {
538
538
  value,
539
539
  getValue: () => value,
540
540
  };
541
- }
541
+ };
542
542
 
543
543
  /**
544
544
  * -------------------------------------------------------------------------------------------
@@ -792,10 +792,10 @@ const BackingStoreKey = "backingStoreEnabled";
792
792
  * @param fields The fields of the object
793
793
  * @returns boolean indicating if the object is a BackedModel
794
794
  */
795
- function isBackingStoreEnabled(fields) {
795
+ const isBackingStoreEnabled = (fields) => {
796
796
  // Check if the fields contain the backing store key
797
797
  return Object.keys(fields).includes(BackingStoreKey);
798
- }
798
+ };
799
799
 
800
800
  /**
801
801
  * -------------------------------------------------------------------------------------------
@@ -810,7 +810,7 @@ function isBackingStoreEnabled(fields) {
810
810
  * @param original The serialization writer to enable the backing store on.
811
811
  * @returns A new serialization writer with the backing store enabled.
812
812
  */
813
- function enableBackingStoreForSerializationWriterFactory(serializationWriterFactoryRegistry, parseNodeFactoryRegistry, original) {
813
+ const enableBackingStoreForSerializationWriterFactory = (serializationWriterFactoryRegistry, parseNodeFactoryRegistry, original) => {
814
814
  if (!original)
815
815
  throw new Error("Original must be specified");
816
816
  let result = original;
@@ -823,14 +823,14 @@ function enableBackingStoreForSerializationWriterFactory(serializationWriterFact
823
823
  enableBackingStoreForSerializationRegistry(serializationWriterFactoryRegistry);
824
824
  enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
825
825
  return result;
826
- }
826
+ };
827
827
  /**
828
828
  * Enables the backing store on default parse node factories and the given parse node factory.
829
829
  * @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on.
830
830
  * @param original The parse node factory to enable the backing store on.
831
831
  * @returns A new parse node factory with the backing store enabled.
832
832
  */
833
- function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry, original) {
833
+ const enableBackingStoreForParseNodeFactory = (parseNodeFactoryRegistry, original) => {
834
834
  if (!original)
835
835
  throw new Error("Original must be specified");
836
836
  let result = original;
@@ -842,29 +842,29 @@ function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry, origina
842
842
  }
843
843
  enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
844
844
  return result;
845
- }
845
+ };
846
846
  /**
847
847
  * Enables the backing store on the given parse node factory registry.
848
848
  * @param registry The parse node factory registry to enable the backing store on.
849
849
  */
850
- function enableBackingStoreForParseNodeRegistry(registry) {
850
+ const enableBackingStoreForParseNodeRegistry = (registry) => {
851
851
  for (const [k, v] of registry.contentTypeAssociatedFactories) {
852
852
  if (!(v instanceof BackingStoreParseNodeFactory || v instanceof ParseNodeFactoryRegistry)) {
853
853
  registry.contentTypeAssociatedFactories.set(k, new BackingStoreParseNodeFactory(v));
854
854
  }
855
855
  }
856
- }
856
+ };
857
857
  /**
858
858
  * Enables the backing store on the given serialization factory registry.
859
859
  * @param registry The serialization factory registry to enable the backing store on.
860
860
  */
861
- function enableBackingStoreForSerializationRegistry(registry) {
861
+ const enableBackingStoreForSerializationRegistry = (registry) => {
862
862
  for (const [k, v] of registry.contentTypeAssociatedFactories) {
863
863
  if (!(v instanceof BackingStoreSerializationWriterProxyFactory || v instanceof SerializationWriterFactoryRegistry)) {
864
864
  registry.contentTypeAssociatedFactories.set(k, new BackingStoreSerializationWriterProxyFactory(v));
865
865
  }
866
866
  }
867
- }
867
+ };
868
868
 
869
869
  /*
870
870
  * Copyright The OpenTelemetry Authors
@@ -2637,9 +2637,9 @@ class DateOnly {
2637
2637
  * @param digits The number of digits to pad
2638
2638
  * @returns The formatted segment
2639
2639
  */
2640
- function formatSegment(segment, digits = 2) {
2640
+ const formatSegment = (segment, digits = 2) => {
2641
2641
  return segment.toString().padStart(digits, "0");
2642
- }
2642
+ };
2643
2643
 
2644
2644
  var dist = {};
2645
2645
 
@@ -2870,7 +2870,7 @@ class Duration {
2870
2870
  * @param canon The function that canonicalizes the property name.
2871
2871
  * @returns A new object that can be used as a dictionary with case-insensitive keys.
2872
2872
  */
2873
- function dictionaryWithCanonicalKeys(canon) {
2873
+ const dictionaryWithCanonicalKeys = (canon) => {
2874
2874
  const keysNormalizationMap = new Map();
2875
2875
  return new Proxy({}, {
2876
2876
  /**
@@ -2879,7 +2879,7 @@ function dictionaryWithCanonicalKeys(canon) {
2879
2879
  * @param prop The property to get.
2880
2880
  * @returns The value of the property.
2881
2881
  */
2882
- get(target, prop) {
2882
+ get: (target, prop) => {
2883
2883
  const normalKey = canon(prop);
2884
2884
  return Reflect.get(target, normalKey);
2885
2885
  },
@@ -2890,7 +2890,7 @@ function dictionaryWithCanonicalKeys(canon) {
2890
2890
  * @param value The value to set.
2891
2891
  * @returns A boolean indicating whether the property was set.
2892
2892
  */
2893
- set(target, prop, value) {
2893
+ set: (target, prop, value) => {
2894
2894
  const nonNormalKey = prop.toString();
2895
2895
  const normalKey = canon(prop);
2896
2896
  keysNormalizationMap.set(normalKey, nonNormalKey);
@@ -2902,7 +2902,7 @@ function dictionaryWithCanonicalKeys(canon) {
2902
2902
  * @param prop The property to check.
2903
2903
  * @returns A boolean indicating whether the property exists.
2904
2904
  */
2905
- has(_, prop) {
2905
+ has: (_, prop) => {
2906
2906
  const normalKey = canon(prop);
2907
2907
  return keysNormalizationMap.has(normalKey);
2908
2908
  },
@@ -2913,7 +2913,7 @@ function dictionaryWithCanonicalKeys(canon) {
2913
2913
  * @param attribs The attributes of the property.
2914
2914
  * @returns A boolean indicating whether the property was defined.
2915
2915
  */
2916
- defineProperty(target, prop, attribs) {
2916
+ defineProperty: (target, prop, attribs) => {
2917
2917
  const nonNormalKey = prop.toString();
2918
2918
  const normalKey = canon(prop);
2919
2919
  keysNormalizationMap.set(normalKey, nonNormalKey);
@@ -2925,7 +2925,7 @@ function dictionaryWithCanonicalKeys(canon) {
2925
2925
  * @param prop The property to delete.
2926
2926
  * @returns A boolean indicating whether the property was deleted.
2927
2927
  */
2928
- deleteProperty(target, prop) {
2928
+ deleteProperty: (target, prop) => {
2929
2929
  const normalKey = canon(prop);
2930
2930
  keysNormalizationMap.delete(normalKey);
2931
2931
  return Reflect.deleteProperty(target, normalKey);
@@ -2936,19 +2936,19 @@ function dictionaryWithCanonicalKeys(canon) {
2936
2936
  * @param prop The property to gets its descriptor.
2937
2937
  * @returns The property descriptor.
2938
2938
  */
2939
- getOwnPropertyDescriptor(target, prop) {
2939
+ getOwnPropertyDescriptor: (target, prop) => {
2940
2940
  return Reflect.getOwnPropertyDescriptor(target, canon(prop));
2941
2941
  },
2942
- ownKeys() {
2942
+ ownKeys: () => {
2943
2943
  return [...keysNormalizationMap.values()];
2944
2944
  },
2945
2945
  });
2946
- }
2946
+ };
2947
2947
  /**
2948
2948
  * A wrapper for type Record that creates a Record with case insensitive keys
2949
2949
  * @returns A new object that can be used as a dictionary with case-insensitive keys.
2950
2950
  */
2951
- function createRecordWithCaseInsensitiveKeys() {
2951
+ const createRecordWithCaseInsensitiveKeys = () => {
2952
2952
  /**
2953
2953
  * A function that takes a property name and returns its canonical form.
2954
2954
  * @param prop The property name to be canonicalized.
@@ -2956,7 +2956,7 @@ function createRecordWithCaseInsensitiveKeys() {
2956
2956
  */
2957
2957
  const record = dictionaryWithCanonicalKeys((p) => (typeof p === "string" ? p.toLowerCase() : p.toString().toLowerCase()));
2958
2958
  return record;
2959
- }
2959
+ };
2960
2960
 
2961
2961
  /**
2962
2962
  * -------------------------------------------------------------------------------------------
@@ -3056,6 +3056,7 @@ class Headers extends Map {
3056
3056
  * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each header in the dictionary.
3057
3057
  * @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.
3058
3058
  */
3059
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3059
3060
  forEach(callbackfn, thisArg) {
3060
3061
  for (const header in this.headers) {
3061
3062
  if (Object.prototype.hasOwnProperty.call(this.headers, header)) {
@@ -3337,10 +3338,10 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
3337
3338
  writer.writeStringValue(undefined, part.content);
3338
3339
  }
3339
3340
  else if (part.content instanceof ArrayBuffer) {
3340
- writer.writeByteArrayValue(undefined, new Uint8Array(part.content));
3341
+ writer.writeByteArrayValue(undefined, new Uint8Array(part.content).buffer);
3341
3342
  }
3342
3343
  else if (part.content instanceof Uint8Array) {
3343
- writer.writeByteArrayValue(undefined, part.content);
3344
+ writer.writeByteArrayValue(undefined, part.content.buffer);
3344
3345
  }
3345
3346
  else if (part.serializationCallback) {
3346
3347
  if (!multipartBody.requestAdapter) {
@@ -3356,7 +3357,7 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
3356
3357
  }
3357
3358
  partSerializationWriter.writeObjectValue(undefined, part.content, part.serializationCallback);
3358
3359
  const partContent = partSerializationWriter.getSerializedContent();
3359
- writer.writeByteArrayValue(undefined, new Uint8Array(partContent));
3360
+ writer.writeByteArrayValue(undefined, new Uint8Array(partContent).buffer);
3360
3361
  }
3361
3362
  else {
3362
3363
  throw new Error("unsupported content type for multipart body: " + typeof part.content);
@@ -4020,6 +4021,10 @@ const apiClientProxifier = (requestAdapter, pathParameters, navigationMetadata,
4020
4021
  return apiClientProxifier(requestAdapter, downWardPathParameters, navigationCandidate.navigationMetadata, navigationCandidate.requestsMetadata);
4021
4022
  };
4022
4023
  }
4024
+ if (name === "then") {
4025
+ // handle returning proxy from an async method
4026
+ return undefined;
4027
+ }
4023
4028
  throw new Error(`couldn't find navigation property ${name} data: ${JSON.stringify(navigationMetadata)}`);
4024
4029
  }
4025
4030
  },
@@ -4057,7 +4062,7 @@ class AllowedHostsValidator {
4057
4062
  */
4058
4063
  constructor(allowedHosts = new Set()) {
4059
4064
  this.validateHosts(allowedHosts);
4060
- this.allowedHosts = allowedHosts !== null && allowedHosts !== void 0 ? allowedHosts : new Set();
4065
+ this.allowedHosts = this.normalizeHosts(allowedHosts);
4061
4066
  }
4062
4067
  /**
4063
4068
  * Gets the list of valid hosts. If the list is empty, all hosts are valid.
@@ -4072,7 +4077,7 @@ class AllowedHostsValidator {
4072
4077
  */
4073
4078
  setAllowedHosts(allowedHosts) {
4074
4079
  this.validateHosts(allowedHosts);
4075
- this.allowedHosts = allowedHosts;
4080
+ this.allowedHosts = this.normalizeHosts(allowedHosts);
4076
4081
  }
4077
4082
  /**
4078
4083
  * Checks whether the provided host is valid.
@@ -4080,7 +4085,7 @@ class AllowedHostsValidator {
4080
4085
  * @returns True if the host is valid, false otherwise.
4081
4086
  */
4082
4087
  isUrlHostValid(url) {
4083
- var _a, _b;
4088
+ var _a;
4084
4089
  if (!url)
4085
4090
  return false;
4086
4091
  if (this.allowedHosts.size === 0)
@@ -4097,7 +4102,7 @@ class AllowedHostsValidator {
4097
4102
  return this.isHostAndPathValid(url);
4098
4103
  }
4099
4104
  if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) {
4100
- return this.allowedHosts.has((_b = window.location.host) === null || _b === void 0 ? void 0 : _b.toLowerCase());
4105
+ return this.isHostValid(window.location.host);
4101
4106
  }
4102
4107
  return false;
4103
4108
  }
@@ -4106,11 +4111,21 @@ class AllowedHostsValidator {
4106
4111
  if (hostAndRest.length >= 2) {
4107
4112
  const host = hostAndRest[0];
4108
4113
  if (host) {
4109
- return this.allowedHosts.has(host.toLowerCase());
4114
+ return this.isHostValid(host.split(":")[0]);
4110
4115
  }
4111
4116
  }
4112
4117
  return false;
4113
4118
  }
4119
+ isHostValid(host) {
4120
+ const normalizedHost = host.toLowerCase();
4121
+ if (this.allowedHosts.has(normalizedHost)) {
4122
+ return true;
4123
+ }
4124
+ return Array.from(this.allowedHosts).some((allowedHost) => allowedHost.startsWith(".") && normalizedHost.endsWith(allowedHost));
4125
+ }
4126
+ normalizeHosts(hostsToNormalize) {
4127
+ return new Set(Array.from(hostsToNormalize, (host) => host.toLowerCase()));
4128
+ }
4114
4129
  validateHosts(hostsToValidate) {
4115
4130
  if (!hostsToValidate) {
4116
4131
  throw new Error("hostsToValidate cannot be null");
@@ -4134,27 +4149,27 @@ const localhostStrings = new Set(["localhost", "[::1]", "::1", "127.0.0.1"]);
4134
4149
  * Validates the protocol of the url.
4135
4150
  * @param url - The url to validate.
4136
4151
  */
4137
- function validateProtocol(url) {
4152
+ const validateProtocol = (url) => {
4138
4153
  if (!isLocalhostUrl(url) && !url.toLocaleLowerCase().startsWith("https://") && !windowUrlStartsWithHttps()) {
4139
4154
  throw new Error("Authentication scheme can only be used with https requests");
4140
4155
  }
4141
- }
4156
+ };
4142
4157
  /**
4143
4158
  * Checks if the window url starts with https.
4144
4159
  * @returns True if the window url starts with https, false otherwise.
4145
4160
  */
4146
- function windowUrlStartsWithHttps() {
4161
+ const windowUrlStartsWithHttps = () => {
4147
4162
  if (!inNodeEnv()) {
4148
4163
  return window.location.protocol.toLocaleLowerCase() === "https:";
4149
4164
  }
4150
4165
  return false;
4151
- }
4166
+ };
4152
4167
  /**
4153
4168
  * Checks if the url is a localhost url.
4154
4169
  * @param urlString - The url to check.
4155
4170
  * @returns True if the url is a localhost url, false otherwise.
4156
4171
  */
4157
- function isLocalhostUrl(urlString) {
4172
+ const isLocalhostUrl = (urlString) => {
4158
4173
  try {
4159
4174
  const url = new URL(urlString);
4160
4175
  return localhostStrings.has(url.hostname);
@@ -4162,7 +4177,7 @@ function isLocalhostUrl(urlString) {
4162
4177
  catch (_a) {
4163
4178
  return false;
4164
4179
  }
4165
- }
4180
+ };
4166
4181
 
4167
4182
  /** Authenticate a request by using an API Key */
4168
4183
  class ApiKeyAuthenticationProvider {
@@ -4287,14 +4302,9 @@ class HttpClient {
4287
4302
  middlewares = (middlewares === null || middlewares === void 0 ? void 0 : middlewares.length) && middlewares[0] ? middlewares : MiddlewareFactory.getDefaultMiddlewares(customFetch);
4288
4303
  // If a custom fetch function is provided, add a CustomFetchHandler to the end of the middleware chain
4289
4304
  if (this.customFetch) {
4290
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
4291
- middlewares.push(new CustomFetchHandler(customFetch));
4292
- }
4293
- // eslint-disable-next-line no-console
4294
- console.debug("Registered middlewares: " + middlewares.map((m) => m.constructor.name).join(", "));
4295
- // eslint-disable-next-line no-console
4296
- console.debug("Hint: To improve performance, use MiddlewareFactory.getPerformanceMiddlewares(customFetch) instead of MiddlewareFactory.getDefaultMiddlewares(customFetch)");
4297
- // Set the middleware chain
4305
+ middlewares.push(new CustomFetchHandler(this.customFetch));
4306
+ }
4307
+ // Set the middleware handlers chain
4298
4308
  this.setMiddleware(...middlewares);
4299
4309
  }
4300
4310
  /**
@@ -4349,7 +4359,7 @@ class ObservabilityOptionsImpl {
4349
4359
  * @param requestOptions The request options
4350
4360
  * @returns The observability options
4351
4361
  */
4352
- function getObservabilityOptionsFromRequest(requestOptions) {
4362
+ const getObservabilityOptionsFromRequest = (requestOptions) => {
4353
4363
  if (requestOptions) {
4354
4364
  const observabilityOptions = requestOptions[ObservabilityOptionKey];
4355
4365
  if (observabilityOptions instanceof ObservabilityOptionsImpl) {
@@ -4357,7 +4367,7 @@ function getObservabilityOptionsFromRequest(requestOptions) {
4357
4367
  }
4358
4368
  }
4359
4369
  return undefined;
4360
- }
4370
+ };
4361
4371
 
4362
4372
  /**
4363
4373
  * -------------------------------------------------------------------------------------------
@@ -4432,31 +4442,34 @@ class FetchRequestAdapter {
4432
4442
  case "number":
4433
4443
  case "boolean":
4434
4444
  case "Date":
4445
+ case "Duration":
4446
+ case "DateOnly":
4447
+ case "TimeOnly":
4435
4448
  // eslint-disable-next-line no-case-declarations
4436
4449
  const rootNode = await this.getRootParseNode(response);
4437
4450
  return trace.getTracer(this.observabilityOptions.getTracerInstrumentationName()).startActiveSpan(`getCollectionOf${responseType}Value`, (deserializeSpan) => {
4438
4451
  try {
4439
4452
  span.setAttribute(FetchRequestAdapter.responseTypeAttributeKey, responseType);
4440
4453
  if (responseType === "string") {
4441
- return rootNode.getCollectionOfPrimitiveValues();
4454
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4442
4455
  }
4443
4456
  else if (responseType === "number") {
4444
- return rootNode.getCollectionOfPrimitiveValues();
4457
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4445
4458
  }
4446
4459
  else if (responseType === "boolean") {
4447
- return rootNode.getCollectionOfPrimitiveValues();
4460
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4448
4461
  }
4449
4462
  else if (responseType === "Date") {
4450
- return rootNode.getCollectionOfPrimitiveValues();
4463
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4451
4464
  }
4452
4465
  else if (responseType === "Duration") {
4453
- return rootNode.getCollectionOfPrimitiveValues();
4466
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4454
4467
  }
4455
4468
  else if (responseType === "DateOnly") {
4456
- return rootNode.getCollectionOfPrimitiveValues();
4469
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4457
4470
  }
4458
4471
  else if (responseType === "TimeOnly") {
4459
- return rootNode.getCollectionOfPrimitiveValues();
4472
+ return rootNode.getCollectionOfPrimitiveValues(responseType);
4460
4473
  }
4461
4474
  else {
4462
4475
  throw new Error("unexpected type to deserialize");
@@ -4987,7 +5000,7 @@ FetchRequestAdapter.authenticateChallengedEventKey = "com.microsoft.kiota.authen
4987
5000
  * @returns A header value for the given key from the request
4988
5001
  */
4989
5002
  const getRequestHeader = (options, key) => {
4990
- if (options && options.headers) {
5003
+ if (options === null || options === void 0 ? void 0 : options.headers) {
4991
5004
  return options.headers[key];
4992
5005
  }
4993
5006
  return undefined;
@@ -5208,7 +5221,7 @@ class CompressionHandler {
5208
5221
  }
5209
5222
  const uint8ArrayToStream = (uint8Array) => {
5210
5223
  return new ReadableStream({
5211
- start(controller) {
5224
+ start: (controller) => {
5212
5225
  controller.enqueue(uint8Array);
5213
5226
  controller.close();
5214
5227
  },
@@ -5465,6 +5478,47 @@ class ParametersNameDecodingHandler {
5465
5478
  * -------------------------------------------------------------------------------------------
5466
5479
  */
5467
5480
  const RedirectHandlerOptionKey = "RedirectHandlerOption";
5481
+ /**
5482
+ * The default implementation for scrubbing sensitive headers during redirects.
5483
+ * This function removes Authorization, Cookie, and Proxy-Authorization headers when the host or scheme changes.
5484
+ *
5485
+ * It is exported so that consumers providing a custom {@link ScrubSensitiveHeaders} callback can call it to
5486
+ * retain the default behavior and then layer additional logic on top (e.g. removing custom headers such as
5487
+ * `X-Api-Key`), matching the composable pattern available in the .NET and Python Kiota SDKs.
5488
+ *
5489
+ * Note: In browser environments, `Proxy-Authorization` is a forbidden header name and typically cannot be set;
5490
+ * it is still removed here if present (e.g. in Node.js or other non-browser runtimes).
5491
+ * @param headers - The headers object to modify
5492
+ * @param originalUrl - The original request URL
5493
+ * @param newUrl - The new redirect URL
5494
+ */
5495
+ const defaultScrubSensitiveHeaders = (headers, originalUrl, newUrl) => {
5496
+ if (!headers || !originalUrl || !newUrl) {
5497
+ return;
5498
+ }
5499
+ try {
5500
+ const originalUri = new URL(originalUrl);
5501
+ const newUri = new URL(newUrl);
5502
+ // Remove Authorization, Cookie, and Proxy-Authorization headers if the request's scheme or host changes.
5503
+ // Header keys must be matched case-insensitively because FetchRequestAdapter.getRequestFromRequestInformation
5504
+ // lower-cases every header key before the headers object reaches this middleware, so PascalCase
5505
+ // property deletes such as `delete headers.Authorization` would otherwise be a no-op.
5506
+ const isDifferentHostOrScheme = originalUri.host.toLowerCase() !== newUri.host.toLowerCase() || originalUri.protocol.toLowerCase() !== newUri.protocol.toLowerCase();
5507
+ if (isDifferentHostOrScheme) {
5508
+ for (const key of Object.keys(headers)) {
5509
+ const lower = key.toLowerCase();
5510
+ if (lower === "authorization" || lower === "cookie" || lower === "proxy-authorization") {
5511
+ delete headers[key];
5512
+ }
5513
+ }
5514
+ }
5515
+ }
5516
+ catch (_a) {
5517
+ // If URL parsing fails, don't modify headers
5518
+ // This handles cases where invalid URLs are passed
5519
+ return;
5520
+ }
5521
+ };
5468
5522
  /**
5469
5523
  * MiddlewareOptions
5470
5524
  * A class representing RedirectHandlerOptions
@@ -5479,7 +5533,7 @@ class RedirectHandlerOptions {
5479
5533
  * @example const options = new RedirectHandlerOptions({ maxRedirects: 5 });
5480
5534
  */
5481
5535
  constructor(options = {}) {
5482
- var _a, _b;
5536
+ var _a, _b, _c;
5483
5537
  if (options.maxRedirects && options.maxRedirects > RedirectHandlerOptions.MAX_MAX_REDIRECTS) {
5484
5538
  const error = new Error(`MaxRedirects should not be more than ${RedirectHandlerOptions.MAX_MAX_REDIRECTS}`);
5485
5539
  error.name = "MaxLimitExceeded";
@@ -5492,6 +5546,7 @@ class RedirectHandlerOptions {
5492
5546
  }
5493
5547
  this.maxRedirects = (_a = options.maxRedirects) !== null && _a !== void 0 ? _a : RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS;
5494
5548
  this.shouldRedirect = (_b = options.shouldRedirect) !== null && _b !== void 0 ? _b : RedirectHandlerOptions.defaultShouldRetry;
5549
+ this.scrubSensitiveHeaders = (_c = options.scrubSensitiveHeaders) !== null && _c !== void 0 ? _c : RedirectHandlerOptions.defaultScrubSensitiveHeaders;
5495
5550
  }
5496
5551
  getKey() {
5497
5552
  return RedirectHandlerOptionKey;
@@ -5511,6 +5566,11 @@ RedirectHandlerOptions.MAX_MAX_REDIRECTS = 20;
5511
5566
  * @returns true
5512
5567
  */
5513
5568
  RedirectHandlerOptions.defaultShouldRetry = () => true;
5569
+ /**
5570
+ * The default {@link ScrubSensitiveHeaders} callback used when none is supplied.
5571
+ * Delegates to the exported {@link defaultScrubSensitiveHeaders} function.
5572
+ */
5573
+ RedirectHandlerOptions.defaultScrubSensitiveHeaders = defaultScrubSensitiveHeaders;
5514
5574
 
5515
5575
  /**
5516
5576
  * -------------------------------------------------------------------------------------------
@@ -5577,27 +5637,6 @@ class RedirectHandler {
5577
5637
  isRelativeURL(url) {
5578
5638
  return !url.includes("://");
5579
5639
  }
5580
- /**
5581
- *
5582
- * To check whether the authorization header in the request should be dropped for consequent redirected requests
5583
- * @param requestUrl - The request url value
5584
- * @param redirectUrl - The redirect url value
5585
- * @returns A boolean representing whether the authorization header in the request should be dropped for consequent redirected requests
5586
- */
5587
- shouldDropAuthorizationHeader(requestUrl, redirectUrl) {
5588
- const schemeHostRegex = /^[A-Za-z].+?:\/\/.+?(?=\/|$)/;
5589
- const requestMatches = schemeHostRegex.exec(requestUrl);
5590
- let requestAuthority;
5591
- let redirectAuthority;
5592
- if (requestMatches !== null) {
5593
- requestAuthority = requestMatches[0];
5594
- }
5595
- const redirectMatches = schemeHostRegex.exec(redirectUrl);
5596
- if (redirectMatches !== null) {
5597
- redirectAuthority = redirectMatches[0];
5598
- }
5599
- return typeof requestAuthority !== "undefined" && typeof redirectAuthority !== "undefined" && requestAuthority !== redirectAuthority;
5600
- }
5601
5640
  /**
5602
5641
  * To execute the next middleware and to handle in case of redirect response returned by the server
5603
5642
  * @param url - The url string value
@@ -5616,19 +5655,22 @@ class RedirectHandler {
5616
5655
  }
5617
5656
  if (redirectCount < currentOptions.maxRedirects && this.isRedirect(response) && this.hasLocationHeader(response) && currentOptions.shouldRedirect(response)) {
5618
5657
  ++redirectCount;
5658
+ const redirectUrl = this.getLocationHeader(response);
5659
+ if (!redirectUrl) {
5660
+ return response;
5661
+ }
5662
+ // Resolve relative URLs
5663
+ const newUrl = this.isRelativeURL(redirectUrl) ? new URL(redirectUrl, url).toString() : redirectUrl;
5664
+ // Scrub sensitive headers before following the redirect
5665
+ if (fetchRequestInit.headers) {
5666
+ currentOptions.scrubSensitiveHeaders(fetchRequestInit.headers, url, newUrl);
5667
+ }
5668
+ // Handle 303 See Other: change POST to GET
5619
5669
  if (response.status === RedirectHandler.STATUS_CODE_SEE_OTHER) {
5620
5670
  fetchRequestInit.method = HttpMethod.GET;
5621
5671
  delete fetchRequestInit.body;
5622
5672
  }
5623
- else {
5624
- const redirectUrl = this.getLocationHeader(response);
5625
- if (redirectUrl) {
5626
- if (fetchRequestInit.headers && !this.isRelativeURL(redirectUrl) && this.shouldDropAuthorizationHeader(url, redirectUrl)) {
5627
- delete fetchRequestInit.headers[RedirectHandler.AUTHORIZATION_HEADER];
5628
- }
5629
- url = redirectUrl;
5630
- }
5631
- }
5673
+ url = newUrl;
5632
5674
  if (tracerName) {
5633
5675
  return trace.getTracer(tracerName).startActiveSpan(`redirectHandler - redirect ${redirectCount}`, (span) => {
5634
5676
  try {
@@ -5694,10 +5736,6 @@ RedirectHandler.STATUS_CODE_SEE_OTHER = 303;
5694
5736
  * A member holding the name of the location header
5695
5737
  */
5696
5738
  RedirectHandler.LOCATION_HEADER = "Location";
5697
- /**
5698
- * A member representing the authorization header name
5699
- */
5700
- RedirectHandler.AUTHORIZATION_HEADER = "Authorization";
5701
5739
  /**
5702
5740
  * A member holding the manual redirect value
5703
5741
  */
@@ -6194,7 +6232,6 @@ class MiddlewareFactory {
6194
6232
  * Returns the default middleware chain an array with the middleware handlers
6195
6233
  * @returns an array of the middleware handlers of the default middleware chain
6196
6234
  */
6197
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
6198
6235
  static getDefaultMiddlewares(customFetch = (...args) => fetch(...args)) {
6199
6236
  return [new RetryHandler(), new RedirectHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new HeadersInspectionHandler(), new UrlReplaceHandler(), new CustomFetchHandler(customFetch)];
6200
6237
  }
@@ -6203,7 +6240,6 @@ class MiddlewareFactory {
6203
6240
  * Returns the default middleware chain + performance middleware
6204
6241
  * @returns an array of the middleware handlers of the default + performance middleware chain
6205
6242
  */
6206
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return
6207
6243
  static getPerformanceMiddlewares(customFetch = (...args) => fetch(...args)) {
6208
6244
  const middlewares = MiddlewareFactory.getDefaultMiddlewares(customFetch);
6209
6245
  middlewares.splice(middlewares.length - 3, 0, new CompressionHandler()); // insert CompressionHandler before HeadersInspectionHandler
@@ -9658,6 +9694,7 @@ function deserializeIntoCreateWebhookRequestResponseSchema_data(createWebhookReq
9658
9694
  return {
9659
9695
  "createdAt": n => { createWebhookRequestResponseSchema_data.createdAt = n.getStringValue(); },
9660
9696
  "description": n => { createWebhookRequestResponseSchema_data.description = n.getStringValue(); },
9697
+ "disabledAt": n => { createWebhookRequestResponseSchema_data.disabledAt = n.getStringValue(); },
9661
9698
  "id": n => { createWebhookRequestResponseSchema_data.id = n.getStringValue(); },
9662
9699
  "name": n => { createWebhookRequestResponseSchema_data.name = n.getStringValue(); },
9663
9700
  "organisation": n => { createWebhookRequestResponseSchema_data.organisation = n.getStringValue(); },
@@ -10650,6 +10687,7 @@ function deserializeIntoGetEventDetailSchema_data_destinations_data_webhook(getE
10650
10687
  return {
10651
10688
  "createdAt": n => { getEventDetailSchema_data_destinations_data_webhook.createdAt = n.getStringValue(); },
10652
10689
  "description": n => { getEventDetailSchema_data_destinations_data_webhook.description = n.getStringValue(); },
10690
+ "disabledAt": n => { getEventDetailSchema_data_destinations_data_webhook.disabledAt = n.getStringValue(); },
10653
10691
  "id": n => { getEventDetailSchema_data_destinations_data_webhook.id = n.getStringValue(); },
10654
10692
  "name": n => { getEventDetailSchema_data_destinations_data_webhook.name = n.getStringValue(); },
10655
10693
  "organisation": n => { getEventDetailSchema_data_destinations_data_webhook.organisation = n.getStringValue(); },
@@ -12318,7 +12356,7 @@ function deserializeIntoGetPlanListSchema_data_tierTag(getPlanListSchema_data_ti
12318
12356
  // @ts-ignore
12319
12357
  function deserializeIntoGetPlanListSchema_filterOptions(getPlanListSchema_filterOptions = {}) {
12320
12358
  return {
12321
- "currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues(); },
12359
+ "currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues("string"); },
12322
12360
  "intervals": n => { getPlanListSchema_filterOptions.intervals = n.getCollectionOfObjectValues(createGetPlanListSchema_filterOptions_intervalsFromDiscriminatorValue); },
12323
12361
  };
12324
12362
  }
@@ -13167,7 +13205,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_sub
13167
13205
  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 = {}) {
13168
13206
  return {
13169
13207
  "invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoice = n.getStringValue(); },
13170
- "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
13208
+ "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
13171
13209
  };
13172
13210
  }
13173
13211
  /**
@@ -13320,7 +13358,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_
13320
13358
  function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items = {}) {
13321
13359
  return {
13322
13360
  "invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoice = n.getStringValue(); },
13323
- "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
13361
+ "invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
13324
13362
  };
13325
13363
  }
13326
13364
  /**
@@ -14064,6 +14102,7 @@ function deserializeIntoGetWebhookDetailSchema_data(getWebhookDetailSchema_data
14064
14102
  "createdAt": n => { getWebhookDetailSchema_data.createdAt = n.getStringValue(); },
14065
14103
  "description": n => { getWebhookDetailSchema_data.description = n.getStringValue(); },
14066
14104
  "destinations": n => { getWebhookDetailSchema_data.destinations = n.getObjectValue(createGetWebhookDetailSchema_data_destinationsFromDiscriminatorValue); },
14105
+ "disabledAt": n => { getWebhookDetailSchema_data.disabledAt = n.getStringValue(); },
14067
14106
  "eventTypes": n => { getWebhookDetailSchema_data.eventTypes = n.getObjectValue(createGetWebhookDetailSchema_data_eventTypesFromDiscriminatorValue); },
14068
14107
  "id": n => { getWebhookDetailSchema_data.id = n.getStringValue(); },
14069
14108
  "name": n => { getWebhookDetailSchema_data.name = n.getStringValue(); },
@@ -14176,6 +14215,7 @@ function deserializeIntoGetWebhookListSchema_data(getWebhookListSchema_data = {}
14176
14215
  return {
14177
14216
  "createdAt": n => { getWebhookListSchema_data.createdAt = n.getStringValue(); },
14178
14217
  "description": n => { getWebhookListSchema_data.description = n.getStringValue(); },
14218
+ "disabledAt": n => { getWebhookListSchema_data.disabledAt = n.getStringValue(); },
14179
14219
  "eventTypes": n => { getWebhookListSchema_data.eventTypes = n.getObjectValue(createGetWebhookListSchema_data_eventTypesFromDiscriminatorValue); },
14180
14220
  "id": n => { getWebhookListSchema_data.id = n.getStringValue(); },
14181
14221
  "name": n => { getWebhookListSchema_data.name = n.getStringValue(); },
@@ -15448,6 +15488,7 @@ function serializeUpdateWebhookRequestSchema(writer, updateWebhookRequestSchema
15448
15488
  return;
15449
15489
  }
15450
15490
  writer.writeStringValue("description", updateWebhookRequestSchema.description);
15491
+ writer.writeBooleanValue("disabled", updateWebhookRequestSchema.disabled);
15451
15492
  if (updateWebhookRequestSchema.events)
15452
15493
  writer.writeCollectionOfEnumValues("events", updateWebhookRequestSchema.events);
15453
15494
  writer.writeStringValue("name", updateWebhookRequestSchema.name);
@@ -19741,6 +19782,36 @@ const UsageRecordsRequestBuilderRequestsMetadata = {
19741
19782
  /* tslint:enable */
19742
19783
  /* eslint-enable */
19743
19784
 
19785
+ /* tslint:disable */
19786
+ /* eslint-disable */
19787
+ // Generated by Microsoft Kiota
19788
+ // @ts-ignore
19789
+ /**
19790
+ * Uri template for the request builder.
19791
+ */
19792
+ const PingRequestBuilderUriTemplate = "{+baseurl}/api/webhooks/{id}/ping";
19793
+ /**
19794
+ * Metadata for all the requests in the request builder.
19795
+ */
19796
+ const PingRequestBuilderRequestsMetadata = {
19797
+ post: {
19798
+ uriTemplate: PingRequestBuilderUriTemplate,
19799
+ responseBodyContentType: "application/json",
19800
+ errorMappings: {
19801
+ 400: createErrorResponseBodyFromDiscriminatorValue,
19802
+ 401: createErrorResponseBodyFromDiscriminatorValue,
19803
+ 403: createErrorResponseBodyFromDiscriminatorValue,
19804
+ 404: createErrorResponseBodyFromDiscriminatorValue,
19805
+ 405: createErrorResponseBodyFromDiscriminatorValue,
19806
+ 429: createErrorResponseBodyFromDiscriminatorValue,
19807
+ 500: createErrorResponseBodyFromDiscriminatorValue,
19808
+ },
19809
+ adapterMethodName: "sendNoResponseContent",
19810
+ },
19811
+ };
19812
+ /* tslint:enable */
19813
+ /* eslint-enable */
19814
+
19744
19815
  /* tslint:disable */
19745
19816
  /* eslint-disable */
19746
19817
  // Generated by Microsoft Kiota
@@ -19749,6 +19820,14 @@ const UsageRecordsRequestBuilderRequestsMetadata = {
19749
19820
  * Uri template for the request builder.
19750
19821
  */
19751
19822
  const WebhooksItemRequestBuilderUriTemplate = "{+baseurl}/api/webhooks/{id}{?expand}";
19823
+ /**
19824
+ * Metadata for all the navigation properties in the request builder.
19825
+ */
19826
+ const WebhooksItemRequestBuilderNavigationMetadata = {
19827
+ ping: {
19828
+ requestsMetadata: PingRequestBuilderRequestsMetadata,
19829
+ },
19830
+ };
19752
19831
  /**
19753
19832
  * Metadata for all the requests in the request builder.
19754
19833
  */
@@ -19817,6 +19896,7 @@ const WebhooksRequestBuilderUriTemplate = "{+baseurl}/api/webhooks{?expand}";
19817
19896
  const WebhooksRequestBuilderNavigationMetadata = {
19818
19897
  byId: {
19819
19898
  requestsMetadata: WebhooksItemRequestBuilderRequestsMetadata,
19899
+ navigationMetadata: WebhooksItemRequestBuilderNavigationMetadata,
19820
19900
  pathParametersMappings: ["id"],
19821
19901
  },
19822
19902
  };
@@ -20003,58 +20083,40 @@ class FormParseNode {
20003
20083
  this._rawString = _rawString;
20004
20084
  this.backingStoreFactory = backingStoreFactory;
20005
20085
  this._fields = {};
20006
- this.normalizeKey = (key) => decodeURIComponent(key).trim();
20007
- this.getStringValue = () => decodeURIComponent(this._rawString);
20086
+ this.getStringValue = () => this.getStringValueFromRaw(this._rawString);
20008
20087
  this.getChildNode = (identifier) => {
20009
20088
  if (this._fields[identifier]) {
20010
20089
  return new FormParseNode(this._fields[identifier], this.backingStoreFactory);
20011
20090
  }
20012
20091
  return undefined;
20013
20092
  };
20014
- this.getBooleanValue = () => {
20015
- var _a;
20016
- const value = (_a = this.getStringValue()) === null || _a === void 0 ? void 0 : _a.toLowerCase();
20017
- if (value === "true" || value === "1") {
20018
- return true;
20019
- }
20020
- else if (value === "false" || value === "0") {
20021
- return false;
20022
- }
20023
- return undefined;
20024
- };
20025
- this.getNumberValue = () => parseFloat(this.getStringValue());
20026
- this.getGuidValue = () => parseGuidString(this.getStringValue());
20027
- this.getDateValue = () => new Date(Date.parse(this.getStringValue()));
20028
- this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
20029
- this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
20030
- this.getDurationValue = () => Duration.parse(this.getStringValue());
20031
- this.getCollectionOfPrimitiveValues = () => {
20032
- return this._rawString.split(",").map((x) => {
20033
- const currentParseNode = new FormParseNode(x, this.backingStoreFactory);
20034
- const typeOfX = typeof x;
20035
- if (typeOfX === "boolean") {
20036
- return currentParseNode.getBooleanValue();
20037
- }
20038
- else if (typeOfX === "string") {
20039
- return currentParseNode.getStringValue();
20040
- }
20041
- else if (typeOfX === "number") {
20042
- return currentParseNode.getNumberValue();
20043
- }
20044
- else if (x instanceof Date) {
20045
- return currentParseNode.getDateValue();
20046
- }
20047
- else if (x instanceof DateOnly) {
20048
- return currentParseNode.getDateValue();
20049
- }
20050
- else if (x instanceof TimeOnly) {
20051
- return currentParseNode.getDateValue();
20052
- }
20053
- else if (x instanceof Duration) {
20054
- return currentParseNode.getDateValue();
20055
- }
20056
- else {
20057
- throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
20093
+ this.getBooleanValue = () => this.getBooleanValueFromRaw(this._rawString);
20094
+ this.getNumberValue = () => this.getNumberValueFromRaw(this._rawString);
20095
+ this.getGuidValue = () => this.getGuidValueFromRaw(this._rawString);
20096
+ this.getDateValue = () => this.getDateValueFromRaw(this._rawString);
20097
+ this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._rawString);
20098
+ this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._rawString);
20099
+ this.getDurationValue = () => this.getDurationValueFromRaw(this._rawString);
20100
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
20101
+ const values = this._rawString.split(",");
20102
+ return values.map((x) => {
20103
+ switch (primitiveType) {
20104
+ case "boolean":
20105
+ return this.getBooleanValueFromRaw(x);
20106
+ case "number":
20107
+ return this.getNumberValueFromRaw(x);
20108
+ case "Date":
20109
+ return this.getDateValueFromRaw(x);
20110
+ case "DateOnly":
20111
+ return this.getDateOnlyValueFromRaw(x);
20112
+ case "TimeOnly":
20113
+ return this.getTimeOnlyValueFromRaw(x);
20114
+ case "Duration":
20115
+ return this.getDurationValueFromRaw(x);
20116
+ case "string":
20117
+ return this.getStringValueFromRaw(x);
20118
+ default:
20119
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
20058
20120
  }
20059
20121
  });
20060
20122
  };
@@ -20081,7 +20143,6 @@ class FormParseNode {
20081
20143
  if (!rawValues) {
20082
20144
  return [];
20083
20145
  }
20084
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
20085
20146
  return rawValues.split(",").map((x) => getEnumValueFromStringValue(x, type));
20086
20147
  };
20087
20148
  this.getEnumValue = (type) => {
@@ -20091,20 +20152,6 @@ class FormParseNode {
20091
20152
  }
20092
20153
  return getEnumValueFromStringValue(rawValue, type);
20093
20154
  };
20094
- this.assignFieldValues = (model, parsableFactory) => {
20095
- const fields = parsableFactory(this)(model);
20096
- Object.entries(this._fields)
20097
- .filter((x) => !/^null$/i.test(x[1]))
20098
- .forEach(([k, v]) => {
20099
- const deserializer = fields[k];
20100
- if (deserializer) {
20101
- deserializer(new FormParseNode(v, this.backingStoreFactory));
20102
- }
20103
- else {
20104
- model[k] = v;
20105
- }
20106
- });
20107
- };
20108
20155
  if (!_rawString) {
20109
20156
  throw new Error("rawString cannot be undefined");
20110
20157
  }
@@ -20122,9 +20169,57 @@ class FormParseNode {
20122
20169
  }
20123
20170
  });
20124
20171
  }
20172
+ normalizeKey(key) {
20173
+ return decodeURIComponent(key).trim();
20174
+ }
20175
+ getStringValueFromRaw(value) {
20176
+ return decodeURIComponent(value);
20177
+ }
20178
+ getBooleanValueFromRaw(value) {
20179
+ const decoded = this.getStringValueFromRaw(value).toLowerCase();
20180
+ if (decoded === "true" || decoded === "1") {
20181
+ return true;
20182
+ }
20183
+ else if (decoded === "false" || decoded === "0") {
20184
+ return false;
20185
+ }
20186
+ return undefined;
20187
+ }
20188
+ getNumberValueFromRaw(value) {
20189
+ return parseFloat(this.getStringValueFromRaw(value));
20190
+ }
20191
+ getGuidValueFromRaw(value) {
20192
+ return parseGuidString(this.getStringValueFromRaw(value));
20193
+ }
20194
+ getDateValueFromRaw(value) {
20195
+ return new Date(Date.parse(this.getStringValueFromRaw(value)));
20196
+ }
20197
+ getDateOnlyValueFromRaw(value) {
20198
+ return DateOnly.parse(this.getStringValueFromRaw(value));
20199
+ }
20200
+ getTimeOnlyValueFromRaw(value) {
20201
+ return TimeOnly.parse(this.getStringValueFromRaw(value));
20202
+ }
20203
+ getDurationValueFromRaw(value) {
20204
+ return Duration.parse(this.getStringValueFromRaw(value));
20205
+ }
20125
20206
  getByteArrayValue() {
20126
20207
  throw new Error("serialization of byt arrays is not supported with URI encoding");
20127
20208
  }
20209
+ assignFieldValues(model, parsableFactory) {
20210
+ const fields = parsableFactory(this)(model);
20211
+ Object.entries(this._fields)
20212
+ .filter((x) => !/^null$/i.test(x[1]))
20213
+ .forEach(([k, v]) => {
20214
+ const deserializer = fields[k];
20215
+ if (deserializer) {
20216
+ deserializer(new FormParseNode(v, this.backingStoreFactory));
20217
+ }
20218
+ else {
20219
+ model[k] = v;
20220
+ }
20221
+ });
20222
+ }
20128
20223
  }
20129
20224
 
20130
20225
  /**
@@ -20207,6 +20302,7 @@ class FormSerializationWriter {
20207
20302
  throw new Error(`serialization of collections is not supported with URI encoding`);
20208
20303
  };
20209
20304
  this.writeObjectValue = (key, value, serializerMethod) => {
20305
+ var _a, _b, _c;
20210
20306
  if (++this.depth > 0) {
20211
20307
  throw new Error(`serialization of nested objects is not supported with URI encoding`);
20212
20308
  }
@@ -20217,10 +20313,10 @@ class FormSerializationWriter {
20217
20313
  if (key) {
20218
20314
  this.writePropertyName(key);
20219
20315
  }
20220
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20221
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
20316
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
20317
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20222
20318
  serializerMethod(this, value);
20223
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
20319
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20224
20320
  if (this.writer.length > 0 && this.writer[this.writer.length - 1] === FormSerializationWriter.propertySeparator) {
20225
20321
  // removing the last separator
20226
20322
  this.writer.pop();
@@ -20379,47 +20475,52 @@ class JsonParseNode {
20379
20475
  constructor(_jsonNode, backingStoreFactory) {
20380
20476
  this._jsonNode = _jsonNode;
20381
20477
  this.backingStoreFactory = backingStoreFactory;
20382
- this.getStringValue = () => (typeof this._jsonNode === "string" ? this._jsonNode : undefined);
20478
+ this.getStringValue = () => this.getStringValueFromRaw(this._jsonNode);
20383
20479
  this.getChildNode = (identifier) => (this._jsonNode && typeof this._jsonNode === "object" && this._jsonNode[identifier] !== undefined ? new JsonParseNode(this._jsonNode[identifier], this.backingStoreFactory) : undefined);
20384
20480
  this.getBooleanValue = () => (typeof this._jsonNode === "boolean" ? this._jsonNode : undefined);
20385
20481
  this.getNumberValue = () => (typeof this._jsonNode === "number" ? this._jsonNode : undefined);
20386
- this.getGuidValue = () => parseGuidString(this.getStringValue());
20387
- this.getDateValue = () => (this._jsonNode ? new Date(this._jsonNode) : undefined);
20388
- this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
20389
- this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
20390
- this.getDurationValue = () => Duration.parse(this.getStringValue());
20391
- this.getCollectionOfPrimitiveValues = () => {
20482
+ this.getGuidValue = () => this.getGuidValueFromRaw(this._jsonNode);
20483
+ this.getDateValue = () => this.getDateValueFromRaw(this._jsonNode);
20484
+ this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._jsonNode);
20485
+ this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._jsonNode);
20486
+ this.getDurationValue = () => this.getDurationValueFromRaw(this._jsonNode);
20487
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
20392
20488
  if (!Array.isArray(this._jsonNode)) {
20393
20489
  return undefined;
20394
20490
  }
20395
- return this._jsonNode.map((x) => {
20396
- const currentParseNode = new JsonParseNode(x, this.backingStoreFactory);
20397
- const typeOfX = typeof x;
20398
- if (typeOfX === "boolean") {
20399
- return currentParseNode.getBooleanValue();
20400
- }
20401
- else if (typeOfX === "string") {
20402
- return currentParseNode.getStringValue();
20403
- }
20404
- else if (typeOfX === "number") {
20405
- return currentParseNode.getNumberValue();
20406
- }
20407
- else if (x instanceof Date) {
20408
- return currentParseNode.getDateValue();
20409
- }
20410
- else if (x instanceof DateOnly) {
20411
- return currentParseNode.getDateValue();
20412
- }
20413
- else if (x instanceof TimeOnly) {
20414
- return currentParseNode.getDateValue();
20415
- }
20416
- else if (x instanceof Duration) {
20417
- return currentParseNode.getDateValue();
20418
- }
20419
- else {
20420
- throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
20421
- }
20422
- });
20491
+ return this._jsonNode.map((x) => this.getPrimitiveValue(x, primitiveType));
20492
+ };
20493
+ this.getPrimitiveValue = (value, primitiveType) => {
20494
+ if (value === null) {
20495
+ return null;
20496
+ }
20497
+ switch (primitiveType) {
20498
+ case "boolean":
20499
+ if (typeof value !== "boolean") {
20500
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20501
+ }
20502
+ return value;
20503
+ case "number":
20504
+ if (typeof value !== "number") {
20505
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20506
+ }
20507
+ return value;
20508
+ case "Date":
20509
+ return this.getDateValueFromRaw(value);
20510
+ case "DateOnly":
20511
+ return this.getDateOnlyValueFromRaw(value);
20512
+ case "TimeOnly":
20513
+ return this.getTimeOnlyValueFromRaw(value);
20514
+ case "Duration":
20515
+ return this.getDurationValueFromRaw(value);
20516
+ case "string":
20517
+ if (typeof value !== "string") {
20518
+ throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
20519
+ }
20520
+ return value;
20521
+ default:
20522
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
20523
+ }
20423
20524
  };
20424
20525
  this.getCollectionOfObjectValues = (method) => {
20425
20526
  if (!Array.isArray(this._jsonNode)) {
@@ -20494,10 +20595,12 @@ class JsonParseNode {
20494
20595
  if (Array.isArray(this._jsonNode)) {
20495
20596
  return this._jsonNode
20496
20597
  .map((x) => {
20497
- const node = new JsonParseNode(x, this.backingStoreFactory);
20498
- return node.getEnumValue(type);
20598
+ if (typeof x === "string") {
20599
+ return getEnumValueFromStringValue(x, type);
20600
+ }
20601
+ return undefined;
20499
20602
  })
20500
- .filter(Boolean);
20603
+ .filter((value) => value !== undefined);
20501
20604
  }
20502
20605
  return [];
20503
20606
  };
@@ -20509,6 +20612,33 @@ class JsonParseNode {
20509
20612
  return getEnumValueFromStringValue(rawValue, type);
20510
20613
  };
20511
20614
  }
20615
+ getStringValueFromRaw(value) {
20616
+ return typeof value === "string" ? value : undefined;
20617
+ }
20618
+ getGuidValueFromRaw(value) {
20619
+ return parseGuidString(this.getStringValueFromRaw(value));
20620
+ }
20621
+ getDateValueFromRaw(value) {
20622
+ if (value instanceof Date) {
20623
+ return new Date(value.getTime());
20624
+ }
20625
+ if (typeof value === "number") {
20626
+ return new Date(value);
20627
+ }
20628
+ if (typeof value === "string") {
20629
+ return new Date(value);
20630
+ }
20631
+ return undefined;
20632
+ }
20633
+ getDateOnlyValueFromRaw(value) {
20634
+ return value instanceof DateOnly ? value : DateOnly.parse(this.getStringValueFromRaw(value));
20635
+ }
20636
+ getTimeOnlyValueFromRaw(value) {
20637
+ return value instanceof TimeOnly ? value : TimeOnly.parse(this.getStringValueFromRaw(value));
20638
+ }
20639
+ getDurationValueFromRaw(value) {
20640
+ return value instanceof Duration ? value : Duration.parse(this.getStringValueFromRaw(value));
20641
+ }
20512
20642
  getByteArrayValue() {
20513
20643
  const strValue = this.getStringValue();
20514
20644
  if (strValue && strValue.length > 0) {
@@ -20524,7 +20654,7 @@ class JsonParseNode {
20524
20654
  * TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
20525
20655
  * in the future instead of the current environment-specific approach
20526
20656
  */
20527
- return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
20657
+ return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
20528
20658
  }
20529
20659
  return undefined;
20530
20660
  }
@@ -20586,7 +20716,6 @@ class JsonSerializationWriter {
20586
20716
  }
20587
20717
  if (this.shouldWriteValueOrNull(key, value)) {
20588
20718
  key && this.writePropertyName(key);
20589
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
20590
20719
  this.writer.push(`"${value}"`);
20591
20720
  key && this.writer.push(JsonSerializationWriter.propertySeparator);
20592
20721
  }
@@ -20691,10 +20820,9 @@ class JsonSerializationWriter {
20691
20820
  }
20692
20821
  };
20693
20822
  this.writeNonParsableObjectValue = (key, value) => {
20694
- if (key) {
20695
- this.writePropertyName(key);
20696
- }
20697
- this.writer.push(JSON.stringify(value), JsonSerializationWriter.propertySeparator);
20823
+ key && this.writePropertyName(key);
20824
+ this.writer.push(JSON.stringify(value));
20825
+ key && this.writer.push(JsonSerializationWriter.propertySeparator);
20698
20826
  };
20699
20827
  // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
20700
20828
  this.writeAnyValue = (key, value) => {
@@ -20745,6 +20873,7 @@ class JsonSerializationWriter {
20745
20873
  this.writeStringValue(key, b64);
20746
20874
  }
20747
20875
  writeObjectValue(key, value, serializerMethod) {
20876
+ var _a, _b, _c;
20748
20877
  if (value === undefined) {
20749
20878
  return;
20750
20879
  }
@@ -20803,11 +20932,11 @@ class JsonSerializationWriter {
20803
20932
  }
20804
20933
  if (key)
20805
20934
  this.writePropertyName(key);
20806
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20935
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
20807
20936
  this.startObject();
20808
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
20809
- serializerMethod && serializerMethod(this, value);
20810
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
20937
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20938
+ serializerMethod === null || serializerMethod === void 0 ? void 0 : serializerMethod(this, value);
20939
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20811
20940
  this.removeLastSeparator();
20812
20941
  this.endObject();
20813
20942
  if (key)
@@ -20880,7 +21009,6 @@ class JsonSerializationWriterFactory {
20880
21009
  * See License in the project root for license information.
20881
21010
  * -------------------------------------------------------------------------------------------
20882
21011
  */
20883
- /* eslint-disable @typescript-eslint/no-unused-expressions */
20884
21012
  /** Serialization writer for multipart/form-data */
20885
21013
  class MultipartSerializationWriter {
20886
21014
  constructor() {
@@ -20940,6 +21068,7 @@ class MultipartSerializationWriter {
20940
21068
  throw new Error(`serialization of collections is not supported with multipart`);
20941
21069
  };
20942
21070
  this.writeObjectValue = (key, value, serializerMethod) => {
21071
+ var _a, _b, _c;
20943
21072
  if (!value) {
20944
21073
  throw new Error(`value cannot be undefined`);
20945
21074
  }
@@ -20949,10 +21078,10 @@ class MultipartSerializationWriter {
20949
21078
  if (!serializerMethod) {
20950
21079
  throw new Error(`serializer method cannot be undefined`);
20951
21080
  }
20952
- this.onBeforeObjectSerialization && this.onBeforeObjectSerialization(value);
20953
- this.onStartObjectSerialization && this.onStartObjectSerialization(value, this);
21081
+ (_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
21082
+ (_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
20954
21083
  serializerMethod(this, value);
20955
- this.onAfterObjectSerialization && this.onAfterObjectSerialization(value);
21084
+ (_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
20956
21085
  };
20957
21086
  this.writeEnumValue = (
20958
21087
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -21044,8 +21173,28 @@ class TextParseNode {
21044
21173
  this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
21045
21174
  this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
21046
21175
  this.getDurationValue = () => Duration.parse(this.getStringValue());
21047
- this.getCollectionOfPrimitiveValues = () => {
21048
- throw new Error(TextParseNode.noStructuredDataMessage);
21176
+ this.getCollectionOfPrimitiveValues = (primitiveType) => {
21177
+ return this.text.split(",").map((x) => {
21178
+ const node = new TextParseNode(x);
21179
+ switch (primitiveType) {
21180
+ case "boolean":
21181
+ return node.getBooleanValue();
21182
+ case "number":
21183
+ return node.getNumberValue();
21184
+ case "Date":
21185
+ return node.getDateValue();
21186
+ case "DateOnly":
21187
+ return node.getDateOnlyValue();
21188
+ case "TimeOnly":
21189
+ return node.getTimeOnlyValue();
21190
+ case "Duration":
21191
+ return node.getDurationValue();
21192
+ case "string":
21193
+ return node.getStringValue();
21194
+ default:
21195
+ throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
21196
+ }
21197
+ });
21049
21198
  };
21050
21199
  this.getCollectionOfEnumValues = (type) => {
21051
21200
  throw new Error(TextParseNode.noStructuredDataMessage);
@@ -21076,7 +21225,7 @@ class TextParseNode {
21076
21225
  * TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
21077
21226
  * in the future instead of the current environment-specific approach
21078
21227
  */
21079
- return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
21228
+ return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
21080
21229
  }
21081
21230
  return undefined;
21082
21231
  }
@@ -21133,7 +21282,6 @@ class TextSerializationWriter {
21133
21282
  return this.writeNullValue(key);
21134
21283
  }
21135
21284
  if (value) {
21136
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
21137
21285
  this.writeStringValue(key, `"${value}"`);
21138
21286
  }
21139
21287
  };
@@ -21317,12 +21465,69 @@ const SalableNavigationMetadata = {
21317
21465
  /* tslint:enable */
21318
21466
  /* eslint-enable */
21319
21467
 
21468
+ /**
21469
+ * Kiota's JsonSerializationWriter stringifies null enum values, producing
21470
+ * `"interval": "null"` instead of `"interval": null`, which the API rejects
21471
+ * with an invalid_enum_value error. Unlike every other write method, its
21472
+ * writeEnumValue/writeCollectionOfEnumValues only filter out undefined before
21473
+ * template-stringifying, so null slips through as the string "null".
21474
+ * See https://github.com/microsoft/kiota-typescript — present up to at least
21475
+ * 1.0.0-preview.107. This subclass emits a proper JSON null instead.
21476
+ */
21477
+ class NullSafeJsonSerializationWriter extends JsonSerializationWriter {
21478
+ writeEnumValue = (key, ...values) => {
21479
+ const provided = values.filter((x) => x !== undefined);
21480
+ if (provided.length === 0) {
21481
+ return;
21482
+ }
21483
+ const rawValues = provided.filter((x) => x !== null).map((x) => `${x}`);
21484
+ if (rawValues.length === 0) {
21485
+ this.writeNullValue(key);
21486
+ return;
21487
+ }
21488
+ this.writeStringValue(key, rawValues.join(', '));
21489
+ };
21490
+ writeCollectionOfEnumValues = (key, values) => {
21491
+ if (values === null) {
21492
+ this.writeNullValue(key);
21493
+ return;
21494
+ }
21495
+ if (!values || values.length === 0) {
21496
+ return;
21497
+ }
21498
+ const rawValues = values
21499
+ .filter((x) => x !== undefined)
21500
+ .map((x) => (x === null ? null : `${x}`));
21501
+ if (rawValues.length === 0) {
21502
+ return;
21503
+ }
21504
+ this.writeCollectionOfPrimitiveValues(key, rawValues);
21505
+ };
21506
+ }
21507
+ class NullSafeJsonSerializationWriterFactory extends JsonSerializationWriterFactory {
21508
+ getSerializationWriter(contentType) {
21509
+ if (!contentType) {
21510
+ throw new Error('content type cannot be undefined or empty');
21511
+ }
21512
+ if (this.getValidContentType() !== contentType) {
21513
+ throw new Error(`expected a ${this.getValidContentType()} content type`);
21514
+ }
21515
+ return new NullSafeJsonSerializationWriter();
21516
+ }
21517
+ }
21518
+
21320
21519
  class Salable {
21321
21520
  api;
21322
21521
  constructor(apiKey) {
21323
21522
  const authProvider = new ApiKeyAuthenticationProvider('Bearer ' + apiKey, 'Authorization', ApiKeyLocation.Header);
21324
21523
  const adapter = new FetchRequestAdapter(authProvider);
21325
21524
  this.api = createSalable(adapter).api;
21525
+ // Must run after createSalable, which registers the stock JSON serializer;
21526
+ // re-registering replaces the application/json factory with the null-safe one.
21527
+ const writerRegistry = adapter.getSerializationWriterFactory();
21528
+ if (writerRegistry.registerDefaultSerializer) {
21529
+ writerRegistry.registerDefaultSerializer(NullSafeJsonSerializationWriterFactory);
21530
+ }
21326
21531
  }
21327
21532
  }
21328
21533