Skip to content

Commit 01f119b

Browse files
committed
finalize code
1 parent 6b4de55 commit 01f119b

File tree

3 files changed

+17
-23
lines changed

3 files changed

+17
-23
lines changed

src/tools/apify-properties.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import type { ISchemaProperties } from '../types.js';
22

3+
/**
4+
* Adds resource picker schema structure to array properties with editor === 'resourcePicker'.
5+
* The resource picker allows users to select resources from their Apify account.
6+
*/
37
export function addResourcePickerProperties(property: ISchemaProperties): ISchemaProperties {
48
return {
59
...property,
@@ -39,16 +43,12 @@ export function addKeyValueProperties(property: ISchemaProperties): ISchemaPrope
3943
};
4044
}
4145

42-
/**
43-
* Adds globs schema structure to array properties with editor === 'globs'.
44-
*/
45-
/**
46-
* Adds pseudoUrls schema structure to array properties with items.editor === 'pseudoUrls'.
47-
*/
48-
4946
const USER_DATA_DESCRIPTION = `User data object. A JSON object with custom user data that will be passed in the userData property of the Request object for each URL`;
5047
const HEADERS_DESCRIPTION = `Headers object. A JSON object whose properties and values contain HTTP headers that will sent with the request.`;
5148

49+
/**
50+
* Adds globs schema structure to array properties with editor === 'globs'.
51+
*/
5252
export function addGlobsProperties(property: ISchemaProperties): ISchemaProperties {
5353
return {
5454
...property,
@@ -90,6 +90,9 @@ export function addGlobsProperties(property: ISchemaProperties): ISchemaProperti
9090
};
9191
}
9292

93+
/**
94+
* Adds pseudoUrls schema structure to array properties with items.editor === 'pseudoUrls'.
95+
*/
9396
export function addPseudoUrlsProperties(property: ISchemaProperties): ISchemaProperties {
9497
return {
9598
...property,

src/tools/utils.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,6 @@ export function buildApifySpecificProperties(properties: Record<string, ISchemaP
7878
return clonedProperties;
7979
}
8080

81-
/**
82-
* Filters schema properties to include only the necessary fields.
83-
*
84-
* This is done to reduce the size of the input schema and to make it more readable.
85-
*
86-
* @param properties
87-
*/
88-
8981
/**
9082
* Filters schema properties to include only the necessary fields.
9183
* This is done to reduce the size of the input schema and to make it more readable.

tests/unit/tools.utils.test.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ describe('shortenProperties', () => {
374374
expect(result.prop1.enum.length).toBeLessThan(30);
375375
const totalEnumLen = result.prop1.enum.reduce((sum, v) => sum + v.length, 0);
376376
expect(totalEnumLen).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
377+
378+
// Calculate total character length of enum values
379+
const totalLength = result.prop1.enum.reduce((sum, val) => sum + val.length, 0);
380+
expect(totalLength).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
377381
} else {
378382
expect(result.prop1.enum).toBeUndefined();
379383
}
380-
381-
// Calculate total character length of enum values
382-
const totalLength = result.prop1.enum!.reduce((sum, val) => sum + val.length, 0);
383-
expect(totalLength).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
384384
});
385385

386386
it('should shorten items.enum values if they exceed the limit', () => {
@@ -408,13 +408,12 @@ describe('shortenProperties', () => {
408408
expect(result.prop1.items.enum.length).toBeLessThan(enumValues.length);
409409
const totalLength = result.prop1.items.enum.reduce((sum, val) => sum + val.length, 0);
410410
expect(totalLength).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
411+
412+
// Calculate total character length of enum values
413+
expect(totalLength).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
411414
} else {
412415
expect(result.prop1.items?.enum).toBeUndefined();
413416
}
414-
415-
// Calculate total character length of enum values
416-
const totalLength = result.prop1.items!.enum!.reduce((sum, val) => sum + val.length, 0);
417-
expect(totalLength).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
418417
});
419418

420419
it('should handle properties without enum or items.enum', () => {

0 commit comments

Comments
 (0)