Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit d2a50f2

Browse files
committed
feat: change x-wrtn-prerequisite property to use jmespath
1 parent 1682a08 commit d2a50f2

File tree

1 file changed

+12
-50
lines changed

1 file changed

+12
-50
lines changed

src/structures/IOpenAiSchema.ts

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -449,60 +449,22 @@ export namespace IOpenAiSchema {
449449
path: string;
450450

451451
/**
452-
* Transform function returning label.
452+
* Function returning transformed values using JMESPath expression.
453453
*
454-
* `Prerequisite.Props.label` is a string typed property representing
455-
* a function returning the label from the element instance of the
456-
* prerequisite API respond array.
454+
* `Prerequisite.Props.jmesPath` is a string typed property that extracts desired values
455+
* from the prerequisite API response using a JMESPath expression. This property simplifies
456+
* and replaces the `label`, `value`, and `array` properties.
457457
*
458-
* The function script must be a string value that can be parsed by
459-
* `new Function(string)` statement. Also, its parameter names are
460-
* always `elem`, `index` and `array`. Of course, the function's
461-
* return type must be always `string`.
458+
* JMESPath expressions are used to extract the desired data based on the API response.
459+
* The expression must always be a valid JMESPath syntax.
462460
*
463-
* - type: `label: (elem: Element, index: number, array: Element[]) => string`
464-
* - example: `return elem.title`
465-
* - how to use: `new Function("elem", "index", "array", labelScript)(...)`
461+
* - Type: `jmesPath: string`
462+
* - Example: `"members[*].data.title"`
463+
* - Usage: `jmespath.search(response, jmesPath)`
464+
*
465+
* Note: The `label`, `value`, and `array` properties are no longer in use.
466466
*/
467-
label: string;
468-
469-
/**
470-
* Transform function returning target value.
471-
*
472-
* `Prerequisite.Props.value` is a string typed property representing
473-
* a function returning the target value from the element instance of
474-
* the prerequisite API respond array. If you've defined this `Prerequisite`
475-
* type to a `number` type, the returned value must be actual number type.
476-
*
477-
* The function script must be a string value that can be parsed by
478-
* `new Function(string)` statement. Also, its parameter names are always
479-
* `elem`, `index` and `array`.
480-
*
481-
* - type: `value: (elem: Element, index: number, array: Element[]) => Value`
482-
* - example: `return elem.no`
483-
* - how to use: `new Function("elem", "index", "array", valueScript)(...)`
484-
*/
485-
value: string;
486-
487-
/**
488-
* Transform function returning array instance.
489-
*
490-
* `Prerequisite.Props.array` is a string typed property representing
491-
* a function returning an array instance from the response of the
492-
* prerequisite API.
493-
*
494-
* The function script must be a string value that can be parsed by
495-
* `new Function(string)` statement. Also, its parameter name is
496-
* always `response`.
497-
*
498-
* If the prerequisite API responses an array and it is the desired one,
499-
* you don't need to specify this property.
500-
*
501-
* - type: `array: (response: Response) => Elemenet[]`
502-
* - example: `return response.members.map(m => m.data)`
503-
* - how to use: `new Function("response", arrayScript)(response)`
504-
*/
505-
array?: string;
467+
jmesPath: string;
506468
};
507469
}
508470
}

0 commit comments

Comments
 (0)