{"version":3,"file":"ServerFunctionSerializationAdapter.js","sources":["../../../src/serializer/ServerFunctionSerializationAdapter.ts"],"sourcesContent":["import { createSerializationAdapter } from '@tanstack/router-core'\nimport { TSS_SERVER_FUNCTION } from '@tanstack/start-client-core'\nimport { getServerFnById } from '../getServerFnById'\n\nexport const ServerFunctionSerializationAdapter = createSerializationAdapter({\n  key: '$TSS/serverfn',\n  test: (v): v is { serverFnMeta: { id: string } } => {\n    if (typeof v !== 'function') return false\n\n    if (!(TSS_SERVER_FUNCTION in v)) return false\n\n    return !!v[TSS_SERVER_FUNCTION]\n  },\n  toSerializable: ({ serverFnMeta }) => ({ functionId: serverFnMeta.id }),\n  fromSerializable: ({ functionId }) => {\n    const fn = async (opts: any, signal: any): Promise<any> => {\n      // When a function ID is received through serialization (e.g., as a parameter\n      // to another server function), it originates from the client and must be\n      // validated the same way as direct HTTP calls to server functions.\n      const serverFn = await getServerFnById(functionId, { fromClient: true })\n      const result = await serverFn(opts ?? {}, signal)\n      return result.result\n    }\n    return fn as never\n  },\n})\n"],"names":[],"mappings":";;;AAIO,MAAM,qCAAqC,2BAA2B;AAAA,EAC3E,KAAK;AAAA,EACL,MAAM,CAAC,MAA6C;AAClD,QAAI,OAAO,MAAM,WAAY,QAAO;AAEpC,QAAI,EAAE,uBAAuB,GAAI,QAAO;AAExC,WAAO,CAAC,CAAC,EAAE,mBAAmB;AAAA,EAChC;AAAA,EACA,gBAAgB,CAAC,EAAE,aAAA,OAAoB,EAAE,YAAY,aAAa;EAClE,kBAAkB,CAAC,EAAE,iBAAiB;AACpC,UAAM,KAAK,OAAO,MAAW,WAA8B;AAIzD,YAAM,WAAW,MAAM,gBAAgB,YAAY,EAAE,YAAY,MAAM;AACvE,YAAM,SAAS,MAAM,SAAS,QAAQ,CAAA,GAAI,MAAM;AAChD,aAAO,OAAO;AAAA,IAChB;AACA,WAAO;AAAA,EACT;AACF,CAAC;"}