Skip to content

Commit eb09120

Browse files
committed
fix: expose parserOptions more
1 parent a788a8f commit eb09120

5 files changed

Lines changed: 29 additions & 21 deletions

File tree

src/acl/acl.internal.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020
//
2121

2222
import type { Quad } from "@rdfjs/types";
23-
import { getSolidDataset } from "../resource/solidDataset";
23+
import { getSolidDataset, ParseOptions } from "../resource/solidDataset";
2424
import type {
2525
IriString,
26-
WithChangeLog,
2726
Thing,
27+
WithChangeLog,
2828
WithServerResourceInfo,
2929
} from "../interfaces";
3030
import {
31-
getSourceUrl,
3231
getResourceInfo,
3332
getSourceIri,
33+
getSourceUrl,
3434
} from "../resource/resource";
3535
import { acl, rdf } from "../constants";
3636
import { DataFactory, subjectToRdfJsQuads } from "../rdfjs.internal";
@@ -68,7 +68,7 @@ import { isAcr } from "../acp/acp.internal";
6868
*/
6969
export async function internal_fetchAcl(
7070
resourceInfo: WithServerResourceInfo,
71-
options?: { fetch?: typeof fetch },
71+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
7272
): Promise<WithAcl["internal_acl"]> {
7373
if (!hasAccessibleAcl(resourceInfo)) {
7474
return {
@@ -104,7 +104,7 @@ export async function internal_fetchAcl(
104104
/** @internal */
105105
export async function internal_fetchResourceAcl(
106106
dataset: WithServerResourceInfo,
107-
options?: { fetch?: typeof fetch },
107+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
108108
): Promise<AclDataset | null> {
109109
if (!hasAccessibleAcl(dataset)) {
110110
return null;
@@ -136,7 +136,7 @@ export async function internal_fetchResourceAcl(
136136
/** @internal */
137137
export async function internal_fetchFallbackAcl(
138138
resource: WithAccessibleAcl,
139-
options?: { fetch?: typeof fetch },
139+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
140140
): Promise<AclDataset | null> {
141141
const resourceUrl = new URL(getSourceUrl(resource));
142142
const resourcePath = resourceUrl.pathname;

src/acl/acl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { acl } from "../constants";
2323
import {
2424
createSolidDataset,
2525
getSolidDataset,
26+
ParseOptions,
2627
saveSolidDatasetAt,
2728
} from "../resource/solidDataset";
2829
import type {
@@ -114,7 +115,7 @@ export function hasResourceAcl<
114115
*/
115116
export async function getSolidDatasetWithAcl(
116117
url: UrlString | Url,
117-
options?: { fetch?: typeof fetch },
118+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
118119
): Promise<SolidDataset & WithServerResourceInfo & WithAcl> {
119120
const solidDataset = await getSolidDataset(url, options);
120121
const acl = await internal_fetchAcl(solidDataset, options);

src/acp/acp.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import { getResourceInfo, getSourceUrl } from "../resource/resource";
3535
import type { WithAcl } from "../acl/acl";
3636
import { hasAccessibleAcl } from "../acl/acl";
3737
import { internal_fetchAcl, internal_setAcl } from "../acl/acl.internal";
38-
import { getSolidDataset, saveSolidDatasetAt } from "../resource/solidDataset";
38+
import { getSolidDataset, ParseOptions, saveSolidDatasetAt } from "../resource/solidDataset";
3939
import type { AccessControlResource } from "./control";
4040
import {
4141
getAcrPolicyUrlAll,
@@ -62,7 +62,7 @@ import { isAcr } from "./acp.internal";
6262
*/
6363
export async function getSolidDatasetWithAcr(
6464
url: Url | UrlString,
65-
options?: { fetch?: typeof fetch },
65+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
6666
): Promise<SolidDataset & WithServerResourceInfo & WithAcp> {
6767
const urlString = internal_toIriString(url);
6868
const solidDataset = await getSolidDataset(urlString, options);
@@ -135,7 +135,7 @@ export async function getResourceInfoWithAcr(
135135
*/
136136
export async function getSolidDatasetWithAccessDatasets(
137137
url: Url | UrlString,
138-
options?: { fetch?: typeof fetch },
138+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
139139
): Promise<SolidDataset & (WithAcp | WithAcl)> {
140140
const urlString = internal_toIriString(url);
141141
const solidDataset = await getSolidDataset(urlString, options);
@@ -266,7 +266,7 @@ export function hasAccessibleAcr(
266266

267267
async function fetchAcr(
268268
resource: WithServerResourceInfo,
269-
options?: { fetch?: typeof fetch },
269+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
270270
): Promise<WithAcp> {
271271
let acrUrl: UrlString | undefined;
272272
if (hasLinkedAcr(resource)) {

src/profile/webid.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
//
2121

2222
import type {
23+
ParseOptions,
2324
SolidDataset,
2425
UrlString,
2526
WebId,
@@ -90,11 +91,14 @@ export async function getProfileAll<
9091
options?: {
9192
fetch?: typeof fetch;
9293
webIdProfile?: T;
93-
},
94+
} & Partial<ParseOptions>,
9495
): Promise<ProfileAll<T>>;
9596
export async function getProfileAll(
9697
webId: WebId,
97-
options?: { fetch?: typeof fetch; webIdProfile: undefined },
98+
options?: {
99+
fetch?: typeof fetch;
100+
webIdProfile: undefined;
101+
} & Partial<ParseOptions>,
98102
): Promise<ProfileAll<SolidDataset & WithServerResourceInfo>>;
99103
export async function getProfileAll<
100104
T extends SolidDataset & WithServerResourceInfo,
@@ -103,17 +107,19 @@ export async function getProfileAll<
103107
options?: {
104108
fetch?: typeof fetch;
105109
webIdProfile?: T;
106-
},
110+
} & Partial<ParseOptions>,
107111
): Promise<ProfileAll<T | (SolidDataset & WithServerResourceInfo)>> {
108-
const authFetch = options?.fetch ?? fetch;
112+
const unauthenticatedOptions = Object.assign({}, options);
113+
delete unauthenticatedOptions["fetch"];
114+
109115
const webIdProfile =
110116
options?.webIdProfile ??
111117
// This should always use an unauthenticated fetch.
112-
(await getSolidDataset(webId));
118+
(await getSolidDataset(webId, unauthenticatedOptions));
113119
const altProfileAll = (
114120
await Promise.allSettled(
115121
getAltProfileUrlAllFrom(webId, webIdProfile).map((uniqueProfileIri) =>
116-
getSolidDataset(uniqueProfileIri, { fetch: authFetch }),
122+
getSolidDataset(uniqueProfileIri, options),
117123
),
118124
)
119125
)
@@ -147,7 +153,7 @@ export async function getProfileAll<
147153
*/
148154
export async function getPodUrlAll(
149155
webId: WebId,
150-
options?: { fetch?: typeof fetch },
156+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
151157
): Promise<UrlString[]> {
152158
const profiles = await getProfileAll(webId, options);
153159
return getPodUrlAllFrom(profiles, webId);
@@ -201,6 +207,7 @@ export function getPodUrlAllFrom(
201207
*/
202208
export async function getWebIdDataset(
203209
webId: WebId,
210+
options?: { fetch?: typeof fetch } & Partial<ParseOptions>,
204211
): Promise<ReturnType<typeof getSolidDataset>> {
205-
return getSolidDataset(webId);
212+
return getSolidDataset(webId, options);
206213
}

src/resource/solidDataset.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ export async function responseToSolidDataset(
240240
*/
241241
export async function getSolidDataset(
242242
url: UrlString | Url,
243-
options?: Partial<{ fetch: typeof fetch } & ParseOptions>,
243+
options?: Partial<{ fetch: typeof fetch } & Partial<ParseOptions>>,
244244
): Promise<SolidDataset & WithServerResourceInfo> {
245245
const normalizedUrl = normalizeUrl(internal_toIriString(url));
246246
const parserContentTypes = Object.keys(options?.parsers ?? {});
@@ -1151,7 +1151,7 @@ function resolveLocalIrisInThing(
11511151
*/
11521152
export async function getWellKnownSolid(
11531153
url: UrlString | Url,
1154-
options?: Partial<{ fetch?: typeof fetch } & ParseOptions>,
1154+
options?: Partial<{ fetch?: typeof fetch } & Partial<ParseOptions>>,
11551155
): Promise<SolidDataset & WithServerResourceInfo> {
11561156
const urlString = internal_toIriString(url);
11571157

0 commit comments

Comments
 (0)