MCPcopy Create free account
hub / github.com/Superflows-AI/superflows / rebuildPropertiesArray

Function rebuildPropertiesArray

pages/api/mock/[...slug].ts:351–382  ·  view source on GitHub ↗
(
  hardCodedProperties: Properties,
  propertiesForAi: Properties,
  openAiResponse: string,
  transformed: Properties,
)

Source from the content-addressed store, hash-verified

349}
350
351function rebuildPropertiesArray(
352 hardCodedProperties: Properties,
353 propertiesForAi: Properties,
354 openAiResponse: string,
355 transformed: Properties,
356) {
357 const arrayResponse = [];
358 // Loop through each array element
359 for (let idx = 0; idx < 3; idx++) {
360 // Stick the result from the gpt call back on
361 const readded = addGPTdataToProperties(
362 propertiesForAi,
363 openAiResponse,
364 idx,
365 );
366
367 // hardcoded properties are a whole array, so we need to index
368 let hardcodedProperiesIdx: Properties = {};
369 for (let [key, value] of Object.entries(hardCodedProperties)) {
370 hardcodedProperiesIdx[key] = {
371 ...value,
372 data: value.data[idx],
373 };
374 }
375
376 const newChunks = propertiesToChunks(
377 Object.assign({}, transformed, { ...readded, ...hardcodedProperiesIdx }),
378 );
379 arrayResponse.push(jsonReconstruct(newChunks));
380 }
381 return removePropertiesItems(arrayResponse);
382}
383
384function propertiesFromSchema(schema: OpenAPIV3_1.SchemaObject) {
385 if (schema.properties) return schema.properties;

Callers 1

getMockedPropertiesFunction · 0.85

Calls 4

addGPTdataToPropertiesFunction · 0.90
propertiesToChunksFunction · 0.90
jsonReconstructFunction · 0.90
removePropertiesItemsFunction · 0.85

Tested by

no test coverage detected