solid-logic 1.3.17 → 2.0.0

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 (124) hide show
  1. package/lib/acl/aclLogic.d.ts +3 -30
  2. package/lib/acl/aclLogic.d.ts.map +1 -1
  3. package/lib/acl/aclLogic.js +152 -119
  4. package/lib/acl/aclLogic.js.map +1 -1
  5. package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
  6. package/lib/authn/SolidAuthnLogic.js +3 -3
  7. package/lib/authn/SolidAuthnLogic.js.map +1 -1
  8. package/lib/chat/chatLogic.d.ts +3 -0
  9. package/lib/chat/chatLogic.d.ts.map +1 -0
  10. package/lib/chat/{ChatLogic.js → chatLogic.js} +82 -86
  11. package/lib/chat/chatLogic.js.map +1 -0
  12. package/lib/inbox/inboxLogic.d.ts +3 -0
  13. package/lib/inbox/inboxLogic.d.ts.map +1 -0
  14. package/lib/inbox/{InboxLogic.js → inboxLogic.js} +58 -64
  15. package/lib/inbox/inboxLogic.js.map +1 -0
  16. package/lib/index.d.ts +6 -11
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +5 -25
  19. package/lib/index.js.map +1 -1
  20. package/lib/issuer/issuerLogic.js +1 -1
  21. package/lib/issuer/issuerLogic.js.map +1 -1
  22. package/lib/logic/CustomError.d.ts +4 -0
  23. package/lib/logic/CustomError.d.ts.map +1 -1
  24. package/lib/logic/CustomError.js +17 -1
  25. package/lib/logic/CustomError.js.map +1 -1
  26. package/lib/logic/solidLogic.d.ts +6 -0
  27. package/lib/logic/solidLogic.d.ts.map +1 -0
  28. package/lib/logic/solidLogic.js +92 -0
  29. package/lib/logic/solidLogic.js.map +1 -0
  30. package/lib/logic/solidLogicSingleton.d.ts +1 -2
  31. package/lib/logic/solidLogicSingleton.d.ts.map +1 -1
  32. package/lib/logic/solidLogicSingleton.js +3 -3
  33. package/lib/logic/solidLogicSingleton.js.map +1 -1
  34. package/lib/profile/profileLogic.d.ts +3 -0
  35. package/lib/profile/profileLogic.d.ts.map +1 -0
  36. package/lib/profile/profileLogic.js +246 -0
  37. package/lib/profile/profileLogic.js.map +1 -0
  38. package/lib/typeIndex/typeIndexLogic.d.ts +2 -21
  39. package/lib/typeIndex/typeIndexLogic.d.ts.map +1 -1
  40. package/lib/typeIndex/typeIndexLogic.js +304 -296
  41. package/lib/typeIndex/typeIndexLogic.js.map +1 -1
  42. package/lib/types.d.ts +82 -1
  43. package/lib/types.d.ts.map +1 -1
  44. package/lib/util/containerLogic.d.ts +11 -0
  45. package/lib/util/containerLogic.d.ts.map +1 -0
  46. package/lib/{profile/ProfileLogic.js → util/containerLogic.js} +53 -44
  47. package/lib/util/containerLogic.js.map +1 -0
  48. package/lib/util/ns.d.ts +2 -0
  49. package/lib/util/ns.d.ts.map +1 -0
  50. package/lib/util/ns.js +34 -0
  51. package/lib/util/ns.js.map +1 -0
  52. package/lib/util/utilityLogic.d.ts +15 -0
  53. package/lib/util/utilityLogic.d.ts.map +1 -0
  54. package/lib/util/utilityLogic.js +272 -0
  55. package/lib/util/utilityLogic.js.map +1 -0
  56. package/lib/util/utils.d.ts +8 -0
  57. package/lib/util/utils.d.ts.map +1 -0
  58. package/lib/util/utils.js +48 -0
  59. package/lib/util/utils.js.map +1 -0
  60. package/package.json +16 -14
  61. package/src/acl/aclLogic.ts +137 -118
  62. package/src/authn/SolidAuthnLogic.ts +8 -7
  63. package/src/chat/chatLogic.ts +225 -0
  64. package/src/inbox/inboxLogic.ts +58 -0
  65. package/src/index.ts +11 -29
  66. package/src/issuer/issuerLogic.ts +1 -1
  67. package/src/logic/CustomError.ts +5 -1
  68. package/src/logic/solidLogic.ts +75 -0
  69. package/src/logic/solidLogicSingleton.ts +3 -3
  70. package/src/profile/profileLogic.ts +126 -0
  71. package/src/typeIndex/typeIndexLogic.ts +175 -182
  72. package/src/types.ts +83 -4
  73. package/src/util/containerLogic.ts +54 -0
  74. package/src/util/ns.ts +5 -0
  75. package/src/util/utilityLogic.ts +155 -0
  76. package/src/util/utils.ts +52 -0
  77. package/test/aclLogic.test.ts +13 -4
  78. package/test/chatLogic.test.ts +70 -71
  79. package/test/container.test.ts +56 -0
  80. package/test/helpers/dataSetup.ts +134 -0
  81. package/test/helpers/setup.ts +4 -0
  82. package/test/inboxLogic.test.ts +39 -38
  83. package/test/logic.test.ts +10 -9
  84. package/test/profileLogic.test.ts +246 -0
  85. package/test/typeIndexLogic.test.ts +488 -30
  86. package/test/utilityLogic.test.ts +172 -126
  87. package/test/utils.test.ts +32 -0
  88. package/lib/chat/ChatLogic.d.ts +0 -26
  89. package/lib/chat/ChatLogic.d.ts.map +0 -1
  90. package/lib/chat/ChatLogic.js.map +0 -1
  91. package/lib/chat/determineChatContainer.d.ts +0 -3
  92. package/lib/chat/determineChatContainer.d.ts.map +0 -1
  93. package/lib/chat/determineChatContainer.js +0 -12
  94. package/lib/chat/determineChatContainer.js.map +0 -1
  95. package/lib/discovery/discoveryLogic.d.ts +0 -13
  96. package/lib/discovery/discoveryLogic.d.ts.map +0 -1
  97. package/lib/discovery/discoveryLogic.js +0 -203
  98. package/lib/discovery/discoveryLogic.js.map +0 -1
  99. package/lib/inbox/InboxLogic.d.ts +0 -18
  100. package/lib/inbox/InboxLogic.d.ts.map +0 -1
  101. package/lib/inbox/InboxLogic.js.map +0 -1
  102. package/lib/logic/SolidLogic.d.ts +0 -48
  103. package/lib/logic/SolidLogic.d.ts.map +0 -1
  104. package/lib/logic/SolidLogic.js +0 -321
  105. package/lib/logic/SolidLogic.js.map +0 -1
  106. package/lib/profile/ProfileLogic.d.ts +0 -13
  107. package/lib/profile/ProfileLogic.d.ts.map +0 -1
  108. package/lib/profile/ProfileLogic.js.map +0 -1
  109. package/lib/util/UtilityLogic.d.ts +0 -33
  110. package/lib/util/UtilityLogic.d.ts.map +0 -1
  111. package/lib/util/UtilityLogic.js +0 -240
  112. package/lib/util/UtilityLogic.js.map +0 -1
  113. package/lib/util/uri.d.ts +0 -3
  114. package/lib/util/uri.d.ts.map +0 -1
  115. package/lib/util/uri.js +0 -9
  116. package/lib/util/uri.js.map +0 -1
  117. package/src/chat/ChatLogic.ts +0 -244
  118. package/src/chat/determineChatContainer.ts +0 -14
  119. package/src/discovery/discoveryLogic.ts +0 -90
  120. package/src/inbox/InboxLogic.ts +0 -66
  121. package/src/logic/SolidLogic.ts +0 -262
  122. package/src/profile/ProfileLogic.ts +0 -44
  123. package/src/util/UtilityLogic.ts +0 -161
  124. package/src/util/uri.ts +0 -5
@@ -1,133 +1,179 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import { UtilityLogic } from "../src/util/UtilityLogic";
3
- import solidNamespace from "solid-namespace";
4
- import * as rdf from "rdflib";
1
+ /**
2
+ * @jest-environment jsdom
3
+ *
4
+ */
5
5
  import fetchMock from "jest-fetch-mock";
6
- import { UpdateManager } from "rdflib";
7
- import { SolidNamespace } from "../src/types";
6
+ import { UpdateManager, sym, Fetcher, Store } from "rdflib";
7
+ import { createAclLogic } from "../src/acl/aclLogic";
8
+ import { WebOperationError } from "../src/logic/CustomError";
9
+ import { createContainerLogic } from "../src/util/containerLogic";
10
+ import { ns } from "../src/util/ns";
11
+ import { createUtilityLogic } from "../src/util/utilityLogic";
12
+ import { alice, AlicePhotoFolder, AlicePhotos, AlicePreferences, AlicePreferencesFile, AlicePrivateTypeIndex, AlicePrivateTypes, AliceProfile, AlicePublicTypeIndex, AlicePublicTypes, bob, BobProfile, club, ClubPreferences, ClubPreferencesFile, ClubPrivateTypeIndex, ClubPrivateTypes, ClubProfile, ClubPublicTypeIndex, ClubPublicTypes } from "./helpers/dataSetup";
8
13
 
9
- const ns: SolidNamespace = solidNamespace(rdf);
14
+ window.$SolidTestEnvironment = { username: alice.uri }
15
+ const prefixes = Object.keys(ns).map(prefix => `@prefix ${prefix}: ${ns[prefix]('')}.\n`).join('') // In turtle
10
16
 
11
- const alice = rdf.sym("https://alice.example/profile/card#me");
12
- const bob = rdf.sym("https://bob.example/profile/card#me");
17
+ describe("utilityLogic", () => {
18
+ let store;
19
+ let options;
20
+ let web = {}
21
+ let requests = []
22
+ let statustoBeReturned = 200
23
+ let utilityLogic
24
+ beforeEach(() => {
25
+ fetchMock.resetMocks();
26
+ fetchMock.mockResponse("Not Found", {
27
+ status: 404,
28
+ });
29
+ requests = []
30
+ statustoBeReturned = 200
31
+ const init = { headers: { "Content-Type": "text/turtle" } } // Fetch options tend to be called this
13
32
 
14
- describe("Utility logic", () => {
15
- let util;
16
- let store;
17
- let fetcher;
18
- beforeEach(() => {
19
- fetchMock.resetMocks();
20
- fetchMock.mockResponse("Not Found", {
21
- status: 404,
22
- });
23
- fetcher = { fetch: fetchMock };
24
- store = rdf.graph();
25
- store.fetcher = rdf.fetcher(store, fetcher);
26
- store.updater = new UpdateManager(store);
27
- util = new UtilityLogic(store, ns, fetcher);
28
- });
33
+ fetchMock.mockIf(/^https?.*$/, async req => {
29
34
 
30
- describe("getArchiveUrl", () => {
31
- it("produces the right URL in February", () => {
32
- const url = util.getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('7 Feb 2062 UTC'));
33
- expect(url).toEqual('https://example.com/inbox/archive/2062/02/07/asdf-qwer-asdf-qwer');
34
- });
35
- it("produces the right URL in November", () => {
36
- const url = util.getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('12 Nov 2012 UTC'));
37
- expect(url).toEqual('https://example.com/inbox/archive/2012/11/12/asdf-qwer-asdf-qwer');
38
- });
39
- });
40
- describe("getContainerMembers", () => {
41
- describe("When container is empty", () => {
42
- let result;
43
- beforeEach(async () => {
44
- containerIsEmpty();
45
- result = await util.getContainerMembers('https://container.com/');
46
- });
47
- it("Resolves to an empty array", () => {
48
- expect(result).toEqual([]);
49
- });
50
- });
51
- describe("When container has some containment triples", () => {
52
- let result;
53
- beforeEach(async () => {
54
- containerHasSomeContainmentTriples();
55
- result = await util.getContainerMembers('https://container.com/');
56
- });
57
- it("Resolves to an array with some URLs", () => {
58
- expect(result.sort()).toEqual([
59
- 'https://container.com/foo.txt',
60
- 'https://container.com/bar/'
61
- ].sort());
62
- });
63
- });
64
- });
65
- describe("setSinglePeerAccess", () => {
66
- beforeEach(() => {
67
- fetchMock.mockOnceIf(
68
- "https://owner.com/some/resource",
69
- "hello", {
70
- headers: {
71
- Link: '<https://owner.com/some/acl>; rel="acl"'
72
- }
73
- });
74
- fetchMock.mockOnceIf(
75
- "https://owner.com/some/acl",
76
- "Created", {
77
- status: 201
78
- });
79
- });
80
- it("Creates the right ACL doc", async () => {
81
- await util.setSinglePeerAccess({
82
- ownerWebId: "https://owner.com/#me",
83
- peerWebId: "https://peer.com/#me",
84
- accessToModes: "acl:Read, acl:Control",
85
- defaultModes: "acl:Write",
86
- target: "https://owner.com/some/resource"
87
- });
88
- expect(fetchMock.mock.calls).toEqual([
89
- [ "https://owner.com/some/resource", fetchMock.mock.calls[0][1] ],
90
- [ "https://owner.com/some/acl", {
91
- body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
92
- '\n' +
93
- '<#alice> a acl:Authorization;\n' +
94
- ' acl:agent <https://owner.com/#me>;\n' +
95
- ' acl:accessTo <https://owner.com/some/resource>;\n' +
96
- ' acl:default <https://owner.com/some/resource>;\n' +
97
- ' acl:mode acl:Read, acl:Write, acl:Control.\n' +
98
- '<#bobAccessTo> a acl:Authorization;\n' +
99
- ' acl:agent <https://peer.com/#me>;\n' +
100
- ' acl:accessTo <https://owner.com/some/resource>;\n' +
101
- ' acl:mode acl:Read, acl:Control.\n' +
102
- '<#bobDefault> a acl:Authorization;\n' +
103
- ' acl:agent <https://peer.com/#me>;\n' +
104
- ' acl:default <https://owner.com/some/resource>;\n' +
105
- ' acl:mode acl:Write.\n',
106
- headers: [
107
- ["Content-Type", "text/turtle"]
108
- ],
109
- method: "PUT"
110
- }]
111
- ]);
35
+ if (req.method !== 'GET') {
36
+ requests.push(req)
37
+ if (req.method === 'PUT') {
38
+ const contents = await req.text()
39
+ web[req.url] = contents // Update our dummy web
40
+ console.log(`Tetst: Updated ${req.url} on PUT to <<<${web[req.url]}>>>`)
41
+ }
42
+ return { status: statustoBeReturned }
43
+ }
44
+ const contents = web[req.url]
45
+ if (contents !== undefined) { //
46
+ return {
47
+ body: prefixes + contents, // Add namespaces to anything
48
+ status: 200,
49
+ headers: {
50
+ "Content-Type": "text/turtle",
51
+ "WAC-Allow": 'user="write", public="read"',
52
+ "Accept-Patch": "application/sparql-update"
53
+ }
54
+ }
55
+ } // if contents
56
+ return {
57
+ status: 404,
58
+ body: 'Not Found'
59
+ }
60
+ })
61
+ web = {}
62
+ web[alice.doc().uri] = AliceProfile
63
+ web[AlicePreferencesFile.uri] = AlicePreferences
64
+ web[AlicePrivateTypeIndex.uri] = AlicePrivateTypes
65
+ web[AlicePublicTypeIndex.uri] = AlicePublicTypes
66
+ web[AlicePhotoFolder.uri] = AlicePhotos
67
+ web[bob.doc().uri] = BobProfile
68
+
69
+ web[club.doc().uri] = ClubProfile
70
+ web[ClubPreferencesFile.uri] = ClubPreferences
71
+ web[ClubPrivateTypeIndex.uri] = ClubPrivateTypes
72
+ web[ClubPublicTypeIndex.uri] = ClubPublicTypes
73
+
74
+ options = { fetch: fetch };
75
+ store = new Store()
76
+ store.fetcher = new Fetcher(store, options);
77
+ store.updater = new UpdateManager(store);
78
+ requests = []
79
+ utilityLogic = createUtilityLogic(store, createAclLogic(store), createContainerLogic(store))
112
80
  });
113
- });
114
- function containerIsEmpty() {
115
- fetchMock.mockOnceIf(
116
- "https://container.com/",
117
- " ", // FIXME: https://github.com/jefflau/jest-fetch-mock/issues/189
118
- {
119
- headers: { "Content-Type": "text/turtle" },
120
- }
121
- );
122
- }
123
81
 
124
- function containerHasSomeContainmentTriples() {
125
- fetchMock.mockOnceIf(
126
- "https://container.com/",
127
- "<.> <http://www.w3.org/ns/ldp#contains> <./foo.txt>, <./bar/> .",
128
- {
129
- headers: { "Content-Type": "text/turtle" },
130
- }
131
- );
132
- }
133
- });
82
+ describe('loadOrCreateIfNotExists', () => {
83
+ it('exists', () => {
84
+ expect(utilityLogic.loadOrCreateIfNotExists).toBeInstanceOf(Function)
85
+ })
86
+ it('does nothing if existing file', async () => {
87
+ const result = await utilityLogic.loadOrCreateIfNotExists(alice.doc())
88
+ expect(requests).toEqual([])
89
+
90
+ })
91
+ it('creates empty file if did not exist', async () => {
92
+ const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
93
+ const result = await utilityLogic.loadOrCreateIfNotExists(sym(suggestion))
94
+ expect(requests[0].method).toEqual('PUT')
95
+ expect(requests[0].url).toEqual(suggestion)
96
+ })
97
+ })
98
+
99
+ describe('followOrCreateLink', () => {
100
+ it('exists', () => {
101
+ expect(utilityLogic.followOrCreateLink).toBeInstanceOf(Function)
102
+ })
103
+ it('follows existing link', async () => {
104
+ const suggestion = 'https://alice.example.com/settings/prefsSuggestion.ttl'
105
+ const result = await utilityLogic.followOrCreateLink(alice, ns.space('preferencesFile'), sym(suggestion), alice.doc())
106
+ expect(result).toEqual(AlicePreferencesFile)
107
+
108
+ })
109
+ it('creates empty file if did not exist and new link', async () => {
110
+ const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
111
+ const result = await utilityLogic.followOrCreateLink(bob, ns.space('preferencesFile'), sym(suggestion), bob.doc())
112
+ expect(result).toEqual(sym(suggestion))
113
+ expect(requests[0].method).toEqual('PATCH')
114
+ expect(requests[0].url).toEqual(bob.doc().uri)
115
+ expect(requests[1].method).toEqual('PUT')
116
+ expect(requests[1].url).toEqual(suggestion)
117
+ expect(store.holds(bob, ns.space('preferencesFile'), sym(suggestion), bob.doc())).toEqual(true)
118
+ })
119
+ //
120
+ it('returns null if it cannot create the new file', async () => {
121
+ const suggestion = 'https://bob.example.com/settings/prefsSuggestion.ttl'
122
+ statustoBeReturned = 403 // Unauthorized
123
+ expect(async () => {
124
+ await utilityLogic.followOrCreateLink(bob, ns.space('preferencesFile'), sym(suggestion), bob.doc())
125
+ }).rejects.toThrow(WebOperationError)
126
+ })
127
+
128
+ })
129
+ describe("setSinglePeerAccess", () => {
130
+ beforeEach(() => {
131
+ fetchMock.mockOnceIf(
132
+ "https://owner.com/some/resource",
133
+ "hello", {
134
+ headers: {
135
+ Link: '<https://owner.com/some/acl>; rel="acl"'
136
+ }
137
+ });
138
+ fetchMock.mockOnceIf(
139
+ "https://owner.com/some/acl",
140
+ "Created", {
141
+ status: 201
142
+ });
143
+ });
144
+ it("Creates the right ACL doc", async () => {
145
+ await utilityLogic.setSinglePeerAccess({
146
+ ownerWebId: "https://owner.com/#me",
147
+ peerWebId: "https://peer.com/#me",
148
+ accessToModes: "acl:Read, acl:Control",
149
+ defaultModes: "acl:Write",
150
+ target: "https://owner.com/some/resource"
151
+ });
152
+ expect(fetchMock.mock.calls).toEqual([
153
+ [ "https://owner.com/some/resource", fetchMock.mock.calls[0][1] ],
154
+ [ "https://owner.com/some/acl", {
155
+ body: '@prefix acl: <http://www.w3.org/ns/auth/acl#>.\n' +
156
+ '\n' +
157
+ '<#alice> a acl:Authorization;\n' +
158
+ ' acl:agent <https://owner.com/#me>;\n' +
159
+ ' acl:accessTo <https://owner.com/some/resource>;\n' +
160
+ ' acl:default <https://owner.com/some/resource>;\n' +
161
+ ' acl:mode acl:Read, acl:Write, acl:Control.\n' +
162
+ '<#bobAccessTo> a acl:Authorization;\n' +
163
+ ' acl:agent <https://peer.com/#me>;\n' +
164
+ ' acl:accessTo <https://owner.com/some/resource>;\n' +
165
+ ' acl:mode acl:Read, acl:Control.\n' +
166
+ '<#bobDefault> a acl:Authorization;\n' +
167
+ ' acl:agent <https://peer.com/#me>;\n' +
168
+ ' acl:default <https://owner.com/some/resource>;\n' +
169
+ ' acl:mode acl:Write.\n',
170
+ headers: [
171
+ ["Content-Type", "text/turtle"]
172
+ ],
173
+ method: "PUT"
174
+ }]
175
+ ]);
176
+ });
177
+ });
178
+
179
+ })
@@ -0,0 +1,32 @@
1
+ import * as rdf from "rdflib";
2
+ import { getArchiveUrl, uniqueNodes } from '../src/util/utils';
3
+
4
+ describe('utils', () => {
5
+ describe('uniqueNodes', () => {
6
+ it('exists', () => {
7
+ expect(uniqueNodes).toBeInstanceOf(Function)
8
+ })
9
+ it('removed duplicates', async () => {
10
+ const input = [ rdf.sym('https://a.com/'), rdf.sym('https://b.com/'), rdf.sym('https://a.com/'), rdf.sym('https://a.com/'), rdf.sym('https://c.com/'), ]
11
+ const expected = [ rdf.sym('https://a.com/'), rdf.sym('https://b.com/'), rdf.sym('https://c.com/'), ]
12
+ const result = uniqueNodes(input)
13
+ expect(result).toEqual(expected)
14
+
15
+ })
16
+ it('handles an empty array', async () => {
17
+ const result = await uniqueNodes([])
18
+ expect(result).toEqual([])
19
+ })
20
+ })
21
+
22
+ describe("getArchiveUrl", () => {
23
+ it("produces the right URL in February", () => {
24
+ const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('7 Feb 2062 UTC'));
25
+ expect(url).toEqual('https://example.com/inbox/archive/2062/02/07/asdf-qwer-asdf-qwer');
26
+ });
27
+ it("produces the right URL in November", () => {
28
+ const url = getArchiveUrl('https://example.com/inbox/asdf-qwer-asdf-qwer', new Date('12 Nov 2012 UTC'));
29
+ expect(url).toEqual('https://example.com/inbox/archive/2012/11/12/asdf-qwer-asdf-qwer');
30
+ });
31
+ })
32
+ })
@@ -1,26 +0,0 @@
1
- import { NamedNode, LiveStore } from "rdflib";
2
- import { ProfileLogic } from "../profile/ProfileLogic";
3
- import { SolidNamespace } from "../types";
4
- /**
5
- * Chat-related logic
6
- */
7
- export declare class ChatLogic {
8
- store: LiveStore;
9
- ns: SolidNamespace;
10
- profile: ProfileLogic;
11
- constructor(store: LiveStore, ns: SolidNamespace, profile: ProfileLogic);
12
- setAcl(chatContainer: NamedNode, me: NamedNode, invitee: NamedNode): Promise<void>;
13
- private addToPrivateTypeIndex;
14
- private findChat;
15
- private createChatThing;
16
- private mintNew;
17
- /**
18
- * Find (and optionally create) an individual chat between the current user and the given invitee
19
- * @param invitee - The person to chat with
20
- * @param createIfMissing - Whether the chat should be created, if missing
21
- * @returns null if missing, or a node referring to an already existing chat, or the newly created chat
22
- */
23
- getChat(invitee: NamedNode, createIfMissing?: boolean): Promise<NamedNode | null>;
24
- private sendInvite;
25
- }
26
- //# sourceMappingURL=ChatLogic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatLogic.d.ts","sourceRoot":"","sources":["../../src/chat/ChatLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAgB1C;;GAEG;AACH,qBAAa,SAAS;IACpB,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;gBAEV,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY;IAMjE,MAAM,CACV,aAAa,EAAE,SAAS,EACxB,EAAE,EAAE,SAAS,EACb,OAAO,EAAE,SAAS,GACjB,OAAO,CAAC,IAAI,CAAC;YAsCF,qBAAqB;YAqCrB,QAAQ;YAeR,eAAe;IAW7B,OAAO,CAAC,OAAO;IAoDf;;;;;OAKG;IACG,OAAO,CACX,OAAO,EAAE,SAAS,EAClB,eAAe,UAAO,GACrB,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;YAgBd,UAAU;CA6BzB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ChatLogic.js","sourceRoot":"","sources":["../../src/chat/ChatLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8D;AAG9D,mCAAuC;AACvC,mEAAkE;AAElE,IAAM,0BAA0B,GAAG,gBAAgB,CAAC;AAYpD;;GAEG;AACH;IAKE,m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AK,CAAE,CAAC,CAAC;yBAC9D;wBACK,UAAU,GAAG,sEAErB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,eAAK,SAAS,CAAC,KAAK,YACzC,CAAC;wBAEuB,qBAAM,CAAA,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,0CAAE,YAAY,CAC3D,MAAM,EACN,YAAY,CAAC,KAAK,EAClB;gCACE,IAAI,EAAE,UAAU;gCAChB,WAAW,EAAE,aAAa;6BAC3B,CACF,CAAA,EAAA;;wBAPK,cAAc,GAAG,SAOtB;wBACK,WAAW,GAAG,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;wBAC5D,IAAI,CAAC,WAAW,EAAE;4BAChB,MAAM,IAAI,KAAK,CAAC,oCAA6B,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,CAAE,CAAC,CAAC;yBACxE;;;;;KACF;IACH,gBAAC;AAAD,CAAC,AA9ND,IA8NC;AA9NY,8BAAS"}
@@ -1,3 +0,0 @@
1
- import { NamedNode } from "rdflib";
2
- export declare function determineChatContainer(invitee: NamedNode, podRoot: NamedNode): NamedNode;
3
- //# sourceMappingURL=determineChatContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"determineChatContainer.d.ts","sourceRoot":"","sources":["../../src/chat/determineChatContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,EAClB,OAAO,EAAE,SAAS,GACjB,SAAS,CAQX"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.determineChatContainer = void 0;
4
- var rdflib_1 = require("rdflib");
5
- function determineChatContainer(invitee, podRoot) {
6
- // Create chat
7
- // See https://gitter.im/solid/chat-app?at=5f3c800f855be416a23ae74a
8
- var chatContainerStr = new URL("IndividualChats/".concat(new URL(invitee.value).host, "/"), podRoot.value).toString();
9
- return new rdflib_1.NamedNode(chatContainerStr);
10
- }
11
- exports.determineChatContainer = determineChatContainer;
12
- //# sourceMappingURL=determineChatContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"determineChatContainer.js","sourceRoot":"","sources":["../../src/chat/determineChatContainer.ts"],"names":[],"mappings":";;;AAAA,iCAAmC;AAEnC,SAAgB,sBAAsB,CACpC,OAAkB,EAClB,OAAkB;IAElB,cAAc;IACd,mEAAmE;IACnE,IAAM,gBAAgB,GAAG,IAAI,GAAG,CAC9B,0BAAmB,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,MAAG,EACjD,OAAO,CAAC,KAAK,CACd,CAAC,QAAQ,EAAE,CAAC;IACb,OAAO,IAAI,kBAAS,CAAC,gBAAgB,CAAC,CAAC;AACzC,CAAC;AAXD,wDAWC"}
@@ -1,13 +0,0 @@
1
- import { NamedNode, LiveStore } from "rdflib";
2
- declare type TypeIndex = {
3
- label: string;
4
- index: NamedNode;
5
- agent: NamedNode;
6
- };
7
- export declare function loadProfile(store: LiveStore, user: any): Promise<any>;
8
- export declare function loadPreferences(store: LiveStore, user: any): Promise<NamedNode | undefined>;
9
- export declare function loadTypeIndexesFor(store: LiveStore, user: NamedNode): Promise<Array<TypeIndex>>;
10
- export declare function loadCommunityTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndex[][]>;
11
- export declare function loadAllTypeIndexes(store: LiveStore, user: NamedNode): Promise<TypeIndex[]>;
12
- export {};
13
- //# sourceMappingURL=discoveryLogic.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discoveryLogic.d.ts","sourceRoot":"","sources":["../../src/discovery/discoveryLogic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEzD,aAAK,SAAS,GAAG;IAAG,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAE;AAOzE,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,KAAA,gBAUvD;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,KAAA,GAAG,OAAO,CAAE,SAAS,GAAG,SAAS,CAAE,CAc9F;AAED,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAqBpG;AAED,wBAAsB,wBAAwB,CAAE,KAAK,EAAC,SAAS,EAAE,IAAI,EAAC,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAmBvG;AAED,wBAAsB,kBAAkB,CAAE,KAAK,EAAC,SAAS,EAAE,IAAI,EAAC,SAAS,wBAExE"}
@@ -1,203 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.loadAllTypeIndexes = exports.loadCommunityTypeIndexes = exports.loadTypeIndexesFor = exports.loadPreferences = exports.loadProfile = void 0;
40
- var rdflib_1 = require("rdflib");
41
- var ns = {
42
- solid: (0, rdflib_1.Namespace)('http://www.w3.org/ns/solid/terms#'),
43
- space: (0, rdflib_1.Namespace)('http://www.w3.org/ns/pim/space#')
44
- };
45
- function loadProfile(store, user) {
46
- return __awaiter(this, void 0, void 0, function () {
47
- var err_1;
48
- return __generator(this, function (_a) {
49
- switch (_a.label) {
50
- case 0:
51
- if (!user) {
52
- throw new Error("loadProfile: no user given.");
53
- }
54
- _a.label = 1;
55
- case 1:
56
- _a.trys.push([1, 3, , 4]);
57
- return [4 /*yield*/, store.fetcher.load(user.doc())];
58
- case 2:
59
- _a.sent();
60
- return [3 /*break*/, 4];
61
- case 3:
62
- err_1 = _a.sent();
63
- throw new Error("Unable to load profile of user <".concat(user, ">: ").concat(err_1));
64
- case 4: return [2 /*return*/, user.doc()];
65
- }
66
- });
67
- });
68
- }
69
- exports.loadProfile = loadProfile;
70
- function loadPreferences(store, user) {
71
- return __awaiter(this, void 0, void 0, function () {
72
- var profile, preferencesFile;
73
- return __generator(this, function (_a) {
74
- switch (_a.label) {
75
- case 0: return [4 /*yield*/, loadProfile(store, user)];
76
- case 1:
77
- profile = _a.sent();
78
- preferencesFile = store.any(user, ns.space('preferencesFile'), undefined, profile);
79
- if (!preferencesFile) {
80
- // throw new Error(`USer ${user} has no pointer in profile to preferences file.`)
81
- return [2 /*return*/, undefined];
82
- }
83
- try {
84
- store.fetcher.load(preferencesFile);
85
- }
86
- catch (err) { // Mabeb a permission propblem or origin problem
87
- return [2 /*return*/, undefined
88
- // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
89
- ];
90
- // throw new Error(`Unable to load preferences file ${preferencesFile} of user <${user}>: ${err}`)
91
- }
92
- return [2 /*return*/, preferencesFile];
93
- }
94
- });
95
- });
96
- }
97
- exports.loadPreferences = loadPreferences;
98
- function loadTypeIndexesFor(store, user) {
99
- return __awaiter(this, void 0, void 0, function () {
100
- var profile, publicTypeIndex, _a, pub, preferencesFile, privateTypeIndexes, priv;
101
- return __generator(this, function (_b) {
102
- switch (_b.label) {
103
- case 0:
104
- if (!user)
105
- throw new Error("loadTypeIndexesFor: No user given");
106
- return [4 /*yield*/, loadProfile(store, user)];
107
- case 1:
108
- profile = _b.sent();
109
- publicTypeIndex = store.any(user, ns.solid('publicTypeIndex'), undefined, profile);
110
- if (!publicTypeIndex) return [3 /*break*/, 5];
111
- _b.label = 2;
112
- case 2:
113
- _b.trys.push([2, 4, , 5]);
114
- return [4 /*yield*/, store.fetcher.load(publicTypeIndex)];
115
- case 3:
116
- _b.sent();
117
- return [3 /*break*/, 5];
118
- case 4:
119
- _a = _b.sent();
120
- return [3 /*break*/, 5];
121
- case 5:
122
- pub = publicTypeIndex ? [{ label: 'public', index: publicTypeIndex, agent: user }] : [];
123
- return [4 /*yield*/, loadPreferences(store, user)];
124
- case 6:
125
- preferencesFile = _b.sent();
126
- if (preferencesFile) { // watch out - can be in either as spec was not clear
127
- privateTypeIndexes = store.each(user, ns.solid('privateTypeIndex'), undefined, preferencesFile)
128
- .concat(store.each(user, ns.solid('privateTypeIndex'), undefined, profile));
129
- priv = privateTypeIndexes.length > 0 ? [{ label: 'priSo @@@@@vate', index: privateTypeIndexes[0], agent: user }] : [];
130
- return [2 /*return*/, pub.concat(priv)];
131
- }
132
- return [2 /*return*/, pub];
133
- }
134
- });
135
- });
136
- }
137
- exports.loadTypeIndexesFor = loadTypeIndexesFor;
138
- function loadCommunityTypeIndexes(store, user) {
139
- return __awaiter(this, void 0, void 0, function () {
140
- var preferencesFile, communities, communityTypeIndexesPromise, result1;
141
- var _this = this;
142
- return __generator(this, function (_a) {
143
- switch (_a.label) {
144
- case 0: return [4 /*yield*/, loadPreferences(store, user)];
145
- case 1:
146
- preferencesFile = _a.sent();
147
- if (preferencesFile) {
148
- communities = store.each(user, ns.solid('community'), undefined, preferencesFile);
149
- communityTypeIndexesPromise = communities.map(function (community) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
150
- switch (_a.label) {
151
- case 0: return [4 /*yield*/, loadTypeIndexesFor(store, community)];
152
- case 1: return [2 /*return*/, _a.sent()];
153
- }
154
- }); }); });
155
- result1 = Promise.all(communityTypeIndexesPromise);
156
- // const result2 = Promise.all(result1)
157
- // const flat = result2.flat()
158
- return [2 /*return*/, result1
159
- // const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
160
- /*
161
- let result = [] as TypeIndex[]
162
- for(const community of communities) {
163
- result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
164
- }
165
- */
166
- // return communityTypeIndexesPromise.resolve()
167
- ];
168
- // const communityTypeIndexes = await Promise.all(communityTypeIndexesPromise)
169
- /*
170
- let result = [] as TypeIndex[]
171
- for(const community of communities) {
172
- result = result.concat(await loadTypeIndexesFor(store, community as NamedNode)) as TypeIndex[] // @@ how oto make functional with async?
173
- }
174
- */
175
- // return communityTypeIndexesPromise.resolve()
176
- }
177
- return [2 /*return*/, []];
178
- }
179
- });
180
- });
181
- }
182
- exports.loadCommunityTypeIndexes = loadCommunityTypeIndexes;
183
- function loadAllTypeIndexes(store, user) {
184
- return __awaiter(this, void 0, void 0, function () {
185
- var _a, _b;
186
- return __generator(this, function (_c) {
187
- switch (_c.label) {
188
- case 0: return [4 /*yield*/, loadTypeIndexesFor(store, user)];
189
- case 1:
190
- _b = (_a = (_c.sent())).concat;
191
- return [4 /*yield*/, loadCommunityTypeIndexes(store, user)];
192
- case 2: return [2 /*return*/, _b.apply(_a, [(_c.sent()).flat()])];
193
- }
194
- });
195
- });
196
- }
197
- exports.loadAllTypeIndexes = loadAllTypeIndexes;
198
- /*
199
- export async function getAppInstances (store:LiveStore, klass: NamedNode) {
200
-
201
- }
202
- */
203
- //# sourceMappingURL=discoveryLogic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"discoveryLogic.js","sourceRoot":"","sources":["../../src/discovery/discoveryLogic.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAAyD;AAIzD,IAAM,EAAE,GAAE;IACR,KAAK,EAAE,IAAA,kBAAS,EAAC,mCAAmC,CAAC;IACrD,KAAK,EAAE,IAAA,kBAAS,EAAC,iCAAiC,CAAC;CACpD,CAAA;AAED,SAAsB,WAAW,CAAC,KAAgB,EAAE,IAAI;;;;;;oBACtD,IAAI,CAAC,IAAI,EAAE;wBACT,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;qBAC/C;;;;oBAEC,qBAAM,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,C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