solid-logic 3.0.9-f51524a8 → 3.0.9-fa4d7e8

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 (100) hide show
  1. package/eslint.config.js +24 -23
  2. package/jest.config.js +8 -15
  3. package/lib/acl/aclLogic.d.ts +2 -2
  4. package/lib/acl/aclLogic.d.ts.map +1 -1
  5. package/lib/acl/aclLogic.js +168 -0
  6. package/lib/acl/aclLogic.js.map +1 -0
  7. package/lib/authSession/authSession.js +8 -0
  8. package/lib/authSession/authSession.js.map +1 -0
  9. package/lib/authn/SolidAuthnLogic.d.ts +3 -3
  10. package/lib/authn/SolidAuthnLogic.d.ts.map +1 -1
  11. package/lib/authn/SolidAuthnLogic.js +191 -0
  12. package/lib/authn/SolidAuthnLogic.js.map +1 -0
  13. package/lib/authn/authUtil.d.ts +1 -1
  14. package/lib/authn/authUtil.js +105 -0
  15. package/lib/authn/authUtil.js.map +1 -0
  16. package/lib/chat/chatLogic.d.ts +1 -1
  17. package/lib/chat/chatLogic.js +272 -0
  18. package/lib/chat/chatLogic.js.map +1 -0
  19. package/lib/inbox/inboxLogic.d.ts +1 -1
  20. package/lib/inbox/inboxLogic.d.ts.map +1 -1
  21. package/lib/inbox/inboxLogic.js +139 -0
  22. package/lib/inbox/inboxLogic.js.map +1 -0
  23. package/lib/index.d.ts +2 -1
  24. package/lib/index.d.ts.map +1 -1
  25. package/lib/index.js +31 -0
  26. package/lib/index.js.map +1 -0
  27. package/lib/issuer/issuerLogic.js +52 -0
  28. package/lib/issuer/issuerLogic.js.map +1 -0
  29. package/lib/logic/CustomError.d.ts.map +1 -1
  30. package/lib/logic/CustomError.js +89 -0
  31. package/lib/logic/CustomError.js.map +1 -0
  32. package/lib/logic/solidLogic.d.ts +2 -2
  33. package/lib/logic/solidLogic.d.ts.map +1 -1
  34. package/lib/logic/solidLogic.js +102 -0
  35. package/lib/logic/solidLogic.js.map +1 -0
  36. package/lib/logic/solidLogicSingleton.js +94 -0
  37. package/lib/logic/solidLogicSingleton.js.map +1 -0
  38. package/lib/profile/profileLogic.d.ts +1 -1
  39. package/lib/profile/profileLogic.js +259 -0
  40. package/lib/profile/profileLogic.js.map +1 -0
  41. package/lib/typeIndex/typeIndexLogic.js +399 -0
  42. package/lib/typeIndex/typeIndexLogic.js.map +1 -0
  43. package/lib/types.d.ts +2 -2
  44. package/lib/types.js +3 -0
  45. package/lib/types.js.map +1 -0
  46. package/lib/util/containerLogic.d.ts +1 -1
  47. package/lib/util/containerLogic.d.ts.map +1 -1
  48. package/lib/util/containerLogic.js +102 -0
  49. package/lib/util/containerLogic.js.map +1 -0
  50. package/lib/util/debug.d.ts.map +1 -1
  51. package/lib/util/debug.js +40 -0
  52. package/lib/util/debug.js.map +1 -0
  53. package/lib/util/ns.js +44 -0
  54. package/lib/util/ns.js.map +1 -0
  55. package/lib/util/utilityLogic.d.ts +1 -1
  56. package/lib/util/utilityLogic.d.ts.map +1 -1
  57. package/lib/util/utilityLogic.js +284 -0
  58. package/lib/util/utilityLogic.js.map +1 -0
  59. package/lib/util/utils.d.ts +1 -1
  60. package/lib/util/utils.d.ts.map +1 -1
  61. package/lib/util/utils.js +47 -0
  62. package/lib/util/utils.js.map +1 -0
  63. package/package.json +15 -38
  64. package/src/acl/aclLogic.ts +8 -8
  65. package/src/authn/SolidAuthnLogic.ts +6 -6
  66. package/src/authn/authUtil.ts +1 -1
  67. package/src/chat/chatLogic.ts +75 -75
  68. package/src/inbox/inboxLogic.ts +19 -19
  69. package/src/index.ts +2 -1
  70. package/src/logic/CustomError.ts +6 -6
  71. package/src/logic/solidLogic.ts +22 -22
  72. package/src/logic/solidLogicSingleton.ts +3 -3
  73. package/src/profile/profileLogic.ts +22 -22
  74. package/src/typeIndex/typeIndexLogic.ts +7 -7
  75. package/src/types.ts +2 -2
  76. package/src/util/containerLogic.ts +15 -15
  77. package/src/util/debug.ts +8 -4
  78. package/src/util/utilityLogic.ts +18 -18
  79. package/src/util/utils.ts +12 -12
  80. package/test/aclLogic.test.ts +5 -5
  81. package/test/authUtil.test.ts +1 -1
  82. package/test/chatLogic.test.ts +154 -160
  83. package/test/container.test.ts +23 -23
  84. package/test/helpers/dataSetup.ts +1 -2
  85. package/test/helpers/setup.ts +3 -8
  86. package/test/inboxLogic.test.ts +110 -101
  87. package/test/logic.test.ts +2 -2
  88. package/test/profileLogic.test.ts +33 -35
  89. package/test/solidAuthLogic.test.ts +1 -1
  90. package/test/typeIndexLogic.test.ts +71 -71
  91. package/test/utilityLogic.test.ts +45 -46
  92. package/test/utils.test.ts +11 -11
  93. package/tsconfig.json +3 -5
  94. package/babel.config.js +0 -6
  95. package/lib/solid-logic.js +0 -107
  96. package/lib/solid-logic.js.map +0 -1
  97. package/rollup.config.js +0 -29
  98. package/src/versionInfo.ts +0 -32
  99. package/timestamp.sh +0 -13
  100. package/tsconfig.test.json +0 -8
@@ -1,4 +1,4 @@
1
- import { NamedNode, Statement, sym } from 'rdflib'
1
+ import { NamedNode, Statement, sym } from "rdflib";
2
2
 
3
3
  /**
4
4
  * Container-related class
@@ -9,40 +9,40 @@ export function createContainerLogic(store) {
9
9
  return store
10
10
  .statementsMatching(
11
11
  containerNode,
12
- sym('http://www.w3.org/ns/ldp#contains'),
12
+ sym("http://www.w3.org/ns/ldp#contains"),
13
13
  undefined
14
14
  )
15
- .map((st: Statement) => st.object as NamedNode)
15
+ .map((st: Statement) => st.object as NamedNode);
16
16
  }
17
17
 
18
18
  function isContainer(url: NamedNode) {
19
- const nodeToString = url.value
20
- return nodeToString.charAt(nodeToString.length - 1) === '/'
19
+ const nodeToString = url.value;
20
+ return nodeToString.charAt(nodeToString.length - 1) === "/";
21
21
  }
22
22
 
23
23
  async function createContainer(url: string) {
24
- const stringToNode = sym(url)
24
+ const stringToNode = sym(url);
25
25
  if (!isContainer(stringToNode)) {
26
- throw new Error(`Not a container URL ${url}`)
26
+ throw new Error(`Not a container URL ${url}`);
27
27
  }
28
28
  // Copied from https://github.com/solidos/solid-crud-tests/blob/v3.1.0/test/surface/create-container.test.ts#L56-L64
29
29
  const result = await store.fetcher._fetch(url, {
30
- method: 'PUT',
30
+ method: "PUT",
31
31
  headers: {
32
- 'Content-Type': 'text/turtle',
33
- 'If-None-Match': '*',
32
+ "Content-Type": "text/turtle",
33
+ "If-None-Match": "*",
34
34
  Link: '<http://www.w3.org/ns/ldp#BasicContainer>; rel="type"', // See https://github.com/solidos/node-solid-server/issues/1465
35
35
  },
36
- body: ' ', // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
37
- })
36
+ body: " ", // work around https://github.com/michielbdejong/community-server/issues/4#issuecomment-776222863
37
+ });
38
38
  if (result.status.toString()[0] !== '2') {
39
- throw new Error(`Not OK: got ${result.status} response while creating container at ${url}`)
39
+ throw new Error(`Not OK: got ${result.status} response while creating container at ${url}`);
40
40
  }
41
41
  }
42
42
 
43
43
  async function getContainerMembers(containerUrl: NamedNode): Promise<NamedNode[]> {
44
- await store.fetcher.load(containerUrl)
45
- return getContainerElements(containerUrl)
44
+ await store.fetcher.load(containerUrl);
45
+ return getContainerElements(containerUrl);
46
46
  }
47
47
  return {
48
48
  isContainer,
package/src/util/debug.ts CHANGED
@@ -1,16 +1,20 @@
1
1
  /* eslint-disable @typescript-eslint/no-explicit-any */
2
2
  export function log(...args: any[]): void {
3
- console.log(...args)
3
+ // eslint-disable-next-line no-console
4
+ console.log(...args);
4
5
  }
5
6
 
6
7
  export function warn(...args: any[]): void {
7
- console.warn(...args)
8
+ // eslint-disable-next-line no-console
9
+ console.warn(...args);
8
10
  }
9
11
 
10
12
  export function error(...args: any[]): void {
11
- console.error(...args)
13
+ // eslint-disable-next-line no-console
14
+ console.error(...args);
12
15
  }
13
16
 
14
17
  export function trace(...args: any[]): void {
15
- console.trace(...args)
18
+ // eslint-disable-next-line no-console
19
+ console.trace(...args);
16
20
  }
@@ -1,7 +1,7 @@
1
- import { NamedNode, st, sym } from 'rdflib'
2
- import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from '../logic/CustomError'
3
- import * as debug from '../util/debug'
4
- import { differentOrigin } from './utils'
1
+ import { NamedNode, st, sym } from "rdflib";
2
+ import { CrossOriginForbiddenError, FetchError, NotEditableError, SameOriginForbiddenError, UnauthorizedError, WebOperationError } from "../logic/CustomError";
3
+ import * as debug from '../util/debug';
4
+ import { differentOrigin } from "./utils";
5
5
 
6
6
  export function createUtilityLogic(store, aclLogic, containerLogic) {
7
7
 
@@ -9,16 +9,16 @@ export function createUtilityLogic(store, aclLogic, containerLogic) {
9
9
  try {
10
10
  if (containerLogic.isContainer(containerNode)) {
11
11
  const aclDocUrl = await aclLogic.findAclDocUrl(containerNode)
12
- await store.fetcher._fetch(aclDocUrl, { method: 'DELETE' })
13
- const containerMembers = await containerLogic.getContainerMembers(containerNode)
12
+ await store.fetcher._fetch(aclDocUrl, { method: "DELETE" });
13
+ const containerMembers = await containerLogic.getContainerMembers(containerNode);
14
14
  await Promise.all(
15
15
  containerMembers.map((url) => recursiveDelete(url))
16
- )
16
+ );
17
17
  }
18
- const nodeToStringHere = containerNode.value
19
- return store.fetcher._fetch(nodeToStringHere, { method: 'DELETE' })
18
+ const nodeToStringHere = containerNode.value;
19
+ return store.fetcher._fetch(nodeToStringHere, { method: "DELETE" })
20
20
  } catch (e) {
21
- debug.log(`Please manually remove ${containerNode.value} from your system.`, e)
21
+ debug.log(`Please manually remove ${containerNode.value} from your system.`, e);
22
22
  }
23
23
  }
24
24
 
@@ -43,13 +43,13 @@ export function createUtilityLogic(store, aclLogic, containerLogic) {
43
43
  await store.fetcher.load(doc)
44
44
  } else {
45
45
  if (err.response.status === 401) {
46
- throw new UnauthorizedError()
46
+ throw new UnauthorizedError();
47
47
  }
48
48
  if (err.response.status === 403) {
49
49
  if (differentOrigin(doc)) {
50
- throw new CrossOriginForbiddenError()
50
+ throw new CrossOriginForbiddenError();
51
51
  }
52
- throw new SameOriginForbiddenError()
52
+ throw new SameOriginForbiddenError();
53
53
  }
54
54
  const msg = 'createIfNotExists doc load error NOT 404: ' + doc + ': ' + err
55
55
  throw new FetchError(err.status, err.message + msg)
@@ -87,7 +87,7 @@ export function createUtilityLogic(store, aclLogic, containerLogic) {
87
87
  // store.fetcher.webOperation('PUT', object, { data: '', contentType: 'text/turtle'})
88
88
  } catch (err) {
89
89
  debug.warn(`followOrCreateLink: Error loading or saving new linked document: ${object}: ${err}`)
90
- throw err
90
+ throw err;
91
91
  }
92
92
  return object
93
93
  }
@@ -134,15 +134,15 @@ export function createUtilityLogic(store, aclLogic, containerLogic) {
134
134
  headers: [
135
135
  ['Content-Type', 'text/turtle']
136
136
  ]
137
- })
137
+ });
138
138
  }
139
139
 
140
140
  async function createEmptyRdfDoc(doc: NamedNode, comment: string) {
141
- await store.fetcher.webOperation('PUT', doc.uri, {
141
+ await store.fetcher.webOperation("PUT", doc.uri, {
142
142
  data: `# ${new Date()} ${comment}
143
143
  `,
144
- contentType: 'text/turtle',
145
- })
144
+ contentType: "text/turtle",
145
+ });
146
146
  }
147
147
 
148
148
  return {
package/src/util/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { NamedNode, sym } from 'rdflib'
1
+ import { NamedNode, sym } from "rdflib";
2
2
 
3
3
  export function newThing(doc: NamedNode): NamedNode {
4
- return sym(doc.uri + '#' + 'id' + ('' + Date.now()))
4
+ return sym(doc.uri + "#" + "id" + ("" + Date.now()));
5
5
  }
6
6
 
7
7
  export function uniqueNodes (arr: NamedNode[]): NamedNode[] {
@@ -13,21 +13,21 @@ export function uniqueNodes (arr: NamedNode[]): NamedNode[] {
13
13
  }
14
14
 
15
15
  export function getArchiveUrl(baseUrl: string, date: Date) {
16
- const year = date.getUTCFullYear()
17
- const month = ('0' + (date.getUTCMonth()+1)).slice(-2)
18
- const day = ('0' + (date.getUTCDate())).slice(-2)
19
- const parts = baseUrl.split('/')
20
- const filename = parts[parts.length -1 ]
21
- return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString()
16
+ const year = date.getUTCFullYear();
17
+ const month = ('0' + (date.getUTCMonth()+1)).slice(-2);
18
+ const day = ('0' + (date.getUTCDate())).slice(-2);
19
+ const parts = baseUrl.split('/');
20
+ const filename = parts[parts.length -1 ];
21
+ return new URL(`./archive/${year}/${month}/${day}/${filename}`, baseUrl).toString();
22
22
  }
23
23
 
24
24
  export function differentOrigin(doc): boolean {
25
25
  if (!doc) {
26
- return true
26
+ return true;
27
27
  }
28
28
  return (
29
29
  `${window.location.origin}/` !== new URL(doc.value).origin
30
- )
30
+ );
31
31
  }
32
32
 
33
33
  export function suggestPreferencesFile (me:NamedNode) {
@@ -47,6 +47,6 @@ export function determineChatContainer(
47
47
  const chatContainerStr = new URL(
48
48
  `IndividualChats/${new URL(invitee.value).host}/`,
49
49
  podRoot.value
50
- ).toString()
51
- return new NamedNode(chatContainerStr)
50
+ ).toString();
51
+ return new NamedNode(chatContainerStr);
52
52
  }
@@ -1,14 +1,14 @@
1
- import { Fetcher, Store, sym, UpdateManager } from 'rdflib'
2
- import { createAclLogic } from '../src/acl/aclLogic'
1
+ import { Fetcher, Store, sym, UpdateManager } from 'rdflib';
2
+ import { createAclLogic } from '../src/acl/aclLogic';
3
3
 
4
4
  describe('setACLUserPublic', () => {
5
5
  let aclLogic
6
6
  let store
7
7
  beforeAll(() => {
8
- const options = { fetch: fetch }
8
+ const options = { fetch: fetch };
9
9
  store = new Store()
10
- store.fetcher = new Fetcher(store, options)
11
- store.updater = new UpdateManager(store)
10
+ store.fetcher = new Fetcher(store, options);
11
+ store.updater = new UpdateManager(store);
12
12
  aclLogic = createAclLogic(store)
13
13
  })
14
14
  it('exists', () => {
@@ -18,6 +18,6 @@ describe('appContext', () => {
18
18
  expect(authUtil.appContext).toBeInstanceOf(Function)
19
19
  })
20
20
  it('runs', () => {
21
- expect(authUtil.appContext()).toEqual({'viewingNoAuthPage': false,})
21
+ expect(authUtil.appContext()).toEqual({"viewingNoAuthPage": false,})
22
22
  })
23
23
  })