Skip to content

Commit 381073f

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

File tree

4 files changed

+24
-17
lines changed

4 files changed

+24
-17
lines changed

src/acl/acl.internal.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ import type { Quad } from "@rdfjs/types";
2323
import { getSolidDataset } 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";
@@ -57,6 +57,7 @@ import { removeAll, removeIri } from "../thing/remove";
5757
import { freeze } from "../rdf.internal";
5858
import { internal_cloneResource } from "../resource/resource.internal";
5959
import { isAcr } from "../acp/acp.internal";
60+
import { ParserOptions } from "n3";
6061

6162
/**
6263
* This (currently internal) function fetches the ACL indicated in the [[WithServerResourceInfo]]
@@ -68,7 +69,7 @@ import { isAcr } from "../acp/acp.internal";
6869
*/
6970
export async function internal_fetchAcl(
7071
resourceInfo: WithServerResourceInfo,
71-
options?: { fetch?: typeof fetch },
72+
options?: { fetch?: typeof fetch } & ParserOptions,
7273
): Promise<WithAcl["internal_acl"]> {
7374
if (!hasAccessibleAcl(resourceInfo)) {
7475
return {
@@ -104,7 +105,7 @@ export async function internal_fetchAcl(
104105
/** @internal */
105106
export async function internal_fetchResourceAcl(
106107
dataset: WithServerResourceInfo,
107-
options?: { fetch?: typeof fetch },
108+
options?: { fetch?: typeof fetch } & ParserOptions,
108109
): Promise<AclDataset | null> {
109110
if (!hasAccessibleAcl(dataset)) {
110111
return null;
@@ -136,7 +137,7 @@ export async function internal_fetchResourceAcl(
136137
/** @internal */
137138
export async function internal_fetchFallbackAcl(
138139
resource: WithAccessibleAcl,
139-
options?: { fetch?: typeof fetch },
140+
options?: { fetch?: typeof fetch } & ParserOptions,
140141
): Promise<AclDataset | null> {
141142
const resourceUrl = new URL(getSourceUrl(resource));
142143
const resourcePath = resourceUrl.pathname;

src/acl/acl.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
internal_setAcl,
4848
} from "./acl.internal";
4949
import { freeze } from "../rdf.internal";
50+
import { ParserOptions } from "n3";
5051

5152
/**
5253
* ```{note} The Web Access Control specification is not yet finalised. As such, this
@@ -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 } & ParserOptions,
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ import {
4747
import { internal_getAcr, internal_setAcr } from "./control.internal";
4848
import { normalizeServerSideIri } from "../resource/iri.internal";
4949
import { isAcr } from "./acp.internal";
50+
import { ParserOptions } from "n3";
5051

5152
/**
5253
* ```{note} The Web Access Control specification is not yet finalised. As such, this
@@ -62,7 +63,7 @@ import { isAcr } from "./acp.internal";
6263
*/
6364
export async function getSolidDatasetWithAcr(
6465
url: Url | UrlString,
65-
options?: { fetch?: typeof fetch },
66+
options?: { fetch?: typeof fetch } & ParserOptions,
6667
): Promise<SolidDataset & WithServerResourceInfo & WithAcp> {
6768
const urlString = internal_toIriString(url);
6869
const solidDataset = await getSolidDataset(urlString, options);
@@ -135,7 +136,7 @@ export async function getResourceInfoWithAcr(
135136
*/
136137
export async function getSolidDatasetWithAccessDatasets(
137138
url: Url | UrlString,
138-
options?: { fetch?: typeof fetch },
139+
options?: { fetch?: typeof fetch } & ParserOptions,
139140
): Promise<SolidDataset & (WithAcp | WithAcl)> {
140141
const urlString = internal_toIriString(url);
141142
const solidDataset = await getSolidDataset(urlString, options);
@@ -266,7 +267,7 @@ export function hasAccessibleAcr(
266267

267268
async function fetchAcr(
268269
resource: WithServerResourceInfo,
269-
options?: { fetch?: typeof fetch },
270+
options?: { fetch?: typeof fetch } & ParserOptions,
270271
): Promise<WithAcp> {
271272
let acrUrl: UrlString | undefined;
272273
if (hasLinkedAcr(resource)) {

src/profile/webid.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2020
//
2121

22+
import { ParserOptions } from "n3";
2223
import type {
2324
SolidDataset,
2425
UrlString,
@@ -90,11 +91,11 @@ export async function getProfileAll<
9091
options?: {
9192
fetch?: typeof fetch;
9293
webIdProfile?: T;
93-
},
94+
} & ParserOptions,
9495
): Promise<ProfileAll<T>>;
9596
export async function getProfileAll(
9697
webId: WebId,
97-
options?: { fetch?: typeof fetch; webIdProfile: undefined },
98+
options?: { fetch?: typeof fetch; webIdProfile: undefined } & ParserOptions,
9899
): Promise<ProfileAll<SolidDataset & WithServerResourceInfo>>;
99100
export async function getProfileAll<
100101
T extends SolidDataset & WithServerResourceInfo,
@@ -103,17 +104,19 @@ export async function getProfileAll<
103104
options?: {
104105
fetch?: typeof fetch;
105106
webIdProfile?: T;
106-
},
107+
} & ParserOptions,
107108
): Promise<ProfileAll<T | (SolidDataset & WithServerResourceInfo)>> {
108-
const authFetch = options?.fetch ?? fetch;
109+
const unauthenticatedOptions = Object.assign({}, options);
110+
delete unauthenticatedOptions["fetch"];
111+
109112
const webIdProfile =
110113
options?.webIdProfile ??
111114
// This should always use an unauthenticated fetch.
112-
(await getSolidDataset(webId));
115+
(await getSolidDataset(webId, unauthenticatedOptions));
113116
const altProfileAll = (
114117
await Promise.allSettled(
115118
getAltProfileUrlAllFrom(webId, webIdProfile).map((uniqueProfileIri) =>
116-
getSolidDataset(uniqueProfileIri, { fetch: authFetch }),
119+
getSolidDataset(uniqueProfileIri, options),
117120
),
118121
)
119122
)
@@ -147,7 +150,7 @@ export async function getProfileAll<
147150
*/
148151
export async function getPodUrlAll(
149152
webId: WebId,
150-
options?: { fetch?: typeof fetch },
153+
options?: { fetch?: typeof fetch } & ParserOptions,
151154
): Promise<UrlString[]> {
152155
const profiles = await getProfileAll(webId, options);
153156
return getPodUrlAllFrom(profiles, webId);
@@ -201,6 +204,7 @@ export function getPodUrlAllFrom(
201204
*/
202205
export async function getWebIdDataset(
203206
webId: WebId,
207+
options?: { fetch?: typeof fetch } & ParserOptions,
204208
): Promise<ReturnType<typeof getSolidDataset>> {
205-
return getSolidDataset(webId);
209+
return getSolidDataset(webId, options);
206210
}

0 commit comments

Comments
 (0)