@occultist/occultist 0.0.5 → 0.0.6
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/dist/accept.js +0 -1
- package/dist/actions/actionSets.d.ts +3 -3
- package/dist/actions/actions.d.ts +69 -48
- package/dist/actions/actions.js +39 -4
- package/dist/actions/context.d.ts +15 -11
- package/dist/actions/context.js +5 -0
- package/dist/actions/meta.d.ts +18 -12
- package/dist/actions/meta.js +114 -38
- package/dist/actions/spec.d.ts +3 -3
- package/dist/actions/types.d.ts +45 -16
- package/dist/actions/writer.d.ts +1 -1
- package/dist/actions/writer.test.js +2 -2
- package/dist/cache/cache.d.ts +3 -3
- package/dist/cache/cache.js +111 -42
- package/dist/cache/etag.test.js +1 -1
- package/dist/cache/file.d.ts +32 -1
- package/dist/cache/file.js +89 -10
- package/dist/cache/memory.d.ts +12 -2
- package/dist/cache/memory.js +63 -1
- package/dist/cache/types.d.ts +51 -22
- package/dist/errors.d.ts +1 -1
- package/dist/jsonld.d.ts +1 -1
- package/dist/makeTypeDefs.d.ts +2 -2
- package/dist/mod.d.ts +17 -15
- package/dist/mod.js +17 -15
- package/dist/processAction.d.ts +2 -2
- package/dist/processAction.js +1 -1
- package/dist/registry.d.ts +74 -8
- package/dist/registry.js +70 -8
- package/dist/registry.test.js +1 -1
- package/dist/scopes.d.ts +8 -8
- package/dist/scopes.js +8 -5
- package/dist/utils/contextBuilder.d.ts +1 -1
- package/dist/utils/getActionContext.d.ts +2 -2
- package/dist/utils/getPropertyValueSpecifications.d.ts +1 -1
- package/dist/utils/getRequestBodyValues.d.ts +3 -3
- package/dist/utils/getRequestIRIValues.d.ts +2 -2
- package/dist/utils/isPopulatedObject.js +1 -1
- package/dist/utils/makeAppendProblemDetails.d.ts +1 -1
- package/dist/utils/makeURLPattern.js +1 -0
- package/dist/utils/parseSearchParams.d.ts +2 -2
- package/dist/validators.d.ts +2 -2
- package/dist/validators.js +2 -2
- package/lib/accept.test.ts +1 -1
- package/lib/accept.ts +0 -2
- package/lib/actions/actionSets.ts +4 -4
- package/lib/actions/actions.ts +159 -99
- package/lib/actions/context.ts +22 -10
- package/lib/actions/meta.ts +140 -55
- package/lib/actions/path.test.ts +1 -1
- package/lib/actions/path.ts +1 -1
- package/lib/actions/spec.ts +3 -3
- package/lib/actions/types.ts +60 -15
- package/lib/actions/writer.test.ts +2 -2
- package/lib/actions/writer.ts +1 -1
- package/lib/cache/cache.ts +138 -52
- package/lib/cache/etag.test.ts +1 -1
- package/lib/cache/file.ts +109 -13
- package/lib/cache/memory.ts +85 -3
- package/lib/cache/types.ts +70 -23
- package/lib/errors.ts +1 -1
- package/lib/jsonld.ts +1 -1
- package/lib/makeTypeDefs.ts +5 -5
- package/lib/mod.ts +17 -15
- package/lib/processAction.ts +14 -14
- package/lib/registry.test.ts +1 -1
- package/lib/registry.ts +96 -19
- package/lib/request.ts +1 -1
- package/lib/scopes.test.ts +2 -2
- package/lib/scopes.ts +14 -11
- package/lib/utils/contextBuilder.ts +3 -3
- package/lib/utils/getActionContext.ts +4 -4
- package/lib/utils/getInternalName.ts +1 -1
- package/lib/utils/getPropertyValueSpecifications.ts +4 -4
- package/lib/utils/getRequestBodyValues.ts +5 -5
- package/lib/utils/getRequestIRIValues.ts +4 -4
- package/lib/utils/isPopulatedObject.ts +1 -1
- package/lib/utils/makeAppendProblemDetails.ts +1 -1
- package/lib/utils/makeURLPattern.ts +1 -0
- package/lib/utils/parseSearchParams.ts +2 -2
- package/lib/validators.ts +5 -5
- package/package.json +4 -2
package/dist/registry.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { Accept } from "./accept.
|
|
2
|
-
import { ActionAuth, HandlerDefinition } from "./actions/actions.
|
|
3
|
-
import { type ActionMatchResult, ActionSet } from "./actions/actionSets.
|
|
4
|
-
import type { ImplementedAction } from "./actions/types.
|
|
5
|
-
import { Scope } from './scopes.
|
|
1
|
+
import { Accept } from "./accept.ts";
|
|
2
|
+
import { ActionAuth, HandlerDefinition } from "./actions/actions.ts";
|
|
3
|
+
import { type ActionMatchResult, ActionSet } from "./actions/actionSets.ts";
|
|
4
|
+
import type { CacheHitHeader, ImplementedAction } from "./actions/types.ts";
|
|
5
|
+
import { Scope } from './scopes.ts';
|
|
6
6
|
import { IncomingMessage, type ServerResponse } from "node:http";
|
|
7
|
-
import type { Merge } from "./actions/spec.
|
|
8
|
-
import type { ContextState, Middleware } from "./actions/spec.
|
|
7
|
+
import type { Merge } from "./actions/spec.ts";
|
|
8
|
+
import type { ContextState, Middleware } from "./actions/spec.ts";
|
|
9
9
|
export interface Callable<State extends ContextState = ContextState> {
|
|
10
10
|
method(method: string, name: string, path: string): ActionAuth<State>;
|
|
11
11
|
}
|
|
12
12
|
export declare class HTTP<State extends ContextState = ContextState> {
|
|
13
13
|
#private;
|
|
14
14
|
constructor(callable: Callable<State>);
|
|
15
|
-
trace(name: string, path: string): ActionAuth<State>;
|
|
16
15
|
options(name: string, path: string): ActionAuth<State>;
|
|
17
16
|
head(name: string, path: string): ActionAuth<State>;
|
|
18
17
|
get(name: string, path: string): ActionAuth<State>;
|
|
@@ -20,6 +19,7 @@ export declare class HTTP<State extends ContextState = ContextState> {
|
|
|
20
19
|
patch(name: string, path: string): ActionAuth<State>;
|
|
21
20
|
post(name: string, path: string): ActionAuth<State>;
|
|
22
21
|
delete(name: string, path: string): ActionAuth<State>;
|
|
22
|
+
query(name: string, path: string): ActionAuth<State>;
|
|
23
23
|
}
|
|
24
24
|
export type IndexMatchArgs = {
|
|
25
25
|
debug?: boolean;
|
|
@@ -31,9 +31,75 @@ export declare class IndexEntry {
|
|
|
31
31
|
}
|
|
32
32
|
export type RegistryEvents = 'beforefinalize' | 'afterfinalize';
|
|
33
33
|
export type RegistryArgs = {
|
|
34
|
+
/**
|
|
35
|
+
* The public root endpoint the registry is bound to.
|
|
36
|
+
*/
|
|
34
37
|
rootIRI: string;
|
|
38
|
+
/**
|
|
39
|
+
* Set to `true` if a cache header should be added to the response when
|
|
40
|
+
* cache is successfully hit. Or assign custom header values.
|
|
41
|
+
*/
|
|
42
|
+
cacheHitHeader?: CacheHitHeader;
|
|
43
|
+
/**
|
|
44
|
+
* Enables adding server timing headers to the response.
|
|
45
|
+
*/
|
|
35
46
|
serverTiming?: boolean;
|
|
36
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* All actions of an Occultist based API are created through an action registry.
|
|
50
|
+
* The registry exposes an interface for querying registered actions and emits events
|
|
51
|
+
* when userland actions have all been defined. Extensions can register themselves
|
|
52
|
+
* with the registry and create more actions and endpoints using the actions defined
|
|
53
|
+
* in userland. Userland code might also use the registry's querying functionality
|
|
54
|
+
* to programically make API calls as though they were made over the network via HTTP.
|
|
55
|
+
*
|
|
56
|
+
* @example <caption>Creates a simple registry that responds with a HTML document</caption>
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
59
|
+
* import {createServer} from 'node:http':
|
|
60
|
+
* import {Registry} from '@occultist/occultist';
|
|
61
|
+
*
|
|
62
|
+
* const server = createServer();
|
|
63
|
+
* const registry = new Registry({ rootIRI: 'https://example.com' });
|
|
64
|
+
*
|
|
65
|
+
* registry.http.get('get-root', '/')
|
|
66
|
+
* .handle('text/html', `
|
|
67
|
+
* <!doctype html>
|
|
68
|
+
* <html>
|
|
69
|
+
* <head><title>Hello, World!</title></head>
|
|
70
|
+
* <body>
|
|
71
|
+
* <h1>Hello, World!</h1>
|
|
72
|
+
* </body>
|
|
73
|
+
* </body>
|
|
74
|
+
* `);
|
|
75
|
+
*
|
|
76
|
+
*
|
|
77
|
+
* server.on('request', (req, res) => registry.handleRequest(req, res));
|
|
78
|
+
* server.listen(3000);
|
|
79
|
+
*
|
|
80
|
+
* // makes a call programically to the registry
|
|
81
|
+
* const res = await registry.handleRequest(new Request('https://example.com'));
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param args.rootIRI The public root endpoint the registry is bound to. If the
|
|
85
|
+
* registry responds to requests on a subpath, the subpath should be included
|
|
86
|
+
* in the `rootIRI` value.
|
|
87
|
+
*
|
|
88
|
+
* @param args.cacheHitHeader A custom cache hit header. If set to true Occultist
|
|
89
|
+
* will use the standard `X-Cache` header and the value `HIT`. If a string is
|
|
90
|
+
* provided the header name will be set to the value of the string. If an array
|
|
91
|
+
* is provided the header name will be set to the first item in the array, and
|
|
92
|
+
* the header value the second. Occultist does not set the cache header on
|
|
93
|
+
* cache misses. By default Occultist will not set a cache hit header.
|
|
94
|
+
*
|
|
95
|
+
* @param args.serverTiming Enables server timing headers in responses. When
|
|
96
|
+
* enabled requests log the duration of the steps Occultist takes when
|
|
97
|
+
* finding the action to respond to the request, retrieving values from
|
|
98
|
+
* cache, or calling the handler functions of an action. Browser debug tools
|
|
99
|
+
* add these values to their network performance charts.
|
|
100
|
+
* Enabling server timing can leak information and is not recommended for
|
|
101
|
+
* production environments.
|
|
102
|
+
*/
|
|
37
103
|
export declare class Registry<State extends ContextState = ContextState> implements Callable<State> {
|
|
38
104
|
#private;
|
|
39
105
|
constructor(args: RegistryArgs);
|
package/dist/registry.js
CHANGED
|
@@ -3,7 +3,7 @@ import { ActionAuth } from "./actions/actions.js";
|
|
|
3
3
|
import { ActionSet } from "./actions/actionSets.js";
|
|
4
4
|
import { ActionMeta } from "./actions/meta.js";
|
|
5
5
|
import { ResponseWriter } from "./actions/writer.js";
|
|
6
|
-
import { Scope } from
|
|
6
|
+
import { Scope } from "./scopes.js";
|
|
7
7
|
import { ProblemDetailsError } from "./errors.js";
|
|
8
8
|
import { WrappedRequest } from "./request.js";
|
|
9
9
|
export class HTTP {
|
|
@@ -11,9 +11,6 @@ export class HTTP {
|
|
|
11
11
|
constructor(callable) {
|
|
12
12
|
this.#callable = callable;
|
|
13
13
|
}
|
|
14
|
-
trace(name, path) {
|
|
15
|
-
return this.#callable.method('trace', name, path);
|
|
16
|
-
}
|
|
17
14
|
options(name, path) {
|
|
18
15
|
return this.#callable.method('options', name, path);
|
|
19
16
|
}
|
|
@@ -35,6 +32,9 @@ export class HTTP {
|
|
|
35
32
|
delete(name, path) {
|
|
36
33
|
return this.#callable.method('delete', name, path);
|
|
37
34
|
}
|
|
35
|
+
query(name, path) {
|
|
36
|
+
return this.#callable.method('query', name, path);
|
|
37
|
+
}
|
|
38
38
|
}
|
|
39
39
|
export class IndexEntry {
|
|
40
40
|
#actionSets;
|
|
@@ -52,11 +52,67 @@ export class IndexEntry {
|
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* All actions of an Occultist based API are created through an action registry.
|
|
57
|
+
* The registry exposes an interface for querying registered actions and emits events
|
|
58
|
+
* when userland actions have all been defined. Extensions can register themselves
|
|
59
|
+
* with the registry and create more actions and endpoints using the actions defined
|
|
60
|
+
* in userland. Userland code might also use the registry's querying functionality
|
|
61
|
+
* to programically make API calls as though they were made over the network via HTTP.
|
|
62
|
+
*
|
|
63
|
+
* @example <caption>Creates a simple registry that responds with a HTML document</caption>
|
|
64
|
+
*
|
|
65
|
+
* ```
|
|
66
|
+
* import {createServer} from 'node:http':
|
|
67
|
+
* import {Registry} from '@occultist/occultist';
|
|
68
|
+
*
|
|
69
|
+
* const server = createServer();
|
|
70
|
+
* const registry = new Registry({ rootIRI: 'https://example.com' });
|
|
71
|
+
*
|
|
72
|
+
* registry.http.get('get-root', '/')
|
|
73
|
+
* .handle('text/html', `
|
|
74
|
+
* <!doctype html>
|
|
75
|
+
* <html>
|
|
76
|
+
* <head><title>Hello, World!</title></head>
|
|
77
|
+
* <body>
|
|
78
|
+
* <h1>Hello, World!</h1>
|
|
79
|
+
* </body>
|
|
80
|
+
* </body>
|
|
81
|
+
* `);
|
|
82
|
+
*
|
|
83
|
+
*
|
|
84
|
+
* server.on('request', (req, res) => registry.handleRequest(req, res));
|
|
85
|
+
* server.listen(3000);
|
|
86
|
+
*
|
|
87
|
+
* // makes a call programically to the registry
|
|
88
|
+
* const res = await registry.handleRequest(new Request('https://example.com'));
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @param args.rootIRI The public root endpoint the registry is bound to. If the
|
|
92
|
+
* registry responds to requests on a subpath, the subpath should be included
|
|
93
|
+
* in the `rootIRI` value.
|
|
94
|
+
*
|
|
95
|
+
* @param args.cacheHitHeader A custom cache hit header. If set to true Occultist
|
|
96
|
+
* will use the standard `X-Cache` header and the value `HIT`. If a string is
|
|
97
|
+
* provided the header name will be set to the value of the string. If an array
|
|
98
|
+
* is provided the header name will be set to the first item in the array, and
|
|
99
|
+
* the header value the second. Occultist does not set the cache header on
|
|
100
|
+
* cache misses. By default Occultist will not set a cache hit header.
|
|
101
|
+
*
|
|
102
|
+
* @param args.serverTiming Enables server timing headers in responses. When
|
|
103
|
+
* enabled requests log the duration of the steps Occultist takes when
|
|
104
|
+
* finding the action to respond to the request, retrieving values from
|
|
105
|
+
* cache, or calling the handler functions of an action. Browser debug tools
|
|
106
|
+
* add these values to their network performance charts.
|
|
107
|
+
* Enabling server timing can leak information and is not recommended for
|
|
108
|
+
* production environments.
|
|
109
|
+
*/
|
|
55
110
|
export class Registry {
|
|
56
111
|
#finalized = false;
|
|
57
112
|
#path;
|
|
58
113
|
#rootIRI;
|
|
59
114
|
#serverTiming;
|
|
115
|
+
#cacheHitHeader;
|
|
60
116
|
#http;
|
|
61
117
|
#scopes = [];
|
|
62
118
|
#children = [];
|
|
@@ -71,6 +127,7 @@ export class Registry {
|
|
|
71
127
|
this.#rootIRI = args.rootIRI;
|
|
72
128
|
this.#path = url.pathname;
|
|
73
129
|
this.#serverTiming = args.serverTiming ?? false;
|
|
130
|
+
this.#cacheHitHeader = args.cacheHitHeader ?? false;
|
|
74
131
|
this.#http = new HTTP(this);
|
|
75
132
|
}
|
|
76
133
|
scope(path) {
|
|
@@ -260,6 +317,9 @@ export class Registry {
|
|
|
260
317
|
Object.freeze(this);
|
|
261
318
|
}
|
|
262
319
|
async handleRequest(req, res) {
|
|
320
|
+
if (!this.#finalized) {
|
|
321
|
+
this.finalize();
|
|
322
|
+
}
|
|
263
323
|
const startTime = performance.now();
|
|
264
324
|
const wrapped = new WrappedRequest(this.#rootIRI, req);
|
|
265
325
|
const writer = new ResponseWriter(res);
|
|
@@ -274,6 +334,7 @@ export class Registry {
|
|
|
274
334
|
req: wrapped,
|
|
275
335
|
writer,
|
|
276
336
|
startTime,
|
|
337
|
+
cacheHitHeader: this.#cacheHitHeader,
|
|
277
338
|
});
|
|
278
339
|
}
|
|
279
340
|
}
|
|
@@ -282,6 +343,7 @@ export class Registry {
|
|
|
282
343
|
err = err2;
|
|
283
344
|
}
|
|
284
345
|
else {
|
|
346
|
+
console.log(err2);
|
|
285
347
|
err = new ProblemDetailsError(500, 'Internal server error');
|
|
286
348
|
}
|
|
287
349
|
}
|
|
@@ -289,18 +351,18 @@ export class Registry {
|
|
|
289
351
|
err = new ProblemDetailsError(404, 'Not found');
|
|
290
352
|
}
|
|
291
353
|
if (err instanceof ProblemDetailsError && req instanceof Request) {
|
|
292
|
-
return new Response(err.toContent('application/problem
|
|
354
|
+
return new Response(err.toContent('application/problem.json'), {
|
|
293
355
|
status: err.status,
|
|
294
356
|
headers: {
|
|
295
|
-
'Content-Type': 'application/problem
|
|
357
|
+
'Content-Type': 'application/problem.json',
|
|
296
358
|
},
|
|
297
359
|
});
|
|
298
360
|
}
|
|
299
361
|
else if (err instanceof ProblemDetailsError && res != null) {
|
|
300
362
|
res.writeHead(err.status, {
|
|
301
|
-
'Content-Type': 'application/problem
|
|
363
|
+
'Content-Type': 'application/problem.json',
|
|
302
364
|
});
|
|
303
|
-
res.end(err.toContent('application/problem
|
|
365
|
+
res.end(err.toContent('application/problem.json'));
|
|
304
366
|
return res;
|
|
305
367
|
}
|
|
306
368
|
}
|
package/dist/registry.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from 'node:assert/strict';
|
|
2
2
|
import test from 'node:test';
|
|
3
|
-
import { Registry } from
|
|
3
|
+
import { Registry } from "./registry.js";
|
|
4
4
|
import { createServer } from 'node:http';
|
|
5
5
|
const registry = new Registry({
|
|
6
6
|
rootIRI: 'https://example.com',
|
package/dist/scopes.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ActionAuth, HandlerDefinition } from "./actions/actions.
|
|
2
|
-
import { ActionMeta } from "./actions/meta.
|
|
3
|
-
import type { ContextState } from "./actions/spec.
|
|
4
|
-
import type { ImplementedAction } from "./actions/types.
|
|
5
|
-
import type { HTTPWriter } from "./actions/writer.
|
|
6
|
-
import { type Callable, HTTP, type Registry } from './registry.
|
|
1
|
+
import { ActionAuth, HandlerDefinition } from "./actions/actions.ts";
|
|
2
|
+
import { ActionMeta } from "./actions/meta.ts";
|
|
3
|
+
import type { ContextState } from "./actions/spec.ts";
|
|
4
|
+
import type { AuthMiddleware, ImplementedAction } from "./actions/types.ts";
|
|
5
|
+
import type { HTTPWriter } from "./actions/writer.ts";
|
|
6
|
+
import { type Callable, HTTP, type Registry } from './registry.ts';
|
|
7
7
|
export type MetaPropatator = (meta: ActionMeta) => void;
|
|
8
8
|
export type ScopeArgs = {
|
|
9
9
|
path: string;
|
|
@@ -20,8 +20,8 @@ export declare class Scope<State extends ContextState = ContextState> implements
|
|
|
20
20
|
get http(): HTTP<State>;
|
|
21
21
|
get actions(): Array<ImplementedAction>;
|
|
22
22
|
get handlers(): HandlerDefinition[];
|
|
23
|
-
public(): Scope<State>;
|
|
24
|
-
private(): Scope<State>;
|
|
23
|
+
public(authMiddleware?: AuthMiddleware): Scope<State>;
|
|
24
|
+
private(authMiddleware: AuthMiddleware): Scope<State>;
|
|
25
25
|
/**
|
|
26
26
|
* Creates any HTTP method.
|
|
27
27
|
*
|
package/dist/scopes.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { joinPaths } from "./utils/joinPaths.js";
|
|
2
2
|
import { ActionAuth } from "./actions/actions.js";
|
|
3
3
|
import { ActionMeta } from "./actions/meta.js";
|
|
4
|
-
import { HTTP } from
|
|
4
|
+
import { HTTP } from "./registry.js";
|
|
5
5
|
export class Scope {
|
|
6
6
|
#path;
|
|
7
7
|
#serverTiming = false;
|
|
@@ -10,6 +10,7 @@ export class Scope {
|
|
|
10
10
|
#http;
|
|
11
11
|
#children = [];
|
|
12
12
|
#public = true;
|
|
13
|
+
#auth;
|
|
13
14
|
#propergateMeta;
|
|
14
15
|
constructor({ path, serverTiming, registry, writer, propergateMeta, }) {
|
|
15
16
|
this.#path = path;
|
|
@@ -41,12 +42,14 @@ export class Scope {
|
|
|
41
42
|
get handlers() {
|
|
42
43
|
return this.actions.flatMap((action) => action.handlers);
|
|
43
44
|
}
|
|
44
|
-
public() {
|
|
45
|
+
public(authMiddleware) {
|
|
45
46
|
this.#public = true;
|
|
47
|
+
this.#auth = authMiddleware;
|
|
46
48
|
return this;
|
|
47
49
|
}
|
|
48
|
-
private() {
|
|
50
|
+
private(authMiddleware) {
|
|
49
51
|
this.#public = false;
|
|
52
|
+
this.#auth = authMiddleware;
|
|
50
53
|
return this;
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
@@ -104,14 +107,14 @@ export class Scope {
|
|
|
104
107
|
}
|
|
105
108
|
if (this.#public) {
|
|
106
109
|
this.#registry.http.get('scope-action', joinPaths(this.url(), action.name))
|
|
107
|
-
.public()
|
|
110
|
+
.public(this.#auth)
|
|
108
111
|
.handle('application/ld+json', async (ctx) => {
|
|
109
112
|
ctx.body = JSON.stringify(await action.jsonld());
|
|
110
113
|
});
|
|
111
114
|
}
|
|
112
115
|
else {
|
|
113
116
|
this.#registry.http.get('scope-action', joinPaths(this.url(), action.name))
|
|
114
|
-
.private()
|
|
117
|
+
.private(this.#auth)
|
|
115
118
|
.handle('application/ld+json', async (ctx) => {
|
|
116
119
|
ctx.body = JSON.stringify(await action.jsonld());
|
|
117
120
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JSONLDContext, ContextVersion, TypeDef } from "../jsonld.
|
|
1
|
+
import type { JSONLDContext, ContextVersion, TypeDef } from "../jsonld.ts";
|
|
2
2
|
export declare function contextBuilder({ vocab, version, protect, idTerm, aliases, typeDefs: argsTypeDefs, }: {
|
|
3
3
|
idTerm?: string;
|
|
4
4
|
vocab?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { JSONLDContext } from "../jsonld.
|
|
2
|
-
import type { ActionSpec } from '../actions/spec.
|
|
1
|
+
import type { JSONLDContext } from "../jsonld.ts";
|
|
2
|
+
import type { ActionSpec } from '../actions/spec.ts';
|
|
3
3
|
export declare function getActionContext({ spec, vocab, aliases, }: {
|
|
4
4
|
vocab?: string;
|
|
5
5
|
aliases?: Record<string, string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ActionSpec, SpecValue } from "../actions/spec.
|
|
1
|
+
import type { ActionSpec, SpecValue } from "../actions/spec.ts";
|
|
2
2
|
export declare function getPropertyValueSpecifications(spec: ActionSpec<any>): Promise<SpecValue>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { JSONValue } from "../jsonld.
|
|
2
|
-
import type { ContextState, ActionSpec } from "../actions/spec.
|
|
3
|
-
import type { ImplementedAction } from "../actions/types.
|
|
1
|
+
import type { JSONValue } from "../jsonld.ts";
|
|
2
|
+
import type { ContextState, ActionSpec } from "../actions/spec.ts";
|
|
3
|
+
import type { ImplementedAction } from "../actions/types.ts";
|
|
4
4
|
export type BodyValue = Record<string, JSONValue>;
|
|
5
5
|
export type RequestBodyResult = {
|
|
6
6
|
bodyValues: BodyValue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ImplementedAction } from "../actions/types.
|
|
2
|
-
import type { ActionSpec, ContextState, FileSingleSpec, FileMultiSpec, BooleanSingleSpec, BooleanMultiSpec, NumberSingleSpec, NumberMultiSpec, StringSingleSpec, StringMultiSpec, ParsedIRIValues } from "../actions/spec.
|
|
1
|
+
import type { ImplementedAction } from "../actions/types.ts";
|
|
2
|
+
import type { ActionSpec, ContextState, FileSingleSpec, FileMultiSpec, BooleanSingleSpec, BooleanMultiSpec, NumberSingleSpec, NumberMultiSpec, StringSingleSpec, StringMultiSpec, ParsedIRIValues } from "../actions/spec.ts";
|
|
3
3
|
export type IRIValue<Spec extends ActionSpec<ContextState> = ActionSpec<ContextState>> = {
|
|
4
4
|
[Term in keyof Spec]: (Spec[Term] extends FileSingleSpec | FileMultiSpec ? never : Spec[Term]['valueName'] extends string ? (Spec[Term] extends BooleanSingleSpec ? boolean : Spec[Term] extends BooleanMultiSpec ? boolean[] : Spec[Term] extends NumberSingleSpec ? number : Spec[Term] extends NumberMultiSpec ? number[] : Spec[Term] extends StringSingleSpec ? string : Spec[Term] extends StringMultiSpec ? string[] : never) : never);
|
|
5
5
|
};
|
|
@@ -6,6 +6,7 @@ import url from 'node:url';
|
|
|
6
6
|
export function makeURLPattern(pattern, baseURL) {
|
|
7
7
|
if (typeof URLPattern === 'undefined') {
|
|
8
8
|
const URLPattern = url.URLPattern;
|
|
9
|
+
console.log(url.URLPattern);
|
|
9
10
|
return new URLPattern(pattern, baseURL);
|
|
10
11
|
}
|
|
11
12
|
return new URLPattern(pattern, baseURL);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { ActionSpec, ContextState } from "../actions/spec.
|
|
2
|
-
import type { EmptyObject, JSONObject } from "../jsonld.
|
|
1
|
+
import type { ActionSpec, ContextState } from "../actions/spec.ts";
|
|
2
|
+
import type { EmptyObject, JSONObject } from "../jsonld.ts";
|
|
3
3
|
export declare function parseSearchParams<ActionState extends ContextState = EmptyObject>(spec: ActionSpec<ActionState>, searchParams: URLSearchParams): JSONObject;
|
package/dist/validators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ArraySpec, ObjectArraySpec, ObjectSpec, PropertySpec } from './actions/spec.
|
|
2
|
-
import { JSONValue } from "./jsonld.
|
|
1
|
+
import type { ArraySpec, ObjectArraySpec, ObjectSpec, PropertySpec } from './actions/spec.ts';
|
|
2
|
+
import type { JSONValue } from "./jsonld.ts";
|
|
3
3
|
export declare function isFileData(value: JSONValue | File): value is string | File;
|
|
4
4
|
export declare function isObjectArraySpec(spec: PropertySpec): spec is ObjectArraySpec;
|
|
5
5
|
export declare function isObjectSpec(spec: PropertySpec): spec is ObjectSpec;
|
package/dist/validators.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isObject } from
|
|
2
|
-
import { preferredMediaTypes } from
|
|
1
|
+
import { isObject } from "./utils/isObject.js";
|
|
2
|
+
import { preferredMediaTypes } from "./utils/preferredMediaTypes.js";
|
|
3
3
|
// deno-lint-ignore no-explicit-any
|
|
4
4
|
export function isFileData(value) {
|
|
5
5
|
if (typeof value === 'string' && value.startsWith('data:')) {
|
package/lib/accept.test.ts
CHANGED
package/lib/accept.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { ContentTypeCache, type Accept } from "../accept.
|
|
2
|
-
import { makeURLPattern } from "../utils/makeURLPattern.
|
|
3
|
-
import type { ActionMeta } from "./meta.
|
|
4
|
-
import type { ImplementedAction } from "./types.
|
|
1
|
+
import { ContentTypeCache, type Accept } from "../accept.ts";
|
|
2
|
+
import { makeURLPattern } from "../utils/makeURLPattern.ts";
|
|
3
|
+
import type { ActionMeta } from "./meta.ts";
|
|
4
|
+
import type { ImplementedAction } from "./types.ts";
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
export type UnsupportedContentTypeMatch = {
|