@skipruntime/helpers 0.0.4 → 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/external.d.ts +40 -31
- package/dist/external.d.ts.map +1 -1
- package/dist/external.js +46 -11
- package/dist/external.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/rest.d.ts +108 -20
- package/dist/rest.d.ts.map +1 -1
- package/dist/rest.js +117 -13
- package/dist/rest.js.map +1 -1
- package/package.json +4 -4
- package/src/external.ts +62 -25
- package/src/index.ts +15 -3
- package/src/rest.ts +139 -33
- package/dist/errors.d.ts +0 -3
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -3
- package/dist/errors.js.map +0 -1
- package/dist/remote.d.ts +0 -22
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -71
- package/dist/remote.js.map +0 -1
- package/dist/utils.d.ts +0 -22
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -40
- package/dist/utils.js.map +0 -1
- package/src/errors.ts +0 -1
- package/src/remote.ts +0 -94
- package/src/utils.ts +0 -48
package/dist/external.d.ts
CHANGED
|
@@ -1,61 +1,70 @@
|
|
|
1
1
|
import type { Entry, ExternalService, Json } from "@skipruntime/api";
|
|
2
|
+
/**
|
|
3
|
+
* Interface required by `GenericExternalService` for external resources.
|
|
4
|
+
*/
|
|
2
5
|
export interface ExternalResource {
|
|
3
|
-
open(params: {
|
|
4
|
-
[param: string]: string | number;
|
|
5
|
-
}, callbacks: {
|
|
6
|
+
open(params: Json, callbacks: {
|
|
6
7
|
update: (updates: Entry<Json, Json>[], isInit: boolean) => void;
|
|
7
8
|
error: (error: Json) => void;
|
|
8
9
|
loading: () => void;
|
|
9
10
|
}): void;
|
|
10
|
-
close(params:
|
|
11
|
-
[param: string]: string | number;
|
|
12
|
-
}): void;
|
|
11
|
+
close(params: Json): void;
|
|
13
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* A generic external service providing external resources.
|
|
15
|
+
*
|
|
16
|
+
* `GenericExternalService` provides an implementation of `ExternalService` for external resources by lifting the `open` and `close` operations from `ExternalResource` to the `subscribe` and `unsubscribe` operations required by `ExternalService`.
|
|
17
|
+
*/
|
|
14
18
|
export declare class GenericExternalService implements ExternalService {
|
|
15
|
-
private resources;
|
|
19
|
+
private readonly resources;
|
|
20
|
+
/**
|
|
21
|
+
* @param resources - Association of resource names to `ExternalResource`s.
|
|
22
|
+
*/
|
|
16
23
|
constructor(resources: {
|
|
17
24
|
[name: string]: ExternalResource;
|
|
18
25
|
});
|
|
19
|
-
subscribe(resourceName: string, params: {
|
|
20
|
-
[param: string]: string | number;
|
|
21
|
-
}, callbacks: {
|
|
26
|
+
subscribe(resourceName: string, params: Json, callbacks: {
|
|
22
27
|
update: (updates: Entry<Json, Json>[], isInit: boolean) => void;
|
|
23
28
|
error: (error: Json) => void;
|
|
24
29
|
loading: () => void;
|
|
25
30
|
}): void;
|
|
26
|
-
unsubscribe(resourceName: string, params:
|
|
27
|
-
[param: string]: string;
|
|
28
|
-
}): void;
|
|
31
|
+
unsubscribe(resourceName: string, params: Json): void;
|
|
29
32
|
shutdown(): void;
|
|
30
33
|
}
|
|
31
34
|
export declare class TimerResource implements ExternalResource {
|
|
32
|
-
private intervals;
|
|
33
|
-
open(params: {
|
|
34
|
-
[param: string]: string | number;
|
|
35
|
-
}, callbacks: {
|
|
35
|
+
private readonly intervals;
|
|
36
|
+
open(params: Json, callbacks: {
|
|
36
37
|
update: (updates: Entry<Json, Json>[], isInit: boolean) => void;
|
|
37
38
|
error: (error: Json) => void;
|
|
38
39
|
loading: () => void;
|
|
39
40
|
}): void;
|
|
40
|
-
close(params:
|
|
41
|
-
[param: string]: string | number;
|
|
42
|
-
}): void;
|
|
41
|
+
close(params: Json): void;
|
|
43
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* An external resource that is refreshed at some polling interval.
|
|
45
|
+
*
|
|
46
|
+
* @typeParam S - Type of data received from external resource.
|
|
47
|
+
* @typeParam K - Type of keys.
|
|
48
|
+
* @typeParam V - Type of values.
|
|
49
|
+
*/
|
|
44
50
|
export declare class Polled<S extends Json, K extends Json, V extends Json> implements ExternalResource {
|
|
45
|
-
private url;
|
|
46
|
-
private duration;
|
|
47
|
-
private conv;
|
|
48
|
-
private
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
private readonly url;
|
|
52
|
+
private readonly duration;
|
|
53
|
+
private readonly conv;
|
|
54
|
+
private readonly encodeParams;
|
|
55
|
+
private readonly intervals;
|
|
56
|
+
/**
|
|
57
|
+
* @param url - HTTP endpoint of external resource to poll.
|
|
58
|
+
* @param duration - Refresh interval, in milliseconds.
|
|
59
|
+
* @param conv - Function to convert data of type `S` received from external resource to `key`-`value` entries.
|
|
60
|
+
* @param encodeParams - Function to use to encode params of type `Json` for external resource request.
|
|
61
|
+
*/
|
|
62
|
+
constructor(url: string, duration: number, conv: (data: S) => Entry<K, V>[], encodeParams?: (params: Json) => string);
|
|
63
|
+
open(params: Json, callbacks: {
|
|
53
64
|
update: (updates: Entry<Json, Json>[], isInit: boolean) => void;
|
|
54
65
|
error: (error: Json) => void;
|
|
55
66
|
loading: () => void;
|
|
56
67
|
}): void;
|
|
57
|
-
close(params:
|
|
58
|
-
[param: string]: string | number;
|
|
59
|
-
}): void;
|
|
68
|
+
close(params: Json): void;
|
|
60
69
|
}
|
|
61
70
|
//# sourceMappingURL=external.d.ts.map
|
package/dist/external.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGrE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CACF,MAAM,E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 +1,13 @@
|
|
|
1
1
|
import { fetchJSON } from "./rest.js";
|
|
2
|
+
/**
|
|
3
|
+
* A generic external service providing external resources.
|
|
4
|
+
*
|
|
5
|
+
* `GenericExternalService` provides an implementation of `ExternalService` for external resources by lifting the `open` and `close` operations from `ExternalResource` to the `subscribe` and `unsubscribe` operations required by `ExternalService`.
|
|
6
|
+
*/
|
|
2
7
|
export class GenericExternalService {
|
|
8
|
+
/**
|
|
9
|
+
* @param resources - Association of resource names to `ExternalResource`s.
|
|
10
|
+
*/
|
|
3
11
|
constructor(resources) {
|
|
4
12
|
this.resources = resources;
|
|
5
13
|
}
|
|
@@ -54,21 +62,44 @@ export class TimerResource {
|
|
|
54
62
|
}
|
|
55
63
|
}
|
|
56
64
|
}
|
|
65
|
+
function defaultParamEncoder(params) {
|
|
66
|
+
if (typeof params == "object") {
|
|
67
|
+
const queryParams = {};
|
|
68
|
+
for (const [key, value] of Object.entries(params)) {
|
|
69
|
+
if (typeof value == "object")
|
|
70
|
+
queryParams[key] = JSON.stringify(value);
|
|
71
|
+
else
|
|
72
|
+
queryParams[key] = value.toString();
|
|
73
|
+
}
|
|
74
|
+
return new URLSearchParams(queryParams).toString();
|
|
75
|
+
}
|
|
76
|
+
else
|
|
77
|
+
return `params=${JSON.stringify(params)}`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* An external resource that is refreshed at some polling interval.
|
|
81
|
+
*
|
|
82
|
+
* @typeParam S - Type of data received from external resource.
|
|
83
|
+
* @typeParam K - Type of keys.
|
|
84
|
+
* @typeParam V - Type of values.
|
|
85
|
+
*/
|
|
57
86
|
export class Polled {
|
|
58
|
-
|
|
87
|
+
/**
|
|
88
|
+
* @param url - HTTP endpoint of external resource to poll.
|
|
89
|
+
* @param duration - Refresh interval, in milliseconds.
|
|
90
|
+
* @param conv - Function to convert data of type `S` received from external resource to `key`-`value` entries.
|
|
91
|
+
* @param encodeParams - Function to use to encode params of type `Json` for external resource request.
|
|
92
|
+
*/
|
|
93
|
+
constructor(url, duration, conv, encodeParams = defaultParamEncoder) {
|
|
59
94
|
this.url = url;
|
|
60
95
|
this.duration = duration;
|
|
61
96
|
this.conv = conv;
|
|
97
|
+
this.encodeParams = encodeParams;
|
|
62
98
|
this.intervals = new Map();
|
|
63
99
|
}
|
|
64
100
|
open(params, callbacks) {
|
|
65
101
|
this.close(params);
|
|
66
|
-
const
|
|
67
|
-
for (const [key, value] of Object.entries(params)) {
|
|
68
|
-
queryParams[key] = value.toString();
|
|
69
|
-
}
|
|
70
|
-
const strParams = new URLSearchParams(queryParams).toString();
|
|
71
|
-
const url = `${this.url}?${strParams}`;
|
|
102
|
+
const url = `${this.url}?${this.encodeParams(params)}`;
|
|
72
103
|
const call = () => {
|
|
73
104
|
callbacks.loading();
|
|
74
105
|
fetchJSON(url, "GET", {})
|
|
@@ -91,9 +122,13 @@ export class Polled {
|
|
|
91
122
|
}
|
|
92
123
|
}
|
|
93
124
|
function toId(params) {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
125
|
+
if (typeof params == "object") {
|
|
126
|
+
const strparams = Object.entries(params)
|
|
127
|
+
.map(([key, value]) => `${key}:${btoa(JSON.stringify(value))}`)
|
|
128
|
+
.sort();
|
|
129
|
+
return `[${strparams.join(",")}]`;
|
|
130
|
+
}
|
|
131
|
+
else
|
|
132
|
+
return btoa(JSON.stringify(params));
|
|
98
133
|
}
|
|
99
134
|
//# sourceMappingURL=external.js.map
|
package/dist/external.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.js","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAkBtC;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;IACj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AC,CAAC;gBACpE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACnB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,IAAI,EAAE,CAAC;QACP,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,KAAK,CAAC,MAAY;QAChB,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QAClD,IAAI,QAAQ,EAAE,CAAC;YACb,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF;AAED,SAAS,IAAI,CAAC,MAAY;IACxB,IAAI,OAAO,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;aAC9D,IAAI,EAAE,CAAC;QACV,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACpC,CAAC;;QAAM,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7C,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This package contains items that may be useful for working with the Skip framework, but are not strictly necessary.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
2
6
|
export { type ExternalResource, GenericExternalService, Polled, } from "./external.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
7
|
+
export { SkipServiceBroker, fetchJSON, type Entrypoint } from "./rest.js";
|
|
8
|
+
export { Count, CountMapper, Max, Min, SkipExternalService, Sum, } from "@skipruntime/core";
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,WAAW,EACX,GAAG,EACH,GAAG,EACH,mBAAmB,EACnB,GAAG,GACJ,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This package contains items that may be useful for working with the Skip framework, but are not strictly necessary.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
2
6
|
export { GenericExternalService, Polled, } from "./external.js";
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
7
|
+
export { SkipServiceBroker, fetchJSON } from "./rest.js";
|
|
8
|
+
export { Count, CountMapper, Max, Min, SkipExternalService, Sum, } from "@skipruntime/core";
|
|
5
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAEL,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAmB,MAAM,WAAW,CAAC;AAC1E,OAAO,EACL,KAAK,EACL,WAAW,EACX,GAAG,EACH,GAAG,EACH,mBAAmB,EACnB,GAAG,GACJ,MAAM,mBAAmB,CAAC"}
|
package/dist/rest.d.ts
CHANGED
|
@@ -1,27 +1,115 @@
|
|
|
1
1
|
import type { Json, Entry } from "@skipruntime/api";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import type { Entrypoint } from "@skipruntime/core";
|
|
3
|
+
export type { Entrypoint };
|
|
4
|
+
/**
|
|
5
|
+
* Perform an HTTP fetch where input and output data is `Json`.
|
|
6
|
+
*
|
|
7
|
+
* @typeParam V - Type response is *assumed* to have.
|
|
8
|
+
* @param url - URL from which to fetch.
|
|
9
|
+
* @param method - HTTP method of request.
|
|
10
|
+
* @param headers - Additional headers to add to request.
|
|
11
|
+
* @param data - Data to convert to JSON and send in request body.
|
|
12
|
+
* @returns Response parsed as JSON, and headers.
|
|
13
|
+
*/
|
|
14
|
+
export declare function fetchJSON<V extends Json>(url: string, method?: "POST" | "GET" | "PUT" | "PATCH" | "HEAD" | "DELETE", headers?: {
|
|
9
15
|
[header: string]: string;
|
|
10
16
|
}, data?: Json): Promise<[V | null, Headers]>;
|
|
11
|
-
|
|
12
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Wrapper providing a method-call interface to the Skip service HTTP APIs.
|
|
19
|
+
*
|
|
20
|
+
* Skip services, as started by `runService`, support an HTTP interface for reading from resources and writing to input collections.
|
|
21
|
+
* `SkipServiceBroker` provides a method-call interface to the backing HTTP interface.
|
|
22
|
+
*/
|
|
23
|
+
export declare class SkipServiceBroker {
|
|
24
|
+
private readonly entrypoint;
|
|
25
|
+
/**
|
|
26
|
+
* Construct a broker for a Skip service at the given entry point.
|
|
27
|
+
*
|
|
28
|
+
* @param entrypoint - Entry point of backing service.
|
|
29
|
+
* @returns Method-call broker to service.
|
|
30
|
+
*/
|
|
13
31
|
constructor(entrypoint?: Entrypoint);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Read the entire contents of a resource.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam K - Type of keys.
|
|
36
|
+
* @typeParam V - Type of values.
|
|
37
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
38
|
+
* @param params - Resource instance parameters.
|
|
39
|
+
* @returns All entries in resource.
|
|
40
|
+
*/
|
|
41
|
+
getAll<K extends Json, V extends Json>(resource: string, params: Json): Promise<Entry<K, V>[]>;
|
|
42
|
+
/**
|
|
43
|
+
* Read the values a resource associates with a single key.
|
|
44
|
+
*
|
|
45
|
+
* @typeParam K - Type of keys.
|
|
46
|
+
* @typeParam V - Type of values.
|
|
47
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
48
|
+
* @param params - Resource instance parameters.
|
|
49
|
+
* @param key - Key to read.
|
|
50
|
+
* @returns The values associated to the key.
|
|
51
|
+
*/
|
|
52
|
+
getArray<K extends Json, V extends Json>(resource: string, params: Json, key: K): Promise<V[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Read the single value a resource associates with a key.
|
|
55
|
+
*
|
|
56
|
+
* @typeParam K - Type of keys.
|
|
57
|
+
* @typeParam V - Type of values.
|
|
58
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
59
|
+
* @param params - Resource instance parameters.
|
|
60
|
+
* @param key - Key to read.
|
|
61
|
+
* @returns The value associated to the key.
|
|
62
|
+
* @throws `NonUniqueValueException` when the key is associated to either zero or multiple values.
|
|
63
|
+
*/
|
|
64
|
+
getUnique<K extends Json, V extends Json>(resource: string, params: Json, key: K): Promise<V>;
|
|
65
|
+
/**
|
|
66
|
+
* Write the values for a single key in a collection.
|
|
67
|
+
*
|
|
68
|
+
* @typeParam K - Type of keys.
|
|
69
|
+
* @typeParam V - Type of values.
|
|
70
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
71
|
+
* @param key - Key of entry to write.
|
|
72
|
+
* @param values - Values of entry to write.
|
|
73
|
+
* @returns {void}
|
|
74
|
+
*/
|
|
75
|
+
put<K extends Json, V extends Json>(collection: string, key: K, values: V[]): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Write multiple entries to a collection.
|
|
78
|
+
*
|
|
79
|
+
* @typeParam K - Type of keys.
|
|
80
|
+
* @typeParam V - Type of values.
|
|
81
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
82
|
+
* @param entries - Entries to write.
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
patch<K extends Json, V extends Json>(collection: string, entries: Entry<K, V>[]): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* Remove all values associated with a key in a collection.
|
|
88
|
+
*
|
|
89
|
+
* @typeParam K - Type of keys.
|
|
90
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
91
|
+
* @param key - Key of entry to delete.
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
22
94
|
deleteKey<K extends Json>(collection: string, key: K): Promise<void>;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Create a resource instance UUID.
|
|
97
|
+
*
|
|
98
|
+
* @typeParam K - Type of keys.
|
|
99
|
+
* @typeParam V - Type of values.
|
|
100
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
101
|
+
* @param params - Resource instance parameters.
|
|
102
|
+
* @returns UUID that can be used to subscribe to updates to resource instance.
|
|
103
|
+
*/
|
|
104
|
+
getStreamUUID(resource: string, params?: Json): Promise<string>;
|
|
105
|
+
/**
|
|
106
|
+
* Destroy a resource instance.
|
|
107
|
+
*
|
|
108
|
+
* Under normal circumstances, resource instances are deleted automatically after some period of inactivity; this method enables immediately deleting live streams under exceptional circumstances.
|
|
109
|
+
*
|
|
110
|
+
* @param uuid - Resource instance UUID.
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
deleteUUID(uuid: string): Promise<void>;
|
|
26
114
|
}
|
|
27
115
|
//# sourceMappingURL=rest.d.ts.map
|
package/dist/rest.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEpD,
|
|
1
|
+
{"version":3,"file":"rest.d.ts","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,UAAU,EAAE,CAAC;AAQ3B;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,CAAC,SAAS,IAAI,EAC5C,GAAG,EAAE,MAAM,EACX,MAAM,GAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,QAAgB,EACpE,OAAO,GAAE;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;CAAO,EAC1C,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAqB9B;AAED;;;;;GAKG;A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,EAAE,MAAM,EAAE,MAAM,GAAE,IAAS,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE;;;;;;;OAOG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
package/dist/rest.js
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
+
import { NonUniqueValueException } from "@skipruntime/api";
|
|
1
2
|
function toHttp(entrypoint) {
|
|
2
3
|
if (entrypoint.secured)
|
|
3
4
|
return `https://${entrypoint.host}:${entrypoint.control_port}`;
|
|
4
5
|
return `http://${entrypoint.host}:${entrypoint.control_port}`;
|
|
5
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Perform an HTTP fetch where input and output data is `Json`.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam V - Type response is *assumed* to have.
|
|
11
|
+
* @param url - URL from which to fetch.
|
|
12
|
+
* @param method - HTTP method of request.
|
|
13
|
+
* @param headers - Additional headers to add to request.
|
|
14
|
+
* @param data - Data to convert to JSON and send in request body.
|
|
15
|
+
* @returns Response parsed as JSON, and headers.
|
|
16
|
+
*/
|
|
6
17
|
export async function fetchJSON(url, method = "GET", headers = {}, data) {
|
|
7
18
|
const body = data ? JSON.stringify(data) : undefined;
|
|
8
19
|
const response = await fetch(url, {
|
|
@@ -24,7 +35,19 @@ export async function fetchJSON(url, method = "GET", headers = {}, data) {
|
|
|
24
35
|
: null;
|
|
25
36
|
return [responseJSON, response.headers];
|
|
26
37
|
}
|
|
27
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Wrapper providing a method-call interface to the Skip service HTTP APIs.
|
|
40
|
+
*
|
|
41
|
+
* Skip services, as started by `runService`, support an HTTP interface for reading from resources and writing to input collections.
|
|
42
|
+
* `SkipServiceBroker` provides a method-call interface to the backing HTTP interface.
|
|
43
|
+
*/
|
|
44
|
+
export class SkipServiceBroker {
|
|
45
|
+
/**
|
|
46
|
+
* Construct a broker for a Skip service at the given entry point.
|
|
47
|
+
*
|
|
48
|
+
* @param entrypoint - Entry point of backing service.
|
|
49
|
+
* @returns Method-call broker to service.
|
|
50
|
+
*/
|
|
28
51
|
constructor(entrypoint = {
|
|
29
52
|
host: "localhost",
|
|
30
53
|
streaming_port: 8080,
|
|
@@ -32,32 +55,113 @@ export class RESTWrapperOfSkipService {
|
|
|
32
55
|
}) {
|
|
33
56
|
this.entrypoint = toHttp(entrypoint);
|
|
34
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Read the entire contents of a resource.
|
|
60
|
+
*
|
|
61
|
+
* @typeParam K - Type of keys.
|
|
62
|
+
* @typeParam V - Type of values.
|
|
63
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
64
|
+
* @param params - Resource instance parameters.
|
|
65
|
+
* @returns All entries in resource.
|
|
66
|
+
*/
|
|
35
67
|
async getAll(resource, params) {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
const values = optValues ?? [];
|
|
39
|
-
return values;
|
|
68
|
+
const [data, _headers] = await fetchJSON(`${this.entrypoint}/v1/snapshot/${resource}`, "POST", {}, params);
|
|
69
|
+
return data ?? [];
|
|
40
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Read the values a resource associates with a single key.
|
|
73
|
+
*
|
|
74
|
+
* @typeParam K - Type of keys.
|
|
75
|
+
* @typeParam V - Type of values.
|
|
76
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
77
|
+
* @param params - Resource instance parameters.
|
|
78
|
+
* @param key - Key to read.
|
|
79
|
+
* @returns The values associated to the key.
|
|
80
|
+
*/
|
|
41
81
|
async getArray(resource, params, key) {
|
|
42
|
-
const
|
|
43
|
-
const [data, _headers] = await fetchJSON(`${this.entrypoint}/v1/resources/${resource}/${key}?${qParams}`, "GET");
|
|
82
|
+
const [data, _headers] = await fetchJSON(`${this.entrypoint}/v1/snapshot/${resource}`, "POST", {}, { key, params });
|
|
44
83
|
return data ?? [];
|
|
45
84
|
}
|
|
46
|
-
|
|
47
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Read the single value a resource associates with a key.
|
|
87
|
+
*
|
|
88
|
+
* @typeParam K - Type of keys.
|
|
89
|
+
* @typeParam V - Type of values.
|
|
90
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
91
|
+
* @param params - Resource instance parameters.
|
|
92
|
+
* @param key - Key to read.
|
|
93
|
+
* @returns The value associated to the key.
|
|
94
|
+
* @throws `NonUniqueValueException` when the key is associated to either zero or multiple values.
|
|
95
|
+
*/
|
|
96
|
+
async getUnique(resource, params, key) {
|
|
97
|
+
return this.getArray(resource, params, key).then((values) => {
|
|
98
|
+
if (values.length !== 1 || values[0] === undefined)
|
|
99
|
+
throw new NonUniqueValueException();
|
|
100
|
+
return values[0];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Write the values for a single key in a collection.
|
|
105
|
+
*
|
|
106
|
+
* @typeParam K - Type of keys.
|
|
107
|
+
* @typeParam V - Type of values.
|
|
108
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
109
|
+
* @param key - Key of entry to write.
|
|
110
|
+
* @param values - Values of entry to write.
|
|
111
|
+
* @returns {void}
|
|
112
|
+
*/
|
|
113
|
+
async put(collection, key, values) {
|
|
114
|
+
return await this.patch(collection, [[key, values]]);
|
|
48
115
|
}
|
|
49
|
-
|
|
50
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Write multiple entries to a collection.
|
|
118
|
+
*
|
|
119
|
+
* @typeParam K - Type of keys.
|
|
120
|
+
* @typeParam V - Type of values.
|
|
121
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
122
|
+
* @param entries - Entries to write.
|
|
123
|
+
* @returns {void}
|
|
124
|
+
*/
|
|
125
|
+
async patch(collection, entries) {
|
|
126
|
+
await fetchJSON(`${this.entrypoint}/v1/inputs/${collection}`, "PATCH", {}, entries);
|
|
51
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Remove all values associated with a key in a collection.
|
|
130
|
+
*
|
|
131
|
+
* @typeParam K - Type of keys.
|
|
132
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
133
|
+
* @param key - Key of entry to delete.
|
|
134
|
+
* @returns {void}
|
|
135
|
+
*/
|
|
52
136
|
async deleteKey(collection, key) {
|
|
53
137
|
return await this.patch(collection, [[key, []]]);
|
|
54
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Create a resource instance UUID.
|
|
141
|
+
*
|
|
142
|
+
* @typeParam K - Type of keys.
|
|
143
|
+
* @typeParam V - Type of values.
|
|
144
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
145
|
+
* @param params - Resource instance parameters.
|
|
146
|
+
* @returns UUID that can be used to subscribe to updates to resource instance.
|
|
147
|
+
*/
|
|
55
148
|
async getStreamUUID(resource, params = {}) {
|
|
56
|
-
return fetch(`${this.entrypoint}/v1/streams`, {
|
|
149
|
+
return fetch(`${this.entrypoint}/v1/streams/${resource}`, {
|
|
57
150
|
method: "POST",
|
|
58
151
|
headers: { "Content-Type": "application/json" },
|
|
59
|
-
body: JSON.stringify(
|
|
152
|
+
body: JSON.stringify(params),
|
|
60
153
|
}).then((res) => res.text());
|
|
61
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* Destroy a resource instance.
|
|
157
|
+
*
|
|
158
|
+
* Under normal circumstances, resource instances are deleted automatically after some period of inactivity; this method enables immediately deleting live streams under exceptional circumstances.
|
|
159
|
+
*
|
|
160
|
+
* @param uuid - Resource instance UUID.
|
|
161
|
+
* @returns {void}
|
|
162
|
+
*/
|
|
163
|
+
async deleteUUID(uuid) {
|
|
164
|
+
await fetchJSON(`${this.entrypoint}/v1/streams/${uuid}`, "DELETE");
|
|
165
|
+
}
|
|
62
166
|
}
|
|
63
167
|
//# sourceMappingURL=rest.js.map
|
package/dist/rest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rest.js","sourceRoot":"","sources":["../src/rest.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAI3D,SAAS,MAAM,CAAC,UAAsB;IACpC,IAAI,UAAU,CAAC,OAAO;QACpB,OAAO,WAAW,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;IACjE,OAAO,UAAU,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAW,EACX,SAA+D,KAAK,EACpE,UAAwC,EAAE,EAC1C,IAAW;IAEX,MAAM,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACrD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM;QACN,IAAI;QACJ,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,MAAM,EAAE,kBAAkB;YAC1B,GAAG,OAAO;SACX;QACD,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,CAAC,MAAM,KAAK,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,YAAY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,MAAM,SAAS,CAAC,GAAG,IAAI,CAAC,UAAU,eAAe,IAAI,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrE,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skipruntime/helpers",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
7
|
-
"./errors.js": "./dist/errors.js",
|
|
8
7
|
"./rest.js": "./dist/rest.js",
|
|
9
8
|
"./external.js": "./dist/external.js"
|
|
10
9
|
},
|
|
@@ -21,8 +20,9 @@
|
|
|
21
20
|
},
|
|
22
21
|
"dependencies": {
|
|
23
22
|
"eventsource": "^2.0.2",
|
|
24
|
-
"express": "^4.21.
|
|
25
|
-
"@skipruntime/
|
|
23
|
+
"express": "^4.21.1",
|
|
24
|
+
"@skipruntime/core": "^0.0.3",
|
|
25
|
+
"@skipruntime/api": "^0.0.5"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/eventsource": "^1.1.15"
|