solid-logic 1.3.17-a849582e → 1.3.17-af110ecf

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/lib/acl/aclLogic.d.ts +2 -11
  2. package/lib/acl/aclLogic.d.ts.map +1 -1
  3. package/lib/acl/aclLogic.js +5 -7
  4. package/lib/acl/aclLogic.js.map +1 -1
  5. package/lib/chat/chatLogic.d.ts +2 -15
  6. package/lib/chat/chatLogic.d.ts.map +1 -1
  7. package/lib/chat/chatLogic.js +8 -7
  8. package/lib/chat/chatLogic.js.map +1 -1
  9. package/lib/inbox/inboxLogic.d.ts +2 -6
  10. package/lib/inbox/inboxLogic.d.ts.map +1 -1
  11. package/lib/inbox/inboxLogic.js.map +1 -1
  12. package/lib/index.d.ts +7 -9
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +10 -74
  15. package/lib/index.js.map +1 -1
  16. package/lib/logic/solidLogic.d.ts +6 -0
  17. package/lib/logic/solidLogic.d.ts.map +1 -0
  18. package/lib/logic/solidLogic.js +92 -0
  19. package/lib/logic/solidLogic.js.map +1 -0
  20. package/lib/logic/solidLogicSingleton.d.ts +2 -35
  21. package/lib/logic/solidLogicSingleton.d.ts.map +1 -1
  22. package/lib/logic/solidLogicSingleton.js +7 -86
  23. package/lib/logic/solidLogicSingleton.js.map +1 -1
  24. package/lib/profile/profileLogic.d.ts +2 -12
  25. package/lib/profile/profileLogic.d.ts.map +1 -1
  26. package/lib/profile/profileLogic.js +1 -23
  27. package/lib/profile/profileLogic.js.map +1 -1
  28. package/lib/typeIndex/typeIndexLogic.d.ts +2 -31
  29. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  30. package/lib/typeIndex/typeIndexLogic.js +12 -359
  31. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  32. package/lib/types.d.ts +65 -1
  33. package/lib/types.d.ts.map +1 -1
  34. package/lib/util/ns.d.ts +2 -0
  35. package/lib/util/ns.d.ts.map +1 -0
  36. package/lib/util/ns.js +34 -0
  37. package/lib/util/ns.js.map +1 -0
  38. package/package.json +1 -1
  39. package/src/acl/aclLogic.ts +8 -5
  40. package/src/chat/chatLogic.ts +7 -7
  41. package/src/inbox/inboxLogic.ts +2 -1
  42. package/src/index.ts +12 -83
  43. package/src/logic/solidLogic.ts +75 -0
  44. package/src/logic/solidLogicSingleton.ts +6 -159
  45. package/src/profile/profileLogic.ts +4 -12
  46. package/src/typeIndex/typeIndexLogic.ts +6 -277
  47. package/src/types.ts +76 -1
  48. package/src/util/{ns.js → ns.ts} +0 -0
  49. package/test/logic.test.ts +5 -6
  50. package/test/typeIndexLogic.test.ts +484 -54
  51. package/lib/discovery/discoveryLogic.d.ts +0 -37
  52. package/lib/discovery/discoveryLogic.d.ts.map +0 -1
  53. package/lib/discovery/discoveryLogic.js +0 -500
  54. package/lib/discovery/discoveryLogic.js.map +0 -1
  55. package/src/discovery/discoveryLogic.ts +0 -267
  56. package/test/discoveryLogic.test.ts +0 -712
  57. package/test/typeIndexLogicPart2.test.ts +0 -485
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-logic",
3
- "version": "1.3.17-a849582e",
3
+ "version": "1.3.17-af110ecf",
4
4
  "description": "Core business logic of Solid OS",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,12 +1,15 @@
1
1
  import { graph, NamedNode, Namespace, serialize, sym } from "rdflib"
2
- import ns from '../util/ns'
2
+ import { AclLogic } from "../types";
3
+ import { ns as namespace } from '../util/ns'
3
4
 
4
5
 
5
6
  export const ACL_LINK = sym(
6
7
  "http://www.iana.org/assignments/link-relations/acl"
7
8
  );
8
9
 
9
- export function createAclLogic(store) {
10
+ export function createAclLogic(store): AclLogic {
11
+
12
+ const ns = namespace
10
13
 
11
14
  async function findAclDocUrl(url: string) {
12
15
  const doc = store.sym(url);
@@ -114,9 +117,9 @@ export function createAclLogic(store) {
114
117
  me: NamedNode,
115
118
  aclURI: string,
116
119
  options: {
117
- defaultForNew?: boolean,
118
- public?: []
119
- } = {}
120
+ defaultForNew?: boolean,
121
+ public?: []
122
+ } = {}
120
123
  ): string | undefined {
121
124
  const optPublic = options.public || []
122
125
  const g = graph()
@@ -1,13 +1,13 @@
1
1
  import { NamedNode, Node, st, term } from "rdflib"
2
- import { CreatedPaneOptions, NewPaneOptions } from "../types"
2
+ import { ChatLogic, CreatedPaneOptions, NewPaneOptions, Chat } from "../types"
3
+ import { ns as namespace } from "../util/ns";
3
4
  import { determineChatContainer, newThing } from "../util/utils"
4
- import { ns as namespace } from '../util/ns'
5
5
 
6
- const CHAT_LOCATION_IN_CONTAINER = "index.ttl#this";
6
+ const CHAT_LOCATION_IN_CONTAINER = "index.ttl#this"
7
7
 
8
- export function createChatLogic(store, profileLogic) {
8
+ export function createChatLogic(store, profileLogic): ChatLogic {
9
9
  const ns = namespace
10
-
10
+
11
11
  async function setAcl(
12
12
  chatContainer: NamedNode,
13
13
  me: NamedNode,
@@ -87,7 +87,7 @@ export function createChatLogic(store, profileLogic) {
87
87
  });
88
88
  }
89
89
 
90
- async function findChat(invitee: NamedNode) {
90
+ async function findChat(invitee: NamedNode): Promise<Chat> {
91
91
  const me = await profileLogic.loadMe();
92
92
  const podRoot = await profileLogic.getPodRoot(me);
93
93
  const chatContainer = determineChatContainer(invitee, podRoot);
@@ -206,7 +206,7 @@ export function createChatLogic(store, profileLogic) {
206
206
  ${ns.rdf("seeAlso")} <${chatThing.value}> .
207
207
  `;
208
208
 
209
- const inviteResponse = await store.fetcher.webOperation(
209
+ const inviteResponse = await store.fetcher?.webOperation(
210
210
  "POST",
211
211
  inviteeInbox.value,
212
212
  {
@@ -1,7 +1,8 @@
1
1
  import { NamedNode } from "rdflib";
2
+ import { InboxLogic } from "../types";
2
3
  import { getArchiveUrl } from "../util/utils";
3
4
 
4
- export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic) {
5
+ export function createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic): InboxLogic {
5
6
 
6
7
  async function createInboxFor(peerWebId: string, nick: string) {
7
8
  const myWebId: NamedNode = await profileLogic.loadMe();
package/src/index.ts CHANGED
@@ -1,92 +1,21 @@
1
1
  // Make these variables directly accessible as it is what you need most of the time
2
2
  // This also makes these variable globaly accesible in mashlib
3
- //import { solidLogicSingleton } from './logic/solidLogicSingleton'
4
- //const authn = solidLogicSingleton.authn
5
- //const authSession = solidLogicSingleton.authn.authSession
6
- //const store = solidLogicSingleton.store
3
+ import { solidLogicSingleton } from './logic/solidLogicSingleton'
7
4
 
8
- export {
9
- ACL_LINK
10
- } from './acl/aclLogic'
11
-
12
- export {
13
- findAclDocUrl,
14
- setACLUserPublic,
15
- genACLText,
16
- } from './logic/solidLogicSingleton'
17
-
18
- export {
19
- ensureTypeIndexes,
20
- loadTypeIndexes,
21
- registerInTypeIndex,
22
- loadIndex,
23
- ensureOneTypeIndex,
24
- putIndex,
25
- makeIndexIfNecessary,
26
- loadIndexes,
27
- getTypeIndex,
28
- getRegistrations,
29
- //NEW function for discovery
30
- loadTypeIndexesFor,
31
- loadCommunityTypeIndexes,
32
- loadAllTypeIndexes,
33
- getScopedAppInstances,
34
- getAppInstances,
35
- suggestPublicTypeIndex,
36
- suggestPrivateTypeIndex,
37
- registerInstanceInTypeIndex,
38
- deleteTypeIndexRegistration,
39
- getScopedAppsFromIndex
40
- } from './logic/solidLogicSingleton'
41
-
42
- export {
43
- setAcl,
44
- addToPrivateTypeIndex,
45
- findChat,
46
- createChatThing,
47
- getChat,
48
- sendInvite,
49
- mintNew
50
- } from './logic/solidLogicSingleton'
5
+ const authn = solidLogicSingleton.authn
6
+ const authSession = solidLogicSingleton.authn.authSession
7
+ const store = solidLogicSingleton.store
51
8
 
9
+ export { ACL_LINK } from './acl/aclLogic'
52
10
  export { offlineTestID, appContext } from './authn/authUtil'
53
- export { createInboxFor, getNewMessages, markAsRead } from './logic/solidLogicSingleton'
54
- export {
55
- recursiveDelete,
56
- setSinglePeerAccess,
57
- createEmptyRdfDoc,
58
- //NEW function for discovery
59
- followOrCreateLink,
60
- loadOrCreateIfNotExists,
61
- } from './logic/solidLogicSingleton'
62
-
63
- export {
64
- ensureLoadedPreferences,
65
- loadMe,
66
- getPodRoot,
67
- getMainInbox,
68
- findStorage,
69
- //NEW content from discovery
70
- loadPreferences,
71
- loadProfile,
72
- //NEW function for discovery
73
- silencedLoadPreferences
74
- } from './logic/solidLogicSingleton'
75
-
76
11
  export { getSuggestedIssuers } from './issuer/issuerLogic'
12
+ export { AppDetails, SolidNamespace, AuthenticationContext, SolidLogic } from './types'
13
+ export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'
77
14
 
78
15
  export {
79
- isContainer,
80
- createContainer,
81
- getContainerElements,
82
- getContainerMembers
83
- } from './logic/solidLogicSingleton'
84
-
85
- export { authn, authSession, store } from './logic/solidLogicSingleton'
86
-
87
- //export { SolidLogic } from './logic/SolidLogic'
88
- export { AppDetails, SolidNamespace, AuthenticationContext } from './types'
89
- // solidLogicSingleton is exported entirely because it is used in solid-panes
90
- //export { solidLogicSingleton } from './logic/solidLogicSingleton'
91
- export { UnauthorizedError, CrossOriginForbiddenError, SameOriginForbiddenError, NotFoundError, FetchError, NotEditableError, WebOperationError } from './logic/CustomError'
16
+ solidLogicSingleton, // solidLogicSingleton is exported entirely because it is used in solid-panes
17
+ store,
18
+ authn,
19
+ authSession
20
+ }
92
21
 
@@ -0,0 +1,75 @@
1
+ import { Session } from "@inrupt/solid-client-authn-browser";
2
+ import * as rdf from "rdflib";
3
+ import { LiveStore, NamedNode, Statement } from "rdflib";
4
+ import { createAclLogic } from "../acl/aclLogic";
5
+ import { SolidAuthnLogic } from "../authn/SolidAuthnLogic";
6
+ import { createChatLogic } from "../chat/chatLogic";
7
+ import { createInboxLogic } from "../inbox/inboxLogic";
8
+ import { createProfileLogic } from "../profile/profileLogic";
9
+ import { createTypeIndexLogic } from "../typeIndex/typeIndexLogic";
10
+ import { createContainerLogic } from "../util/containerLogic";
11
+ import { createUtilityLogic } from "../util/utilityLogic";
12
+ import { AuthnLogic, SolidLogic } from "../types";
13
+ import * as debug from "../util/debug";
14
+ /*
15
+ ** It is important to distinquish `fetch`, a function provided by the browser
16
+ ** and `Fetcher`, a helper object for the rdflib Store which turns it
17
+ ** into a `ConnectedStore` or a `LiveStore`. A Fetcher object is
18
+ ** available at store.fetcher, and `fetch` function at `store.fetcher._fetch`,
19
+ */
20
+ export function createSolidLogic(specialFetch: { fetch: (url: any, requestInit: any) => any }, session: Session): SolidLogic {
21
+
22
+ debug.log("SolidLogic: Unique instance created. There should only be one of these.")
23
+ const store: LiveStore = rdf.graph() as LiveStore
24
+ rdf.fetcher(store, {fetch: specialFetch.fetch}); // Attach a web I/O module, store.fetcher
25
+ store.updater = new rdf.UpdateManager(store); // Add real-time live updates store.updater
26
+ store.features = [] // disable automatic node merging on store load
27
+
28
+ const authn: AuthnLogic = new SolidAuthnLogic(session)
29
+
30
+ const acl = createAclLogic(store)
31
+ const containerLogic = createContainerLogic(store)
32
+ const utilityLogic = createUtilityLogic(store, acl, containerLogic)
33
+ const profile = createProfileLogic(store, authn, utilityLogic)
34
+ const chat = createChatLogic(store, profile)
35
+ const inbox = createInboxLogic(store, profile, utilityLogic, containerLogic, acl)
36
+ const typeIndex = createTypeIndexLogic(store, authn, profile, utilityLogic)
37
+ debug.log('SolidAuthnLogic initialized')
38
+
39
+ function load(doc: NamedNode | NamedNode[] | string) {
40
+ return store.fetcher.load(doc);
41
+ }
42
+
43
+ // @@@@ use the one in rdflib.js when it is available and delete this
44
+ function updatePromise(
45
+ del: Array<Statement>,
46
+ ins: Array<Statement> = []
47
+ ): Promise<void> {
48
+ return new Promise((resolve, reject) => {
49
+ store.updater.update(del, ins, function (_uri, ok, errorBody) {
50
+ if (!ok) {
51
+ reject(new Error(errorBody));
52
+ } else {
53
+ resolve();
54
+ }
55
+ }); // callback
56
+ }); // promise
57
+ }
58
+
59
+ function clearStore() {
60
+ store.statements.slice().forEach(store.remove.bind(store));
61
+ }
62
+
63
+ return {
64
+ store,
65
+ authn,
66
+ acl,
67
+ inbox,
68
+ chat,
69
+ profile,
70
+ typeIndex,
71
+ load,
72
+ updatePromise,
73
+ clearStore
74
+ }
75
+ }
@@ -1,14 +1,6 @@
1
- import * as rdf from "rdflib"
2
- import { SolidAuthnLogic } from "../authn/SolidAuthnLogic"
3
- import { authSession } from "../authSession/authSession"
4
- import { createContainerLogic } from "../util/containerLogic"
5
- import { createTypeIndexLogic } from "../typeIndex/typeIndexLogic"
6
1
  import * as debug from "../util/debug"
7
- import { createUtilityLogic } from "../util/utilityLogic"
8
- import { createProfileLogic } from "../profile/profileLogic"
9
- import { createInboxLogic } from "../inbox/inboxLogic"
10
- import { createChatLogic } from "../chat/chatLogic"
11
- import { createAclLogic } from "../acl/aclLogic"
2
+ import { authSession } from "../authSession/authSession"
3
+ import { createSolidLogic } from "./solidLogic"
12
4
 
13
5
  const _fetch = async (url, requestInit) => {
14
6
  const omitCreds = requestInit && requestInit.credentials && requestInit.credentials == 'omit'
@@ -20,154 +12,9 @@ const _fetch = async (url, requestInit) => {
20
12
  }
21
13
  }
22
14
 
23
- debug.log("SolidLogicSingleton: Unique instance created. There should only be one of these.")
24
-
25
- const store = rdf.graph() as rdf.LiveStore; // Make a Quad store
26
- rdf.fetcher(store, { fetch: _fetch}); // Attach a web I/O module, store.fetcher
27
- store.updater = new rdf.UpdateManager(store); // Add real-time live updates store.updater
28
- store.features = [] // disable automatic node merging on store load
29
-
30
- debug.log('SolidAuthnLogic initialized')
31
- const authn = new SolidAuthnLogic(authSession)
32
-
33
- const aclLogic = createAclLogic(store)
34
- const {
35
- findAclDocUrl,
36
- setACLUserPublic,
37
- genACLText
38
- } = aclLogic
39
-
40
- const containerLogic = createContainerLogic(store)
41
- const {
42
- isContainer,
43
- createContainer,
44
- getContainerElements,
45
- getContainerMembers
46
- } = containerLogic
15
+ //this const makes solidLogicSingleton global accessible in mashlib
16
+ const solidLogicSingleton = createSolidLogic({ fetch: _fetch }, authSession)
47
17
 
48
- const utilityLogic = createUtilityLogic(store, aclLogic, containerLogic)
49
- const {
50
- recursiveDelete,
51
- setSinglePeerAccess,
52
- createEmptyRdfDoc,
53
- followOrCreateLink,
54
- loadOrCreateIfNotExists
55
- } = utilityLogic
56
-
57
- const profileLogic = createProfileLogic(store, authn, utilityLogic)
58
- const {
59
- ensureLoadedPreferences,
60
- loadMe,
61
- getPodRoot,
62
- getMainInbox,
63
- findStorage,
64
- loadPreferences,
65
- loadProfile,
66
- silencedLoadPreferences
67
- } = profileLogic
68
-
69
- const chatLogic = createChatLogic(store, profileLogic)
70
- const {
71
- setAcl,
72
- addToPrivateTypeIndex,
73
- findChat,
74
- createChatThing,
75
- getChat,
76
- sendInvite,
77
- mintNew
78
- } = chatLogic
79
-
80
- const inboxLogic = createInboxLogic(store, profileLogic, utilityLogic, containerLogic, aclLogic)
81
- const {
82
- createInboxFor,
83
- getNewMessages,
84
- markAsRead
85
- } = inboxLogic
86
-
87
- const typeIndexLogic = createTypeIndexLogic(store, authn, profileLogic, utilityLogic)
88
- const {
89
- ensureTypeIndexes,
90
- loadTypeIndexes,
91
- registerInTypeIndex,
92
- loadIndex,
93
- ensureOneTypeIndex,
94
- putIndex,
95
- makeIndexIfNecessary,
96
- loadIndexes,
97
- getTypeIndex,
98
- getRegistrations,
99
- loadTypeIndexesFor,
100
- loadCommunityTypeIndexes,
101
- loadAllTypeIndexes,
102
- getScopedAppInstances,
103
- getAppInstances,
104
- suggestPublicTypeIndex,
105
- suggestPrivateTypeIndex,
106
- registerInstanceInTypeIndex,
107
- deleteTypeIndexRegistration,
108
- getScopedAppsFromIndex
109
- } = typeIndexLogic
110
-
111
- export {
112
- store,
113
- authn,
114
- authSession,
115
- //unilityLogic
116
- recursiveDelete,
117
- setSinglePeerAccess,
118
- createEmptyRdfDoc,
119
- followOrCreateLink,
120
- loadOrCreateIfNotExists,
121
- //containerLogic
122
- isContainer,
123
- createContainer,
124
- getContainerElements,
125
- getContainerMembers,
126
- //typeIndexLogic
127
- ensureTypeIndexes,
128
- loadTypeIndexes,
129
- registerInTypeIndex,
130
- loadIndex,
131
- ensureOneTypeIndex,
132
- putIndex,
133
- makeIndexIfNecessary,
134
- loadIndexes,
135
- getTypeIndex,
136
- getRegistrations,
137
- loadTypeIndexesFor,
138
- loadCommunityTypeIndexes,
139
- loadAllTypeIndexes,
140
- getScopedAppInstances,
141
- getAppInstances,
142
- suggestPublicTypeIndex,
143
- suggestPrivateTypeIndex,
144
- registerInstanceInTypeIndex,
145
- deleteTypeIndexRegistration,
146
- getScopedAppsFromIndex,
147
- //profileLogic
148
- ensureLoadedPreferences,
149
- loadMe,
150
- getPodRoot,
151
- getMainInbox,
152
- findStorage,
153
- loadPreferences,
154
- loadProfile,
155
- silencedLoadPreferences,
156
- //inboxLogic
157
- createInboxFor,
158
- getNewMessages,
159
- markAsRead,
160
- //chatLogic
161
- setAcl,
162
- addToPrivateTypeIndex,
163
- findChat,
164
- createChatThing,
165
- getChat,
166
- sendInvite,
167
- mintNew,
168
- //aclLogic
169
- findAclDocUrl,
170
- setACLUserPublic,
171
- genACLText
172
- }
18
+ debug.log('Unique quadstore initialized.')
173
19
 
20
+ export { solidLogicSingleton }
@@ -1,20 +1,13 @@
1
1
  import { NamedNode } from "rdflib";
2
2
  import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from "../logic/CustomError";
3
- import { AuthenticationContext } from "../types";
4
3
  import * as debug from "../util/debug";
5
- import { differentOrigin, suggestPreferencesFile } from "../util/utils";
6
- import { ns as namespace } from '../util/ns'
4
+ import { ns as namespace } from '../util/ns';
5
+ import { differentOrigin, suggestPreferencesFile } from "../util/utils"
6
+ import { ProfileLogic } from "../types"
7
7
 
8
- export function createProfileLogic(store, authn, utilityLogic) {
8
+ export function createProfileLogic(store, authn, utilityLogic): ProfileLogic {
9
9
  const ns = namespace
10
10
 
11
- async function ensureLoadedPreferences (context: AuthenticationContext) {
12
- if (!context.me) throw new Error('@@ ensureLoadedPreferences: no user specified')
13
- context.publicProfile = await loadProfile(context.me)
14
- context.preferencesFile = await silencedLoadPreferences(context.me)
15
- return context
16
- }
17
-
18
11
  /**
19
12
  * loads the preference without throwing errors - if it can create it it does so.
20
13
  * remark: it still throws error if it cannot load profile.
@@ -121,7 +114,6 @@ export function createProfileLogic(store, authn, utilityLogic) {
121
114
  }
122
115
 
123
116
  return {
124
- ensureLoadedPreferences,
125
117
  loadMe,
126
118
  getPodRoot,
127
119
  getMainInbox,