{"version":3,"file":"SolidConnectedPlugin.mjs","names":[],"sources":["../src/SolidConnectedPlugin.ts"],"sourcesContent":["import type { ConnectedContext, ConnectedPlugin } from \"@ldo/connected\";\nimport type { SolidContainerUri, SolidLeafUri, SolidUri } from \"./types\";\nimport { SolidLeaf } from \"./resources/SolidLeaf\";\nimport { SolidContainer } from \"./resources/SolidContainer\";\nimport { isSolidContainerUri, isSolidUri } from \"./util/isSolidUri\";\n\n/**\n * The Type of the SolidConnectedContext\n */\nexport interface SolidConnectedContext {\n  fetch?: typeof fetch;\n}\nexport interface SolidConnectedPlugin\n  extends ConnectedPlugin<\n    \"solid\",\n    SolidUri,\n    SolidLeaf | SolidContainer,\n    SolidConnectedContext,\n    undefined\n  > {\n  name: \"solid\";\n  getResource:\n    | ((uri: SolidLeafUri, context: ConnectedContext<this[]>) => SolidLeaf)\n    | ((\n        uri: SolidContainerUri,\n        context: ConnectedContext<this[]>,\n      ) => SolidContainer);\n  createResource(context: ConnectedContext<this[]>): Promise<SolidLeaf>;\n}\n\nfunction getResource(\n  uri: SolidLeafUri,\n  context: ConnectedContext<SolidConnectedPlugin[]>,\n): SolidLeaf;\nfunction getResource(\n  uri: SolidContainerUri,\n  context: ConnectedContext<SolidConnectedPlugin[]>,\n): SolidContainer;\nfunction getResource(\n  uri: SolidLeafUri | SolidContainerUri,\n  context: ConnectedContext<SolidConnectedPlugin[]>,\n): SolidLeaf | SolidContainer {\n  if (isSolidContainerUri(uri)) {\n    return new SolidContainer(uri, context);\n  } else {\n    return new SolidLeaf(uri, context);\n  }\n}\n\n/**\n * This plugin can be given to a ConnectedDataset to let it connect to Solid\n * servers.\n *\n * @example\n * ```\n * import { createConnectedLdoDataset } from \"@ldo/connected\";\n * import { solidConnectedPlugin } from \"@ldo/connected-solid\";\n *\n * const solidConnectedDataset = createConnectedLdoDataset([\n *   solidConnectedPlugin\n * ]);\n * ```\n */\nexport const solidConnectedPlugin: SolidConnectedPlugin = {\n  name: \"solid\",\n\n  getResource,\n\n  createResource: function (): Promise<SolidLeaf> {\n    throw new Error(\"Function not implemented.\");\n  },\n\n  isUriValid: function (uri: string): uri is SolidLeafUri | SolidContainerUri {\n    return isSolidUri(uri);\n  },\n\n  initialContext: {\n    fetch: undefined,\n  },\n  // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n  // @ts-ignore \"Types\" only exists for the typing system\n  types: {},\n\n  normalizeUri(uri: SolidUri): SolidUri {\n    const url = new URL(uri);\n    url.hash = \"\";\n    url.search = \"\";\n    return url.toString() as SolidUri;\n  },\n};\n"],"mappings":";;;;AAsCA,SAAS,YACP,KACA,SAC4B;AAC5B,KAAI,oBAAoB,IAAI,CAC1B,QAAO,IAAI,eAAe,KAAK,QAAQ;KAEvC,QAAO,IAAI,UAAU,KAAK,QAAQ;;;;;;;;;;;;;;;;AAkBtC,MAAa,uBAA6C;CACxD,MAAM;CAEN;CAEA,gBAAgB,WAAgC;AAC9C,QAAM,IAAI,MAAM,4BAA4B;;CAG9C,YAAY,SAAU,KAAsD;AAC1E,SAAO,WAAW,IAAI;;CAGxB,gBAAgB,EACd,OAAO,KAAA,GACR;CAGD,OAAO,EAAE;CAET,aAAa,KAAyB;EACpC,MAAM,MAAM,IAAI,IAAI,IAAI;AACxB,MAAI,OAAO;AACX,MAAI,SAAS;AACb,SAAO,IAAI,UAAU;;CAExB"}