1+ # ` @inrupt/solid-client ` architectural overview
2+
13This document describes the general design principles and modules of solid-client,
24to help contributors make sure their and others' work is coherent with what's
35there. It assumes that you are already familiar with the external API and
@@ -13,9 +15,9 @@ It can also be insightful to use `git blame` liberally. We've generally kept
1315fairly good Git hygiene, so reading the commit that introduced some code can be
1416helpful in understanding how it relates to the rest of the codebase.
1517
16- # Design principles
18+ ## Design principles
1719
18- ## Avoidance of side effects
20+ ### Avoidance of side effects
1921
2022Generally, our API's tend to avoid side effects whenever possible. That means
2123that we have a number of functions that only perform the side effects we cannot
@@ -32,7 +34,7 @@ support this common use case. (SolidDatasets used to be built on top of
3234[ RDF/JS Datasets] ( https://rdf.js.org/dataset-spec/ ) , but we moved away from that
3335to avoid its mutability and lack of serialisability because of the above.)
3436
35- ## Lumping ACLs and Resources together
37+ ### Lumping ACLs and Resources together
3638
3739Linked Resources, such as an Access Control Lists, are currently attached to the
3840same object that represents the Resource they are linked to. The reason for this
@@ -57,9 +59,9 @@ Resource itself, but also that in one or more linked Resources.
5759This concern was mainly brought up by @pmcb55 , so further questions regarding
5860this can be directed to him.
5961
60- # Concepts
62+ ## Concepts
6163
62- ## Resources, Files and SolidDatasets
64+ ### Resources, Files and SolidDatasets
6365
6466` solid-client ` refers to everything that can be fetched from a URL as a Resource.
6567There are two types of Resources: those containing RDF in a serialisation that
@@ -82,7 +84,7 @@ XML or OpenDocument) or files containing structured data in an RDF format not re
8284by the Solid Protocol (for example RDF/XML) it is up to the server to accept that
8385payload and treat it as a binary resource, interpret it as RDF, or reject it.
8486
85- ## ` With* ` types
87+ ### ` With* ` types
8688
8789Although SolidDatasets and Files (see previous section) are different types of
8890Resources, there is certain data that is common to all Resources. This data is
@@ -106,9 +108,9 @@ the implementation of these data structures. If developers want to access the
106108data contained in them, they should use the functions we provide for them, such
107109as ` getContentType ` . We can, of course, use those internally as well.
108110
109- # Module map
111+ ## Module map
110112
111- ## ` src/resource/* `
113+ ### ` src/resource/* `
112114
113115Everything related to fetching and storing data. ` file.ts ` has everything
114116related to fetching Files, which is mostly a thin wrapper around a regular
@@ -123,18 +125,18 @@ SolidDatasets with the appropriate meta data in their unit tests. This helps
123125avoiding developers from attempting to recreate our metadata data structures,
124126and then breaking in a non-major version.
125127
126- ## ` src/thing/* `
128+ ### ` src/thing/* `
127129
128130Everything related to reading and manipulating data in a SolidDataset.
129131
130- ## ` src/formats/* `
132+ ### ` src/formats/* `
131133
132134We currently just support parsing Turtle natively (though developers can pass in
133135their own parsers), since the spec mandates that all servers should be able to
134136serialise RDF to that, and since we already have a Turtle library to produce
135137serialisations for PATCH requests.
136138
137- ## ` universalAccess ` , ` src/acl/* ` and ` acp_ess_ `
139+ ### ` universalAccess ` , ` src/acl/* ` and ` acp_ess_ `
138140
139141At first, there was one [ authorization mechanism in Solid] ( https://solidproject.org/TR/protocol#authorization ) :
140142Web Access Control ([ WAC] ( https://solidproject.org/TR/wac ) ). WAC uses the Access
@@ -153,7 +155,7 @@ authorization systems (ACL: `src/acl/*` and ACP: `acp_ess_`). Those lower level
153155functions are for the time being still experimental and we don't advise using
154156them in production code.
155157
156- ## ` e2e/browser ` and ` e2e/node `
158+ ### ` e2e/browser ` and ` e2e/node `
157159
158160` solid-client ` can run in both Node and in the browser. To ensure that everything
159161works as intended, we have a suite of tests that attempts to use its APIs to
@@ -170,7 +172,7 @@ The Node-based end-to-end test suite is the more extensive one. It verifies not
170172just that the library works in Node, but also that e.g. manipulating access
171173correctly prevents or allows the right people access _ in practice_ .
172174
173- # Opportunities for improvement
175+ ## Opportunities for improvement
174176
175177Given that the code base has existed for more than a day, some parts of the code
176178have evolved in a certain way that would have been done differently if they had
@@ -180,7 +182,7 @@ across them and start wondering whether there's a good reason for things to be
180182that way. In the spirit of [ Chesterton's Fence] ( https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence ) ,
181183if I tell you why they are the way they are, you can feel safe to change them!
182184
183- ## Using the solid-client-authn-browser default session
185+ ### Using the solid-client-authn-browser default session
184186
185187Currently, developers wanting to make authenticated requests will have to make
186188sure they pass in an authenticated ` fetch ` function. However, in the browser,
@@ -195,7 +197,7 @@ implemented yet.
195197The interaction with bundlers here can be pretty tricky so, when implementing
196198this, be sure to test it well.
197199
198- ## The entire low-level Access Control Policies API
200+ ### The entire low-level Access Control Policies API
199201
200202(i.e. ` acp_ess_1 ` and ` acp_ess_2 ` )
201203
@@ -222,27 +224,27 @@ mechanism to attach linked Resources in general. (Keep in mind that that will
222224not work for Web Access Control, since that might require fetching a Resource
223225linked to a Resource higher up in the Container hierarchy.)
224226
225- ## ` WithServerResourceInfo["aclUrl"] `
227+ ### ` WithServerResourceInfo["aclUrl"] `
226228
227229When the ` aclUrl ` property was added to the ` WithServerResourceInfo ` interface,
228230it was not clear to us that linked resources (i.e. those linked in the HTTP
229231Link header) would be a commonly-used mechanism to expose related data.
230- We later added the `WithServerResourceInfo[ "linkedResources"] property, which
232+ We later added the ` WithServerResourceInfo["linkedResources"] ` property, which
231233_ also_ exposes the ACL URL, but didn't bother to update the old code to make
232234use of that instead.
233235
234- ## ` src/interfaces.ts `
236+ ### ` src/interfaces.ts `
235237
236238The interfaces defined here would probably make more sense defined in the
237239relevant modules. It might not even be necessary to add aliases from the old
238240module to the new one, as long as TypeScript does not support exports maps
239241yet. (Though adding them just to be sure probably isn't a bad idea.)
240242
241- ## ChangeLog
243+ ### ChangeLog
242244
243245The ChangeLog currently consists of two arrays of RDF/JS Quads. This can be
244246problematic since those are instantiated classes, conflicting with e.g. [ Vue's
245- desire to keep [ data] plain] ( https://vuex.vuejs.org/guide/state.html#single-state-tree )
247+ desire to keep data plain] ( https://vuex.vuejs.org/guide/state.html#single-state-tree )
246248or [ SWR only considering own properties] ( https://swr.vercel.app/advanced/performance#deep-comparison ) .
247249In practice this is probably not much of a problem, since the ChangeLog is only
248250updated when the SolidDataset itself is as well. However, if it turns out
@@ -251,7 +253,7 @@ objects.
251253
252254Or alternatively...
253255
254- ## PATCH and 412 conflicts
256+ ### PATCH and 412 conflicts
255257
256258...it could be considered to remove the ChangeLog functionality altogether. One
257259of the most recurring problems people run into is not using the return value
@@ -266,7 +268,7 @@ calling `overwriteFile`. This might more often do what the developer expects,
266268at the cost of sending bigger payloads and bigger risk of overwriting data that
267269was inserted in parallel on a different device or by a different user.
268270
269- ## ` File `
271+ ### ` File `
270272
271273` File ` is a bit awkward now for two reasons:
272274
@@ -281,7 +283,7 @@ was inserted in parallel on a different device or by a different user.
281283 This too, is hard to change without being breaking, although of course an
282284 alias could be added.
283285
284- ## ThingBuilder
286+ ### ThingBuilder
285287
286288` ThingBuilder ` was created after the observation that this was a common pattern:
287289
@@ -318,7 +320,7 @@ Given that ThingBuilders are usually limited to a local scope, making it
318320stateful could be a nice quality of life improvement, and can be implemented
319321without breaking anything.
320322
321- ## ` *StringNoLocale `
323+ ### ` *StringNoLocale `
322324
323325It might seem weird that there are ` *StringNoLocale ` and ` *StringWithLocale `
324326functions, rather than just ` *String ` functions with an optional ` locale `
0 commit comments