@microsoft/kiota-serialization-form
Advanced tools
Comparing version 1.0.0-preview.6 to 1.0.0-preview.7
@@ -22,4 +22,4 @@ import { DateOnly, Duration, Parsable, ParsableFactory, ParseNode, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
getCollectionOfPrimitiveValues: <T>() => T[] | undefined; | ||
getCollectionOfObjectValues: <T extends Parsable>(_type: ParsableFactory<T>) => T[] | undefined; | ||
getObjectValue: <T extends Parsable>(type: ParsableFactory<T>) => T; | ||
getCollectionOfObjectValues: <T extends Parsable>(parsableFactory: ParsableFactory<T>) => T[] | undefined; | ||
getObjectValue: <T extends Parsable>(parsableFactory: ParsableFactory<T>) => T; | ||
getEnumValues: <T>(type: any) => T[]; | ||
@@ -26,0 +26,0 @@ getEnumValue: <T>(type: any) => T | undefined; |
@@ -42,15 +42,15 @@ "use strict"; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_type) => { | ||
parsableFactory) => { | ||
throw new Error(`serialization of collections is not supported with URI encoding`); | ||
}; | ||
this.getObjectValue = (type) => { | ||
const result = type(this); | ||
this.getObjectValue = (parsableFactory) => { | ||
const value = {}; | ||
if (this.onBeforeAssignFieldValues) { | ||
this.onBeforeAssignFieldValues(result); | ||
this.onBeforeAssignFieldValues(value); | ||
} | ||
this.assignFieldValues(result); | ||
this.assignFieldValues(value, parsableFactory); | ||
if (this.onAfterAssignFieldValues) { | ||
this.onAfterAssignFieldValues(result); | ||
this.onAfterAssignFieldValues(value); | ||
} | ||
return result; | ||
return value; | ||
}; | ||
@@ -73,9 +73,4 @@ this.getEnumValues = (type) => { | ||
}; | ||
this.assignFieldValues = (item) => { | ||
const fields = item.getFieldDeserializers(); | ||
let itemAdditionalData; | ||
const holder = item; | ||
if (holder && holder.additionalData) { | ||
itemAdditionalData = holder.additionalData; | ||
} | ||
this.assignFieldValues = (model, parsableFactory) => { | ||
const fields = parsableFactory(this)(model); | ||
Object.entries(this._fields) | ||
@@ -88,4 +83,4 @@ .filter((x) => !/^null$/i.test(x[1])) | ||
} | ||
else if (itemAdditionalData) { | ||
itemAdditionalData[k] = v; | ||
else { | ||
model[k] = v; | ||
} | ||
@@ -92,0 +87,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { DateOnly, Duration, Parsable, SerializationWriter, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
import { DateOnly, Duration, ModelSerializerFunction, Parsable, SerializationWriter, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
export declare class FormSerializationWriter implements SerializationWriter { | ||
@@ -21,9 +21,9 @@ private readonly writer; | ||
writeCollectionOfObjectValues: <T extends Parsable>(_key?: string, _values?: T[] | undefined) => void; | ||
writeObjectValue: <T extends Parsable>(key?: string, value?: T | undefined) => void; | ||
writeObjectValue: <T extends Parsable>(key: string | undefined, value: T | undefined, serializerMethod: ModelSerializerFunction<T>) => void; | ||
writeEnumValue: <T>(key?: string | undefined, ...values: (T | undefined)[]) => void; | ||
getSerializedContent: () => ArrayBuffer; | ||
private convertStringToArrayBuffer; | ||
writeAdditionalData: (value: Record<string, unknown>) => void; | ||
writeAdditionalData: (additionalData: Record<string, unknown> | undefined) => void; | ||
private writeAnyValue; | ||
} | ||
//# sourceMappingURL=formSerializationWriter.d.ts.map |
@@ -60,3 +60,3 @@ "use strict"; | ||
}; | ||
this.writeObjectValue = (key, value) => { | ||
this.writeObjectValue = (key, value, serializerMethod) => { | ||
if (++this.depth > 0) { | ||
@@ -73,3 +73,3 @@ throw new Error(`serialization of nested objects is not supported with URI encoding`); | ||
this.onStartObjectSerialization(value, this); | ||
value.serialize(this); | ||
serializerMethod(this, value); | ||
this.onAfterObjectSerialization && this.onAfterObjectSerialization(value); | ||
@@ -106,11 +106,12 @@ if (this.writer.length > 0 && | ||
}; | ||
this.writeAdditionalData = (value) => { | ||
if (!value) | ||
this.writeAdditionalData = (additionalData) => { | ||
// Do not use !value here, because value can be `false`. | ||
if (additionalData === undefined) | ||
return; | ||
for (const key in value) { | ||
this.writeAnyValue(key, value[key]); | ||
for (const key in additionalData) { | ||
this.writeAnyValue(key, additionalData[key]); | ||
} | ||
}; | ||
this.writeAnyValue = (key, value) => { | ||
if (value !== undefined && value !== null) { | ||
if (value !== null && value !== undefined) { | ||
const valueType = typeof value; | ||
@@ -139,3 +140,3 @@ if (valueType === "boolean") { | ||
else { | ||
throw new Error(`encountered unknown value type during serialization ${valueType}`); | ||
throw new Error(`encountered unknown ${value} value type during serialization ${valueType} for key ${key}`); | ||
} | ||
@@ -142,0 +143,0 @@ } |
@@ -22,4 +22,4 @@ import { DateOnly, Duration, Parsable, ParsableFactory, ParseNode, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
getCollectionOfPrimitiveValues: <T>() => T[] | undefined; | ||
getCollectionOfObjectValues: <T extends Parsable>(_type: ParsableFactory<T>) => T[] | undefined; | ||
getObjectValue: <T extends Parsable>(type: ParsableFactory<T>) => T; | ||
getCollectionOfObjectValues: <T extends Parsable>(parsableFactory: ParsableFactory<T>) => T[] | undefined; | ||
getObjectValue: <T extends Parsable>(parsableFactory: ParsableFactory<T>) => T; | ||
getEnumValues: <T>(type: any) => T[]; | ||
@@ -26,0 +26,0 @@ getEnumValue: <T>(type: any) => T | undefined; |
@@ -39,15 +39,15 @@ import { DateOnly, Duration, TimeOnly, toFirstCharacterUpper, } from "@microsoft/kiota-abstractions"; | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
_type) => { | ||
parsableFactory) => { | ||
throw new Error(`serialization of collections is not supported with URI encoding`); | ||
}; | ||
this.getObjectValue = (type) => { | ||
const result = type(this); | ||
this.getObjectValue = (parsableFactory) => { | ||
const value = {}; | ||
if (this.onBeforeAssignFieldValues) { | ||
this.onBeforeAssignFieldValues(result); | ||
this.onBeforeAssignFieldValues(value); | ||
} | ||
this.assignFieldValues(result); | ||
this.assignFieldValues(value, parsableFactory); | ||
if (this.onAfterAssignFieldValues) { | ||
this.onAfterAssignFieldValues(result); | ||
this.onAfterAssignFieldValues(value); | ||
} | ||
return result; | ||
return value; | ||
}; | ||
@@ -70,9 +70,4 @@ this.getEnumValues = (type) => { | ||
}; | ||
this.assignFieldValues = (item) => { | ||
const fields = item.getFieldDeserializers(); | ||
let itemAdditionalData; | ||
const holder = item; | ||
if (holder && holder.additionalData) { | ||
itemAdditionalData = holder.additionalData; | ||
} | ||
this.assignFieldValues = (model, parsableFactory) => { | ||
const fields = parsableFactory(this)(model); | ||
Object.entries(this._fields) | ||
@@ -85,4 +80,4 @@ .filter((x) => !/^null$/i.test(x[1])) | ||
} | ||
else if (itemAdditionalData) { | ||
itemAdditionalData[k] = v; | ||
else { | ||
model[k] = v; | ||
} | ||
@@ -89,0 +84,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
import { DateOnly, Duration, Parsable, SerializationWriter, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
import { DateOnly, Duration, ModelSerializerFunction, Parsable, SerializationWriter, TimeOnly } from "@microsoft/kiota-abstractions"; | ||
export declare class FormSerializationWriter implements SerializationWriter { | ||
@@ -21,9 +21,9 @@ private readonly writer; | ||
writeCollectionOfObjectValues: <T extends Parsable>(_key?: string, _values?: T[] | undefined) => void; | ||
writeObjectValue: <T extends Parsable>(key?: string, value?: T | undefined) => void; | ||
writeObjectValue: <T extends Parsable>(key: string | undefined, value: T | undefined, serializerMethod: ModelSerializerFunction<T>) => void; | ||
writeEnumValue: <T>(key?: string | undefined, ...values: (T | undefined)[]) => void; | ||
getSerializedContent: () => ArrayBuffer; | ||
private convertStringToArrayBuffer; | ||
writeAdditionalData: (value: Record<string, unknown>) => void; | ||
writeAdditionalData: (additionalData: Record<string, unknown> | undefined) => void; | ||
private writeAnyValue; | ||
} | ||
//# sourceMappingURL=formSerializationWriter.d.ts.map |
@@ -57,3 +57,3 @@ /* eslint-disable @typescript-eslint/no-unused-expressions */ | ||
}; | ||
this.writeObjectValue = (key, value) => { | ||
this.writeObjectValue = (key, value, serializerMethod) => { | ||
if (++this.depth > 0) { | ||
@@ -70,3 +70,3 @@ throw new Error(`serialization of nested objects is not supported with URI encoding`); | ||
this.onStartObjectSerialization(value, this); | ||
value.serialize(this); | ||
serializerMethod(this, value); | ||
this.onAfterObjectSerialization && this.onAfterObjectSerialization(value); | ||
@@ -103,11 +103,12 @@ if (this.writer.length > 0 && | ||
}; | ||
this.writeAdditionalData = (value) => { | ||
if (!value) | ||
this.writeAdditionalData = (additionalData) => { | ||
// Do not use !value here, because value can be `false`. | ||
if (additionalData === undefined) | ||
return; | ||
for (const key in value) { | ||
this.writeAnyValue(key, value[key]); | ||
for (const key in additionalData) { | ||
this.writeAnyValue(key, additionalData[key]); | ||
} | ||
}; | ||
this.writeAnyValue = (key, value) => { | ||
if (value !== undefined && value !== null) { | ||
if (value !== null && value !== undefined) { | ||
const valueType = typeof value; | ||
@@ -136,3 +137,3 @@ if (valueType === "boolean") { | ||
else { | ||
throw new Error(`encountered unknown value type during serialization ${valueType}`); | ||
throw new Error(`encountered unknown ${value} value type during serialization ${valueType} for key ${key}`); | ||
} | ||
@@ -139,0 +140,0 @@ } |
{ | ||
"name": "@microsoft/kiota-serialization-form", | ||
"version": "1.0.0-preview.6", | ||
"version": "1.0.0-preview.7", | ||
"description": "Implementation of Kiota Serialization interfaces for URI from encoded", | ||
@@ -42,3 +42,3 @@ "main": "dist/cjs/src/index.js", | ||
"dependencies": { | ||
"@microsoft/kiota-abstractions": "^1.0.0-preview.14", | ||
"@microsoft/kiota-abstractions": "1.0.0-preview.18", | ||
"tslib": "^2.3.1" | ||
@@ -49,3 +49,3 @@ }, | ||
}, | ||
"gitHead": "636d98b782a61f219f049bf06ac2334d37e4dfa8" | ||
"gitHead": "c3c635a01523a75a2815bf09f84fc5495d1a62dd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
129390
806
+ Added@microsoft/kiota-abstractions@1.0.0-preview.18(transitive)
+ Addeduri-template-lite@22.9.0(transitive)
+ Addeduuid@9.0.1(transitive)
- Removed@microsoft/kiota-abstractions@1.0.0-preview.75(transitive)
- Removed@std-uritemplate/std-uritemplate@1.0.6(transitive)
- Removeduuid@11.0.3(transitive)