{"version":3,"file":"shared.mjs","names":[],"sources":["../../src/resources/shared.ts"],"sourcesContent":["import type { Client } from '../generated/mapi/client';\nimport type { FetchOptions } from '../client';\n\nexport interface SpaceIdPathOverride {\n  path?: {\n    space_id?: number;\n  };\n}\n\n/**\n * Assembles the optional fields shared by every wrapped SDK call: a\n * `throwOnError` override (forwarded only when explicitly set) and\n * `fetchOptions` merged into the client's configured `kyOptions`.\n */\nexport function buildCallOptions(\n  client: Client,\n  throwOnError: boolean | undefined,\n  fetchOptions: FetchOptions | undefined,\n): { throwOnError?: boolean; kyOptions?: Record<string, unknown> } {\n  return {\n    ...(throwOnError === undefined ? {} : { throwOnError }),\n    ...(fetchOptions ? { kyOptions: { ...client.getConfig().kyOptions, ...fetchOptions } } : {}),\n  };\n}\n\nexport function resolveSpaceId(spaceId: number | undefined, path?: SpaceIdPathOverride['path']): number {\n  const resolvedSpaceId = path?.space_id ?? spaceId;\n\n  if (resolvedSpaceId === undefined) {\n    throw new Error('Missing space_id. Provide `spaceId` when creating the client or pass `path.space_id` to the request method.');\n  }\n\n  return resolvedSpaceId;\n}\n"],"mappings":";;;;;;AAcA,SAAgB,iBACd,QACA,cACA,cACiE;AACjE,QAAO;EACL,GAAI,iBAAiB,SAAY,EAAE,GAAG,EAAE,cAAc;EACtD,GAAI,eAAe,EAAE,WAAW;GAAE,GAAG,OAAO,WAAW,CAAC;GAAW,GAAG;GAAc,EAAE,GAAG,EAAE;EAC5F;;AAGH,SAAgB,eAAe,SAA6B,MAA4C;CACtG,MAAM,kBAAkB,MAAM,YAAY;AAE1C,KAAI,oBAAoB,OACtB,OAAM,IAAI,MAAM,8GAA8G;AAGhI,QAAO"}