@noeldemartin/solid-utils 0.5.0 → 0.6.0-next.cccdc9c7e033588e2df9d1887ceae49788344d84

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 (43) hide show
  1. package/dist/noeldemartin-solid-utils.d.ts +10 -62
  2. package/dist/noeldemartin-solid-utils.js +590 -0
  3. package/dist/noeldemartin-solid-utils.js.map +1 -0
  4. package/package.json +54 -63
  5. package/src/helpers/auth.test.ts +221 -0
  6. package/src/helpers/auth.ts +28 -27
  7. package/src/helpers/identifiers.test.ts +76 -0
  8. package/src/helpers/identifiers.ts +1 -1
  9. package/src/helpers/index.ts +0 -1
  10. package/src/helpers/interop.ts +23 -16
  11. package/src/helpers/io.test.ts +228 -0
  12. package/src/helpers/io.ts +53 -73
  13. package/src/helpers/jsonld.ts +3 -3
  14. package/src/helpers/wac.test.ts +64 -0
  15. package/src/helpers/wac.ts +10 -6
  16. package/src/index.ts +3 -0
  17. package/src/models/SolidDocument.test.ts +77 -0
  18. package/src/models/SolidDocument.ts +14 -18
  19. package/src/models/SolidStore.ts +22 -12
  20. package/src/models/SolidThing.ts +5 -7
  21. package/src/models/index.ts +2 -0
  22. package/.github/workflows/ci.yml +0 -16
  23. package/.nvmrc +0 -1
  24. package/CHANGELOG.md +0 -70
  25. package/dist/noeldemartin-solid-utils.cjs.js +0 -2
  26. package/dist/noeldemartin-solid-utils.cjs.js.map +0 -1
  27. package/dist/noeldemartin-solid-utils.esm.js +0 -2
  28. package/dist/noeldemartin-solid-utils.esm.js.map +0 -1
  29. package/dist/noeldemartin-solid-utils.umd.js +0 -90
  30. package/dist/noeldemartin-solid-utils.umd.js.map +0 -1
  31. package/noeldemartin.config.js +0 -9
  32. package/src/helpers/testing.ts +0 -190
  33. package/src/main.ts +0 -5
  34. package/src/plugins/chai/assertions.ts +0 -40
  35. package/src/plugins/chai/index.ts +0 -5
  36. package/src/plugins/cypress/types.d.ts +0 -15
  37. package/src/plugins/index.ts +0 -2
  38. package/src/plugins/jest/index.ts +0 -5
  39. package/src/plugins/jest/matchers.ts +0 -65
  40. package/src/plugins/jest/types.d.ts +0 -14
  41. package/src/testing/ResponseStub.ts +0 -46
  42. package/src/testing/index.ts +0 -2
  43. package/src/testing/mocking.ts +0 -33
@@ -1,20 +1,10 @@
1
- declare global {
2
-
3
- namespace jest {
4
-
5
- // TODO generate automatically
6
- interface Matchers<R> {
7
- toEqualSparql(sparql: string): R;
8
- toEqualTurtle(turtle: string): R;
9
- toEqualJsonLD(jsonld: JsonLD): Promise<R>;
10
- }
11
-
12
- }
13
-
14
- }
1
+ import { BlankNode } from '@rdfjs/types';
15
2
  import { JSError } from '@noeldemartin/utils';
16
- import type { JSErrorOptions } from '@noeldemartin/utils';
17
- import type { Quad } from 'rdf-js';
3
+ import { JSErrorOptions } from '@noeldemartin/utils';
4
+ import { Literal } from '@rdfjs/types';
5
+ import { NamedNode } from '@rdfjs/types';
6
+ import { Quad } from '@rdfjs/types';
7
+ import { Variable } from '@rdfjs/types';
18
8
 
19
9
  export declare type AnyFetch = (input: any, options?: any) => Promise<Response>;
20
10
 
@@ -34,13 +24,6 @@ export declare function createSolidDocument(url: string, body: string, fetch?: F
34
24
 
35
25
  export declare function defineIRIPrefix(name: string, value: string): void;
36
26
 
37
- export declare interface EqualityResult {
38
- success: boolean;
39
- message: string;
40
- expected: string;
41
- actual: string;
42
- }
43
-
44
27
  export declare function expandIRI(iri: string, options?: Partial<ExpandIRIOptions>): string;
45
28
 
46
29
  export declare interface ExpandIRIOptions {
@@ -56,11 +39,6 @@ export declare interface FetchLoginUserProfileOptions extends FetchUserProfileOp
56
39
  required?: boolean;
57
40
  }
58
41
 
59
- export declare interface FetchMockMethods {
60
- mockResponse(body?: string, headers?: Record<string, string>, status?: number): void;
61
- mockNotFoundResponse(): void;
62
- }
63
-
64
42
  export declare function fetchSolidDocument(url: string, options?: FetchSolidDocumentOptions): Promise<SolidDocument>;
65
43
 
66
44
  export declare function fetchSolidDocumentACL(documentUrl: string, fetch: Fetch): Promise<{
@@ -91,10 +69,6 @@ export declare function findContainerRegistrations(typeIndexUrl: string, type: s
91
69
  */
92
70
  export declare function findInstanceRegistrations(typeIndexUrl: string, type: string | string[], fetch?: Fetch): Promise<string[]>;
93
71
 
94
- export declare function installChaiPlugin(): void;
95
-
96
- export declare function installJestPlugin(): void;
97
-
98
72
  export declare function isJsonLDGraph(jsonld: JsonLD): jsonld is JsonLDGraph;
99
73
 
100
74
  export declare type JsonLD = Partial<{
@@ -105,8 +79,6 @@ export declare type JsonLD = Partial<{
105
79
  [k: string]: unknown;
106
80
  };
107
81
 
108
- export declare function jsonldEquals(expected: JsonLD, actual: JsonLD): Promise<EqualityResult>;
109
-
110
82
  export declare type JsonLDGraph = {
111
83
  '@context'?: Record<string, unknown>;
112
84
  '@graph': JsonLDResource[];
@@ -127,8 +99,6 @@ export declare class MalformedSolidDocumentError extends JSError {
127
99
 
128
100
  export declare function mintJsonLDIdentifiers(jsonld: JsonLD): JsonLDResource;
129
101
 
130
- export declare function mockFetch<T = any>(): T;
131
-
132
102
  export declare class NetworkRequestError extends JSError {
133
103
  readonly url: string;
134
104
  constructor(url: string, options?: JSErrorOptions);
@@ -165,27 +135,6 @@ export declare interface RDFGraphData {
165
135
  containsRelativeIRIs: boolean;
166
136
  }
167
137
 
168
- export declare class ResponseStub implements Response {
169
- private rawBody;
170
- readonly body: ReadableStream<Uint8Array> | null;
171
- readonly bodyUsed: boolean;
172
- readonly headers: Headers;
173
- readonly ok: boolean;
174
- readonly redirected: boolean;
175
- readonly status: number;
176
- readonly statusText: string;
177
- readonly trailer: Promise<Headers>;
178
- readonly type: ResponseType;
179
- readonly url: string;
180
- constructor(rawBody?: string, headers?: Record<string, string>, status?: number);
181
- arrayBuffer(): Promise<ArrayBuffer>;
182
- blob(): Promise<Blob>;
183
- formData(): Promise<FormData>;
184
- json(): Promise<unknown>;
185
- text(): Promise<string>;
186
- clone(): Response;
187
- }
188
-
189
138
  export declare class SolidDocument extends SolidStore {
190
139
  readonly url: string;
191
140
  readonly headers: Headers;
@@ -221,11 +170,12 @@ export declare class SolidStore {
221
170
  isEmpty(): boolean;
222
171
  getQuads(): Quad[];
223
172
  addQuads(quads: Quad[]): void;
224
- statements(subject?: string, predicate?: string, object?: string): Quad[];
225
- statement(subject?: string, predicate?: string, object?: string): Quad | null;
173
+ statements(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad[];
174
+ statement(subject?: Term | string, predicate?: Term | string, object?: Term | string): Quad | null;
226
175
  contains(subject: string, predicate?: string, object?: string): boolean;
227
176
  getThing(subject: string): SolidThing;
228
177
  protected expandIRI(iri: string): string;
178
+ protected termMatches(term: Term, value: Term | string): boolean;
229
179
  }
230
180
 
231
181
  export declare class SolidThing {
@@ -248,8 +198,6 @@ export declare interface SolidUserProfile {
248
198
  privateTypeIndexUrl?: string;
249
199
  }
250
200
 
251
- export declare function sparqlEquals(expected: string, actual: string): EqualityResult;
252
-
253
201
  export declare function sparqlToQuads(sparql: string, options?: Partial<ParsingOptions>): Promise<Record<string, Quad[]>>;
254
202
 
255
203
  export declare function sparqlToQuadsSync(sparql: string, options?: Partial<ParsingOptions>): Record<string, Quad[]>;
@@ -260,7 +208,7 @@ export declare interface SubjectParts {
260
208
  resourceHash?: string;
261
209
  }
262
210
 
263
- export declare function turtleEquals(expected: string, actual: string): EqualityResult;
211
+ export declare type Term = NamedNode | Literal | BlankNode | Quad | Variable;
264
212
 
265
213
  export declare function turtleToQuads(turtle: string, options?: Partial<ParsingOptions>): Promise<Quad[]>;
266
214