1+ import { cloneDeep } from 'es-toolkit' ;
2+
13/**
24 * Transforms a JSON schema so that all properties without a `default` value are marked as required.
35 * Properties that have a `default` are left optional, since Apify fills them in at runtime.
46 * Recurses into nested object properties.
57 */
68export function makePropertiesRequired ( schema : Record < string , unknown > ) : Record < string , unknown > {
7- const clone = structuredClone ( schema ) ;
9+ const clone = cloneDeep ( schema ) ;
810
911 if ( ! clone . properties || typeof clone . properties !== 'object' ) {
1012 return clone ;
@@ -35,7 +37,7 @@ export function makePropertiesRequired(schema: Record<string, unknown>): Record<
3537 * making every property optional at all nesting levels.
3638 */
3739export function clearAllRequired ( schema : Record < string , unknown > ) : Record < string , unknown > {
38- const clone = structuredClone ( schema ) ;
40+ const clone = cloneDeep ( schema ) ;
3941
4042 delete clone . required ;
4143
@@ -59,7 +61,7 @@ export function clearAllRequired(schema: Record<string, unknown>): Record<string
5961 * to be inlined, ensuring only one exported interface per schema.
6062 */
6163export function stripTitles ( schema : Record < string , unknown > ) : Record < string , unknown > {
62- const clone = structuredClone ( schema ) ;
64+ const clone = cloneDeep ( schema ) ;
6365
6466 delete clone . title ;
6567
@@ -137,7 +139,7 @@ export function prepareFieldsSchemaForCompilation(schema: Record<string, unknown
137139 return null ;
138140 }
139141
140- const clone = structuredClone ( fields ) ;
142+ const clone = cloneDeep ( fields ) ;
141143
142144 if ( ! clone . type ) {
143145 clone . type = 'object' ;
@@ -162,7 +164,7 @@ export function prepareOutputSchemaForCompilation(schema: Record<string, unknown
162164 return null ;
163165 }
164166
165- const clonedProperties = structuredClone ( properties ) ;
167+ const clonedProperties = cloneDeep ( properties ) ;
166168
167169 // Strip non-JSON-Schema keys (like `template`) from each property
168170 for ( const prop of Object . values ( clonedProperties ) ) {
@@ -214,7 +216,7 @@ export function prepareKvsCollectionsForCompilation(
214216 continue ;
215217 }
216218
217- const clone = structuredClone ( jsonSchema ) ;
219+ const clone = cloneDeep ( jsonSchema ) ;
218220
219221 if ( ! clone . type ) {
220222 clone . type = 'object' ;
0 commit comments