@salable/sdk 1.0.42 → 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 +394 -233
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +394 -233
- package/dist/index.js.map +1 -1
- package/dist/serialization.d.ts +18 -0
- package/package.json +7 -7
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
460
|
+
const isUntypedNull = (node) => {
|
|
461
461
|
return node.value === null;
|
|
462
|
-
}
|
|
462
|
+
};
|
|
463
463
|
/**
|
|
464
|
-
* Factory to create an UntypedNull
|
|
464
|
+
* Factory to create an UntypedNull.
|
|
465
465
|
* @returns The created UntypedNull.
|
|
466
466
|
*/
|
|
467
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4291
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
@@ -12318,7 +12354,7 @@ function deserializeIntoGetPlanListSchema_data_tierTag(getPlanListSchema_data_ti
|
|
|
12318
12354
|
// @ts-ignore
|
|
12319
12355
|
function deserializeIntoGetPlanListSchema_filterOptions(getPlanListSchema_filterOptions = {}) {
|
|
12320
12356
|
return {
|
|
12321
|
-
"currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues(); },
|
|
12357
|
+
"currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues("string"); },
|
|
12322
12358
|
"intervals": n => { getPlanListSchema_filterOptions.intervals = n.getCollectionOfObjectValues(createGetPlanListSchema_filterOptions_intervalsFromDiscriminatorValue); },
|
|
12323
12359
|
};
|
|
12324
12360
|
}
|
|
@@ -13167,7 +13203,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_sub
|
|
|
13167
13203
|
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
13204
|
return {
|
|
13169
13205
|
"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(); },
|
|
13206
|
+
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
|
|
13171
13207
|
};
|
|
13172
13208
|
}
|
|
13173
13209
|
/**
|
|
@@ -13320,7 +13356,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_
|
|
|
13320
13356
|
function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items = {}) {
|
|
13321
13357
|
return {
|
|
13322
13358
|
"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(); },
|
|
13359
|
+
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
|
|
13324
13360
|
};
|
|
13325
13361
|
}
|
|
13326
13362
|
/**
|
|
@@ -20003,58 +20039,40 @@ class FormParseNode {
|
|
|
20003
20039
|
this._rawString = _rawString;
|
|
20004
20040
|
this.backingStoreFactory = backingStoreFactory;
|
|
20005
20041
|
this._fields = {};
|
|
20006
|
-
this.
|
|
20007
|
-
this.getStringValue = () => decodeURIComponent(this._rawString);
|
|
20042
|
+
this.getStringValue = () => this.getStringValueFromRaw(this._rawString);
|
|
20008
20043
|
this.getChildNode = (identifier) => {
|
|
20009
20044
|
if (this._fields[identifier]) {
|
|
20010
20045
|
return new FormParseNode(this._fields[identifier], this.backingStoreFactory);
|
|
20011
20046
|
}
|
|
20012
20047
|
return undefined;
|
|
20013
20048
|
};
|
|
20014
|
-
this.getBooleanValue = () =>
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
|
|
20022
|
-
|
|
20023
|
-
return
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
|
|
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}`);
|
|
20049
|
+
this.getBooleanValue = () => this.getBooleanValueFromRaw(this._rawString);
|
|
20050
|
+
this.getNumberValue = () => this.getNumberValueFromRaw(this._rawString);
|
|
20051
|
+
this.getGuidValue = () => this.getGuidValueFromRaw(this._rawString);
|
|
20052
|
+
this.getDateValue = () => this.getDateValueFromRaw(this._rawString);
|
|
20053
|
+
this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._rawString);
|
|
20054
|
+
this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._rawString);
|
|
20055
|
+
this.getDurationValue = () => this.getDurationValueFromRaw(this._rawString);
|
|
20056
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
20057
|
+
const values = this._rawString.split(",");
|
|
20058
|
+
return values.map((x) => {
|
|
20059
|
+
switch (primitiveType) {
|
|
20060
|
+
case "boolean":
|
|
20061
|
+
return this.getBooleanValueFromRaw(x);
|
|
20062
|
+
case "number":
|
|
20063
|
+
return this.getNumberValueFromRaw(x);
|
|
20064
|
+
case "Date":
|
|
20065
|
+
return this.getDateValueFromRaw(x);
|
|
20066
|
+
case "DateOnly":
|
|
20067
|
+
return this.getDateOnlyValueFromRaw(x);
|
|
20068
|
+
case "TimeOnly":
|
|
20069
|
+
return this.getTimeOnlyValueFromRaw(x);
|
|
20070
|
+
case "Duration":
|
|
20071
|
+
return this.getDurationValueFromRaw(x);
|
|
20072
|
+
case "string":
|
|
20073
|
+
return this.getStringValueFromRaw(x);
|
|
20074
|
+
default:
|
|
20075
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
20058
20076
|
}
|
|
20059
20077
|
});
|
|
20060
20078
|
};
|
|
@@ -20081,7 +20099,6 @@ class FormParseNode {
|
|
|
20081
20099
|
if (!rawValues) {
|
|
20082
20100
|
return [];
|
|
20083
20101
|
}
|
|
20084
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
20085
20102
|
return rawValues.split(",").map((x) => getEnumValueFromStringValue(x, type));
|
|
20086
20103
|
};
|
|
20087
20104
|
this.getEnumValue = (type) => {
|
|
@@ -20091,20 +20108,6 @@ class FormParseNode {
|
|
|
20091
20108
|
}
|
|
20092
20109
|
return getEnumValueFromStringValue(rawValue, type);
|
|
20093
20110
|
};
|
|
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
20111
|
if (!_rawString) {
|
|
20109
20112
|
throw new Error("rawString cannot be undefined");
|
|
20110
20113
|
}
|
|
@@ -20122,9 +20125,57 @@ class FormParseNode {
|
|
|
20122
20125
|
}
|
|
20123
20126
|
});
|
|
20124
20127
|
}
|
|
20128
|
+
normalizeKey(key) {
|
|
20129
|
+
return decodeURIComponent(key).trim();
|
|
20130
|
+
}
|
|
20131
|
+
getStringValueFromRaw(value) {
|
|
20132
|
+
return decodeURIComponent(value);
|
|
20133
|
+
}
|
|
20134
|
+
getBooleanValueFromRaw(value) {
|
|
20135
|
+
const decoded = this.getStringValueFromRaw(value).toLowerCase();
|
|
20136
|
+
if (decoded === "true" || decoded === "1") {
|
|
20137
|
+
return true;
|
|
20138
|
+
}
|
|
20139
|
+
else if (decoded === "false" || decoded === "0") {
|
|
20140
|
+
return false;
|
|
20141
|
+
}
|
|
20142
|
+
return undefined;
|
|
20143
|
+
}
|
|
20144
|
+
getNumberValueFromRaw(value) {
|
|
20145
|
+
return parseFloat(this.getStringValueFromRaw(value));
|
|
20146
|
+
}
|
|
20147
|
+
getGuidValueFromRaw(value) {
|
|
20148
|
+
return parseGuidString(this.getStringValueFromRaw(value));
|
|
20149
|
+
}
|
|
20150
|
+
getDateValueFromRaw(value) {
|
|
20151
|
+
return new Date(Date.parse(this.getStringValueFromRaw(value)));
|
|
20152
|
+
}
|
|
20153
|
+
getDateOnlyValueFromRaw(value) {
|
|
20154
|
+
return DateOnly.parse(this.getStringValueFromRaw(value));
|
|
20155
|
+
}
|
|
20156
|
+
getTimeOnlyValueFromRaw(value) {
|
|
20157
|
+
return TimeOnly.parse(this.getStringValueFromRaw(value));
|
|
20158
|
+
}
|
|
20159
|
+
getDurationValueFromRaw(value) {
|
|
20160
|
+
return Duration.parse(this.getStringValueFromRaw(value));
|
|
20161
|
+
}
|
|
20125
20162
|
getByteArrayValue() {
|
|
20126
20163
|
throw new Error("serialization of byt arrays is not supported with URI encoding");
|
|
20127
20164
|
}
|
|
20165
|
+
assignFieldValues(model, parsableFactory) {
|
|
20166
|
+
const fields = parsableFactory(this)(model);
|
|
20167
|
+
Object.entries(this._fields)
|
|
20168
|
+
.filter((x) => !/^null$/i.test(x[1]))
|
|
20169
|
+
.forEach(([k, v]) => {
|
|
20170
|
+
const deserializer = fields[k];
|
|
20171
|
+
if (deserializer) {
|
|
20172
|
+
deserializer(new FormParseNode(v, this.backingStoreFactory));
|
|
20173
|
+
}
|
|
20174
|
+
else {
|
|
20175
|
+
model[k] = v;
|
|
20176
|
+
}
|
|
20177
|
+
});
|
|
20178
|
+
}
|
|
20128
20179
|
}
|
|
20129
20180
|
|
|
20130
20181
|
/**
|
|
@@ -20207,6 +20258,7 @@ class FormSerializationWriter {
|
|
|
20207
20258
|
throw new Error(`serialization of collections is not supported with URI encoding`);
|
|
20208
20259
|
};
|
|
20209
20260
|
this.writeObjectValue = (key, value, serializerMethod) => {
|
|
20261
|
+
var _a, _b, _c;
|
|
20210
20262
|
if (++this.depth > 0) {
|
|
20211
20263
|
throw new Error(`serialization of nested objects is not supported with URI encoding`);
|
|
20212
20264
|
}
|
|
@@ -20217,10 +20269,10 @@ class FormSerializationWriter {
|
|
|
20217
20269
|
if (key) {
|
|
20218
20270
|
this.writePropertyName(key);
|
|
20219
20271
|
}
|
|
20220
|
-
this.onBeforeObjectSerialization
|
|
20221
|
-
this.onStartObjectSerialization
|
|
20272
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
20273
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20222
20274
|
serializerMethod(this, value);
|
|
20223
|
-
this.onAfterObjectSerialization
|
|
20275
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20224
20276
|
if (this.writer.length > 0 && this.writer[this.writer.length - 1] === FormSerializationWriter.propertySeparator) {
|
|
20225
20277
|
// removing the last separator
|
|
20226
20278
|
this.writer.pop();
|
|
@@ -20379,47 +20431,52 @@ class JsonParseNode {
|
|
|
20379
20431
|
constructor(_jsonNode, backingStoreFactory) {
|
|
20380
20432
|
this._jsonNode = _jsonNode;
|
|
20381
20433
|
this.backingStoreFactory = backingStoreFactory;
|
|
20382
|
-
this.getStringValue = () =>
|
|
20434
|
+
this.getStringValue = () => this.getStringValueFromRaw(this._jsonNode);
|
|
20383
20435
|
this.getChildNode = (identifier) => (this._jsonNode && typeof this._jsonNode === "object" && this._jsonNode[identifier] !== undefined ? new JsonParseNode(this._jsonNode[identifier], this.backingStoreFactory) : undefined);
|
|
20384
20436
|
this.getBooleanValue = () => (typeof this._jsonNode === "boolean" ? this._jsonNode : undefined);
|
|
20385
20437
|
this.getNumberValue = () => (typeof this._jsonNode === "number" ? this._jsonNode : undefined);
|
|
20386
|
-
this.getGuidValue = () =>
|
|
20387
|
-
this.getDateValue = () =>
|
|
20388
|
-
this.getDateOnlyValue = () =>
|
|
20389
|
-
this.getTimeOnlyValue = () =>
|
|
20390
|
-
this.getDurationValue = () =>
|
|
20391
|
-
this.getCollectionOfPrimitiveValues = () => {
|
|
20438
|
+
this.getGuidValue = () => this.getGuidValueFromRaw(this._jsonNode);
|
|
20439
|
+
this.getDateValue = () => this.getDateValueFromRaw(this._jsonNode);
|
|
20440
|
+
this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._jsonNode);
|
|
20441
|
+
this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._jsonNode);
|
|
20442
|
+
this.getDurationValue = () => this.getDurationValueFromRaw(this._jsonNode);
|
|
20443
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
20392
20444
|
if (!Array.isArray(this._jsonNode)) {
|
|
20393
20445
|
return undefined;
|
|
20394
20446
|
}
|
|
20395
|
-
return this._jsonNode.map((x) =>
|
|
20396
|
-
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
|
|
20404
|
-
|
|
20405
|
-
|
|
20406
|
-
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
|
|
20410
|
-
|
|
20411
|
-
return
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
|
|
20416
|
-
|
|
20417
|
-
return
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20421
|
-
|
|
20422
|
-
|
|
20447
|
+
return this._jsonNode.map((x) => this.getPrimitiveValue(x, primitiveType));
|
|
20448
|
+
};
|
|
20449
|
+
this.getPrimitiveValue = (value, primitiveType) => {
|
|
20450
|
+
if (value === null) {
|
|
20451
|
+
return null;
|
|
20452
|
+
}
|
|
20453
|
+
switch (primitiveType) {
|
|
20454
|
+
case "boolean":
|
|
20455
|
+
if (typeof value !== "boolean") {
|
|
20456
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20457
|
+
}
|
|
20458
|
+
return value;
|
|
20459
|
+
case "number":
|
|
20460
|
+
if (typeof value !== "number") {
|
|
20461
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20462
|
+
}
|
|
20463
|
+
return value;
|
|
20464
|
+
case "Date":
|
|
20465
|
+
return this.getDateValueFromRaw(value);
|
|
20466
|
+
case "DateOnly":
|
|
20467
|
+
return this.getDateOnlyValueFromRaw(value);
|
|
20468
|
+
case "TimeOnly":
|
|
20469
|
+
return this.getTimeOnlyValueFromRaw(value);
|
|
20470
|
+
case "Duration":
|
|
20471
|
+
return this.getDurationValueFromRaw(value);
|
|
20472
|
+
case "string":
|
|
20473
|
+
if (typeof value !== "string") {
|
|
20474
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20475
|
+
}
|
|
20476
|
+
return value;
|
|
20477
|
+
default:
|
|
20478
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
20479
|
+
}
|
|
20423
20480
|
};
|
|
20424
20481
|
this.getCollectionOfObjectValues = (method) => {
|
|
20425
20482
|
if (!Array.isArray(this._jsonNode)) {
|
|
@@ -20494,10 +20551,12 @@ class JsonParseNode {
|
|
|
20494
20551
|
if (Array.isArray(this._jsonNode)) {
|
|
20495
20552
|
return this._jsonNode
|
|
20496
20553
|
.map((x) => {
|
|
20497
|
-
|
|
20498
|
-
|
|
20554
|
+
if (typeof x === "string") {
|
|
20555
|
+
return getEnumValueFromStringValue(x, type);
|
|
20556
|
+
}
|
|
20557
|
+
return undefined;
|
|
20499
20558
|
})
|
|
20500
|
-
.filter(
|
|
20559
|
+
.filter((value) => value !== undefined);
|
|
20501
20560
|
}
|
|
20502
20561
|
return [];
|
|
20503
20562
|
};
|
|
@@ -20509,6 +20568,33 @@ class JsonParseNode {
|
|
|
20509
20568
|
return getEnumValueFromStringValue(rawValue, type);
|
|
20510
20569
|
};
|
|
20511
20570
|
}
|
|
20571
|
+
getStringValueFromRaw(value) {
|
|
20572
|
+
return typeof value === "string" ? value : undefined;
|
|
20573
|
+
}
|
|
20574
|
+
getGuidValueFromRaw(value) {
|
|
20575
|
+
return parseGuidString(this.getStringValueFromRaw(value));
|
|
20576
|
+
}
|
|
20577
|
+
getDateValueFromRaw(value) {
|
|
20578
|
+
if (value instanceof Date) {
|
|
20579
|
+
return new Date(value.getTime());
|
|
20580
|
+
}
|
|
20581
|
+
if (typeof value === "number") {
|
|
20582
|
+
return new Date(value);
|
|
20583
|
+
}
|
|
20584
|
+
if (typeof value === "string") {
|
|
20585
|
+
return new Date(value);
|
|
20586
|
+
}
|
|
20587
|
+
return undefined;
|
|
20588
|
+
}
|
|
20589
|
+
getDateOnlyValueFromRaw(value) {
|
|
20590
|
+
return value instanceof DateOnly ? value : DateOnly.parse(this.getStringValueFromRaw(value));
|
|
20591
|
+
}
|
|
20592
|
+
getTimeOnlyValueFromRaw(value) {
|
|
20593
|
+
return value instanceof TimeOnly ? value : TimeOnly.parse(this.getStringValueFromRaw(value));
|
|
20594
|
+
}
|
|
20595
|
+
getDurationValueFromRaw(value) {
|
|
20596
|
+
return value instanceof Duration ? value : Duration.parse(this.getStringValueFromRaw(value));
|
|
20597
|
+
}
|
|
20512
20598
|
getByteArrayValue() {
|
|
20513
20599
|
const strValue = this.getStringValue();
|
|
20514
20600
|
if (strValue && strValue.length > 0) {
|
|
@@ -20524,7 +20610,7 @@ class JsonParseNode {
|
|
|
20524
20610
|
* TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
|
|
20525
20611
|
* in the future instead of the current environment-specific approach
|
|
20526
20612
|
*/
|
|
20527
|
-
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
|
|
20613
|
+
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
|
|
20528
20614
|
}
|
|
20529
20615
|
return undefined;
|
|
20530
20616
|
}
|
|
@@ -20586,7 +20672,6 @@ class JsonSerializationWriter {
|
|
|
20586
20672
|
}
|
|
20587
20673
|
if (this.shouldWriteValueOrNull(key, value)) {
|
|
20588
20674
|
key && this.writePropertyName(key);
|
|
20589
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
20590
20675
|
this.writer.push(`"${value}"`);
|
|
20591
20676
|
key && this.writer.push(JsonSerializationWriter.propertySeparator);
|
|
20592
20677
|
}
|
|
@@ -20691,10 +20776,9 @@ class JsonSerializationWriter {
|
|
|
20691
20776
|
}
|
|
20692
20777
|
};
|
|
20693
20778
|
this.writeNonParsableObjectValue = (key, value) => {
|
|
20694
|
-
|
|
20695
|
-
|
|
20696
|
-
|
|
20697
|
-
this.writer.push(JSON.stringify(value), JsonSerializationWriter.propertySeparator);
|
|
20779
|
+
key && this.writePropertyName(key);
|
|
20780
|
+
this.writer.push(JSON.stringify(value));
|
|
20781
|
+
key && this.writer.push(JsonSerializationWriter.propertySeparator);
|
|
20698
20782
|
};
|
|
20699
20783
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
20700
20784
|
this.writeAnyValue = (key, value) => {
|
|
@@ -20745,6 +20829,7 @@ class JsonSerializationWriter {
|
|
|
20745
20829
|
this.writeStringValue(key, b64);
|
|
20746
20830
|
}
|
|
20747
20831
|
writeObjectValue(key, value, serializerMethod) {
|
|
20832
|
+
var _a, _b, _c;
|
|
20748
20833
|
if (value === undefined) {
|
|
20749
20834
|
return;
|
|
20750
20835
|
}
|
|
@@ -20803,11 +20888,11 @@ class JsonSerializationWriter {
|
|
|
20803
20888
|
}
|
|
20804
20889
|
if (key)
|
|
20805
20890
|
this.writePropertyName(key);
|
|
20806
|
-
this.onBeforeObjectSerialization
|
|
20891
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
20807
20892
|
this.startObject();
|
|
20808
|
-
this.onStartObjectSerialization
|
|
20809
|
-
serializerMethod
|
|
20810
|
-
this.onAfterObjectSerialization
|
|
20893
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20894
|
+
serializerMethod === null || serializerMethod === void 0 ? void 0 : serializerMethod(this, value);
|
|
20895
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20811
20896
|
this.removeLastSeparator();
|
|
20812
20897
|
this.endObject();
|
|
20813
20898
|
if (key)
|
|
@@ -20880,7 +20965,6 @@ class JsonSerializationWriterFactory {
|
|
|
20880
20965
|
* See License in the project root for license information.
|
|
20881
20966
|
* -------------------------------------------------------------------------------------------
|
|
20882
20967
|
*/
|
|
20883
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
20884
20968
|
/** Serialization writer for multipart/form-data */
|
|
20885
20969
|
class MultipartSerializationWriter {
|
|
20886
20970
|
constructor() {
|
|
@@ -20940,6 +21024,7 @@ class MultipartSerializationWriter {
|
|
|
20940
21024
|
throw new Error(`serialization of collections is not supported with multipart`);
|
|
20941
21025
|
};
|
|
20942
21026
|
this.writeObjectValue = (key, value, serializerMethod) => {
|
|
21027
|
+
var _a, _b, _c;
|
|
20943
21028
|
if (!value) {
|
|
20944
21029
|
throw new Error(`value cannot be undefined`);
|
|
20945
21030
|
}
|
|
@@ -20949,10 +21034,10 @@ class MultipartSerializationWriter {
|
|
|
20949
21034
|
if (!serializerMethod) {
|
|
20950
21035
|
throw new Error(`serializer method cannot be undefined`);
|
|
20951
21036
|
}
|
|
20952
|
-
this.onBeforeObjectSerialization
|
|
20953
|
-
this.onStartObjectSerialization
|
|
21037
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
21038
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20954
21039
|
serializerMethod(this, value);
|
|
20955
|
-
this.onAfterObjectSerialization
|
|
21040
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20956
21041
|
};
|
|
20957
21042
|
this.writeEnumValue = (
|
|
20958
21043
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -21044,8 +21129,28 @@ class TextParseNode {
|
|
|
21044
21129
|
this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
|
|
21045
21130
|
this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
|
|
21046
21131
|
this.getDurationValue = () => Duration.parse(this.getStringValue());
|
|
21047
|
-
this.getCollectionOfPrimitiveValues = () => {
|
|
21048
|
-
|
|
21132
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
21133
|
+
return this.text.split(",").map((x) => {
|
|
21134
|
+
const node = new TextParseNode(x);
|
|
21135
|
+
switch (primitiveType) {
|
|
21136
|
+
case "boolean":
|
|
21137
|
+
return node.getBooleanValue();
|
|
21138
|
+
case "number":
|
|
21139
|
+
return node.getNumberValue();
|
|
21140
|
+
case "Date":
|
|
21141
|
+
return node.getDateValue();
|
|
21142
|
+
case "DateOnly":
|
|
21143
|
+
return node.getDateOnlyValue();
|
|
21144
|
+
case "TimeOnly":
|
|
21145
|
+
return node.getTimeOnlyValue();
|
|
21146
|
+
case "Duration":
|
|
21147
|
+
return node.getDurationValue();
|
|
21148
|
+
case "string":
|
|
21149
|
+
return node.getStringValue();
|
|
21150
|
+
default:
|
|
21151
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
21152
|
+
}
|
|
21153
|
+
});
|
|
21049
21154
|
};
|
|
21050
21155
|
this.getCollectionOfEnumValues = (type) => {
|
|
21051
21156
|
throw new Error(TextParseNode.noStructuredDataMessage);
|
|
@@ -21076,7 +21181,7 @@ class TextParseNode {
|
|
|
21076
21181
|
* TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
|
|
21077
21182
|
* in the future instead of the current environment-specific approach
|
|
21078
21183
|
*/
|
|
21079
|
-
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
|
|
21184
|
+
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
|
|
21080
21185
|
}
|
|
21081
21186
|
return undefined;
|
|
21082
21187
|
}
|
|
@@ -21133,7 +21238,6 @@ class TextSerializationWriter {
|
|
|
21133
21238
|
return this.writeNullValue(key);
|
|
21134
21239
|
}
|
|
21135
21240
|
if (value) {
|
|
21136
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
21137
21241
|
this.writeStringValue(key, `"${value}"`);
|
|
21138
21242
|
}
|
|
21139
21243
|
};
|
|
@@ -21317,12 +21421,69 @@ const SalableNavigationMetadata = {
|
|
|
21317
21421
|
/* tslint:enable */
|
|
21318
21422
|
/* eslint-enable */
|
|
21319
21423
|
|
|
21424
|
+
/**
|
|
21425
|
+
* Kiota's JsonSerializationWriter stringifies null enum values, producing
|
|
21426
|
+
* `"interval": "null"` instead of `"interval": null`, which the API rejects
|
|
21427
|
+
* with an invalid_enum_value error. Unlike every other write method, its
|
|
21428
|
+
* writeEnumValue/writeCollectionOfEnumValues only filter out undefined before
|
|
21429
|
+
* template-stringifying, so null slips through as the string "null".
|
|
21430
|
+
* See https://github.com/microsoft/kiota-typescript — present up to at least
|
|
21431
|
+
* 1.0.0-preview.107. This subclass emits a proper JSON null instead.
|
|
21432
|
+
*/
|
|
21433
|
+
class NullSafeJsonSerializationWriter extends JsonSerializationWriter {
|
|
21434
|
+
writeEnumValue = (key, ...values) => {
|
|
21435
|
+
const provided = values.filter((x) => x !== undefined);
|
|
21436
|
+
if (provided.length === 0) {
|
|
21437
|
+
return;
|
|
21438
|
+
}
|
|
21439
|
+
const rawValues = provided.filter((x) => x !== null).map((x) => `${x}`);
|
|
21440
|
+
if (rawValues.length === 0) {
|
|
21441
|
+
this.writeNullValue(key);
|
|
21442
|
+
return;
|
|
21443
|
+
}
|
|
21444
|
+
this.writeStringValue(key, rawValues.join(', '));
|
|
21445
|
+
};
|
|
21446
|
+
writeCollectionOfEnumValues = (key, values) => {
|
|
21447
|
+
if (values === null) {
|
|
21448
|
+
this.writeNullValue(key);
|
|
21449
|
+
return;
|
|
21450
|
+
}
|
|
21451
|
+
if (!values || values.length === 0) {
|
|
21452
|
+
return;
|
|
21453
|
+
}
|
|
21454
|
+
const rawValues = values
|
|
21455
|
+
.filter((x) => x !== undefined)
|
|
21456
|
+
.map((x) => (x === null ? null : `${x}`));
|
|
21457
|
+
if (rawValues.length === 0) {
|
|
21458
|
+
return;
|
|
21459
|
+
}
|
|
21460
|
+
this.writeCollectionOfPrimitiveValues(key, rawValues);
|
|
21461
|
+
};
|
|
21462
|
+
}
|
|
21463
|
+
class NullSafeJsonSerializationWriterFactory extends JsonSerializationWriterFactory {
|
|
21464
|
+
getSerializationWriter(contentType) {
|
|
21465
|
+
if (!contentType) {
|
|
21466
|
+
throw new Error('content type cannot be undefined or empty');
|
|
21467
|
+
}
|
|
21468
|
+
if (this.getValidContentType() !== contentType) {
|
|
21469
|
+
throw new Error(`expected a ${this.getValidContentType()} content type`);
|
|
21470
|
+
}
|
|
21471
|
+
return new NullSafeJsonSerializationWriter();
|
|
21472
|
+
}
|
|
21473
|
+
}
|
|
21474
|
+
|
|
21320
21475
|
class Salable {
|
|
21321
21476
|
api;
|
|
21322
21477
|
constructor(apiKey) {
|
|
21323
21478
|
const authProvider = new ApiKeyAuthenticationProvider('Bearer ' + apiKey, 'Authorization', ApiKeyLocation.Header);
|
|
21324
21479
|
const adapter = new FetchRequestAdapter(authProvider);
|
|
21325
21480
|
this.api = createSalable(adapter).api;
|
|
21481
|
+
// Must run after createSalable, which registers the stock JSON serializer;
|
|
21482
|
+
// re-registering replaces the application/json factory with the null-safe one.
|
|
21483
|
+
const writerRegistry = adapter.getSerializationWriterFactory();
|
|
21484
|
+
if (writerRegistry.registerDefaultSerializer) {
|
|
21485
|
+
writerRegistry.registerDefaultSerializer(NullSafeJsonSerializationWriterFactory);
|
|
21486
|
+
}
|
|
21326
21487
|
}
|
|
21327
21488
|
}
|
|
21328
21489
|
|