@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.es.js
CHANGED
|
@@ -407,21 +407,21 @@ const deserializeIntoUntypedNode = (untypedNode = {}) => {
|
|
|
407
407
|
* @param node The object to check.
|
|
408
408
|
* @returns boolean indicating if the node is an UntypedNumber.
|
|
409
409
|
*/
|
|
410
|
-
|
|
410
|
+
const isUntypedNumber = (node) => {
|
|
411
411
|
const proposedNode = node;
|
|
412
412
|
return proposedNode && typeof proposedNode.value === "number";
|
|
413
|
-
}
|
|
413
|
+
};
|
|
414
414
|
/**
|
|
415
415
|
* Factory to create an UntypedNumber from a number.
|
|
416
416
|
* @param value The number value to create from.
|
|
417
417
|
* @returns The created UntypedNumber.
|
|
418
418
|
*/
|
|
419
|
-
|
|
419
|
+
const createUntypedNumber = (value) => {
|
|
420
420
|
return {
|
|
421
421
|
value,
|
|
422
422
|
getValue: () => value,
|
|
423
423
|
};
|
|
424
|
-
}
|
|
424
|
+
};
|
|
425
425
|
|
|
426
426
|
/**
|
|
427
427
|
* -------------------------------------------------------------------------------------------
|
|
@@ -455,19 +455,19 @@ const createUntypedArray = (value) => {
|
|
|
455
455
|
* @param node The object to check.
|
|
456
456
|
* @returns boolean indicating if the node is an UntypedNull.
|
|
457
457
|
*/
|
|
458
|
-
|
|
458
|
+
const isUntypedNull = (node) => {
|
|
459
459
|
return node.value === null;
|
|
460
|
-
}
|
|
460
|
+
};
|
|
461
461
|
/**
|
|
462
|
-
* Factory to create an UntypedNull
|
|
462
|
+
* Factory to create an UntypedNull.
|
|
463
463
|
* @returns The created UntypedNull.
|
|
464
464
|
*/
|
|
465
|
-
|
|
465
|
+
const createUntypedNull = () => {
|
|
466
466
|
return {
|
|
467
467
|
value: null,
|
|
468
468
|
getValue: () => null,
|
|
469
469
|
};
|
|
470
|
-
}
|
|
470
|
+
};
|
|
471
471
|
|
|
472
472
|
/**
|
|
473
473
|
* -------------------------------------------------------------------------------------------
|
|
@@ -501,42 +501,42 @@ const createUntypedObject = (value) => {
|
|
|
501
501
|
* @param node The object to check.
|
|
502
502
|
* @returns boolean indicating if the node is an UntypedString.
|
|
503
503
|
*/
|
|
504
|
-
|
|
504
|
+
const isUntypedString = (node) => {
|
|
505
505
|
const proposedNode = node;
|
|
506
506
|
return proposedNode && typeof proposedNode.value === "string";
|
|
507
|
-
}
|
|
507
|
+
};
|
|
508
508
|
/**
|
|
509
509
|
* Factory to create an UntypedString from a string.
|
|
510
510
|
* @param value The string value to create from.
|
|
511
511
|
* @returns The created UntypedString.
|
|
512
512
|
*/
|
|
513
|
-
|
|
513
|
+
const createUntypedString = (value) => {
|
|
514
514
|
return {
|
|
515
515
|
value,
|
|
516
516
|
getValue: () => value,
|
|
517
517
|
};
|
|
518
|
-
}
|
|
518
|
+
};
|
|
519
519
|
|
|
520
520
|
/**
|
|
521
521
|
* Type guard to assert that an UntypedNode instance is an UntypedBoolean.
|
|
522
522
|
* @param node The UntypedNode to check.
|
|
523
523
|
* @returns boolean indicating if the node is an UntypedBoolean.
|
|
524
524
|
*/
|
|
525
|
-
|
|
525
|
+
const isUntypedBoolean = (node) => {
|
|
526
526
|
const proposedNode = node;
|
|
527
527
|
return proposedNode && typeof proposedNode.value === "boolean";
|
|
528
|
-
}
|
|
528
|
+
};
|
|
529
529
|
/**
|
|
530
530
|
* Factory to create an UntypedBoolean from a boolean.
|
|
531
531
|
* @param value The boolean value to create from.
|
|
532
532
|
* @returns The created UntypedBoolean.
|
|
533
533
|
*/
|
|
534
|
-
|
|
534
|
+
const createUntypedBoolean = (value) => {
|
|
535
535
|
return {
|
|
536
536
|
value,
|
|
537
537
|
getValue: () => value,
|
|
538
538
|
};
|
|
539
|
-
}
|
|
539
|
+
};
|
|
540
540
|
|
|
541
541
|
/**
|
|
542
542
|
* -------------------------------------------------------------------------------------------
|
|
@@ -790,10 +790,10 @@ const BackingStoreKey = "backingStoreEnabled";
|
|
|
790
790
|
* @param fields The fields of the object
|
|
791
791
|
* @returns boolean indicating if the object is a BackedModel
|
|
792
792
|
*/
|
|
793
|
-
|
|
793
|
+
const isBackingStoreEnabled = (fields) => {
|
|
794
794
|
// Check if the fields contain the backing store key
|
|
795
795
|
return Object.keys(fields).includes(BackingStoreKey);
|
|
796
|
-
}
|
|
796
|
+
};
|
|
797
797
|
|
|
798
798
|
/**
|
|
799
799
|
* -------------------------------------------------------------------------------------------
|
|
@@ -808,7 +808,7 @@ function isBackingStoreEnabled(fields) {
|
|
|
808
808
|
* @param original The serialization writer to enable the backing store on.
|
|
809
809
|
* @returns A new serialization writer with the backing store enabled.
|
|
810
810
|
*/
|
|
811
|
-
|
|
811
|
+
const enableBackingStoreForSerializationWriterFactory = (serializationWriterFactoryRegistry, parseNodeFactoryRegistry, original) => {
|
|
812
812
|
if (!original)
|
|
813
813
|
throw new Error("Original must be specified");
|
|
814
814
|
let result = original;
|
|
@@ -821,14 +821,14 @@ function enableBackingStoreForSerializationWriterFactory(serializationWriterFact
|
|
|
821
821
|
enableBackingStoreForSerializationRegistry(serializationWriterFactoryRegistry);
|
|
822
822
|
enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
|
|
823
823
|
return result;
|
|
824
|
-
}
|
|
824
|
+
};
|
|
825
825
|
/**
|
|
826
826
|
* Enables the backing store on default parse node factories and the given parse node factory.
|
|
827
827
|
* @param parseNodeFactoryRegistry The parse node factory registry to enable the backing store on.
|
|
828
828
|
* @param original The parse node factory to enable the backing store on.
|
|
829
829
|
* @returns A new parse node factory with the backing store enabled.
|
|
830
830
|
*/
|
|
831
|
-
|
|
831
|
+
const enableBackingStoreForParseNodeFactory = (parseNodeFactoryRegistry, original) => {
|
|
832
832
|
if (!original)
|
|
833
833
|
throw new Error("Original must be specified");
|
|
834
834
|
let result = original;
|
|
@@ -840,29 +840,29 @@ function enableBackingStoreForParseNodeFactory(parseNodeFactoryRegistry, origina
|
|
|
840
840
|
}
|
|
841
841
|
enableBackingStoreForParseNodeRegistry(parseNodeFactoryRegistry);
|
|
842
842
|
return result;
|
|
843
|
-
}
|
|
843
|
+
};
|
|
844
844
|
/**
|
|
845
845
|
* Enables the backing store on the given parse node factory registry.
|
|
846
846
|
* @param registry The parse node factory registry to enable the backing store on.
|
|
847
847
|
*/
|
|
848
|
-
|
|
848
|
+
const enableBackingStoreForParseNodeRegistry = (registry) => {
|
|
849
849
|
for (const [k, v] of registry.contentTypeAssociatedFactories) {
|
|
850
850
|
if (!(v instanceof BackingStoreParseNodeFactory || v instanceof ParseNodeFactoryRegistry)) {
|
|
851
851
|
registry.contentTypeAssociatedFactories.set(k, new BackingStoreParseNodeFactory(v));
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
}
|
|
854
|
+
};
|
|
855
855
|
/**
|
|
856
856
|
* Enables the backing store on the given serialization factory registry.
|
|
857
857
|
* @param registry The serialization factory registry to enable the backing store on.
|
|
858
858
|
*/
|
|
859
|
-
|
|
859
|
+
const enableBackingStoreForSerializationRegistry = (registry) => {
|
|
860
860
|
for (const [k, v] of registry.contentTypeAssociatedFactories) {
|
|
861
861
|
if (!(v instanceof BackingStoreSerializationWriterProxyFactory || v instanceof SerializationWriterFactoryRegistry)) {
|
|
862
862
|
registry.contentTypeAssociatedFactories.set(k, new BackingStoreSerializationWriterProxyFactory(v));
|
|
863
863
|
}
|
|
864
864
|
}
|
|
865
|
-
}
|
|
865
|
+
};
|
|
866
866
|
|
|
867
867
|
/*
|
|
868
868
|
* Copyright The OpenTelemetry Authors
|
|
@@ -2635,9 +2635,9 @@ class DateOnly {
|
|
|
2635
2635
|
* @param digits The number of digits to pad
|
|
2636
2636
|
* @returns The formatted segment
|
|
2637
2637
|
*/
|
|
2638
|
-
|
|
2638
|
+
const formatSegment = (segment, digits = 2) => {
|
|
2639
2639
|
return segment.toString().padStart(digits, "0");
|
|
2640
|
-
}
|
|
2640
|
+
};
|
|
2641
2641
|
|
|
2642
2642
|
var dist = {};
|
|
2643
2643
|
|
|
@@ -2868,7 +2868,7 @@ class Duration {
|
|
|
2868
2868
|
* @param canon The function that canonicalizes the property name.
|
|
2869
2869
|
* @returns A new object that can be used as a dictionary with case-insensitive keys.
|
|
2870
2870
|
*/
|
|
2871
|
-
|
|
2871
|
+
const dictionaryWithCanonicalKeys = (canon) => {
|
|
2872
2872
|
const keysNormalizationMap = new Map();
|
|
2873
2873
|
return new Proxy({}, {
|
|
2874
2874
|
/**
|
|
@@ -2877,7 +2877,7 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2877
2877
|
* @param prop The property to get.
|
|
2878
2878
|
* @returns The value of the property.
|
|
2879
2879
|
*/
|
|
2880
|
-
get(target, prop) {
|
|
2880
|
+
get: (target, prop) => {
|
|
2881
2881
|
const normalKey = canon(prop);
|
|
2882
2882
|
return Reflect.get(target, normalKey);
|
|
2883
2883
|
},
|
|
@@ -2888,7 +2888,7 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2888
2888
|
* @param value The value to set.
|
|
2889
2889
|
* @returns A boolean indicating whether the property was set.
|
|
2890
2890
|
*/
|
|
2891
|
-
set(target, prop, value) {
|
|
2891
|
+
set: (target, prop, value) => {
|
|
2892
2892
|
const nonNormalKey = prop.toString();
|
|
2893
2893
|
const normalKey = canon(prop);
|
|
2894
2894
|
keysNormalizationMap.set(normalKey, nonNormalKey);
|
|
@@ -2900,7 +2900,7 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2900
2900
|
* @param prop The property to check.
|
|
2901
2901
|
* @returns A boolean indicating whether the property exists.
|
|
2902
2902
|
*/
|
|
2903
|
-
has(_, prop) {
|
|
2903
|
+
has: (_, prop) => {
|
|
2904
2904
|
const normalKey = canon(prop);
|
|
2905
2905
|
return keysNormalizationMap.has(normalKey);
|
|
2906
2906
|
},
|
|
@@ -2911,7 +2911,7 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2911
2911
|
* @param attribs The attributes of the property.
|
|
2912
2912
|
* @returns A boolean indicating whether the property was defined.
|
|
2913
2913
|
*/
|
|
2914
|
-
defineProperty(target, prop, attribs) {
|
|
2914
|
+
defineProperty: (target, prop, attribs) => {
|
|
2915
2915
|
const nonNormalKey = prop.toString();
|
|
2916
2916
|
const normalKey = canon(prop);
|
|
2917
2917
|
keysNormalizationMap.set(normalKey, nonNormalKey);
|
|
@@ -2923,7 +2923,7 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2923
2923
|
* @param prop The property to delete.
|
|
2924
2924
|
* @returns A boolean indicating whether the property was deleted.
|
|
2925
2925
|
*/
|
|
2926
|
-
deleteProperty(target, prop) {
|
|
2926
|
+
deleteProperty: (target, prop) => {
|
|
2927
2927
|
const normalKey = canon(prop);
|
|
2928
2928
|
keysNormalizationMap.delete(normalKey);
|
|
2929
2929
|
return Reflect.deleteProperty(target, normalKey);
|
|
@@ -2934,19 +2934,19 @@ function dictionaryWithCanonicalKeys(canon) {
|
|
|
2934
2934
|
* @param prop The property to gets its descriptor.
|
|
2935
2935
|
* @returns The property descriptor.
|
|
2936
2936
|
*/
|
|
2937
|
-
getOwnPropertyDescriptor(target, prop) {
|
|
2937
|
+
getOwnPropertyDescriptor: (target, prop) => {
|
|
2938
2938
|
return Reflect.getOwnPropertyDescriptor(target, canon(prop));
|
|
2939
2939
|
},
|
|
2940
|
-
ownKeys() {
|
|
2940
|
+
ownKeys: () => {
|
|
2941
2941
|
return [...keysNormalizationMap.values()];
|
|
2942
2942
|
},
|
|
2943
2943
|
});
|
|
2944
|
-
}
|
|
2944
|
+
};
|
|
2945
2945
|
/**
|
|
2946
2946
|
* A wrapper for type Record that creates a Record with case insensitive keys
|
|
2947
2947
|
* @returns A new object that can be used as a dictionary with case-insensitive keys.
|
|
2948
2948
|
*/
|
|
2949
|
-
|
|
2949
|
+
const createRecordWithCaseInsensitiveKeys = () => {
|
|
2950
2950
|
/**
|
|
2951
2951
|
* A function that takes a property name and returns its canonical form.
|
|
2952
2952
|
* @param prop The property name to be canonicalized.
|
|
@@ -2954,7 +2954,7 @@ function createRecordWithCaseInsensitiveKeys() {
|
|
|
2954
2954
|
*/
|
|
2955
2955
|
const record = dictionaryWithCanonicalKeys((p) => (typeof p === "string" ? p.toLowerCase() : p.toString().toLowerCase()));
|
|
2956
2956
|
return record;
|
|
2957
|
-
}
|
|
2957
|
+
};
|
|
2958
2958
|
|
|
2959
2959
|
/**
|
|
2960
2960
|
* -------------------------------------------------------------------------------------------
|
|
@@ -3054,6 +3054,7 @@ class Headers extends Map {
|
|
|
3054
3054
|
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each header in the dictionary.
|
|
3055
3055
|
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
3056
3056
|
*/
|
|
3057
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3057
3058
|
forEach(callbackfn, thisArg) {
|
|
3058
3059
|
for (const header in this.headers) {
|
|
3059
3060
|
if (Object.prototype.hasOwnProperty.call(this.headers, header)) {
|
|
@@ -3335,10 +3336,10 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
|
|
|
3335
3336
|
writer.writeStringValue(undefined, part.content);
|
|
3336
3337
|
}
|
|
3337
3338
|
else if (part.content instanceof ArrayBuffer) {
|
|
3338
|
-
writer.writeByteArrayValue(undefined, new Uint8Array(part.content));
|
|
3339
|
+
writer.writeByteArrayValue(undefined, new Uint8Array(part.content).buffer);
|
|
3339
3340
|
}
|
|
3340
3341
|
else if (part.content instanceof Uint8Array) {
|
|
3341
|
-
writer.writeByteArrayValue(undefined, part.content);
|
|
3342
|
+
writer.writeByteArrayValue(undefined, part.content.buffer);
|
|
3342
3343
|
}
|
|
3343
3344
|
else if (part.serializationCallback) {
|
|
3344
3345
|
if (!multipartBody.requestAdapter) {
|
|
@@ -3354,7 +3355,7 @@ const serializeMultipartBody = (writer, multipartBody = new MultipartBody()) =>
|
|
|
3354
3355
|
}
|
|
3355
3356
|
partSerializationWriter.writeObjectValue(undefined, part.content, part.serializationCallback);
|
|
3356
3357
|
const partContent = partSerializationWriter.getSerializedContent();
|
|
3357
|
-
writer.writeByteArrayValue(undefined, new Uint8Array(partContent));
|
|
3358
|
+
writer.writeByteArrayValue(undefined, new Uint8Array(partContent).buffer);
|
|
3358
3359
|
}
|
|
3359
3360
|
else {
|
|
3360
3361
|
throw new Error("unsupported content type for multipart body: " + typeof part.content);
|
|
@@ -4018,6 +4019,10 @@ const apiClientProxifier = (requestAdapter, pathParameters, navigationMetadata,
|
|
|
4018
4019
|
return apiClientProxifier(requestAdapter, downWardPathParameters, navigationCandidate.navigationMetadata, navigationCandidate.requestsMetadata);
|
|
4019
4020
|
};
|
|
4020
4021
|
}
|
|
4022
|
+
if (name === "then") {
|
|
4023
|
+
// handle returning proxy from an async method
|
|
4024
|
+
return undefined;
|
|
4025
|
+
}
|
|
4021
4026
|
throw new Error(`couldn't find navigation property ${name} data: ${JSON.stringify(navigationMetadata)}`);
|
|
4022
4027
|
}
|
|
4023
4028
|
},
|
|
@@ -4055,7 +4060,7 @@ class AllowedHostsValidator {
|
|
|
4055
4060
|
*/
|
|
4056
4061
|
constructor(allowedHosts = new Set()) {
|
|
4057
4062
|
this.validateHosts(allowedHosts);
|
|
4058
|
-
this.allowedHosts = allowedHosts
|
|
4063
|
+
this.allowedHosts = this.normalizeHosts(allowedHosts);
|
|
4059
4064
|
}
|
|
4060
4065
|
/**
|
|
4061
4066
|
* Gets the list of valid hosts. If the list is empty, all hosts are valid.
|
|
@@ -4070,7 +4075,7 @@ class AllowedHostsValidator {
|
|
|
4070
4075
|
*/
|
|
4071
4076
|
setAllowedHosts(allowedHosts) {
|
|
4072
4077
|
this.validateHosts(allowedHosts);
|
|
4073
|
-
this.allowedHosts = allowedHosts;
|
|
4078
|
+
this.allowedHosts = this.normalizeHosts(allowedHosts);
|
|
4074
4079
|
}
|
|
4075
4080
|
/**
|
|
4076
4081
|
* Checks whether the provided host is valid.
|
|
@@ -4078,7 +4083,7 @@ class AllowedHostsValidator {
|
|
|
4078
4083
|
* @returns True if the host is valid, false otherwise.
|
|
4079
4084
|
*/
|
|
4080
4085
|
isUrlHostValid(url) {
|
|
4081
|
-
var _a
|
|
4086
|
+
var _a;
|
|
4082
4087
|
if (!url)
|
|
4083
4088
|
return false;
|
|
4084
4089
|
if (this.allowedHosts.size === 0)
|
|
@@ -4095,7 +4100,7 @@ class AllowedHostsValidator {
|
|
|
4095
4100
|
return this.isHostAndPathValid(url);
|
|
4096
4101
|
}
|
|
4097
4102
|
if ((_a = window === null || window === void 0 ? void 0 : window.location) === null || _a === void 0 ? void 0 : _a.host) {
|
|
4098
|
-
return this.
|
|
4103
|
+
return this.isHostValid(window.location.host);
|
|
4099
4104
|
}
|
|
4100
4105
|
return false;
|
|
4101
4106
|
}
|
|
@@ -4104,11 +4109,21 @@ class AllowedHostsValidator {
|
|
|
4104
4109
|
if (hostAndRest.length >= 2) {
|
|
4105
4110
|
const host = hostAndRest[0];
|
|
4106
4111
|
if (host) {
|
|
4107
|
-
return this.
|
|
4112
|
+
return this.isHostValid(host.split(":")[0]);
|
|
4108
4113
|
}
|
|
4109
4114
|
}
|
|
4110
4115
|
return false;
|
|
4111
4116
|
}
|
|
4117
|
+
isHostValid(host) {
|
|
4118
|
+
const normalizedHost = host.toLowerCase();
|
|
4119
|
+
if (this.allowedHosts.has(normalizedHost)) {
|
|
4120
|
+
return true;
|
|
4121
|
+
}
|
|
4122
|
+
return Array.from(this.allowedHosts).some((allowedHost) => allowedHost.startsWith(".") && normalizedHost.endsWith(allowedHost));
|
|
4123
|
+
}
|
|
4124
|
+
normalizeHosts(hostsToNormalize) {
|
|
4125
|
+
return new Set(Array.from(hostsToNormalize, (host) => host.toLowerCase()));
|
|
4126
|
+
}
|
|
4112
4127
|
validateHosts(hostsToValidate) {
|
|
4113
4128
|
if (!hostsToValidate) {
|
|
4114
4129
|
throw new Error("hostsToValidate cannot be null");
|
|
@@ -4132,27 +4147,27 @@ const localhostStrings = new Set(["localhost", "[::1]", "::1", "127.0.0.1"]);
|
|
|
4132
4147
|
* Validates the protocol of the url.
|
|
4133
4148
|
* @param url - The url to validate.
|
|
4134
4149
|
*/
|
|
4135
|
-
|
|
4150
|
+
const validateProtocol = (url) => {
|
|
4136
4151
|
if (!isLocalhostUrl(url) && !url.toLocaleLowerCase().startsWith("https://") && !windowUrlStartsWithHttps()) {
|
|
4137
4152
|
throw new Error("Authentication scheme can only be used with https requests");
|
|
4138
4153
|
}
|
|
4139
|
-
}
|
|
4154
|
+
};
|
|
4140
4155
|
/**
|
|
4141
4156
|
* Checks if the window url starts with https.
|
|
4142
4157
|
* @returns True if the window url starts with https, false otherwise.
|
|
4143
4158
|
*/
|
|
4144
|
-
|
|
4159
|
+
const windowUrlStartsWithHttps = () => {
|
|
4145
4160
|
if (!inNodeEnv()) {
|
|
4146
4161
|
return window.location.protocol.toLocaleLowerCase() === "https:";
|
|
4147
4162
|
}
|
|
4148
4163
|
return false;
|
|
4149
|
-
}
|
|
4164
|
+
};
|
|
4150
4165
|
/**
|
|
4151
4166
|
* Checks if the url is a localhost url.
|
|
4152
4167
|
* @param urlString - The url to check.
|
|
4153
4168
|
* @returns True if the url is a localhost url, false otherwise.
|
|
4154
4169
|
*/
|
|
4155
|
-
|
|
4170
|
+
const isLocalhostUrl = (urlString) => {
|
|
4156
4171
|
try {
|
|
4157
4172
|
const url = new URL(urlString);
|
|
4158
4173
|
return localhostStrings.has(url.hostname);
|
|
@@ -4160,7 +4175,7 @@ function isLocalhostUrl(urlString) {
|
|
|
4160
4175
|
catch (_a) {
|
|
4161
4176
|
return false;
|
|
4162
4177
|
}
|
|
4163
|
-
}
|
|
4178
|
+
};
|
|
4164
4179
|
|
|
4165
4180
|
/** Authenticate a request by using an API Key */
|
|
4166
4181
|
class ApiKeyAuthenticationProvider {
|
|
@@ -4285,14 +4300,9 @@ class HttpClient {
|
|
|
4285
4300
|
middlewares = (middlewares === null || middlewares === void 0 ? void 0 : middlewares.length) && middlewares[0] ? middlewares : MiddlewareFactory.getDefaultMiddlewares(customFetch);
|
|
4286
4301
|
// If a custom fetch function is provided, add a CustomFetchHandler to the end of the middleware chain
|
|
4287
4302
|
if (this.customFetch) {
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
// eslint-disable-next-line no-console
|
|
4292
|
-
console.debug("Registered middlewares: " + middlewares.map((m) => m.constructor.name).join(", "));
|
|
4293
|
-
// eslint-disable-next-line no-console
|
|
4294
|
-
console.debug("Hint: To improve performance, use MiddlewareFactory.getPerformanceMiddlewares(customFetch) instead of MiddlewareFactory.getDefaultMiddlewares(customFetch)");
|
|
4295
|
-
// Set the middleware chain
|
|
4303
|
+
middlewares.push(new CustomFetchHandler(this.customFetch));
|
|
4304
|
+
}
|
|
4305
|
+
// Set the middleware handlers chain
|
|
4296
4306
|
this.setMiddleware(...middlewares);
|
|
4297
4307
|
}
|
|
4298
4308
|
/**
|
|
@@ -4347,7 +4357,7 @@ class ObservabilityOptionsImpl {
|
|
|
4347
4357
|
* @param requestOptions The request options
|
|
4348
4358
|
* @returns The observability options
|
|
4349
4359
|
*/
|
|
4350
|
-
|
|
4360
|
+
const getObservabilityOptionsFromRequest = (requestOptions) => {
|
|
4351
4361
|
if (requestOptions) {
|
|
4352
4362
|
const observabilityOptions = requestOptions[ObservabilityOptionKey];
|
|
4353
4363
|
if (observabilityOptions instanceof ObservabilityOptionsImpl) {
|
|
@@ -4355,7 +4365,7 @@ function getObservabilityOptionsFromRequest(requestOptions) {
|
|
|
4355
4365
|
}
|
|
4356
4366
|
}
|
|
4357
4367
|
return undefined;
|
|
4358
|
-
}
|
|
4368
|
+
};
|
|
4359
4369
|
|
|
4360
4370
|
/**
|
|
4361
4371
|
* -------------------------------------------------------------------------------------------
|
|
@@ -4430,31 +4440,34 @@ class FetchRequestAdapter {
|
|
|
4430
4440
|
case "number":
|
|
4431
4441
|
case "boolean":
|
|
4432
4442
|
case "Date":
|
|
4443
|
+
case "Duration":
|
|
4444
|
+
case "DateOnly":
|
|
4445
|
+
case "TimeOnly":
|
|
4433
4446
|
// eslint-disable-next-line no-case-declarations
|
|
4434
4447
|
const rootNode = await this.getRootParseNode(response);
|
|
4435
4448
|
return trace.getTracer(this.observabilityOptions.getTracerInstrumentationName()).startActiveSpan(`getCollectionOf${responseType}Value`, (deserializeSpan) => {
|
|
4436
4449
|
try {
|
|
4437
4450
|
span.setAttribute(FetchRequestAdapter.responseTypeAttributeKey, responseType);
|
|
4438
4451
|
if (responseType === "string") {
|
|
4439
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4452
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4440
4453
|
}
|
|
4441
4454
|
else if (responseType === "number") {
|
|
4442
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4455
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4443
4456
|
}
|
|
4444
4457
|
else if (responseType === "boolean") {
|
|
4445
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4458
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4446
4459
|
}
|
|
4447
4460
|
else if (responseType === "Date") {
|
|
4448
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4461
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4449
4462
|
}
|
|
4450
4463
|
else if (responseType === "Duration") {
|
|
4451
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4464
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4452
4465
|
}
|
|
4453
4466
|
else if (responseType === "DateOnly") {
|
|
4454
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4467
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4455
4468
|
}
|
|
4456
4469
|
else if (responseType === "TimeOnly") {
|
|
4457
|
-
return rootNode.getCollectionOfPrimitiveValues();
|
|
4470
|
+
return rootNode.getCollectionOfPrimitiveValues(responseType);
|
|
4458
4471
|
}
|
|
4459
4472
|
else {
|
|
4460
4473
|
throw new Error("unexpected type to deserialize");
|
|
@@ -4985,7 +4998,7 @@ FetchRequestAdapter.authenticateChallengedEventKey = "com.microsoft.kiota.authen
|
|
|
4985
4998
|
* @returns A header value for the given key from the request
|
|
4986
4999
|
*/
|
|
4987
5000
|
const getRequestHeader = (options, key) => {
|
|
4988
|
-
if (options
|
|
5001
|
+
if (options === null || options === void 0 ? void 0 : options.headers) {
|
|
4989
5002
|
return options.headers[key];
|
|
4990
5003
|
}
|
|
4991
5004
|
return undefined;
|
|
@@ -5206,7 +5219,7 @@ class CompressionHandler {
|
|
|
5206
5219
|
}
|
|
5207
5220
|
const uint8ArrayToStream = (uint8Array) => {
|
|
5208
5221
|
return new ReadableStream({
|
|
5209
|
-
start(controller) {
|
|
5222
|
+
start: (controller) => {
|
|
5210
5223
|
controller.enqueue(uint8Array);
|
|
5211
5224
|
controller.close();
|
|
5212
5225
|
},
|
|
@@ -5463,6 +5476,47 @@ class ParametersNameDecodingHandler {
|
|
|
5463
5476
|
* -------------------------------------------------------------------------------------------
|
|
5464
5477
|
*/
|
|
5465
5478
|
const RedirectHandlerOptionKey = "RedirectHandlerOption";
|
|
5479
|
+
/**
|
|
5480
|
+
* The default implementation for scrubbing sensitive headers during redirects.
|
|
5481
|
+
* This function removes Authorization, Cookie, and Proxy-Authorization headers when the host or scheme changes.
|
|
5482
|
+
*
|
|
5483
|
+
* It is exported so that consumers providing a custom {@link ScrubSensitiveHeaders} callback can call it to
|
|
5484
|
+
* retain the default behavior and then layer additional logic on top (e.g. removing custom headers such as
|
|
5485
|
+
* `X-Api-Key`), matching the composable pattern available in the .NET and Python Kiota SDKs.
|
|
5486
|
+
*
|
|
5487
|
+
* Note: In browser environments, `Proxy-Authorization` is a forbidden header name and typically cannot be set;
|
|
5488
|
+
* it is still removed here if present (e.g. in Node.js or other non-browser runtimes).
|
|
5489
|
+
* @param headers - The headers object to modify
|
|
5490
|
+
* @param originalUrl - The original request URL
|
|
5491
|
+
* @param newUrl - The new redirect URL
|
|
5492
|
+
*/
|
|
5493
|
+
const defaultScrubSensitiveHeaders = (headers, originalUrl, newUrl) => {
|
|
5494
|
+
if (!headers || !originalUrl || !newUrl) {
|
|
5495
|
+
return;
|
|
5496
|
+
}
|
|
5497
|
+
try {
|
|
5498
|
+
const originalUri = new URL(originalUrl);
|
|
5499
|
+
const newUri = new URL(newUrl);
|
|
5500
|
+
// Remove Authorization, Cookie, and Proxy-Authorization headers if the request's scheme or host changes.
|
|
5501
|
+
// Header keys must be matched case-insensitively because FetchRequestAdapter.getRequestFromRequestInformation
|
|
5502
|
+
// lower-cases every header key before the headers object reaches this middleware, so PascalCase
|
|
5503
|
+
// property deletes such as `delete headers.Authorization` would otherwise be a no-op.
|
|
5504
|
+
const isDifferentHostOrScheme = originalUri.host.toLowerCase() !== newUri.host.toLowerCase() || originalUri.protocol.toLowerCase() !== newUri.protocol.toLowerCase();
|
|
5505
|
+
if (isDifferentHostOrScheme) {
|
|
5506
|
+
for (const key of Object.keys(headers)) {
|
|
5507
|
+
const lower = key.toLowerCase();
|
|
5508
|
+
if (lower === "authorization" || lower === "cookie" || lower === "proxy-authorization") {
|
|
5509
|
+
delete headers[key];
|
|
5510
|
+
}
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
}
|
|
5514
|
+
catch (_a) {
|
|
5515
|
+
// If URL parsing fails, don't modify headers
|
|
5516
|
+
// This handles cases where invalid URLs are passed
|
|
5517
|
+
return;
|
|
5518
|
+
}
|
|
5519
|
+
};
|
|
5466
5520
|
/**
|
|
5467
5521
|
* MiddlewareOptions
|
|
5468
5522
|
* A class representing RedirectHandlerOptions
|
|
@@ -5477,7 +5531,7 @@ class RedirectHandlerOptions {
|
|
|
5477
5531
|
* @example const options = new RedirectHandlerOptions({ maxRedirects: 5 });
|
|
5478
5532
|
*/
|
|
5479
5533
|
constructor(options = {}) {
|
|
5480
|
-
var _a, _b;
|
|
5534
|
+
var _a, _b, _c;
|
|
5481
5535
|
if (options.maxRedirects && options.maxRedirects > RedirectHandlerOptions.MAX_MAX_REDIRECTS) {
|
|
5482
5536
|
const error = new Error(`MaxRedirects should not be more than ${RedirectHandlerOptions.MAX_MAX_REDIRECTS}`);
|
|
5483
5537
|
error.name = "MaxLimitExceeded";
|
|
@@ -5490,6 +5544,7 @@ class RedirectHandlerOptions {
|
|
|
5490
5544
|
}
|
|
5491
5545
|
this.maxRedirects = (_a = options.maxRedirects) !== null && _a !== void 0 ? _a : RedirectHandlerOptions.DEFAULT_MAX_REDIRECTS;
|
|
5492
5546
|
this.shouldRedirect = (_b = options.shouldRedirect) !== null && _b !== void 0 ? _b : RedirectHandlerOptions.defaultShouldRetry;
|
|
5547
|
+
this.scrubSensitiveHeaders = (_c = options.scrubSensitiveHeaders) !== null && _c !== void 0 ? _c : RedirectHandlerOptions.defaultScrubSensitiveHeaders;
|
|
5493
5548
|
}
|
|
5494
5549
|
getKey() {
|
|
5495
5550
|
return RedirectHandlerOptionKey;
|
|
@@ -5509,6 +5564,11 @@ RedirectHandlerOptions.MAX_MAX_REDIRECTS = 20;
|
|
|
5509
5564
|
* @returns true
|
|
5510
5565
|
*/
|
|
5511
5566
|
RedirectHandlerOptions.defaultShouldRetry = () => true;
|
|
5567
|
+
/**
|
|
5568
|
+
* The default {@link ScrubSensitiveHeaders} callback used when none is supplied.
|
|
5569
|
+
* Delegates to the exported {@link defaultScrubSensitiveHeaders} function.
|
|
5570
|
+
*/
|
|
5571
|
+
RedirectHandlerOptions.defaultScrubSensitiveHeaders = defaultScrubSensitiveHeaders;
|
|
5512
5572
|
|
|
5513
5573
|
/**
|
|
5514
5574
|
* -------------------------------------------------------------------------------------------
|
|
@@ -5575,27 +5635,6 @@ class RedirectHandler {
|
|
|
5575
5635
|
isRelativeURL(url) {
|
|
5576
5636
|
return !url.includes("://");
|
|
5577
5637
|
}
|
|
5578
|
-
/**
|
|
5579
|
-
*
|
|
5580
|
-
* To check whether the authorization header in the request should be dropped for consequent redirected requests
|
|
5581
|
-
* @param requestUrl - The request url value
|
|
5582
|
-
* @param redirectUrl - The redirect url value
|
|
5583
|
-
* @returns A boolean representing whether the authorization header in the request should be dropped for consequent redirected requests
|
|
5584
|
-
*/
|
|
5585
|
-
shouldDropAuthorizationHeader(requestUrl, redirectUrl) {
|
|
5586
|
-
const schemeHostRegex = /^[A-Za-z].+?:\/\/.+?(?=\/|$)/;
|
|
5587
|
-
const requestMatches = schemeHostRegex.exec(requestUrl);
|
|
5588
|
-
let requestAuthority;
|
|
5589
|
-
let redirectAuthority;
|
|
5590
|
-
if (requestMatches !== null) {
|
|
5591
|
-
requestAuthority = requestMatches[0];
|
|
5592
|
-
}
|
|
5593
|
-
const redirectMatches = schemeHostRegex.exec(redirectUrl);
|
|
5594
|
-
if (redirectMatches !== null) {
|
|
5595
|
-
redirectAuthority = redirectMatches[0];
|
|
5596
|
-
}
|
|
5597
|
-
return typeof requestAuthority !== "undefined" && typeof redirectAuthority !== "undefined" && requestAuthority !== redirectAuthority;
|
|
5598
|
-
}
|
|
5599
5638
|
/**
|
|
5600
5639
|
* To execute the next middleware and to handle in case of redirect response returned by the server
|
|
5601
5640
|
* @param url - The url string value
|
|
@@ -5614,19 +5653,22 @@ class RedirectHandler {
|
|
|
5614
5653
|
}
|
|
5615
5654
|
if (redirectCount < currentOptions.maxRedirects && this.isRedirect(response) && this.hasLocationHeader(response) && currentOptions.shouldRedirect(response)) {
|
|
5616
5655
|
++redirectCount;
|
|
5656
|
+
const redirectUrl = this.getLocationHeader(response);
|
|
5657
|
+
if (!redirectUrl) {
|
|
5658
|
+
return response;
|
|
5659
|
+
}
|
|
5660
|
+
// Resolve relative URLs
|
|
5661
|
+
const newUrl = this.isRelativeURL(redirectUrl) ? new URL(redirectUrl, url).toString() : redirectUrl;
|
|
5662
|
+
// Scrub sensitive headers before following the redirect
|
|
5663
|
+
if (fetchRequestInit.headers) {
|
|
5664
|
+
currentOptions.scrubSensitiveHeaders(fetchRequestInit.headers, url, newUrl);
|
|
5665
|
+
}
|
|
5666
|
+
// Handle 303 See Other: change POST to GET
|
|
5617
5667
|
if (response.status === RedirectHandler.STATUS_CODE_SEE_OTHER) {
|
|
5618
5668
|
fetchRequestInit.method = HttpMethod.GET;
|
|
5619
5669
|
delete fetchRequestInit.body;
|
|
5620
5670
|
}
|
|
5621
|
-
|
|
5622
|
-
const redirectUrl = this.getLocationHeader(response);
|
|
5623
|
-
if (redirectUrl) {
|
|
5624
|
-
if (fetchRequestInit.headers && !this.isRelativeURL(redirectUrl) && this.shouldDropAuthorizationHeader(url, redirectUrl)) {
|
|
5625
|
-
delete fetchRequestInit.headers[RedirectHandler.AUTHORIZATION_HEADER];
|
|
5626
|
-
}
|
|
5627
|
-
url = redirectUrl;
|
|
5628
|
-
}
|
|
5629
|
-
}
|
|
5671
|
+
url = newUrl;
|
|
5630
5672
|
if (tracerName) {
|
|
5631
5673
|
return trace.getTracer(tracerName).startActiveSpan(`redirectHandler - redirect ${redirectCount}`, (span) => {
|
|
5632
5674
|
try {
|
|
@@ -5692,10 +5734,6 @@ RedirectHandler.STATUS_CODE_SEE_OTHER = 303;
|
|
|
5692
5734
|
* A member holding the name of the location header
|
|
5693
5735
|
*/
|
|
5694
5736
|
RedirectHandler.LOCATION_HEADER = "Location";
|
|
5695
|
-
/**
|
|
5696
|
-
* A member representing the authorization header name
|
|
5697
|
-
*/
|
|
5698
|
-
RedirectHandler.AUTHORIZATION_HEADER = "Authorization";
|
|
5699
5737
|
/**
|
|
5700
5738
|
* A member holding the manual redirect value
|
|
5701
5739
|
*/
|
|
@@ -6192,7 +6230,6 @@ class MiddlewareFactory {
|
|
|
6192
6230
|
* Returns the default middleware chain an array with the middleware handlers
|
|
6193
6231
|
* @returns an array of the middleware handlers of the default middleware chain
|
|
6194
6232
|
*/
|
|
6195
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
6196
6233
|
static getDefaultMiddlewares(customFetch = (...args) => fetch(...args)) {
|
|
6197
6234
|
return [new RetryHandler(), new RedirectHandler(), new ParametersNameDecodingHandler(), new UserAgentHandler(), new HeadersInspectionHandler(), new UrlReplaceHandler(), new CustomFetchHandler(customFetch)];
|
|
6198
6235
|
}
|
|
@@ -6201,7 +6238,6 @@ class MiddlewareFactory {
|
|
|
6201
6238
|
* Returns the default middleware chain + performance middleware
|
|
6202
6239
|
* @returns an array of the middleware handlers of the default + performance middleware chain
|
|
6203
6240
|
*/
|
|
6204
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
6205
6241
|
static getPerformanceMiddlewares(customFetch = (...args) => fetch(...args)) {
|
|
6206
6242
|
const middlewares = MiddlewareFactory.getDefaultMiddlewares(customFetch);
|
|
6207
6243
|
middlewares.splice(middlewares.length - 3, 0, new CompressionHandler()); // insert CompressionHandler before HeadersInspectionHandler
|
|
@@ -12316,7 +12352,7 @@ function deserializeIntoGetPlanListSchema_data_tierTag(getPlanListSchema_data_ti
|
|
|
12316
12352
|
// @ts-ignore
|
|
12317
12353
|
function deserializeIntoGetPlanListSchema_filterOptions(getPlanListSchema_filterOptions = {}) {
|
|
12318
12354
|
return {
|
|
12319
|
-
"currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues(); },
|
|
12355
|
+
"currencies": n => { getPlanListSchema_filterOptions.currencies = n.getCollectionOfPrimitiveValues("string"); },
|
|
12320
12356
|
"intervals": n => { getPlanListSchema_filterOptions.intervals = n.getCollectionOfObjectValues(createGetPlanListSchema_filterOptions_intervalsFromDiscriminatorValue); },
|
|
12321
12357
|
};
|
|
12322
12358
|
}
|
|
@@ -13165,7 +13201,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_sub
|
|
|
13165
13201
|
function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items = {}) {
|
|
13166
13202
|
return {
|
|
13167
13203
|
"invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoice = n.getStringValue(); },
|
|
13168
|
-
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
|
|
13204
|
+
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_parent_subscription_item_details_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
|
|
13169
13205
|
};
|
|
13170
13206
|
}
|
|
13171
13207
|
/**
|
|
@@ -13318,7 +13354,7 @@ function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_
|
|
|
13318
13354
|
function deserializeIntoGetSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items(getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items = {}) {
|
|
13319
13355
|
return {
|
|
13320
13356
|
"invoice": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoice = n.getStringValue(); },
|
|
13321
|
-
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues(); },
|
|
13357
|
+
"invoice_line_items": n => { getSubscriptionInvoicesSchema_data_lines_data_proration_details_credited_items.invoiceLineItems = n.getCollectionOfPrimitiveValues("string"); },
|
|
13322
13358
|
};
|
|
13323
13359
|
}
|
|
13324
13360
|
/**
|
|
@@ -20001,58 +20037,40 @@ class FormParseNode {
|
|
|
20001
20037
|
this._rawString = _rawString;
|
|
20002
20038
|
this.backingStoreFactory = backingStoreFactory;
|
|
20003
20039
|
this._fields = {};
|
|
20004
|
-
this.
|
|
20005
|
-
this.getStringValue = () => decodeURIComponent(this._rawString);
|
|
20040
|
+
this.getStringValue = () => this.getStringValueFromRaw(this._rawString);
|
|
20006
20041
|
this.getChildNode = (identifier) => {
|
|
20007
20042
|
if (this._fields[identifier]) {
|
|
20008
20043
|
return new FormParseNode(this._fields[identifier], this.backingStoreFactory);
|
|
20009
20044
|
}
|
|
20010
20045
|
return undefined;
|
|
20011
20046
|
};
|
|
20012
|
-
this.getBooleanValue = () =>
|
|
20013
|
-
|
|
20014
|
-
|
|
20015
|
-
|
|
20016
|
-
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20020
|
-
|
|
20021
|
-
return
|
|
20022
|
-
|
|
20023
|
-
|
|
20024
|
-
|
|
20025
|
-
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
|
|
20029
|
-
|
|
20030
|
-
|
|
20031
|
-
|
|
20032
|
-
|
|
20033
|
-
|
|
20034
|
-
|
|
20035
|
-
|
|
20036
|
-
|
|
20037
|
-
|
|
20038
|
-
|
|
20039
|
-
else if (typeOfX === "number") {
|
|
20040
|
-
return currentParseNode.getNumberValue();
|
|
20041
|
-
}
|
|
20042
|
-
else if (x instanceof Date) {
|
|
20043
|
-
return currentParseNode.getDateValue();
|
|
20044
|
-
}
|
|
20045
|
-
else if (x instanceof DateOnly) {
|
|
20046
|
-
return currentParseNode.getDateValue();
|
|
20047
|
-
}
|
|
20048
|
-
else if (x instanceof TimeOnly) {
|
|
20049
|
-
return currentParseNode.getDateValue();
|
|
20050
|
-
}
|
|
20051
|
-
else if (x instanceof Duration) {
|
|
20052
|
-
return currentParseNode.getDateValue();
|
|
20053
|
-
}
|
|
20054
|
-
else {
|
|
20055
|
-
throw new Error(`encountered an unknown type during deserialization ${typeof x}`);
|
|
20047
|
+
this.getBooleanValue = () => this.getBooleanValueFromRaw(this._rawString);
|
|
20048
|
+
this.getNumberValue = () => this.getNumberValueFromRaw(this._rawString);
|
|
20049
|
+
this.getGuidValue = () => this.getGuidValueFromRaw(this._rawString);
|
|
20050
|
+
this.getDateValue = () => this.getDateValueFromRaw(this._rawString);
|
|
20051
|
+
this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._rawString);
|
|
20052
|
+
this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._rawString);
|
|
20053
|
+
this.getDurationValue = () => this.getDurationValueFromRaw(this._rawString);
|
|
20054
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
20055
|
+
const values = this._rawString.split(",");
|
|
20056
|
+
return values.map((x) => {
|
|
20057
|
+
switch (primitiveType) {
|
|
20058
|
+
case "boolean":
|
|
20059
|
+
return this.getBooleanValueFromRaw(x);
|
|
20060
|
+
case "number":
|
|
20061
|
+
return this.getNumberValueFromRaw(x);
|
|
20062
|
+
case "Date":
|
|
20063
|
+
return this.getDateValueFromRaw(x);
|
|
20064
|
+
case "DateOnly":
|
|
20065
|
+
return this.getDateOnlyValueFromRaw(x);
|
|
20066
|
+
case "TimeOnly":
|
|
20067
|
+
return this.getTimeOnlyValueFromRaw(x);
|
|
20068
|
+
case "Duration":
|
|
20069
|
+
return this.getDurationValueFromRaw(x);
|
|
20070
|
+
case "string":
|
|
20071
|
+
return this.getStringValueFromRaw(x);
|
|
20072
|
+
default:
|
|
20073
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
20056
20074
|
}
|
|
20057
20075
|
});
|
|
20058
20076
|
};
|
|
@@ -20079,7 +20097,6 @@ class FormParseNode {
|
|
|
20079
20097
|
if (!rawValues) {
|
|
20080
20098
|
return [];
|
|
20081
20099
|
}
|
|
20082
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
20083
20100
|
return rawValues.split(",").map((x) => getEnumValueFromStringValue(x, type));
|
|
20084
20101
|
};
|
|
20085
20102
|
this.getEnumValue = (type) => {
|
|
@@ -20089,20 +20106,6 @@ class FormParseNode {
|
|
|
20089
20106
|
}
|
|
20090
20107
|
return getEnumValueFromStringValue(rawValue, type);
|
|
20091
20108
|
};
|
|
20092
|
-
this.assignFieldValues = (model, parsableFactory) => {
|
|
20093
|
-
const fields = parsableFactory(this)(model);
|
|
20094
|
-
Object.entries(this._fields)
|
|
20095
|
-
.filter((x) => !/^null$/i.test(x[1]))
|
|
20096
|
-
.forEach(([k, v]) => {
|
|
20097
|
-
const deserializer = fields[k];
|
|
20098
|
-
if (deserializer) {
|
|
20099
|
-
deserializer(new FormParseNode(v, this.backingStoreFactory));
|
|
20100
|
-
}
|
|
20101
|
-
else {
|
|
20102
|
-
model[k] = v;
|
|
20103
|
-
}
|
|
20104
|
-
});
|
|
20105
|
-
};
|
|
20106
20109
|
if (!_rawString) {
|
|
20107
20110
|
throw new Error("rawString cannot be undefined");
|
|
20108
20111
|
}
|
|
@@ -20120,9 +20123,57 @@ class FormParseNode {
|
|
|
20120
20123
|
}
|
|
20121
20124
|
});
|
|
20122
20125
|
}
|
|
20126
|
+
normalizeKey(key) {
|
|
20127
|
+
return decodeURIComponent(key).trim();
|
|
20128
|
+
}
|
|
20129
|
+
getStringValueFromRaw(value) {
|
|
20130
|
+
return decodeURIComponent(value);
|
|
20131
|
+
}
|
|
20132
|
+
getBooleanValueFromRaw(value) {
|
|
20133
|
+
const decoded = this.getStringValueFromRaw(value).toLowerCase();
|
|
20134
|
+
if (decoded === "true" || decoded === "1") {
|
|
20135
|
+
return true;
|
|
20136
|
+
}
|
|
20137
|
+
else if (decoded === "false" || decoded === "0") {
|
|
20138
|
+
return false;
|
|
20139
|
+
}
|
|
20140
|
+
return undefined;
|
|
20141
|
+
}
|
|
20142
|
+
getNumberValueFromRaw(value) {
|
|
20143
|
+
return parseFloat(this.getStringValueFromRaw(value));
|
|
20144
|
+
}
|
|
20145
|
+
getGuidValueFromRaw(value) {
|
|
20146
|
+
return parseGuidString(this.getStringValueFromRaw(value));
|
|
20147
|
+
}
|
|
20148
|
+
getDateValueFromRaw(value) {
|
|
20149
|
+
return new Date(Date.parse(this.getStringValueFromRaw(value)));
|
|
20150
|
+
}
|
|
20151
|
+
getDateOnlyValueFromRaw(value) {
|
|
20152
|
+
return DateOnly.parse(this.getStringValueFromRaw(value));
|
|
20153
|
+
}
|
|
20154
|
+
getTimeOnlyValueFromRaw(value) {
|
|
20155
|
+
return TimeOnly.parse(this.getStringValueFromRaw(value));
|
|
20156
|
+
}
|
|
20157
|
+
getDurationValueFromRaw(value) {
|
|
20158
|
+
return Duration.parse(this.getStringValueFromRaw(value));
|
|
20159
|
+
}
|
|
20123
20160
|
getByteArrayValue() {
|
|
20124
20161
|
throw new Error("serialization of byt arrays is not supported with URI encoding");
|
|
20125
20162
|
}
|
|
20163
|
+
assignFieldValues(model, parsableFactory) {
|
|
20164
|
+
const fields = parsableFactory(this)(model);
|
|
20165
|
+
Object.entries(this._fields)
|
|
20166
|
+
.filter((x) => !/^null$/i.test(x[1]))
|
|
20167
|
+
.forEach(([k, v]) => {
|
|
20168
|
+
const deserializer = fields[k];
|
|
20169
|
+
if (deserializer) {
|
|
20170
|
+
deserializer(new FormParseNode(v, this.backingStoreFactory));
|
|
20171
|
+
}
|
|
20172
|
+
else {
|
|
20173
|
+
model[k] = v;
|
|
20174
|
+
}
|
|
20175
|
+
});
|
|
20176
|
+
}
|
|
20126
20177
|
}
|
|
20127
20178
|
|
|
20128
20179
|
/**
|
|
@@ -20205,6 +20256,7 @@ class FormSerializationWriter {
|
|
|
20205
20256
|
throw new Error(`serialization of collections is not supported with URI encoding`);
|
|
20206
20257
|
};
|
|
20207
20258
|
this.writeObjectValue = (key, value, serializerMethod) => {
|
|
20259
|
+
var _a, _b, _c;
|
|
20208
20260
|
if (++this.depth > 0) {
|
|
20209
20261
|
throw new Error(`serialization of nested objects is not supported with URI encoding`);
|
|
20210
20262
|
}
|
|
@@ -20215,10 +20267,10 @@ class FormSerializationWriter {
|
|
|
20215
20267
|
if (key) {
|
|
20216
20268
|
this.writePropertyName(key);
|
|
20217
20269
|
}
|
|
20218
|
-
this.onBeforeObjectSerialization
|
|
20219
|
-
this.onStartObjectSerialization
|
|
20270
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
20271
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20220
20272
|
serializerMethod(this, value);
|
|
20221
|
-
this.onAfterObjectSerialization
|
|
20273
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20222
20274
|
if (this.writer.length > 0 && this.writer[this.writer.length - 1] === FormSerializationWriter.propertySeparator) {
|
|
20223
20275
|
// removing the last separator
|
|
20224
20276
|
this.writer.pop();
|
|
@@ -20377,47 +20429,52 @@ class JsonParseNode {
|
|
|
20377
20429
|
constructor(_jsonNode, backingStoreFactory) {
|
|
20378
20430
|
this._jsonNode = _jsonNode;
|
|
20379
20431
|
this.backingStoreFactory = backingStoreFactory;
|
|
20380
|
-
this.getStringValue = () =>
|
|
20432
|
+
this.getStringValue = () => this.getStringValueFromRaw(this._jsonNode);
|
|
20381
20433
|
this.getChildNode = (identifier) => (this._jsonNode && typeof this._jsonNode === "object" && this._jsonNode[identifier] !== undefined ? new JsonParseNode(this._jsonNode[identifier], this.backingStoreFactory) : undefined);
|
|
20382
20434
|
this.getBooleanValue = () => (typeof this._jsonNode === "boolean" ? this._jsonNode : undefined);
|
|
20383
20435
|
this.getNumberValue = () => (typeof this._jsonNode === "number" ? this._jsonNode : undefined);
|
|
20384
|
-
this.getGuidValue = () =>
|
|
20385
|
-
this.getDateValue = () =>
|
|
20386
|
-
this.getDateOnlyValue = () =>
|
|
20387
|
-
this.getTimeOnlyValue = () =>
|
|
20388
|
-
this.getDurationValue = () =>
|
|
20389
|
-
this.getCollectionOfPrimitiveValues = () => {
|
|
20436
|
+
this.getGuidValue = () => this.getGuidValueFromRaw(this._jsonNode);
|
|
20437
|
+
this.getDateValue = () => this.getDateValueFromRaw(this._jsonNode);
|
|
20438
|
+
this.getDateOnlyValue = () => this.getDateOnlyValueFromRaw(this._jsonNode);
|
|
20439
|
+
this.getTimeOnlyValue = () => this.getTimeOnlyValueFromRaw(this._jsonNode);
|
|
20440
|
+
this.getDurationValue = () => this.getDurationValueFromRaw(this._jsonNode);
|
|
20441
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
20390
20442
|
if (!Array.isArray(this._jsonNode)) {
|
|
20391
20443
|
return undefined;
|
|
20392
20444
|
}
|
|
20393
|
-
return this._jsonNode.map((x) =>
|
|
20394
|
-
|
|
20395
|
-
|
|
20396
|
-
|
|
20397
|
-
|
|
20398
|
-
|
|
20399
|
-
|
|
20400
|
-
|
|
20401
|
-
|
|
20402
|
-
|
|
20403
|
-
|
|
20404
|
-
|
|
20405
|
-
|
|
20406
|
-
|
|
20407
|
-
|
|
20408
|
-
|
|
20409
|
-
return
|
|
20410
|
-
|
|
20411
|
-
|
|
20412
|
-
|
|
20413
|
-
|
|
20414
|
-
|
|
20415
|
-
return
|
|
20416
|
-
|
|
20417
|
-
|
|
20418
|
-
|
|
20419
|
-
|
|
20420
|
-
|
|
20445
|
+
return this._jsonNode.map((x) => this.getPrimitiveValue(x, primitiveType));
|
|
20446
|
+
};
|
|
20447
|
+
this.getPrimitiveValue = (value, primitiveType) => {
|
|
20448
|
+
if (value === null) {
|
|
20449
|
+
return null;
|
|
20450
|
+
}
|
|
20451
|
+
switch (primitiveType) {
|
|
20452
|
+
case "boolean":
|
|
20453
|
+
if (typeof value !== "boolean") {
|
|
20454
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20455
|
+
}
|
|
20456
|
+
return value;
|
|
20457
|
+
case "number":
|
|
20458
|
+
if (typeof value !== "number") {
|
|
20459
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20460
|
+
}
|
|
20461
|
+
return value;
|
|
20462
|
+
case "Date":
|
|
20463
|
+
return this.getDateValueFromRaw(value);
|
|
20464
|
+
case "DateOnly":
|
|
20465
|
+
return this.getDateOnlyValueFromRaw(value);
|
|
20466
|
+
case "TimeOnly":
|
|
20467
|
+
return this.getTimeOnlyValueFromRaw(value);
|
|
20468
|
+
case "Duration":
|
|
20469
|
+
return this.getDurationValueFromRaw(value);
|
|
20470
|
+
case "string":
|
|
20471
|
+
if (typeof value !== "string") {
|
|
20472
|
+
throw new Error(`encountered an unsupported type during deserialization ${typeof value}`);
|
|
20473
|
+
}
|
|
20474
|
+
return value;
|
|
20475
|
+
default:
|
|
20476
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
20477
|
+
}
|
|
20421
20478
|
};
|
|
20422
20479
|
this.getCollectionOfObjectValues = (method) => {
|
|
20423
20480
|
if (!Array.isArray(this._jsonNode)) {
|
|
@@ -20492,10 +20549,12 @@ class JsonParseNode {
|
|
|
20492
20549
|
if (Array.isArray(this._jsonNode)) {
|
|
20493
20550
|
return this._jsonNode
|
|
20494
20551
|
.map((x) => {
|
|
20495
|
-
|
|
20496
|
-
|
|
20552
|
+
if (typeof x === "string") {
|
|
20553
|
+
return getEnumValueFromStringValue(x, type);
|
|
20554
|
+
}
|
|
20555
|
+
return undefined;
|
|
20497
20556
|
})
|
|
20498
|
-
.filter(
|
|
20557
|
+
.filter((value) => value !== undefined);
|
|
20499
20558
|
}
|
|
20500
20559
|
return [];
|
|
20501
20560
|
};
|
|
@@ -20507,6 +20566,33 @@ class JsonParseNode {
|
|
|
20507
20566
|
return getEnumValueFromStringValue(rawValue, type);
|
|
20508
20567
|
};
|
|
20509
20568
|
}
|
|
20569
|
+
getStringValueFromRaw(value) {
|
|
20570
|
+
return typeof value === "string" ? value : undefined;
|
|
20571
|
+
}
|
|
20572
|
+
getGuidValueFromRaw(value) {
|
|
20573
|
+
return parseGuidString(this.getStringValueFromRaw(value));
|
|
20574
|
+
}
|
|
20575
|
+
getDateValueFromRaw(value) {
|
|
20576
|
+
if (value instanceof Date) {
|
|
20577
|
+
return new Date(value.getTime());
|
|
20578
|
+
}
|
|
20579
|
+
if (typeof value === "number") {
|
|
20580
|
+
return new Date(value);
|
|
20581
|
+
}
|
|
20582
|
+
if (typeof value === "string") {
|
|
20583
|
+
return new Date(value);
|
|
20584
|
+
}
|
|
20585
|
+
return undefined;
|
|
20586
|
+
}
|
|
20587
|
+
getDateOnlyValueFromRaw(value) {
|
|
20588
|
+
return value instanceof DateOnly ? value : DateOnly.parse(this.getStringValueFromRaw(value));
|
|
20589
|
+
}
|
|
20590
|
+
getTimeOnlyValueFromRaw(value) {
|
|
20591
|
+
return value instanceof TimeOnly ? value : TimeOnly.parse(this.getStringValueFromRaw(value));
|
|
20592
|
+
}
|
|
20593
|
+
getDurationValueFromRaw(value) {
|
|
20594
|
+
return value instanceof Duration ? value : Duration.parse(this.getStringValueFromRaw(value));
|
|
20595
|
+
}
|
|
20510
20596
|
getByteArrayValue() {
|
|
20511
20597
|
const strValue = this.getStringValue();
|
|
20512
20598
|
if (strValue && strValue.length > 0) {
|
|
@@ -20522,7 +20608,7 @@ class JsonParseNode {
|
|
|
20522
20608
|
* TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
|
|
20523
20609
|
* in the future instead of the current environment-specific approach
|
|
20524
20610
|
*/
|
|
20525
|
-
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
|
|
20611
|
+
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
|
|
20526
20612
|
}
|
|
20527
20613
|
return undefined;
|
|
20528
20614
|
}
|
|
@@ -20584,7 +20670,6 @@ class JsonSerializationWriter {
|
|
|
20584
20670
|
}
|
|
20585
20671
|
if (this.shouldWriteValueOrNull(key, value)) {
|
|
20586
20672
|
key && this.writePropertyName(key);
|
|
20587
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
20588
20673
|
this.writer.push(`"${value}"`);
|
|
20589
20674
|
key && this.writer.push(JsonSerializationWriter.propertySeparator);
|
|
20590
20675
|
}
|
|
@@ -20689,10 +20774,9 @@ class JsonSerializationWriter {
|
|
|
20689
20774
|
}
|
|
20690
20775
|
};
|
|
20691
20776
|
this.writeNonParsableObjectValue = (key, value) => {
|
|
20692
|
-
|
|
20693
|
-
|
|
20694
|
-
|
|
20695
|
-
this.writer.push(JSON.stringify(value), JsonSerializationWriter.propertySeparator);
|
|
20777
|
+
key && this.writePropertyName(key);
|
|
20778
|
+
this.writer.push(JSON.stringify(value));
|
|
20779
|
+
key && this.writer.push(JsonSerializationWriter.propertySeparator);
|
|
20696
20780
|
};
|
|
20697
20781
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
20698
20782
|
this.writeAnyValue = (key, value) => {
|
|
@@ -20743,6 +20827,7 @@ class JsonSerializationWriter {
|
|
|
20743
20827
|
this.writeStringValue(key, b64);
|
|
20744
20828
|
}
|
|
20745
20829
|
writeObjectValue(key, value, serializerMethod) {
|
|
20830
|
+
var _a, _b, _c;
|
|
20746
20831
|
if (value === undefined) {
|
|
20747
20832
|
return;
|
|
20748
20833
|
}
|
|
@@ -20801,11 +20886,11 @@ class JsonSerializationWriter {
|
|
|
20801
20886
|
}
|
|
20802
20887
|
if (key)
|
|
20803
20888
|
this.writePropertyName(key);
|
|
20804
|
-
this.onBeforeObjectSerialization
|
|
20889
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
20805
20890
|
this.startObject();
|
|
20806
|
-
this.onStartObjectSerialization
|
|
20807
|
-
serializerMethod
|
|
20808
|
-
this.onAfterObjectSerialization
|
|
20891
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20892
|
+
serializerMethod === null || serializerMethod === void 0 ? void 0 : serializerMethod(this, value);
|
|
20893
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20809
20894
|
this.removeLastSeparator();
|
|
20810
20895
|
this.endObject();
|
|
20811
20896
|
if (key)
|
|
@@ -20878,7 +20963,6 @@ class JsonSerializationWriterFactory {
|
|
|
20878
20963
|
* See License in the project root for license information.
|
|
20879
20964
|
* -------------------------------------------------------------------------------------------
|
|
20880
20965
|
*/
|
|
20881
|
-
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
|
20882
20966
|
/** Serialization writer for multipart/form-data */
|
|
20883
20967
|
class MultipartSerializationWriter {
|
|
20884
20968
|
constructor() {
|
|
@@ -20938,6 +21022,7 @@ class MultipartSerializationWriter {
|
|
|
20938
21022
|
throw new Error(`serialization of collections is not supported with multipart`);
|
|
20939
21023
|
};
|
|
20940
21024
|
this.writeObjectValue = (key, value, serializerMethod) => {
|
|
21025
|
+
var _a, _b, _c;
|
|
20941
21026
|
if (!value) {
|
|
20942
21027
|
throw new Error(`value cannot be undefined`);
|
|
20943
21028
|
}
|
|
@@ -20947,10 +21032,10 @@ class MultipartSerializationWriter {
|
|
|
20947
21032
|
if (!serializerMethod) {
|
|
20948
21033
|
throw new Error(`serializer method cannot be undefined`);
|
|
20949
21034
|
}
|
|
20950
|
-
this.onBeforeObjectSerialization
|
|
20951
|
-
this.onStartObjectSerialization
|
|
21035
|
+
(_a = this.onBeforeObjectSerialization) === null || _a === void 0 ? void 0 : _a.call(this, value);
|
|
21036
|
+
(_b = this.onStartObjectSerialization) === null || _b === void 0 ? void 0 : _b.call(this, value, this);
|
|
20952
21037
|
serializerMethod(this, value);
|
|
20953
|
-
this.onAfterObjectSerialization
|
|
21038
|
+
(_c = this.onAfterObjectSerialization) === null || _c === void 0 ? void 0 : _c.call(this, value);
|
|
20954
21039
|
};
|
|
20955
21040
|
this.writeEnumValue = (
|
|
20956
21041
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -21042,8 +21127,28 @@ class TextParseNode {
|
|
|
21042
21127
|
this.getDateOnlyValue = () => DateOnly.parse(this.getStringValue());
|
|
21043
21128
|
this.getTimeOnlyValue = () => TimeOnly.parse(this.getStringValue());
|
|
21044
21129
|
this.getDurationValue = () => Duration.parse(this.getStringValue());
|
|
21045
|
-
this.getCollectionOfPrimitiveValues = () => {
|
|
21046
|
-
|
|
21130
|
+
this.getCollectionOfPrimitiveValues = (primitiveType) => {
|
|
21131
|
+
return this.text.split(",").map((x) => {
|
|
21132
|
+
const node = new TextParseNode(x);
|
|
21133
|
+
switch (primitiveType) {
|
|
21134
|
+
case "boolean":
|
|
21135
|
+
return node.getBooleanValue();
|
|
21136
|
+
case "number":
|
|
21137
|
+
return node.getNumberValue();
|
|
21138
|
+
case "Date":
|
|
21139
|
+
return node.getDateValue();
|
|
21140
|
+
case "DateOnly":
|
|
21141
|
+
return node.getDateOnlyValue();
|
|
21142
|
+
case "TimeOnly":
|
|
21143
|
+
return node.getTimeOnlyValue();
|
|
21144
|
+
case "Duration":
|
|
21145
|
+
return node.getDurationValue();
|
|
21146
|
+
case "string":
|
|
21147
|
+
return node.getStringValue();
|
|
21148
|
+
default:
|
|
21149
|
+
throw new Error(`encountered an unsupported type during deserialization ${primitiveType}`);
|
|
21150
|
+
}
|
|
21151
|
+
});
|
|
21047
21152
|
};
|
|
21048
21153
|
this.getCollectionOfEnumValues = (type) => {
|
|
21049
21154
|
throw new Error(TextParseNode.noStructuredDataMessage);
|
|
@@ -21074,7 +21179,7 @@ class TextParseNode {
|
|
|
21074
21179
|
* TODO: Consider standardizing on a cross-platform UInt8Array.fromBase64 (after the API is stabilized across browsers)
|
|
21075
21180
|
* in the future instead of the current environment-specific approach
|
|
21076
21181
|
*/
|
|
21077
|
-
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue);
|
|
21182
|
+
return inNodeEnv() ? new Uint8Array(Buffer.from(strValue, "base64")).buffer : new TextEncoder().encode(strValue).buffer;
|
|
21078
21183
|
}
|
|
21079
21184
|
return undefined;
|
|
21080
21185
|
}
|
|
@@ -21131,7 +21236,6 @@ class TextSerializationWriter {
|
|
|
21131
21236
|
return this.writeNullValue(key);
|
|
21132
21237
|
}
|
|
21133
21238
|
if (value) {
|
|
21134
|
-
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
21135
21239
|
this.writeStringValue(key, `"${value}"`);
|
|
21136
21240
|
}
|
|
21137
21241
|
};
|
|
@@ -21315,12 +21419,69 @@ const SalableNavigationMetadata = {
|
|
|
21315
21419
|
/* tslint:enable */
|
|
21316
21420
|
/* eslint-enable */
|
|
21317
21421
|
|
|
21422
|
+
/**
|
|
21423
|
+
* Kiota's JsonSerializationWriter stringifies null enum values, producing
|
|
21424
|
+
* `"interval": "null"` instead of `"interval": null`, which the API rejects
|
|
21425
|
+
* with an invalid_enum_value error. Unlike every other write method, its
|
|
21426
|
+
* writeEnumValue/writeCollectionOfEnumValues only filter out undefined before
|
|
21427
|
+
* template-stringifying, so null slips through as the string "null".
|
|
21428
|
+
* See https://github.com/microsoft/kiota-typescript — present up to at least
|
|
21429
|
+
* 1.0.0-preview.107. This subclass emits a proper JSON null instead.
|
|
21430
|
+
*/
|
|
21431
|
+
class NullSafeJsonSerializationWriter extends JsonSerializationWriter {
|
|
21432
|
+
writeEnumValue = (key, ...values) => {
|
|
21433
|
+
const provided = values.filter((x) => x !== undefined);
|
|
21434
|
+
if (provided.length === 0) {
|
|
21435
|
+
return;
|
|
21436
|
+
}
|
|
21437
|
+
const rawValues = provided.filter((x) => x !== null).map((x) => `${x}`);
|
|
21438
|
+
if (rawValues.length === 0) {
|
|
21439
|
+
this.writeNullValue(key);
|
|
21440
|
+
return;
|
|
21441
|
+
}
|
|
21442
|
+
this.writeStringValue(key, rawValues.join(', '));
|
|
21443
|
+
};
|
|
21444
|
+
writeCollectionOfEnumValues = (key, values) => {
|
|
21445
|
+
if (values === null) {
|
|
21446
|
+
this.writeNullValue(key);
|
|
21447
|
+
return;
|
|
21448
|
+
}
|
|
21449
|
+
if (!values || values.length === 0) {
|
|
21450
|
+
return;
|
|
21451
|
+
}
|
|
21452
|
+
const rawValues = values
|
|
21453
|
+
.filter((x) => x !== undefined)
|
|
21454
|
+
.map((x) => (x === null ? null : `${x}`));
|
|
21455
|
+
if (rawValues.length === 0) {
|
|
21456
|
+
return;
|
|
21457
|
+
}
|
|
21458
|
+
this.writeCollectionOfPrimitiveValues(key, rawValues);
|
|
21459
|
+
};
|
|
21460
|
+
}
|
|
21461
|
+
class NullSafeJsonSerializationWriterFactory extends JsonSerializationWriterFactory {
|
|
21462
|
+
getSerializationWriter(contentType) {
|
|
21463
|
+
if (!contentType) {
|
|
21464
|
+
throw new Error('content type cannot be undefined or empty');
|
|
21465
|
+
}
|
|
21466
|
+
if (this.getValidContentType() !== contentType) {
|
|
21467
|
+
throw new Error(`expected a ${this.getValidContentType()} content type`);
|
|
21468
|
+
}
|
|
21469
|
+
return new NullSafeJsonSerializationWriter();
|
|
21470
|
+
}
|
|
21471
|
+
}
|
|
21472
|
+
|
|
21318
21473
|
class Salable {
|
|
21319
21474
|
api;
|
|
21320
21475
|
constructor(apiKey) {
|
|
21321
21476
|
const authProvider = new ApiKeyAuthenticationProvider('Bearer ' + apiKey, 'Authorization', ApiKeyLocation.Header);
|
|
21322
21477
|
const adapter = new FetchRequestAdapter(authProvider);
|
|
21323
21478
|
this.api = createSalable(adapter).api;
|
|
21479
|
+
// Must run after createSalable, which registers the stock JSON serializer;
|
|
21480
|
+
// re-registering replaces the application/json factory with the null-safe one.
|
|
21481
|
+
const writerRegistry = adapter.getSerializationWriterFactory();
|
|
21482
|
+
if (writerRegistry.registerDefaultSerializer) {
|
|
21483
|
+
writerRegistry.registerDefaultSerializer(NullSafeJsonSerializationWriterFactory);
|
|
21484
|
+
}
|
|
21324
21485
|
}
|
|
21325
21486
|
}
|
|
21326
21487
|
|