Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetAudienceByIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ partial void ProcessGetAudiencesResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ partial void ProcessCommandResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ partial void ProcessCreateDocumentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ partial void ProcessDeleteDocumentByIdResponse(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

}
catch (global::System.Exception __ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ partial void ProcessGetAllDocumentsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetDocumentByIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ partial void ProcessUpdateDocumentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ partial void ProcessDeleteKnowledgeDocumentResponse(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

}
catch (global::System.Exception __ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetKnowledgeDocumentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ partial void ProcessGetKnowledgeDocumentsResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ partial void ProcessSearchKnowledgeResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ partial void ProcessUpdateKnowledgeDocumentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ partial void ProcessUploadKnowledgeDocumentResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
126 changes: 124 additions & 2 deletions src/libs/JasperAI/Generated/JasperAI.Polyfills.g.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

#if !NET6_0_OR_GREATER
#nullable enable

namespace JasperAI
Expand All @@ -9,6 +8,7 @@ namespace JasperAI
/// </summary>
public static partial class AutoSdkPolyfills
{
#if !NET6_0_OR_GREATER
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -48,6 +48,128 @@ public static partial class AutoSdkPolyfills
content = content ?? throw new global::System.ArgumentNullException(nameof(content));
return content.ReadAsByteArrayAsync();
}
#endif

/// <summary>
/// Creates a JSON request content instance.
/// </summary>
public static global::System.Net.Http.HttpContent CreateJsonContent<T>(
T inputValue,
string mediaType,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions)
{
if (string.IsNullOrWhiteSpace(mediaType))
{
throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
}

#if NET5_0_OR_GREATER
return global::System.Net.Http.Json.JsonContent.Create(
inputValue: inputValue,
mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType),
options: jsonSerializerOptions);
#else
var json = global::System.Text.Json.JsonSerializer.Serialize(inputValue, jsonSerializerOptions);
var stringContent = new global::System.Net.Http.StringContent(
content: json,
encoding: global::System.Text.Encoding.UTF8);
stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
{
CharSet = global::System.Text.Encoding.UTF8.WebName,
};
return stringContent;
#endif
}

/// <summary>
/// Creates a JSON request content instance using a source-generated serializer context.
/// </summary>
public static global::System.Net.Http.HttpContent CreateJsonContent(
object? inputValue,
global::System.Type inputType,
string mediaType,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext)
{
inputType = inputType ?? throw new global::System.ArgumentNullException(nameof(inputType));
jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));

if (string.IsNullOrWhiteSpace(mediaType))
{
throw new global::System.ArgumentException("Media type is required.", nameof(mediaType));
}

#if NET5_0_OR_GREATER
var jsonTypeInfo = jsonSerializerContext.GetTypeInfo(inputType) ??
throw new global::System.InvalidOperationException($"No JsonTypeInfo registered for '{inputType}'.");
return global::System.Net.Http.Json.JsonContent.Create(
inputValue: inputValue,
jsonTypeInfo: jsonTypeInfo,
mediaType: new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType));
#else
var json = global::System.Text.Json.JsonSerializer.Serialize(
value: inputValue,
inputType: inputType,
jsonSerializerContext);
var stringContent = new global::System.Net.Http.StringContent(
content: json,
encoding: global::System.Text.Encoding.UTF8);
stringContent.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue(mediaType)
{
CharSet = global::System.Text.Encoding.UTF8.WebName,
};
return stringContent;
#endif
}

/// <summary>
/// Reads JSON content into the specified type using serializer options.
/// </summary>
public static async global::System.Threading.Tasks.Task<T?> ReadFromJsonAsync<T>(
this global::System.Net.Http.HttpContent content,
global::System.Text.Json.JsonSerializerOptions? jsonSerializerOptions,
global::System.Threading.CancellationToken cancellationToken)
{
content = content ?? throw new global::System.ArgumentNullException(nameof(content));

#if NET5_0_OR_GREATER
return await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync<T>(
content,
jsonSerializerOptions,
cancellationToken).ConfigureAwait(false);
#else
using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
return await global::System.Text.Json.JsonSerializer.DeserializeAsync<T>(
utf8Json: stream,
options: jsonSerializerOptions,
cancellationToken: cancellationToken).ConfigureAwait(false);
#endif
}

/// <summary>
/// Reads JSON content into the specified type using a source-generated serializer context.
/// </summary>
public static async global::System.Threading.Tasks.Task<T?> ReadFromJsonAsync<T>(
this global::System.Net.Http.HttpContent content,
global::System.Text.Json.Serialization.JsonSerializerContext jsonSerializerContext,
global::System.Threading.CancellationToken cancellationToken)
{
content = content ?? throw new global::System.ArgumentNullException(nameof(content));
jsonSerializerContext = jsonSerializerContext ?? throw new global::System.ArgumentNullException(nameof(jsonSerializerContext));

#if NET5_0_OR_GREATER
return (T?)await global::System.Net.Http.Json.HttpContentJsonExtensions.ReadFromJsonAsync(
content,
typeof(T),
jsonSerializerContext,
cancellationToken).ConfigureAwait(false);
#else
using var stream = await AutoSdkPolyfills.ReadAsStreamAsync(content, cancellationToken).ConfigureAwait(false);
return (T?)await global::System.Text.Json.JsonSerializer.DeserializeAsync(
utf8Json: stream,
returnType: typeof(T),
jsonSerializerContext,
cancellationToken: cancellationToken).ConfigureAwait(false);
#endif
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetStyleByIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ partial void ProcessGetStylesResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ partial void ProcessGetTaskByIdResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,6 @@ partial void ProcessListTasksResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ partial void ProcessRunTaskResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ partial void ProcessGetUsageResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ partial void ProcessGetAllUsersResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetUserResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ partial void ProcessCreateToneResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,6 @@ partial void ProcessDeleteToneResponse(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

}
catch (global::System.Exception __ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ partial void ProcessGetAllTonesResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ partial void ProcessGetToneResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ partial void ProcessUpdateToneResponseContent(
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
Expand Down