@wictorwilen/cocogen 1.1.0-preview.5 → 1.1.0-preview.6
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/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.1.0-preview.6] - 2026-04-07
|
|
11
|
+
|
|
10
12
|
## [1.1.0-preview.5] - 2026-04-07
|
|
11
13
|
|
|
12
14
|
### Changed
|
|
@@ -361,6 +363,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
361
363
|
- Collection values no longer split on commas; use semicolons instead.
|
|
362
364
|
|
|
363
365
|
[Unreleased]: https://github.com/wictorwilen/cocogen/compare/v1.0.16...HEAD
|
|
366
|
+
[1.1.0-preview.6]: https://github.com/wictorwilen/cocogen/compare/main...v1.1.0-preview.6
|
|
364
367
|
[1.1.0-preview.5]: https://github.com/wictorwilen/cocogen/compare/main...v1.1.0-preview.5
|
|
365
368
|
[1.1.0-preview.4]: https://github.com/wictorwilen/cocogen/compare/main...v1.1.0-preview.4
|
|
366
369
|
[1.1.0-preview.3]: https://github.com/wictorwilen/cocogen/compare/main...v1.1.0-preview.3
|
|
@@ -14,6 +14,7 @@ using System.CommandLine;
|
|
|
14
14
|
using System.Net.Http.Headers;
|
|
15
15
|
using System.Text;
|
|
16
16
|
using System.Text.Json;
|
|
17
|
+
using System.Text.Json.Serialization;
|
|
17
18
|
using System.Threading;
|
|
18
19
|
|
|
19
20
|
using <%= namespaceName %>.Datasource;
|
|
@@ -26,6 +27,12 @@ namespace <%= namespaceName %>.Core;
|
|
|
26
27
|
/// </summary>
|
|
27
28
|
public sealed class ConnectorCore<TItem>
|
|
28
29
|
{
|
|
30
|
+
private static readonly JsonSerializerOptions VerbosePayloadSerializerOptions = new()
|
|
31
|
+
{
|
|
32
|
+
WriteIndented = true,
|
|
33
|
+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
34
|
+
};
|
|
35
|
+
|
|
29
36
|
private readonly GraphServiceClient? _graph;
|
|
30
37
|
private readonly TokenCredential? _credential;
|
|
31
38
|
private readonly IItemPayload<TItem> _itemPayload;
|
|
@@ -150,7 +157,7 @@ public sealed class ConnectorCore<TItem>
|
|
|
150
157
|
Console.WriteLine("verbose: PUT " + url);
|
|
151
158
|
var payloadJson = JsonSerializer.Serialize(
|
|
152
159
|
externalItem,
|
|
153
|
-
|
|
160
|
+
VerbosePayloadSerializerOptions
|
|
154
161
|
);
|
|
155
162
|
Console.WriteLine("verbose: payload " + payloadJson);
|
|
156
163
|
}
|
|
@@ -269,7 +276,7 @@ public sealed class ConnectorCore<TItem>
|
|
|
269
276
|
{
|
|
270
277
|
var payloadJson = JsonSerializer.Serialize(
|
|
271
278
|
_itemPayload.ToExternalItem(item),
|
|
272
|
-
|
|
279
|
+
VerbosePayloadSerializerOptions
|
|
273
280
|
);
|
|
274
281
|
Console.WriteLine($"verbose: DRY RUN item {index} (id={itemId}) payload " + payloadJson);
|
|
275
282
|
}
|
|
@@ -112,6 +112,24 @@ const validateSdkGraphObject = <T>(
|
|
|
112
112
|
return value as T;
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
+
const stripNullObjectProperties = (value: unknown): unknown => {
|
|
116
|
+
if (Array.isArray(value)) {
|
|
117
|
+
return value.map((entry) => stripNullObjectProperties(entry));
|
|
118
|
+
}
|
|
119
|
+
if (!isRecord(value)) {
|
|
120
|
+
return value;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const cleaned: UnknownObject = {};
|
|
124
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
125
|
+
if (entry === null || entry === undefined) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
cleaned[key] = stripNullObjectProperties(entry);
|
|
129
|
+
}
|
|
130
|
+
return cleaned;
|
|
131
|
+
};
|
|
132
|
+
|
|
115
133
|
const serializeSdkSingleValue = <T>(
|
|
116
134
|
value: unknown,
|
|
117
135
|
fieldName: string,
|
|
@@ -119,7 +137,8 @@ const serializeSdkSingleValue = <T>(
|
|
|
119
137
|
): string | undefined => {
|
|
120
138
|
const payload = normalizeSingleValue(value, fieldName);
|
|
121
139
|
if (!payload) return undefined;
|
|
122
|
-
|
|
140
|
+
const validated = validateSdkGraphObject<T>(payload, fieldName, disallowReadonlyItemFacetFields);
|
|
141
|
+
return JSON.stringify(stripNullObjectProperties(validated));
|
|
123
142
|
};
|
|
124
143
|
|
|
125
144
|
const serializeSdkCollectionValue = <T>(
|
|
@@ -129,7 +148,9 @@ const serializeSdkCollectionValue = <T>(
|
|
|
129
148
|
): string[] =>
|
|
130
149
|
payloads.map((payload, index) =>
|
|
131
150
|
JSON.stringify(
|
|
132
|
-
|
|
151
|
+
stripNullObjectProperties(
|
|
152
|
+
validateSdkGraphObject<T>(payload, `${fieldName}[${index}]`, disallowReadonlyItemFacetFields)
|
|
153
|
+
)
|
|
133
154
|
)
|
|
134
155
|
);
|
|
135
156
|
|
package/package.json
CHANGED