@skipruntime/helpers 0.0.5 → 0.0.7
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 +34 -25
- 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 +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/remote.d.ts +33 -0
- package/dist/remote.d.ts.map +1 -0
- package/dist/remote.js +88 -0
- package/dist/remote.js.map +1 -0
- package/dist/rest.d.ts +80 -40
- package/dist/rest.d.ts.map +1 -1
- package/dist/rest.js +70 -33
- package/dist/rest.js.map +1 -1
- package/package.json +3 -2
- package/src/external.ts +54 -19
- package/src/index.ts +9 -1
- package/src/remote.ts +109 -0
- package/src/rest.ts +100 -55
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
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
35
|
private readonly intervals;
|
|
33
|
-
open(params: {
|
|
34
|
-
[param: string]: string | number;
|
|
35
|
-
}, callbacks: {
|
|
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
51
|
private readonly url;
|
|
46
52
|
private readonly duration;
|
|
47
53
|
private readonly conv;
|
|
54
|
+
private readonly encodeParams;
|
|
48
55
|
private readonly intervals;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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,EAAE
|
|
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;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CACF,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC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;;;;GAMG;AACH,qBAAa,MAAM,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,EAAE,CAAC,SAAS,IAAI,CAChE,YAAW,gBAAgB;IAWzB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,YAAY;IAZ/B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA8B;IAExD;;;;;OAKG;gBAEgB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAChC,YAAY,GAAE,CAC7B,MAAM,EAAE,IAAI,KACT,MAA4B;IAGnC,IAAI,CACF,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;QAChE,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;QAC7B,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,GACA,IAAI;IAkBP,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI;CAM1B"}
|
package/dist/external.js
CHANGED
|
@@ -1,5 +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;IACjC;;OAEG;IACH,YACmB,SAA+C;QAA/C,cAAS,GAAT,SAAS,CAAsC;IAC/D,CAAC;IAEJ,SAAS,CACP,YAAoB,EACpB,MAAY,EACZ,SAIC;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,YAAY,CAE/B,CAAC;QACd,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,2BAA2B,YAAY,GAAG,CAAC,CAAC;QAC9D,CAAC;QACD,QAAQ,CAAC,IA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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,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
6
|
export { type ExternalResource, GenericExternalService, Polled, } from "./external.js";
|
|
2
|
-
export {
|
|
7
|
+
export { SkipExternalService } from "./remote.js";
|
|
8
|
+
export { SkipServiceBroker, fetchJSON, type Entrypoint } from "./rest.js";
|
|
9
|
+
export { Count, Max, Min, Sum } from "@skipruntime/core";
|
|
3
10
|
//# 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,OAAO,EACL,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,
|
|
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,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
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
|
+
*/
|
|
1
6
|
export { GenericExternalService, Polled, } from "./external.js";
|
|
2
|
-
export {
|
|
7
|
+
export { SkipExternalService } from "./remote.js";
|
|
8
|
+
export { SkipServiceBroker, fetchJSON } from "./rest.js";
|
|
9
|
+
export { Count, Max, Min, Sum } from "@skipruntime/core";
|
|
3
10
|
//# 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,OAAO,EAEL,sBAAsB,EACtB,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,
|
|
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,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAmB,MAAM,WAAW,CAAC;AAC1E,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/remote.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Entry, ExternalService, Json } from "@skipruntime/api";
|
|
2
|
+
import type { Entrypoint } from "./rest.js";
|
|
3
|
+
/**
|
|
4
|
+
* An external Skip reactive service.
|
|
5
|
+
*
|
|
6
|
+
* `SkipExternalService` provides an implementation of `ExternalService` for an external Skip service.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SkipExternalService implements ExternalService {
|
|
9
|
+
private readonly url;
|
|
10
|
+
private readonly control_url;
|
|
11
|
+
private readonly resources;
|
|
12
|
+
/**
|
|
13
|
+
* @param url - URL to use for the service's streaming interface.
|
|
14
|
+
* @param control_url - URL to use for the service's control interface.
|
|
15
|
+
*/
|
|
16
|
+
constructor(url: string, control_url: string);
|
|
17
|
+
/**
|
|
18
|
+
* Constructor accepting an `Entrypoint`.
|
|
19
|
+
*
|
|
20
|
+
* @param entrypoint - The entry point for the external Skip service.
|
|
21
|
+
* @returns An `ExternalService` to interact with the service running at `entrypoint`.
|
|
22
|
+
*/
|
|
23
|
+
static direct(entrypoint: Entrypoint): SkipExternalService;
|
|
24
|
+
subscribe(resource: string, params: Json, callbacks: {
|
|
25
|
+
update: (updates: Entry<Json, Json>[], isInitial: boolean) => void;
|
|
26
|
+
error: (error: Json) => void;
|
|
27
|
+
loading: () => void;
|
|
28
|
+
}): void;
|
|
29
|
+
unsubscribe(resource: string, params: Json): void;
|
|
30
|
+
shutdown(): void;
|
|
31
|
+
private toId;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=remote.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.d.ts","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAM5C;;;;GAIG;AACH,qBAAa,mBAAoB,YAAW,eAAe;IAQvD,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,WAAW;IAR9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA+B;IAEzD;;;OAGG;gBAEgB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM;IAGtC;;;;;OAKG;IAEH,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,UAAU,GAAG,mBAAmB;IAU1D,SAAS,CACP,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE;QACT,MAAM,EAAE,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;QAEnE,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,IAAI,CAAC;QAE7B,OAAO,EAAE,MAAM,IAAI,CAAC;KACrB,GACA,IAAI;IAiCP,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI;IAK1C,QAAQ,IAAI,IAAI;IAMhB,OAAO,CAAC,IAAI;CAQb"}
|
package/dist/remote.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// TODO: Remove once global `EventSource` makes it out of experimental
|
|
2
|
+
// in nodejs LTS.
|
|
3
|
+
import EventSource from "eventsource";
|
|
4
|
+
/**
|
|
5
|
+
* An external Skip reactive service.
|
|
6
|
+
*
|
|
7
|
+
* `SkipExternalService` provides an implementation of `ExternalService` for an external Skip service.
|
|
8
|
+
*/
|
|
9
|
+
export class SkipExternalService {
|
|
10
|
+
/**
|
|
11
|
+
* @param url - URL to use for the service's streaming interface.
|
|
12
|
+
* @param control_url - URL to use for the service's control interface.
|
|
13
|
+
*/
|
|
14
|
+
constructor(url, control_url) {
|
|
15
|
+
this.url = url;
|
|
16
|
+
this.control_url = control_url;
|
|
17
|
+
this.resources = new Map();
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Constructor accepting an `Entrypoint`.
|
|
21
|
+
*
|
|
22
|
+
* @param entrypoint - The entry point for the external Skip service.
|
|
23
|
+
* @returns An `ExternalService` to interact with the service running at `entrypoint`.
|
|
24
|
+
*/
|
|
25
|
+
// TODO: Support Skip external services going through a gateway.
|
|
26
|
+
static direct(entrypoint) {
|
|
27
|
+
let url = `http://${entrypoint.host}:${entrypoint.streaming_port.toString()}`;
|
|
28
|
+
let control_url = `http://${entrypoint.host}:${entrypoint.control_port.toString()}`;
|
|
29
|
+
if (entrypoint.secured) {
|
|
30
|
+
url = `https://${entrypoint.host}:${entrypoint.streaming_port.toString()}`;
|
|
31
|
+
control_url = `https://${entrypoint.host}:${entrypoint.control_port.toString()}`;
|
|
32
|
+
}
|
|
33
|
+
return new SkipExternalService(url, control_url);
|
|
34
|
+
}
|
|
35
|
+
subscribe(resource, params, callbacks) {
|
|
36
|
+
// TODO Manage Status
|
|
37
|
+
fetch(`${this.control_url}/v1/streams`, {
|
|
38
|
+
method: "POST",
|
|
39
|
+
headers: {
|
|
40
|
+
"Content-Type": "application/json",
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
resource,
|
|
44
|
+
params,
|
|
45
|
+
}),
|
|
46
|
+
})
|
|
47
|
+
.then((resp) => resp.text())
|
|
48
|
+
.then((uuid) => {
|
|
49
|
+
const evSource = new EventSource(`${this.url}/v1/streams/${uuid}`);
|
|
50
|
+
evSource.addEventListener("init", (e) => {
|
|
51
|
+
const updates = JSON.parse(e.data);
|
|
52
|
+
callbacks.update(updates, true);
|
|
53
|
+
});
|
|
54
|
+
evSource.addEventListener("update", (e) => {
|
|
55
|
+
const updates = JSON.parse(e.data);
|
|
56
|
+
callbacks.update(updates, false);
|
|
57
|
+
});
|
|
58
|
+
evSource.onerror = (e) => {
|
|
59
|
+
console.log(e);
|
|
60
|
+
};
|
|
61
|
+
this.resources.set(this.toId(resource, params), evSource);
|
|
62
|
+
})
|
|
63
|
+
.catch((e) => {
|
|
64
|
+
console.log(e);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
unsubscribe(resource, params) {
|
|
68
|
+
const closable = this.resources.get(this.toId(resource, params));
|
|
69
|
+
if (closable)
|
|
70
|
+
closable.close();
|
|
71
|
+
}
|
|
72
|
+
shutdown() {
|
|
73
|
+
for (const res of this.resources.values()) {
|
|
74
|
+
res.close();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
toId(resource, params) {
|
|
78
|
+
if (typeof params == "object") {
|
|
79
|
+
const strparams = Object.entries(params)
|
|
80
|
+
.map(([key, value]) => `${key}:${btoa(JSON.stringify(value))}`)
|
|
81
|
+
.sort();
|
|
82
|
+
return `${resource}[${strparams.join(",")}]`;
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
return `${resource}[${btoa(JSON.stringify(params))}]`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=remote.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../src/remote.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,iBAAiB;AACjB,OAAO,WAAW,MAAM,aAAa,CAAC;AAUtC;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAG9B;;;OAGG;IACH,YACmB,GAAW,EACX,WAAmB;QADnB,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAQ;QARrB,cAAS,GAAG,IAAI,GAAG,EAAoB,CAAC;IAStD,CAAC;IAEJ;;;;;OAKG;IACH,gEAAgE;IAChE,MAAM,CAAC,MAAM,CAAC,UAAsB;QAClC,IAAI,GAAG,GAAG,UAAU,UAAU,CAAC,IAAI,IAAI,UAAU,CA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S,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;iBAC9D,IAAI,EAAE,CAAC;YACV,OAAO,GAAG,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;QAC/C,CAAC;;YAAM,OAAO,GAAG,QAAQ,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC;IAC/D,CAAC;CACF"}
|
package/dist/rest.d.ts
CHANGED
|
@@ -5,14 +5,42 @@ import type { Json, Entry } from "@skipruntime/api";
|
|
|
5
5
|
* URLs for the service's control and streaming APIs can be constructed from an `Entrypoint`.
|
|
6
6
|
*/
|
|
7
7
|
export type Entrypoint = {
|
|
8
|
+
/**
|
|
9
|
+
* Hostname of the service.
|
|
10
|
+
*/
|
|
8
11
|
host: string;
|
|
12
|
+
/**
|
|
13
|
+
* Port to use for the service's streaming interface.
|
|
14
|
+
*/
|
|
9
15
|
streaming_port: number;
|
|
16
|
+
/**
|
|
17
|
+
* Port to use for the service's control interface.
|
|
18
|
+
*/
|
|
10
19
|
control_port: number;
|
|
20
|
+
/**
|
|
21
|
+
* Flag that when set indicates that https should be used instead of http.
|
|
22
|
+
*/
|
|
11
23
|
secured?: boolean;
|
|
12
24
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Perform an HTTP fetch where input and output data is `Json`.
|
|
27
|
+
*
|
|
28
|
+
* @typeParam V - Type response is *assumed* to have.
|
|
29
|
+
* @param url - URL from which to fetch.
|
|
30
|
+
* @param method - HTTP method of request.
|
|
31
|
+
* @param options - Optional parameters.
|
|
32
|
+
* @param options.headers - Additional headers to add to request.
|
|
33
|
+
* @param options.body - Data to convert to JSON and send in request body.
|
|
34
|
+
* @param options.timeout - Timeout for request, in milliseconds. Defaults to 1000ms.
|
|
35
|
+
* @returns Response parsed as JSON, and headers.
|
|
36
|
+
*/
|
|
37
|
+
export declare function fetchJSON<V extends Json>(url: string, method?: "POST" | "GET" | "PUT" | "PATCH" | "HEAD" | "DELETE", options?: {
|
|
38
|
+
headers?: {
|
|
39
|
+
[header: string]: string;
|
|
40
|
+
};
|
|
41
|
+
body?: Json;
|
|
42
|
+
timeout?: number;
|
|
43
|
+
}): Promise<[V | null, Headers]>;
|
|
16
44
|
/**
|
|
17
45
|
* Wrapper providing a method-call interface to the Skip service HTTP APIs.
|
|
18
46
|
*
|
|
@@ -23,78 +51,90 @@ export declare class SkipServiceBroker {
|
|
|
23
51
|
private readonly entrypoint;
|
|
24
52
|
/**
|
|
25
53
|
* Construct a broker for a Skip service at the given entry point.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
54
|
+
*
|
|
55
|
+
* @param entrypoint - Entry point of backing service.
|
|
56
|
+
* @returns Method-call broker to service.
|
|
28
57
|
*/
|
|
29
58
|
constructor(entrypoint?: Entrypoint);
|
|
30
59
|
/**
|
|
31
60
|
* Read the entire contents of a resource.
|
|
32
61
|
*
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
62
|
+
* @typeParam K - Type of keys.
|
|
63
|
+
* @typeParam V - Type of values.
|
|
64
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
65
|
+
* @param params - Resource instance parameters.
|
|
66
|
+
* @returns All entries in resource.
|
|
36
67
|
*/
|
|
37
|
-
getAll<K extends Json, V extends Json>(resource: string, params:
|
|
38
|
-
[param: string]: string;
|
|
39
|
-
}): Promise<Entry<K, V>[]>;
|
|
68
|
+
getAll<K extends Json, V extends Json>(resource: string, params: Json): Promise<Entry<K, V>[]>;
|
|
40
69
|
/**
|
|
41
70
|
* Read the values a resource associates with a single key.
|
|
42
|
-
*
|
|
43
|
-
* @
|
|
44
|
-
* @
|
|
45
|
-
* @
|
|
71
|
+
*
|
|
72
|
+
* @typeParam K - Type of keys.
|
|
73
|
+
* @typeParam V - Type of values.
|
|
74
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
75
|
+
* @param params - Resource instance parameters.
|
|
76
|
+
* @param key - Key to read.
|
|
77
|
+
* @returns The values associated to the key.
|
|
46
78
|
*/
|
|
47
|
-
getArray<V extends Json>(resource: string, params:
|
|
48
|
-
[param: string]: string;
|
|
49
|
-
}, key: string): Promise<V[]>;
|
|
79
|
+
getArray<K extends Json, V extends Json>(resource: string, params: Json, key: K): Promise<V[]>;
|
|
50
80
|
/**
|
|
51
81
|
* Read the single value a resource associates with a key.
|
|
52
|
-
*
|
|
53
|
-
* @
|
|
54
|
-
* @
|
|
55
|
-
* @
|
|
56
|
-
* @
|
|
82
|
+
*
|
|
83
|
+
* @typeParam K - Type of keys.
|
|
84
|
+
* @typeParam V - Type of values.
|
|
85
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
86
|
+
* @param params - Resource instance parameters.
|
|
87
|
+
* @param key - Key to read.
|
|
88
|
+
* @returns The value associated to the key.
|
|
89
|
+
* @throws `NonUniqueValueException` when the key is associated to either zero or multiple values.
|
|
57
90
|
*/
|
|
58
|
-
getUnique<V extends Json>(resource: string, params:
|
|
59
|
-
[param: string]: string;
|
|
60
|
-
}, key: string): Promise<V>;
|
|
91
|
+
getUnique<K extends Json, V extends Json>(resource: string, params: Json, key: K): Promise<V>;
|
|
61
92
|
/**
|
|
62
93
|
* Write the values for a single key in a collection.
|
|
63
|
-
*
|
|
64
|
-
* @
|
|
65
|
-
* @
|
|
94
|
+
*
|
|
95
|
+
* @typeParam K - Type of keys.
|
|
96
|
+
* @typeParam V - Type of values.
|
|
97
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
98
|
+
* @param key - Key of entry to write.
|
|
99
|
+
* @param values - Values of entry to write.
|
|
66
100
|
* @returns {void}
|
|
67
101
|
*/
|
|
68
102
|
put<K extends Json, V extends Json>(collection: string, key: K, values: V[]): Promise<void>;
|
|
69
103
|
/**
|
|
70
104
|
* Write multiple entries to a collection.
|
|
71
|
-
*
|
|
72
|
-
* @
|
|
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 entries - Entries to write.
|
|
73
110
|
* @returns {void}
|
|
74
111
|
*/
|
|
75
112
|
patch<K extends Json, V extends Json>(collection: string, entries: Entry<K, V>[]): Promise<void>;
|
|
76
113
|
/**
|
|
77
114
|
* Remove all values associated with a key in a collection.
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
115
|
+
*
|
|
116
|
+
* @typeParam K - Type of keys.
|
|
117
|
+
* @param collection - Name of the input collection to update, must be a key of the `Inputs` type parameter of the `SkipService` running at `entrypoint`.
|
|
118
|
+
* @param key - Key of entry to delete.
|
|
80
119
|
* @returns {void}
|
|
81
120
|
*/
|
|
82
121
|
deleteKey<K extends Json>(collection: string, key: K): Promise<void>;
|
|
83
122
|
/**
|
|
84
123
|
* Create a resource instance UUID.
|
|
85
|
-
*
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
124
|
+
*
|
|
125
|
+
* @typeParam K - Type of keys.
|
|
126
|
+
* @typeParam V - Type of values.
|
|
127
|
+
* @param resource - Name of resource, must be a key of the `resources` field of the `SkipService` running at `entrypoint`.
|
|
128
|
+
* @param params - Resource instance parameters.
|
|
129
|
+
* @returns UUID that can be used to subscribe to updates to resource instance.
|
|
88
130
|
*/
|
|
89
|
-
getStreamUUID(resource: string, params?:
|
|
90
|
-
[param: string]: string;
|
|
91
|
-
}): Promise<string>;
|
|
131
|
+
getStreamUUID(resource: string, params?: Json): Promise<string>;
|
|
92
132
|
/**
|
|
93
133
|
* Destroy a resource instance.
|
|
94
134
|
*
|
|
95
135
|
* Under normal circumstances, resource instances are deleted automatically after some period of inactivity; this method enables immediately deleting live streams under exceptional circumstances.
|
|
96
136
|
*
|
|
97
|
-
* @param uuid -
|
|
137
|
+
* @param uuid - Resource instance UUID.
|
|
98
138
|
* @returns {void}
|
|
99
139
|
*/
|
|
100
140
|
deleteUUID(uuid: string): Promise<void>;
|
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;AAGpD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;
|
|
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;AAGpD;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACvB;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAQF;;;;;;;;;;;GAWG;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;IACP,OAAO,CAAC,EAAE;QAAE,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IACvC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC;CAIlB,GACA,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC,CAqB9B;AAED;;;;;GAKG;AACH,q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