@noeldemartin/solid-utils 0.3.0 → 0.4.0-next.30aceafb9d58f505d02a146d8e81f2e3a041b92f
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 +16 -0
- package/CHANGELOG.md +18 -4
- package/README.md +1 -1
- package/dist/noeldemartin-solid-utils.cjs.js +1 -1
- package/dist/noeldemartin-solid-utils.cjs.js.map +1 -1
- package/dist/noeldemartin-solid-utils.d.ts +14 -28
- package/dist/noeldemartin-solid-utils.esm.js +1 -1
- package/dist/noeldemartin-solid-utils.esm.js.map +1 -1
- package/dist/noeldemartin-solid-utils.umd.js +16 -16
- package/dist/noeldemartin-solid-utils.umd.js.map +1 -1
- package/package.json +3 -6
- package/src/helpers/auth.ts +6 -2
- package/src/helpers/interop.ts +16 -1
- package/src/helpers/vocabs.ts +1 -0
- package/src/testing/index.ts +0 -1
- package/src/testing/mocking.ts +4 -5
- package/.semaphore/semaphore.yml +0 -26
- package/src/testing/faking.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@noeldemartin/solid-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0-next.30aceafb9d58f505d02a146d8e81f2e3a041b92f",
|
|
4
4
|
"description": "My JavaScript utilities for Solid",
|
|
5
5
|
"main": "dist/noeldemartin-solid-utils.cjs.js",
|
|
6
6
|
"module": "dist/noeldemartin-solid-utils.esm.js",
|
|
@@ -31,12 +31,10 @@
|
|
|
31
31
|
"homepage": "https://github.com/noeldemartin/solid-utils",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.14.0",
|
|
34
|
-
"@noeldemartin/faker": "^7.6.0",
|
|
35
34
|
"@noeldemartin/solid-utils-external": "^0.1.1",
|
|
36
|
-
"@noeldemartin/utils": "^0.
|
|
37
|
-
"@types
|
|
35
|
+
"@noeldemartin/utils": "^0.5.1",
|
|
36
|
+
"@rdfjs/types": "^1.1.0",
|
|
38
37
|
"core-js": "^3.12.1",
|
|
39
|
-
"jest-diff": "^26.6.2",
|
|
40
38
|
"md5": "^2.3.0"
|
|
41
39
|
},
|
|
42
40
|
"devDependencies": {
|
|
@@ -55,7 +53,6 @@
|
|
|
55
53
|
"@rollup/plugin-typescript": "^8.2.1",
|
|
56
54
|
"@types/chai": "^4.2.18",
|
|
57
55
|
"@types/jest": "^26.0.23",
|
|
58
|
-
"@types/jest-diff": "^24.3.0",
|
|
59
56
|
"@types/md5": "^2.3.0",
|
|
60
57
|
"babel-plugin-transform-remove-imports": "^1.5.4",
|
|
61
58
|
"eslint": "^7.26.0",
|
package/src/helpers/auth.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type { Fetch } from './io';
|
|
|
9
9
|
|
|
10
10
|
export interface SolidUserProfile {
|
|
11
11
|
webId: string;
|
|
12
|
-
storageUrls: string[];
|
|
12
|
+
storageUrls: [string, ...string[]];
|
|
13
13
|
cloaked: boolean;
|
|
14
14
|
writableProfileUrl: string | null;
|
|
15
15
|
name?: string;
|
|
@@ -106,11 +106,15 @@ async function fetchUserProfile(webId: string, fetch?: Fetch): Promise<SolidUser
|
|
|
106
106
|
parentUrl = urlParentDirectory(parentUrl);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
+
if (storageUrls.length === 0) {
|
|
110
|
+
throw new Error(`Could not find any storage for ${webId}.`);
|
|
111
|
+
}
|
|
112
|
+
|
|
109
113
|
return {
|
|
110
114
|
webId,
|
|
111
115
|
cloaked,
|
|
112
116
|
writableProfileUrl,
|
|
113
|
-
storageUrls: arrayUnique(storageUrls),
|
|
117
|
+
storageUrls: arrayUnique(storageUrls) as [string, ...string[]],
|
|
114
118
|
...objectWithoutEmpty({
|
|
115
119
|
name:
|
|
116
120
|
store.statement(webId, 'vcard:fn')?.object.value ??
|
package/src/helpers/interop.ts
CHANGED
|
@@ -44,12 +44,15 @@ async function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetc
|
|
|
44
44
|
]);
|
|
45
45
|
|
|
46
46
|
if (type === 'public') {
|
|
47
|
-
// TODO
|
|
47
|
+
// TODO This is currently implemented in soukai-solid.
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return typeIndexUrl;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @deprecated Use soukai-solid instead
|
|
55
|
+
*/
|
|
53
56
|
async function findRegistrations(
|
|
54
57
|
typeIndexUrl: string,
|
|
55
58
|
type: string | string[],
|
|
@@ -70,14 +73,23 @@ async function findRegistrations(
|
|
|
70
73
|
).flat();
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use soukai-solid instead
|
|
78
|
+
*/
|
|
73
79
|
export async function createPublicTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {
|
|
74
80
|
return createTypeIndex(user, 'public', fetch);
|
|
75
81
|
}
|
|
76
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Use soukai-solid instead
|
|
85
|
+
*/
|
|
77
86
|
export async function createPrivateTypeIndex(user: SolidUserProfile, fetch?: Fetch): Promise<string> {
|
|
78
87
|
return createTypeIndex(user, 'private', fetch);
|
|
79
88
|
}
|
|
80
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @deprecated Use soukai-solid instead
|
|
92
|
+
*/
|
|
81
93
|
export async function findContainerRegistrations(
|
|
82
94
|
typeIndexUrl: string,
|
|
83
95
|
type: string | string[],
|
|
@@ -86,6 +98,9 @@ export async function findContainerRegistrations(
|
|
|
86
98
|
return findRegistrations(typeIndexUrl, type, 'solid:instanceContainer', fetch);
|
|
87
99
|
}
|
|
88
100
|
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use soukai-solid instead
|
|
103
|
+
*/
|
|
89
104
|
export async function findInstanceRegistrations(
|
|
90
105
|
typeIndexUrl: string,
|
|
91
106
|
type: string | string[],
|
package/src/helpers/vocabs.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface ExpandIRIOptions {
|
|
|
8
8
|
const knownPrefixes: RDFContext = {
|
|
9
9
|
acl: 'http://www.w3.org/ns/auth/acl#',
|
|
10
10
|
foaf: 'http://xmlns.com/foaf/0.1/',
|
|
11
|
+
ldp: 'http://www.w3.org/ns/ldp#',
|
|
11
12
|
pim: 'http://www.w3.org/ns/pim/space#',
|
|
12
13
|
purl: 'http://purl.org/dc/terms/',
|
|
13
14
|
rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
|
package/src/testing/index.ts
CHANGED
package/src/testing/mocking.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fail } from '@noeldemartin/utils';
|
|
2
|
-
import type { GetClosureArgs
|
|
2
|
+
import type { GetClosureArgs } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
4
|
import type { Fetch } from '@/helpers/io';
|
|
5
5
|
|
|
@@ -10,9 +10,8 @@ export interface FetchMockMethods {
|
|
|
10
10
|
mockNotFoundResponse(): void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export function mockFetch(): FetchMock {
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
export function mockFetch<T = any>(): T {
|
|
16
15
|
const responses: ResponseStub[] = [];
|
|
17
16
|
const methods: FetchMockMethods = {
|
|
18
17
|
mockResponse(body, headers, status) {
|
|
@@ -30,5 +29,5 @@ export function mockFetch(): FetchMock {
|
|
|
30
29
|
|
|
31
30
|
Object.assign(fetchMock, methods);
|
|
32
31
|
|
|
33
|
-
return fetchMock as
|
|
32
|
+
return fetchMock as unknown as T;
|
|
34
33
|
}
|
package/.semaphore/semaphore.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
version: v1.0
|
|
2
|
-
name: Solid Utils
|
|
3
|
-
agent:
|
|
4
|
-
machine:
|
|
5
|
-
type: e1-standard-2
|
|
6
|
-
os_image: ubuntu1804
|
|
7
|
-
blocks:
|
|
8
|
-
- name: CI
|
|
9
|
-
task:
|
|
10
|
-
prologue:
|
|
11
|
-
commands:
|
|
12
|
-
- checkout
|
|
13
|
-
- nvm install
|
|
14
|
-
- cache restore
|
|
15
|
-
- npm ci
|
|
16
|
-
- cache store
|
|
17
|
-
jobs:
|
|
18
|
-
- name: Linting
|
|
19
|
-
commands:
|
|
20
|
-
- npm run lint
|
|
21
|
-
- name: Tests
|
|
22
|
-
commands:
|
|
23
|
-
- npm test
|
|
24
|
-
- name: Build
|
|
25
|
-
commands:
|
|
26
|
-
- npm run build
|
package/src/testing/faking.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { faker } from '@noeldemartin/faker';
|
|
2
|
-
import { stringToSlug } from '@noeldemartin/utils';
|
|
3
|
-
|
|
4
|
-
export interface ContainerOptions {
|
|
5
|
-
baseUrl: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface DocumentOptions extends ContainerOptions {
|
|
9
|
-
containerUrl: string;
|
|
10
|
-
name: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface ResourceOptions extends DocumentOptions {
|
|
14
|
-
documentUrl: string;
|
|
15
|
-
hash: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function fakeContainerUrl(options: Partial<ContainerOptions> = {}): string {
|
|
19
|
-
const baseUrl = options.baseUrl ?? faker.internet.url();
|
|
20
|
-
|
|
21
|
-
return baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function fakeDocumentUrl(options: Partial<DocumentOptions> = {}): string {
|
|
25
|
-
const containerUrl = options.containerUrl ?? fakeContainerUrl(options);
|
|
26
|
-
const name = options.name ?? faker.random.word();
|
|
27
|
-
|
|
28
|
-
return containerUrl + stringToSlug(name);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function fakeResourceUrl(options: Partial<ResourceOptions> = {}): string {
|
|
32
|
-
const documentUrl = options.documentUrl ?? fakeDocumentUrl(options);
|
|
33
|
-
const hash = options.hash ?? 'it';
|
|
34
|
-
|
|
35
|
-
return documentUrl + '#' + hash;
|
|
36
|
-
}
|