MCPcopy Create free account
hub / github.com/chainjet/platform / getItemSchemaFromRes

Function getItemSchemaFromRes

apps/runner/src/utils/trigger.utils.ts:101–121  ·  view source on GitHub ↗
(idKey: string, schema: JSONSchema7)

Source from the content-addressed store, hash-verified

99}
100
101export function getItemSchemaFromRes(idKey: string, schema: JSONSchema7): JSONSchema7 | null {
102 const objectKeys = idKey
103 .replace(/\[]\./g, '.0.')
104 .split('.')
105 .filter((key) => key)
106
107 let iterationSchema: JSONSchema7 = schema
108 let resultSchema: JSONSchema7 = schema
109 for (const key of objectKeys) {
110 if (key.toString() === '0' && iterationSchema.items) {
111 iterationSchema = iterationSchema.items as JSONSchema7
112 } else if (iterationSchema.properties?.[key]) {
113 resultSchema = iterationSchema
114 iterationSchema = iterationSchema.properties[key] as JSONSchema7
115 } else {
116 return null
117 }
118 }
119
120 return resultSchema
121}

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected