Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 5856f17

Browse files
authored
Merge pull request #266 from inrupt/release/0.5.4
Release/0.5.4
2 parents dd2008b + dd12bf5 commit 5856f17

62 files changed

Lines changed: 2611 additions & 2329 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
# misc
1515
.DS_Store
16-
.idea
1716
.env.local
1817
.env.development.local
1918
.env.test.local
2019
.env.production.local
2120

2221
# editors
2322
.idea
23+
*.iml
2424

2525
npm-debug.log*
2626
yarn-debug.log*

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v12.7.0

package-lock.json

Lines changed: 2281 additions & 1912 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,23 @@
5757
"license": "MIT",
5858
"dependencies": {
5959
"@babel/runtime": "^7.1.2",
60+
"@inrupt/lit-generated-vocab-common": "^0.3.9",
61+
"@inrupt/lit-generated-vocab-inrupt-common": "^0.3.9",
62+
"@inrupt/lit-generated-vocab-solid-common": "^0.3.9",
6063
"@inrupt/solid-sdk-forms": "0.1.1",
6164
"@rdfjs/data-model": "^1.1.1",
6265
"@shexjs/core": "^1.0.0-alpha.9",
6366
"@shexjs/loader": "^1.0.0-alpha.5",
6467
"@shexjs/parser": "^1.0.0-alpha.4",
6568
"@solid/query-ldflex": "^2.6.0",
6669
"@solid/react": "^1.10.0",
67-
"date-fns": "^2.8.0",
70+
"date-fns": "^2.14.0",
6871
"file-type": "^10.7.1",
6972
"html-webpack-include-assets-plugin": "^1.0.6",
7073
"jsonld": "^1.6.2",
7174
"ldflex": "^2.4.0",
7275
"lodash": "^4.17.15",
73-
"mime-types": "^2.1.24",
76+
"mime-types": "^2.1.27",
7477
"n3": "^1.1.1",
7578
"parse-link-header": "^1.0.1",
7679
"react-color": "^2.17.3",
@@ -93,8 +96,8 @@
9396
"@storybook/addons": "^5.0.5",
9497
"@storybook/react": "^5.0.11",
9598
"@svgr/webpack": "2.4.1",
96-
"@testing-library/jest-dom": "^5.1.1",
97-
"@testing-library/react": "^10.0.1",
99+
"@testing-library/jest-dom": "^5.9.0",
100+
"@testing-library/react": "^10.0.5",
98101
"@testing-library/react-hooks": "^3.2.1",
99102
"babel-core": "7.0.0-bridge.0",
100103
"babel-eslint": "9.0.0",
@@ -114,8 +117,8 @@
114117
"eslint-config-airbnb": "^17.1.0",
115118
"eslint-config-prettier": "^4.3.0",
116119
"eslint-config-react-app": "^3.0.5",
117-
"eslint-import-resolver-babel-module": "^5.1.0",
118-
"eslint-import-resolver-webpack": "^0.11.1",
120+
"eslint-import-resolver-babel-module": "^5.1.2",
121+
"eslint-import-resolver-webpack": "^0.12.1",
119122
"eslint-loader": "2.1.1",
120123
"eslint-plugin-flowtype": "2.50.1",
121124
"eslint-plugin-import": "^2.14.0",
@@ -160,7 +163,7 @@
160163
"uglify-js": "^3.6.0",
161164
"url-loader": "1.1.1",
162165
"webpack": "^4.41.2",
163-
"webpack-dev-server": "3.1.14",
166+
"webpack-dev-server": "^3.11.0",
164167
"webpack-manifest-plugin": "2.0.4",
165168
"workbox-webpack-plugin": "3.6.3"
166169
},

src/demo/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useEffect, useState, useCallback } from 'react';
22
import { useWebId } from '@solid/react';
33
import styled from 'styled-components';
44
// import { FormModel as FormModelClass } from '@inrupt/solid-sdk-forms';
5+
import { AS } from '@inrupt/lit-generated-vocab-common';
56
import SolidImg from '../assets/solid_logo.png';
67
import {
78
ProviderLogin,
@@ -13,7 +14,6 @@ import {
1314
ProfileViewer
1415
} from '@lib';
1516
import { AccessControlList, ACLFactory } from '@classes';
16-
import { NotificationTypes } from '@constants';
1717

1818
const HeaderWrapper = styled.section`
1919
margin-top: 60px;
@@ -129,7 +129,7 @@ const App = () => {
129129
actor: 'https://solidsdk.inrupt.net/profile/card#me'
130130
},
131131
inboxUrl,
132-
NotificationTypes.ANNOUNCE
132+
AS.Announce.iriAsString
133133
);
134134
} catch (ex) {
135135
// eslint-disable-next-line no-console

src/lib/classes/access-control-list.js

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import solid from 'solid-auth-client';
33
import * as N3 from 'n3';
44
import { isEqual } from 'lodash';
55
import ldflex from '@solid/query-ldflex';
6+
import { FOAF, RDF, VCARD } from '@inrupt/lit-generated-vocab-common';
7+
import { ACL } from '@inrupt/lit-generated-vocab-solid-common';
68
import { SolidError } from '@utils';
7-
import { PERMISSIONS, ACL_PREFIXES } from '@constants';
9+
import { PERMISSIONS } from '@constants';
810

911
type Permissions = {
1012
agents: null | String | Array,
@@ -45,30 +47,29 @@ export default class AccessControlList {
4547
* @param {Array<String> | null} agents Array of webId or null if for everyone
4648
*/
4749
createQuadList = (modes: Array<String>, agents: Array<String> | null) => {
48-
const { acl, foaf, rdf } = ACL_PREFIXES;
4950
const subject = `${this.aclUri}#${modes.join('')}`;
5051
const { documentUri } = this;
5152
const originalPredicates = [
52-
this.createQuad(subject, `${rdf}type`, namedNode(`${acl}Authorization`)),
53-
this.createQuad(subject, `${acl}accessTo`, namedNode(documentUri)),
54-
this.createQuad(subject, `${acl}default`, namedNode(documentUri))
53+
this.createQuad(subject, RDF.type.iriAsString, ACL.Authorization),
54+
this.createQuad(subject, ACL.accessTo.iriAsString, namedNode(documentUri)),
55+
this.createQuad(subject, ACL.default_.iriAsString, namedNode(documentUri))
5556
];
5657
let predicates = [];
5758
if (agents) {
5859
const agentsArray = Array.isArray(agents) ? agents : [agents];
5960
const agentsQuads = agentsArray.map(agent =>
60-
this.createQuad(subject, `${acl}agent`, namedNode(agent))
61+
this.createQuad(subject, ACL.agent.iriAsString, namedNode(agent))
6162
);
6263
predicates = [...originalPredicates, ...agentsQuads];
6364
} else {
64-
const publicQuad = this.createQuad(subject, `${acl}agentClass`, namedNode(`${foaf}Agent`));
65+
const publicQuad = this.createQuad(subject, ACL.agentClass.iriAsString, FOAF.Agent);
6566
predicates = [...originalPredicates, publicQuad];
6667
}
6768

6869
const quadList = modes.reduce(
6970
(array, mode) => [
7071
...array,
71-
this.createQuad(subject, `${acl}mode`, namedNode(`${acl}${mode}`))
72+
this.createQuad(subject, ACL.mode.iriAsString, namedNode(`${ACL.NAMESPACE}${mode}`))
7273
],
7374
predicates
7475
);
@@ -83,7 +84,16 @@ export default class AccessControlList {
8384
*/
8485
createPermissionsTurtle = (permissions: Array<Permissions>) => {
8586
const { DataFactory } = N3;
86-
const prefixes = { ...ACL_PREFIXES, '': `${this.aclUri}#`, me: this.owner };
87+
88+
const prefixes = {
89+
...ACL.PREFIX_AND_NAMESPACE,
90+
...FOAF.PREFIX_AND_NAMESPACE,
91+
...RDF.PREFIX_AND_NAMESPACE,
92+
...VCARD.PREFIX_AND_NAMESPACE,
93+
'': `${this.aclUri}#`,
94+
me: this.owner
95+
};
96+
8797
const { namedNode, quad } = DataFactory;
8898
const writer = new N3.Writer({ prefixes });
8999
const quadPermissions = permissions.map(({ modes, agents }) =>
@@ -185,10 +195,10 @@ export default class AccessControlList {
185195
for await (const subject of document.subjects) {
186196
let agents = [];
187197
let modes = [];
188-
for await (const agent of subject['acl:agent']) {
198+
for await (const agent of subject[ACL.agent]) {
189199
agents = [...agents, agent.value];
190200
}
191-
for await (const mode of subject['acl:mode']) {
201+
for await (const mode of subject[ACL.mode]) {
192202
const modeName = mode.value ? mode.value.split('#')[1] : '';
193203
modes = [...modes, modeName];
194204
}
@@ -243,9 +253,8 @@ export default class AccessControlList {
243253
*/
244254
createMode = async ({ modes, agents }) => {
245255
try {
246-
const { acl, foaf } = ACL_PREFIXES;
247256
const subject = `${this.aclUri}#${modes.join('')}`;
248-
await ldflex[subject].type.add(namedNode(`${acl}Authorization`));
257+
await ldflex[subject].type.add(ACL.Authorization);
249258
const path = namedNode(this.documentUri);
250259
await ldflex[subject]['acl:accessTo'].add(path);
251260
await ldflex[subject]['acl:default'].add(path);
@@ -255,11 +264,11 @@ export default class AccessControlList {
255264
await ldflex[subject]['acl:agent'].add(namedNode(agent));
256265
}
257266
} else {
258-
await ldflex[subject]['acl:agentClass'].add(namedNode(`${foaf}Agent`));
267+
await ldflex[subject]['acl:agentClass'].add(FOAF.Agent);
259268
}
260269

261270
for await (const mode of modes) {
262-
await ldflex[subject]['acl:mode'].add(namedNode(`${acl}${mode}`));
271+
await ldflex[subject]['acl:mode'].add(namedNode(`${ACL.NAMESPACE}${mode}`));
263272
}
264273
return { modes, agents };
265274
} catch (e) {

src/lib/classes/notification.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import solid from 'solid-auth-client';
22
import * as N3 from 'n3';
33
import data from '@solid/query-ldflex';
4+
import { AS } from '@inrupt/lit-generated-vocab-common';
45
import { solidResponse, SolidError, shexUtil, getBasicPod } from '@utils';
56
import defaultShape from '../shapes/notification.json';
67
import AccessControlList from './access-control-list';
78
import ACLFactory from './access-control-factory';
8-
import { NotificationTypes } from '@constants';
99
import { ensureSlash } from '../utils/solidFetch';
1010

1111
const PREFIXES = {
@@ -239,7 +239,7 @@ export class Notification {
239239
const licenseType = 'http://schema.org/license';
240240

241241
// If a type has not been set, default to Announce type
242-
const notificationType = type || NotificationTypes.ANNOUNCE;
242+
const notificationType = type || AS.Announce.iriAsString;
243243

244244
// If a license has not been set, default to the CC license
245245
const licenseLink = license || 'https://creativecommons.org/licenses/by-sa/4.0/';
@@ -461,7 +461,7 @@ export class Notification {
461461
* Validate the list of notification IRIs and return a list of valid ones
462462
*/
463463
const coreNotificationShape =
464-
'https://shexshapes.inrupt.net/public/notifications/app-notification.shex';
464+
'https://shexshapes.inrupt.net/public/notifications/core-notification.shex';
465465
const validNotifications = await shexUtil.validateList(
466466
notificationPaths,
467467
coreNotificationShape

src/lib/components/FormModel/children/Form/UI/CheckBox/check-box.component.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useEffect, useState, useContext } from 'react';
2+
import { UI } from '@inrupt/lit-generated-vocab-common';
23
import { ThemeContext } from '@context';
3-
import { UI } from '@constants';
44
import { InputGroup } from '../Input/input.styles';
55

66
type Props = {
@@ -17,7 +17,7 @@ export const CheckBox = (props: Props) => {
1717

1818
useEffect(() => {
1919
try {
20-
const podValue = data[UI.VALUE];
20+
const podValue = data[UI.value];
2121
if (!podValue || podValue === 'false') {
2222
setChecked(false);
2323
} else {
@@ -26,9 +26,9 @@ export const CheckBox = (props: Props) => {
2626
} catch (e) {
2727
setChecked(false);
2828
}
29-
}, [data[UI.VALUE]]);
29+
}, [data[UI.value]]);
3030

31-
const { [UI.LABEL]: label } = data;
31+
const { [UI.label]: label } = data;
3232

3333
const onChange = event => {
3434
const updatedPart = { ...data, value: String(event.target.checked) };

src/lib/components/FormModel/children/Form/UI/CheckBox/check-box.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
import { render, cleanup } from '@testing-library/react';
33
import { getByText, getByLabelText } from '@testing-library/dom';
4+
import { UI } from '@inrupt/lit-generated-vocab-common';
45
import { CheckBox } from './check-box.component';
5-
import { UI } from '@constants';
66
import 'jest-dom/extend-expect';
77

88
afterAll(cleanup);
@@ -15,25 +15,25 @@ test('Renders without crashing', () => {
1515

1616
test('Renders the label', () => {
1717
const data = {
18-
[UI.LABEL]: 'check'
18+
[UI.label]: 'check'
1919
};
2020
const { container } = render(<CheckBox data={data} />);
2121
expect(getByText(container, 'check')).toBeTruthy();
2222
});
2323

2424
test('Renders a checked box', () => {
2525
const data = {
26-
[UI.LABEL]: 'checklabel',
27-
[UI.VALUE]: 'true'
26+
[UI.label]: 'checklabel',
27+
[UI.value]: 'true'
2828
};
2929
const { container } = render(<CheckBox id="testid" data={data} />);
3030
expect(getByLabelText(container, 'checklabel').checked).toBeTruthy();
3131
});
3232

3333
test('Renders an unchecked box', () => {
3434
const data = {
35-
[UI.LABEL]: 'checklabel',
36-
[UI.VALUE]: 'false'
35+
[UI.label]: 'checklabel',
36+
[UI.value]: 'false'
3737
};
3838
const { container } = render(<CheckBox id="testid" data={data} />);
3939
expect(getByLabelText(container, 'checklabel').checked).toBeFalsy();

src/lib/components/FormModel/children/Form/UI/Classifier/classifier.component.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import React, { useState, useEffect, useCallback, useContext } from 'react';
22
import { n3Helper } from '@inrupt/solid-sdk-forms';
33
import unique from 'unique';
4-
import { SelectWrapper } from './classifier.style';
4+
import { UI } from '@inrupt/lit-generated-vocab-common';
55
import { ThemeContext } from '@context';
6-
import { UI } from '@constants';
6+
import { SelectWrapper } from './classifier.style';
77

88
export const Classifier = props => {
99
const { id, data, updateData } = props;
1010
const { theme } = useContext(ThemeContext);
1111

1212
const {
13-
[UI.LABEL]: label,
14-
[UI.VALUE]: initialValue,
15-
[UI.CATEGORY]: category,
16-
[UI.VALUES]: values
13+
[UI.label]: label,
14+
[UI.value]: initialValue,
15+
[UI.category]: category,
16+
[UI.values]: values
1717
} = data;
1818

1919
const [options, setOptions] = useState([]);

0 commit comments

Comments
 (0)