MCPcopy Create free account
hub / github.com/ShipSecAI/studio / unwrapEffects

Function unwrapEffects

packages/component-sdk/src/schema-validation.ts:228–258  ·  view source on GitHub ↗

* Unwrap optional, nullable, default effects

(schema: z.ZodTypeAny)

Source from the content-addressed store, hash-verified

226 * Unwrap optional, nullable, default effects
227 */
228function unwrapEffects(schema: z.ZodTypeAny): z.ZodTypeAny {
229 let current = schema;
230
231 while (true) {
232 const def = (current as any)._def as ZodDef | undefined;
233
234 if (!def) break;
235
236 const typeName = getDefType(def);
237
238 if (typeName === 'optional' || typeName === 'nullable' || typeName === 'default') {
239 current = def.innerType;
240 continue;
241 }
242
243 if (typeName === 'effects') {
244 current = def.schema;
245 continue;
246 }
247
248 if (typeName === 'pipe') {
249 current = def.out ?? def.schema ?? def.innerType ?? def.in ?? current;
250 if (current === schema) break;
251 continue;
252 }
253
254 break;
255 }
256
257 return current;
258}
259
260function unwrapToObject(
261 schema: z.ZodTypeAny

Callers 2

validateComponentSchemaFunction · 0.70
calculateDepthFunction · 0.70

Calls 1

getDefTypeFunction · 0.70

Tested by

no test coverage detected