@noeldemartin/solid-utils 0.3.0 → 0.4.0-next.088119819f89e5ceabdc6c32a91004b4f85c7fd7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noeldemartin/solid-utils",
3
- "version": "0.3.0",
3
+ "version": "0.4.0-next.088119819f89e5ceabdc6c32a91004b4f85c7fd7",
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",
@@ -33,10 +33,9 @@
33
33
  "@babel/runtime": "^7.14.0",
34
34
  "@noeldemartin/faker": "^7.6.0",
35
35
  "@noeldemartin/solid-utils-external": "^0.1.1",
36
- "@noeldemartin/utils": "^0.4.0",
36
+ "@noeldemartin/utils": "^0.5.1",
37
37
  "@types/rdf-js": "^4.0.1",
38
38
  "core-js": "^3.12.1",
39
- "jest-diff": "^26.6.2",
40
39
  "md5": "^2.3.0"
41
40
  },
42
41
  "devDependencies": {
@@ -55,7 +54,6 @@
55
54
  "@rollup/plugin-typescript": "^8.2.1",
56
55
  "@types/chai": "^4.2.18",
57
56
  "@types/jest": "^26.0.23",
58
- "@types/jest-diff": "^24.3.0",
59
57
  "@types/md5": "^2.3.0",
60
58
  "babel-plugin-transform-remove-imports": "^1.5.4",
61
59
  "eslint": "^7.26.0",
@@ -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 ??
@@ -44,12 +44,15 @@ async function createTypeIndex(user: SolidUserProfile, type: TypeIndexType, fetc
44
44
  ]);
45
45
 
46
46
  if (type === 'public') {
47
- // TODO Implement updating ACLs for the listing itself to public
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[],
@@ -16,9 +16,11 @@ export interface ResourceOptions extends DocumentOptions {
16
16
  }
17
17
 
18
18
  export function fakeContainerUrl(options: Partial<ContainerOptions> = {}): string {
19
+ const containerSlug = stringToSlug(faker.random.word());
19
20
  const baseUrl = options.baseUrl ?? faker.internet.url();
21
+ const parentContainerUrl = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
20
22
 
21
- return baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
23
+ return parentContainerUrl + containerSlug + '/';
22
24
  }
23
25
 
24
26
  export function fakeDocumentUrl(options: Partial<DocumentOptions> = {}): string {
@@ -1,5 +1,5 @@
1
1
  import { fail } from '@noeldemartin/utils';
2
- import type { GetClosureArgs, GetClosureResult } from '@noeldemartin/utils';
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
- export type FetchMock = jest.Mock<GetClosureResult<Fetch>, GetClosureArgs<Fetch>> & Fetch & FetchMockMethods;
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 FetchMock;
32
+ return fetchMock as unknown as T;
34
33
  }
@@ -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