solid-logic 1.3.14-3629edd5 → 1.3.14-73b319bb
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.
- package/.github/workflows/ci.yml +0 -1
- package/.nvmrc +1 -0
- package/package.json +1 -1
- package/test/chatLogic.test.ts +1 -1
- package/lib/contacts/ContactsLogic.d.ts +0 -30
- package/lib/contacts/ContactsLogic.d.ts.map +0 -1
- package/lib/contacts/ContactsLogic.js +0 -132
- package/lib/contacts/ContactsLogic.js.map +0 -1
- package/lib/contacts/unit.test.d.ts +0 -2
- package/lib/contacts/unit.test.d.ts.map +0 -1
- package/lib/contacts/unit.test.js +0 -166
- package/lib/contacts/unit.test.js.map +0 -1
- package/renovate.json +0 -5
- package/src/contacts/ContactsLogic.ts +0 -68
- package/src/contacts/unit.test.ts +0 -102
package/.github/workflows/ci.yml
CHANGED
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v16.14.0
|
package/package.json
CHANGED
package/test/chatLogic.test.ts
CHANGED
|
@@ -20,7 +20,7 @@ describe("Chat logic", () => {
|
|
|
20
20
|
status: 404,
|
|
21
21
|
});
|
|
22
22
|
store = rdf.graph();
|
|
23
|
-
store.fetcher = rdf.fetcher(store, { fetch: fetchMock });
|
|
23
|
+
store.fetcher = rdf.fetcher(store, { fetch: fetchMock, timeout: 5 });
|
|
24
24
|
store.updater = new UpdateManager(store);
|
|
25
25
|
const authn = {
|
|
26
26
|
currentUser: () => {
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NamedNode } from "rdflib";
|
|
2
|
-
import { SolidNamespace } from "../types";
|
|
3
|
-
import { LiveStore } from "rdflib";
|
|
4
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
5
|
-
import { UtilityLogic } from "../util/UtilityLogic";
|
|
6
|
-
export declare class Contact {
|
|
7
|
-
uri: NamedNode;
|
|
8
|
-
store: LiveStore;
|
|
9
|
-
constructor(uri: NamedNode, store: LiveStore);
|
|
10
|
-
getFullName(): string | null;
|
|
11
|
-
}
|
|
12
|
-
export declare class Addressbook {
|
|
13
|
-
uri: NamedNode;
|
|
14
|
-
store: LiveStore;
|
|
15
|
-
constructor(uri: NamedNode, store: LiveStore);
|
|
16
|
-
fetch(): Promise<void>;
|
|
17
|
-
getMembers(): Contact[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Contacts-related logic
|
|
21
|
-
*/
|
|
22
|
-
export declare class ContactsLogic {
|
|
23
|
-
store: LiveStore;
|
|
24
|
-
ns: SolidNamespace;
|
|
25
|
-
profile: ProfileLogic;
|
|
26
|
-
util: UtilityLogic;
|
|
27
|
-
constructor(store: LiveStore, ns: SolidNamespace, profile: ProfileLogic, util: UtilityLogic);
|
|
28
|
-
getAddressbook(uri: NamedNode): Promise<Addressbook>;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=ContactsLogic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContactsLogic.d.ts","sourceRoot":"","sources":["../../src/contacts/ContactsLogic.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAQ,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,qBAAa,OAAO;IAClB,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,SAAS,CAAA;gBAEJ,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS;IAK5C,WAAW,IAAI,MAAM,GAAG,IAAI;CAI7B;AAED,qBAAa,WAAW;IACtB,GAAG,EAAE,SAAS,CAAA;IACd,KAAK,EAAE,SAAS,CAAA;gBAEJ,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS;IAKtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B,UAAU,IAAI,OAAO,EAAE;CAKxB;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,YAAY,CAAC;IACtB,IAAI,EAAE,YAAY,CAAC;gBAEP,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY;IAOrF,cAAc,CAClB,GAAG,EAAE,SAAS,GACb,OAAO,CAAC,WAAW,CAAC;CAKxB"}
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
-
function step(op) {
|
|
35
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
37
|
-
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;
|
|
38
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
-
switch (op[0]) {
|
|
40
|
-
case 0: case 1: t = op; break;
|
|
41
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
-
default:
|
|
45
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
-
if (t[2]) _.ops.pop();
|
|
50
|
-
_.trys.pop(); continue;
|
|
51
|
-
}
|
|
52
|
-
op = body.call(thisArg, _);
|
|
53
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
exports.ContactsLogic = exports.Addressbook = exports.Contact = void 0;
|
|
62
|
-
var rdf = __importStar(require("rdflib"));
|
|
63
|
-
var solid_namespace_1 = __importDefault(require("solid-namespace"));
|
|
64
|
-
var ns = (0, solid_namespace_1.default)(rdf);
|
|
65
|
-
var Contact = /** @class */ (function () {
|
|
66
|
-
function Contact(uri, store) {
|
|
67
|
-
this.uri = uri;
|
|
68
|
-
this.store = store;
|
|
69
|
-
}
|
|
70
|
-
Contact.prototype.getFullName = function () {
|
|
71
|
-
var node = this.store.any(this.uri, ns.vcard('fn'));
|
|
72
|
-
return (node ? node.value : null);
|
|
73
|
-
};
|
|
74
|
-
return Contact;
|
|
75
|
-
}());
|
|
76
|
-
exports.Contact = Contact;
|
|
77
|
-
var Addressbook = /** @class */ (function () {
|
|
78
|
-
function Addressbook(uri, store) {
|
|
79
|
-
this.uri = uri;
|
|
80
|
-
this.store = store;
|
|
81
|
-
}
|
|
82
|
-
Addressbook.prototype.fetch = function () {
|
|
83
|
-
var _a;
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
return __generator(this, function (_b) {
|
|
86
|
-
switch (_b.label) {
|
|
87
|
-
case 0: return [4 /*yield*/, ((_a = this.store.fetcher) === null || _a === void 0 ? void 0 : _a.load(this.uri.doc().value))];
|
|
88
|
-
case 1:
|
|
89
|
-
_b.sent();
|
|
90
|
-
return [2 /*return*/];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
Addressbook.prototype.getMembers = function () {
|
|
96
|
-
var _this = this;
|
|
97
|
-
// FIXME: https://gitter.im/solid/solidos?at=603659fb4821572018f9d82d
|
|
98
|
-
var members = this.store.each(null, ns.vcard('inAddressBook'), this.uri, this.uri.doc());
|
|
99
|
-
return members.map(function (node) { return new Contact(node, _this.store); });
|
|
100
|
-
};
|
|
101
|
-
return Addressbook;
|
|
102
|
-
}());
|
|
103
|
-
exports.Addressbook = Addressbook;
|
|
104
|
-
/**
|
|
105
|
-
* Contacts-related logic
|
|
106
|
-
*/
|
|
107
|
-
var ContactsLogic = /** @class */ (function () {
|
|
108
|
-
function ContactsLogic(store, ns, profile, util) {
|
|
109
|
-
this.store = store;
|
|
110
|
-
this.ns = ns;
|
|
111
|
-
this.profile = profile;
|
|
112
|
-
this.util = util;
|
|
113
|
-
}
|
|
114
|
-
ContactsLogic.prototype.getAddressbook = function (uri) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
-
var addressbook;
|
|
117
|
-
return __generator(this, function (_a) {
|
|
118
|
-
switch (_a.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
addressbook = new Addressbook(uri, this.store);
|
|
121
|
-
return [4 /*yield*/, addressbook.fetch()];
|
|
122
|
-
case 1:
|
|
123
|
-
_a.sent();
|
|
124
|
-
return [2 /*return*/, addressbook];
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
return ContactsLogic;
|
|
130
|
-
}());
|
|
131
|
-
exports.ContactsLogic = ContactsLogic;
|
|
132
|
-
//# sourceMappingURL=ContactsLogic.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ContactsLogic.js","sourceRoot":"","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CAAC,GAAG,CAAC,UAAC,IAAU,IAAK,OAAA,IAAI,OAAO,CAAC,IAAiB,EAAE,KAAI,CAAC,KAAK,CAAC,EAA1C,CAA0C,CAAC,CAAC;IACjF,CAAC;IACH,kBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBY,kCAAW;AAoBxB;;GAEG;AACH;IAME,uBAAY,KAAgB,EAAE,EAAkB,EAAE,OAAqB,EAAE,IAAkB;QACzF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAEK,sCAAc,GAApB,UACE,GAAc;;;;;;wBAER,WAAW,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;wBACrD,qBAAM,WAAW,CAAC,KAAK,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;wBAC1B,sBAAO,WAAW,EAAC;;;;KACpB;IACH,oBAAC;AAAD,CAAC,AApBD,IAoBC;AApBY,sCAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit.test.d.ts","sourceRoot":"","sources":["../../src/contacts/unit.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
-
}) : (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
o[k2] = m[k];
|
|
8
|
-
}));
|
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
-
}) : function(o, v) {
|
|
12
|
-
o["default"] = v;
|
|
13
|
-
});
|
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
-
if (mod && mod.__esModule) return mod;
|
|
16
|
-
var result = {};
|
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
-
__setModuleDefault(result, mod);
|
|
19
|
-
return result;
|
|
20
|
-
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
-
function step(op) {
|
|
35
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
37
|
-
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;
|
|
38
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
-
switch (op[0]) {
|
|
40
|
-
case 0: case 1: t = op; break;
|
|
41
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
-
default:
|
|
45
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
-
if (t[2]) _.ops.pop();
|
|
50
|
-
_.trys.pop(); continue;
|
|
51
|
-
}
|
|
52
|
-
op = body.call(thisArg, _);
|
|
53
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
|
-
};
|
|
60
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
62
|
-
var UtilityLogic_1 = require("../util/UtilityLogic");
|
|
63
|
-
var solid_namespace_1 = __importDefault(require("solid-namespace"));
|
|
64
|
-
var rdf = __importStar(require("rdflib"));
|
|
65
|
-
var ProfileLogic_1 = require("../profile/ProfileLogic");
|
|
66
|
-
var jest_fetch_mock_1 = __importDefault(require("jest-fetch-mock"));
|
|
67
|
-
var rdflib_1 = require("rdflib");
|
|
68
|
-
var ContactsLogic_1 = require("./ContactsLogic");
|
|
69
|
-
var authSession_1 = require("../authSession/authSession");
|
|
70
|
-
var ns = (0, solid_namespace_1.default)(rdf);
|
|
71
|
-
var alice = rdf.sym("https://alice.example/profile/card#me");
|
|
72
|
-
var addressbook = rdf.sym("https://alice.example/addressbook.ttl#this");
|
|
73
|
-
var bob = rdf.sym("https://bob.example/profile/card#me");
|
|
74
|
-
describe("Addressbook", function () {
|
|
75
|
-
var contacts;
|
|
76
|
-
var store;
|
|
77
|
-
beforeEach(function () {
|
|
78
|
-
jest_fetch_mock_1.default.resetMocks();
|
|
79
|
-
jest_fetch_mock_1.default.mockResponse("Not Found", {
|
|
80
|
-
status: 404,
|
|
81
|
-
});
|
|
82
|
-
var fetcher = { fetch: jest_fetch_mock_1.default };
|
|
83
|
-
store = rdf.graph();
|
|
84
|
-
store.fetcher = rdf.fetcher(store, fetcher);
|
|
85
|
-
store.updater = new rdflib_1.UpdateManager(store);
|
|
86
|
-
var authn = {
|
|
87
|
-
authSession: authSession_1.authSession,
|
|
88
|
-
currentUser: function () {
|
|
89
|
-
return alice;
|
|
90
|
-
},
|
|
91
|
-
checkUser: function (alice) {
|
|
92
|
-
return alice;
|
|
93
|
-
},
|
|
94
|
-
saveUser: function () {
|
|
95
|
-
return alice;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
var profile = new ProfileLogic_1.ProfileLogic(store, ns, authn);
|
|
99
|
-
var util = new UtilityLogic_1.UtilityLogic(store, ns, fetcher);
|
|
100
|
-
contacts = new ContactsLogic_1.ContactsLogic(store, ns, profile, util);
|
|
101
|
-
});
|
|
102
|
-
describe("getMembers", function () {
|
|
103
|
-
describe("When Addressbook is empty", function () {
|
|
104
|
-
var result;
|
|
105
|
-
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
106
|
-
var addressbookObj;
|
|
107
|
-
return __generator(this, function (_a) {
|
|
108
|
-
switch (_a.label) {
|
|
109
|
-
case 0:
|
|
110
|
-
addressbookIsEmpty();
|
|
111
|
-
return [4 /*yield*/, contacts.getAddressbook(addressbook)];
|
|
112
|
-
case 1:
|
|
113
|
-
addressbookObj = _a.sent();
|
|
114
|
-
result = addressbookObj.getMembers();
|
|
115
|
-
return [2 /*return*/];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}); });
|
|
119
|
-
it("Resolves to an empty array", function () {
|
|
120
|
-
expect(result).toEqual([]);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
describe("When Addressbook contains Bob", function () {
|
|
124
|
-
var result;
|
|
125
|
-
beforeEach(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
126
|
-
var addressbookObj;
|
|
127
|
-
return __generator(this, function (_a) {
|
|
128
|
-
switch (_a.label) {
|
|
129
|
-
case 0:
|
|
130
|
-
addressbookContainsBob();
|
|
131
|
-
return [4 /*yield*/, contacts.getAddressbook(addressbook)];
|
|
132
|
-
case 1:
|
|
133
|
-
addressbookObj = _a.sent();
|
|
134
|
-
result = addressbookObj.getMembers();
|
|
135
|
-
return [2 /*return*/];
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}); });
|
|
139
|
-
it("Resolves to an array containing Bob", function () {
|
|
140
|
-
expect(result.length).toEqual(1);
|
|
141
|
-
expect(result[0].getFullName()).toEqual("Bob the Builder");
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
function addressbookIsEmpty() {
|
|
146
|
-
jest_fetch_mock_1.default.mockOnceIf(addressbook.doc().value, " ", {
|
|
147
|
-
headers: { "Content-Type": "text/turtle" },
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
function addressbookContainsBob() {
|
|
151
|
-
jest_fetch_mock_1.default.mockOnceIf(addressbook.doc().value, "@prefix acl: <http://www.w3.org/ns/auth/acl#> .\n" +
|
|
152
|
-
"@prefix dc: <http://purl.org/dc/elements/1.1/> .\n" +
|
|
153
|
-
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .\n" +
|
|
154
|
-
"<#this> a vcard:AddressBook ;\n" +
|
|
155
|
-
" dc:title \"New address Book\" ;\n" +
|
|
156
|
-
" acl:owner </profile/card#me> .\n" +
|
|
157
|
-
"<#bob> a vcard:Individual ;\n" +
|
|
158
|
-
" vcard:inAddressBook <#this> ;\n" +
|
|
159
|
-
" vcard:fn \"Bob the Builder\" ;\n" +
|
|
160
|
-
" vcard:url [ a vcard:WebID ; vcard:value <https://bob.example/profile/card#me> ] ;\n" +
|
|
161
|
-
" vcard:url [ a vcard:WebID ; vcard:value <https://bob.alternative/profile/card#me> ] .\n", {
|
|
162
|
-
headers: { "Content-Type": "text/turtle" },
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
//# sourceMappingURL=unit.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unit.test.js","sourceRoot":"","sources":["../../src/contacts/unit.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA6D;AAC7D,qDAAoD;AACpD,oEAA6C;AAE7C,0CAA8B;AAC9B,wDAAuD;AACvD,oEAAwC;AACxC,iCAAuC;AACvC,iDAAgD;AAChD,0DAAyD;AAEzD,IAAM,EAAE,GAAG,IAAA,yBAAc,EAAC,GAAG,CAAC,CAAC;AAE/B,IAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAC,uCAAuC,CAAC,CAAC;AAC/D,IAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;AAC1E,IAAM,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;AAE3D,QAAQ,CAAC,aAAa,EAAE;IACtB,IAAI,QAAQ,CAAC;IACb,IAAI,KAAK,CAAC;IACV,UAAU,CAAC;QACT,yBAAS,CAAC,UAAU,EAAE,CAAC;QACvB,yBAAS,CAAC,YAAY,CAAC,WAAW,EAAE;YAClC,MAAM,EAAE,GAAG;SACZ,CAAC,CAAC;QACH,IAAM,OAAO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AAE;YACxC,IAAI,MAAM,CAAC;YACX,UAAU,CAAC;;;;;4BACT,sBAAsB,EAAE,CAAC;4BACF,qBAAM,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,EAAA;;4BAA3D,cAAc,GAAG,SAA0C;4BACjE,MAAM,GAAG,cAAc,CAAC,UAAU,EAAE,CAAC;;;;iBACtC,CAAC,CAAC;YACH,EAAE,CAAC,qCAAqC,EAAE;gBACxC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBACjC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,SAAS,kBAAkB;QACzB,yBAAS,CAAC,UAAU,CAClB,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,EACvB,GAAG,EACH;YACE,OAAO,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE;SAC3C,CACF,CAAC;IACJ,CAAC;IAED,SAAS,sBAAsB;QAC7B,yBAAS,CAAC,UAAU,CAClB,WAAW,CAAC,GAAG,EAAE,CAAC,KAAK,EACvB,qDAAqD;YACrD,uDAAuD;YACvD,uDAAuD;YACvD,iCAAiC;YACjC,qCAAqC;YACrC,mCAAmC;YACnC,+BAA+B;YAC/B,mCAAmC;YACnC,+CAA+C;YAC/C,uFAAuF;YACvF,2FAA2F,EAC3F;YACE,OAAO,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE;SAC3C,CACF,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as rdf from "rdflib"
|
|
2
|
-
import { NamedNode, Node } from "rdflib";
|
|
3
|
-
import { SolidNamespace } from "../types";
|
|
4
|
-
import { LiveStore } from "rdflib";
|
|
5
|
-
import solidNamespace from "solid-namespace";
|
|
6
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
7
|
-
import { UtilityLogic } from "../util/UtilityLogic";
|
|
8
|
-
const ns: SolidNamespace = solidNamespace(rdf);
|
|
9
|
-
|
|
10
|
-
export class Contact {
|
|
11
|
-
uri: NamedNode
|
|
12
|
-
store: LiveStore
|
|
13
|
-
|
|
14
|
-
constructor(uri: NamedNode, store: LiveStore) {
|
|
15
|
-
this.uri = uri;
|
|
16
|
-
this.store = store;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
getFullName(): string | null {
|
|
20
|
-
const node = this.store.any(this.uri, ns.vcard('fn'));
|
|
21
|
-
return (node ? node.value : null);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class Addressbook {
|
|
26
|
-
uri: NamedNode
|
|
27
|
-
store: LiveStore
|
|
28
|
-
|
|
29
|
-
constructor(uri: NamedNode, store: LiveStore) {
|
|
30
|
-
this.uri = uri;
|
|
31
|
-
this.store = store;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async fetch(): Promise<void> {
|
|
35
|
-
await this.store.fetcher?.load(this.uri.doc().value);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
getMembers(): Contact[] {
|
|
39
|
-
// FIXME: https://gitter.im/solid/solidos?at=603659fb4821572018f9d82d
|
|
40
|
-
const members: Node[] = this.store.each(null, ns.vcard('inAddressBook'), this.uri, this.uri.doc());
|
|
41
|
-
return members.map((node: Node) => new Contact(node as NamedNode, this.store));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Contacts-related logic
|
|
47
|
-
*/
|
|
48
|
-
export class ContactsLogic {
|
|
49
|
-
store: LiveStore;
|
|
50
|
-
ns: SolidNamespace;
|
|
51
|
-
profile: ProfileLogic;
|
|
52
|
-
util: UtilityLogic;
|
|
53
|
-
|
|
54
|
-
constructor(store: LiveStore, ns: SolidNamespace, profile: ProfileLogic, util: UtilityLogic) {
|
|
55
|
-
this.store = store;
|
|
56
|
-
this.ns = ns;
|
|
57
|
-
this.profile = profile;
|
|
58
|
-
this.util = util;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async getAddressbook(
|
|
62
|
-
uri: NamedNode
|
|
63
|
-
): Promise<Addressbook> {
|
|
64
|
-
const addressbook = new Addressbook(uri, this.store);
|
|
65
|
-
await addressbook.fetch();
|
|
66
|
-
return addressbook;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { UtilityLogic } from "../util/UtilityLogic";
|
|
3
|
-
import solidNamespace from "solid-namespace";
|
|
4
|
-
|
|
5
|
-
import * as rdf from "rdflib";
|
|
6
|
-
import { ProfileLogic } from "../profile/ProfileLogic";
|
|
7
|
-
import fetchMock from "jest-fetch-mock";
|
|
8
|
-
import { UpdateManager } from "rdflib";
|
|
9
|
-
import { ContactsLogic } from "./ContactsLogic";
|
|
10
|
-
import { authSession } from "../authSession/authSession";
|
|
11
|
-
|
|
12
|
-
const ns = solidNamespace(rdf);
|
|
13
|
-
|
|
14
|
-
const alice = rdf.sym("https://alice.example/profile/card#me");
|
|
15
|
-
const addressbook = rdf.sym("https://alice.example/addressbook.ttl#this");
|
|
16
|
-
const bob = rdf.sym("https://bob.example/profile/card#me");
|
|
17
|
-
|
|
18
|
-
describe("Addressbook", () => {
|
|
19
|
-
let contacts;
|
|
20
|
-
let store;
|
|
21
|
-
beforeEach(() => {
|
|
22
|
-
fetchMock.resetMocks();
|
|
23
|
-
fetchMock.mockResponse("Not Found", {
|
|
24
|
-
status: 404,
|
|
25
|
-
});
|
|
26
|
-
const fetcher = { fetch: fetchMock };
|
|
27
|
-
store = rdf.graph();
|
|
28
|
-
store.fetcher = rdf.fetcher(store, fetcher);
|
|
29
|
-
store.updater = new UpdateManager(store);
|
|
30
|
-
const authn = {
|
|
31
|
-
authSession: authSession,
|
|
32
|
-
currentUser: () => {
|
|
33
|
-
return alice;
|
|
34
|
-
},
|
|
35
|
-
checkUser: (alice) => {
|
|
36
|
-
return alice;
|
|
37
|
-
},
|
|
38
|
-
saveUser: () => {
|
|
39
|
-
return alice;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const profile = new ProfileLogic(store, ns, authn);
|
|
43
|
-
const util = new UtilityLogic(store, ns, fetcher);
|
|
44
|
-
contacts = new ContactsLogic(store, ns, profile, util);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("getMembers", () => {
|
|
48
|
-
describe("When Addressbook is empty", () => {
|
|
49
|
-
let result;
|
|
50
|
-
beforeEach(async () => {
|
|
51
|
-
addressbookIsEmpty();
|
|
52
|
-
const addressbookObj = await contacts.getAddressbook(addressbook);
|
|
53
|
-
result = addressbookObj.getMembers();
|
|
54
|
-
});
|
|
55
|
-
it("Resolves to an empty array", () => {
|
|
56
|
-
expect(result).toEqual([]);
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
describe("When Addressbook contains Bob", () => {
|
|
60
|
-
let result;
|
|
61
|
-
beforeEach(async () => {
|
|
62
|
-
addressbookContainsBob();
|
|
63
|
-
const addressbookObj = await contacts.getAddressbook(addressbook);
|
|
64
|
-
result = addressbookObj.getMembers();
|
|
65
|
-
});
|
|
66
|
-
it("Resolves to an array containing Bob", () => {
|
|
67
|
-
expect(result.length).toEqual(1);
|
|
68
|
-
expect(result[0].getFullName()).toEqual("Bob the Builder");
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
function addressbookIsEmpty() {
|
|
74
|
-
fetchMock.mockOnceIf(
|
|
75
|
-
addressbook.doc().value,
|
|
76
|
-
" ",
|
|
77
|
-
{
|
|
78
|
-
headers: { "Content-Type": "text/turtle" },
|
|
79
|
-
}
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function addressbookContainsBob() {
|
|
84
|
-
fetchMock.mockOnceIf(
|
|
85
|
-
addressbook.doc().value,
|
|
86
|
-
"@prefix acl: <http://www.w3.org/ns/auth/acl#> .\n" +
|
|
87
|
-
"@prefix dc: <http://purl.org/dc/elements/1.1/> .\n" +
|
|
88
|
-
"@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .\n" +
|
|
89
|
-
"<#this> a vcard:AddressBook ;\n" +
|
|
90
|
-
" dc:title \"New address Book\" ;\n" +
|
|
91
|
-
" acl:owner </profile/card#me> .\n" +
|
|
92
|
-
"<#bob> a vcard:Individual ;\n" +
|
|
93
|
-
" vcard:inAddressBook <#this> ;\n" +
|
|
94
|
-
" vcard:fn \"Bob the Builder\" ;\n" +
|
|
95
|
-
" vcard:url [ a vcard:WebID ; vcard:value <https://bob.example/profile/card#me> ] ;\n" +
|
|
96
|
-
" vcard:url [ a vcard:WebID ; vcard:value <https://bob.alternative/profile/card#me> ] .\n",
|
|
97
|
-
{
|
|
98
|
-
headers: { "Content-Type": "text/turtle" },
|
|
99
|
-
}
|
|
100
|
-
);
|
|
101
|
-
}
|
|
102
|
-
});
|