@toa.io/extensions.realtime 1.0.0-alpha.66 → 1.0.0-alpha.67
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/components/streams/manifest.toa.yaml +0 -1
- package/components/streams/operations/create.d.ts +4 -2
- package/components/streams/operations/create.js +15 -4
- package/components/streams/operations/create.js.map +1 -1
- package/components/streams/operations/lib/{stream.d.ts → Stream.d.ts} +3 -0
- package/components/streams/operations/lib/{stream.js → Stream.js} +15 -1
- package/components/streams/operations/lib/Stream.js.map +1 -0
- package/components/streams/operations/{types.d.ts → lib/types.d.ts} +4 -1
- package/components/streams/operations/lib/types.js.map +1 -0
- package/components/streams/operations/push.d.ts +1 -1
- package/components/streams/operations/tsconfig.tsbuildinfo +1 -1
- package/components/streams/source/create.ts +18 -4
- package/components/streams/source/lib/{stream.ts → Stream.ts} +18 -0
- package/components/streams/source/{types.ts → lib/types.ts} +4 -1
- package/components/streams/source/push.ts +1 -1
- package/package.json +3 -3
- package/readme.md +6 -5
- package/source/Composition.ts +1 -1
- package/source/Receiver.ts +31 -0
- package/source/Routes.ts +4 -25
- package/source/extension.ts +62 -0
- package/source/index.ts +1 -0
- package/transpiled/Composition.d.ts +1 -0
- package/transpiled/Composition.js +2 -1
- package/transpiled/Composition.js.map +1 -1
- package/transpiled/Receiver.d.ts +10 -0
- package/transpiled/Receiver.js +28 -0
- package/transpiled/Receiver.js.map +1 -0
- package/transpiled/Routes.d.ts +0 -1
- package/transpiled/Routes.js +3 -16
- package/transpiled/Routes.js.map +1 -1
- package/transpiled/extension.d.ts +5 -0
- package/transpiled/extension.js +45 -0
- package/transpiled/extension.js.map +1 -0
- package/transpiled/index.d.ts +1 -0
- package/transpiled/index.js +15 -0
- package/transpiled/index.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
- package/components/streams/operations/lib/stream.js.map +0 -1
- package/components/streams/operations/types.js.map +0 -1
- package/stage/streams.test.ts_rename +0 -129
- /package/components/streams/operations/{types.js → lib/types.js} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Connector, type Message } from '@toa.io/core'
|
|
2
|
+
import { console } from 'openspan'
|
|
3
|
+
import type { Readable } from 'node:stream'
|
|
4
|
+
|
|
5
|
+
export class Receiver extends Connector {
|
|
6
|
+
private readonly event: string
|
|
7
|
+
private readonly properties: string[]
|
|
8
|
+
private readonly stream: Readable
|
|
9
|
+
|
|
10
|
+
public constructor (event: string, properties: string[], stream: Readable) {
|
|
11
|
+
super()
|
|
12
|
+
|
|
13
|
+
this.event = event
|
|
14
|
+
this.properties = properties
|
|
15
|
+
this.stream = stream
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public receive (message: Message<Record<string, string>>): void {
|
|
19
|
+
for (const property of this.properties) {
|
|
20
|
+
const key = message.payload[property]
|
|
21
|
+
|
|
22
|
+
if (key === undefined) {
|
|
23
|
+
console.error('Event does not contain the expected property', { event, property })
|
|
24
|
+
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
this.stream.push({ key, event: this.event, data: message.payload })
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
package/source/Routes.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Readable } from 'node:stream'
|
|
2
2
|
import { console } from 'openspan'
|
|
3
|
-
import { Connector
|
|
3
|
+
import { Connector } from '@toa.io/core'
|
|
4
4
|
import { decode } from '@toa.io/generic'
|
|
5
5
|
import { type Bootloader } from './Factory'
|
|
6
|
+
import { Receiver } from './Receiver'
|
|
6
7
|
|
|
7
8
|
export class Routes extends Connector {
|
|
8
9
|
public events = new Events()
|
|
@@ -27,7 +28,7 @@ export class Routes extends Connector {
|
|
|
27
28
|
const creating = []
|
|
28
29
|
|
|
29
30
|
for (const { event, properties } of routes) {
|
|
30
|
-
const consumer = this.boot.receive(event,
|
|
31
|
+
const consumer = this.boot.receive(event, new Receiver(event, properties, this.events))
|
|
31
32
|
|
|
32
33
|
creating.push(consumer)
|
|
33
34
|
}
|
|
@@ -40,30 +41,12 @@ export class Routes extends Connector {
|
|
|
40
41
|
await Promise.all(connecting)
|
|
41
42
|
this.depends(consumers)
|
|
42
43
|
|
|
43
|
-
console.info('Event sources connected', {
|
|
44
|
+
console.info('Event sources connected', { count: creating.length })
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
public override async close (): Promise<void> {
|
|
47
48
|
console.info('Event sources disconnected')
|
|
48
49
|
}
|
|
49
|
-
|
|
50
|
-
private getReceiver (event: string, properties: string[]): Receiver {
|
|
51
|
-
return {
|
|
52
|
-
receive: (message: Message<Record<string, string>>) => {
|
|
53
|
-
for (const property of properties) {
|
|
54
|
-
const key = message.payload[property]
|
|
55
|
-
|
|
56
|
-
if (key === undefined) {
|
|
57
|
-
console.error('Event does not contain the expected property', { event, property })
|
|
58
|
-
|
|
59
|
-
return
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.events.push({ key, event, data: message.payload })
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
50
|
}
|
|
68
51
|
|
|
69
52
|
class Events extends Readable {
|
|
@@ -79,7 +62,3 @@ export interface Route {
|
|
|
79
62
|
event: string
|
|
80
63
|
properties: string[]
|
|
81
64
|
}
|
|
82
|
-
|
|
83
|
-
interface Receiver {
|
|
84
|
-
receive: (message: Message<Record<string, string>>) => void
|
|
85
|
-
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { basename } from 'node:path'
|
|
2
|
+
import { encode } from '@toa.io/generic'
|
|
3
|
+
import { find } from './Composition'
|
|
4
|
+
import type { Dependency, Instances, Service } from '@toa.io/operations'
|
|
5
|
+
|
|
6
|
+
export const standalone = true
|
|
7
|
+
|
|
8
|
+
export function deployment (instances: Instances<Declaration>, annotation?: Declaration): Dependency {
|
|
9
|
+
const routes = []
|
|
10
|
+
|
|
11
|
+
if (annotation !== undefined)
|
|
12
|
+
routes.push(...parse(annotation))
|
|
13
|
+
|
|
14
|
+
for (const instance of instances) {
|
|
15
|
+
const completed: Declaration = {}
|
|
16
|
+
|
|
17
|
+
for (const [key, value] of Object.entries(instance.manifest)) {
|
|
18
|
+
const event = instance.locator.id + '.' + key
|
|
19
|
+
|
|
20
|
+
completed[event] = value
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
routes.push(...parse(completed))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const service: Service = {
|
|
27
|
+
group: 'realtime',
|
|
28
|
+
name: 'streams',
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
30
|
+
version: require('../package.json').version,
|
|
31
|
+
components: labels(),
|
|
32
|
+
variables: [{
|
|
33
|
+
name: 'TOA_REALTIME',
|
|
34
|
+
value: encode(routes)
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return { services: [service] }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function parse (declaration: Declaration): Route[] {
|
|
42
|
+
const routes: Route[] = []
|
|
43
|
+
|
|
44
|
+
for (const [event, value] of Object.entries(declaration)) {
|
|
45
|
+
const properties = Array.isArray(value) ? value : [value]
|
|
46
|
+
|
|
47
|
+
routes.push({ event, properties })
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return routes
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function labels (): string[] {
|
|
54
|
+
return find().map((path) => 'realtime-' + basename(path))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type Declaration = Record<string, string | string[]>
|
|
58
|
+
|
|
59
|
+
interface Route {
|
|
60
|
+
event: string
|
|
61
|
+
properties: string[]
|
|
62
|
+
}
|
package/source/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Composition = void 0;
|
|
3
|
+
exports.find = exports.Composition = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
5
|
const node_path_1 = require("node:path");
|
|
6
6
|
const core_1 = require("@toa.io/core");
|
|
@@ -21,6 +21,7 @@ exports.Composition = Composition;
|
|
|
21
21
|
function find() {
|
|
22
22
|
return entries().map((entry) => (0, node_path_1.resolve)(ROOT, entry.name));
|
|
23
23
|
}
|
|
24
|
+
exports.find = find;
|
|
24
25
|
function entries() {
|
|
25
26
|
const entries = (0, node_fs_1.readdirSync)(ROOT, { withFileTypes: true });
|
|
26
27
|
return entries.filter((entry) => entry.isDirectory());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../source/Composition.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAClD,yCAAmC;AACnC,uCAAwC;AAGxC,MAAa,WAAY,SAAQ,gBAAS;IACvB,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAA;QACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAEtD,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;QAE3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3B,CAAC;CACF;AAhBD,kCAgBC;AAED,
|
|
1
|
+
{"version":3,"file":"Composition.js","sourceRoot":"","sources":["../source/Composition.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAClD,yCAAmC;AACnC,uCAAwC;AAGxC,MAAa,WAAY,SAAQ,gBAAS;IACvB,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEkB,KAAK,CAAC,IAAI;QAC3B,MAAM,KAAK,GAAG,IAAI,EAAE,CAAA;QACpB,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;QAEtD,MAAM,WAAW,CAAC,OAAO,EAAE,CAAA;QAE3B,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3B,CAAC;CACF;AAhBD,kCAgBC;AAED,SAAgB,IAAI;IAClB,OAAO,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,mBAAO,EAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC5D,CAAC;AAFD,oBAEC;AAED,SAAS,OAAO;IACd,MAAM,OAAO,GAAG,IAAA,qBAAW,EAAC,IAAI,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IAE1D,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAA;AACvD,CAAC;AAED,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Connector, type Message } from '@toa.io/core';
|
|
3
|
+
import type { Readable } from 'node:stream';
|
|
4
|
+
export declare class Receiver extends Connector {
|
|
5
|
+
private readonly event;
|
|
6
|
+
private readonly properties;
|
|
7
|
+
private readonly stream;
|
|
8
|
+
constructor(event: string, properties: string[], stream: Readable);
|
|
9
|
+
receive(message: Message<Record<string, string>>): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Receiver = void 0;
|
|
4
|
+
const core_1 = require("@toa.io/core");
|
|
5
|
+
const openspan_1 = require("openspan");
|
|
6
|
+
class Receiver extends core_1.Connector {
|
|
7
|
+
event;
|
|
8
|
+
properties;
|
|
9
|
+
stream;
|
|
10
|
+
constructor(event, properties, stream) {
|
|
11
|
+
super();
|
|
12
|
+
this.event = event;
|
|
13
|
+
this.properties = properties;
|
|
14
|
+
this.stream = stream;
|
|
15
|
+
}
|
|
16
|
+
receive(message) {
|
|
17
|
+
for (const property of this.properties) {
|
|
18
|
+
const key = message.payload[property];
|
|
19
|
+
if (key === undefined) {
|
|
20
|
+
openspan_1.console.error('Event does not contain the expected property', { event, property });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
this.stream.push({ key, event: this.event, data: message.payload });
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.Receiver = Receiver;
|
|
28
|
+
//# sourceMappingURL=Receiver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Receiver.js","sourceRoot":"","sources":["../source/Receiver.ts"],"names":[],"mappings":";;;AAAA,uCAAsD;AACtD,uCAAkC;AAGlC,MAAa,QAAS,SAAQ,gBAAS;IACpB,KAAK,CAAQ;IACb,UAAU,CAAU;IACpB,MAAM,CAAU;IAEjC,YAAoB,KAAa,EAAE,UAAoB,EAAE,MAAgB;QACvE,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,OAAO,CAAE,OAAwC;QACtD,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACvC,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;YAErC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,kBAAO,CAAC,KAAK,CAAC,8CAA8C,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAA;gBAElF,OAAM;YACR,CAAC;YAED,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;QACrE,CAAC;IACH,CAAC;CACF;AA1BD,4BA0BC"}
|
package/transpiled/Routes.d.ts
CHANGED
package/transpiled/Routes.js
CHANGED
|
@@ -5,6 +5,7 @@ const node_stream_1 = require("node:stream");
|
|
|
5
5
|
const openspan_1 = require("openspan");
|
|
6
6
|
const core_1 = require("@toa.io/core");
|
|
7
7
|
const generic_1 = require("@toa.io/generic");
|
|
8
|
+
const Receiver_1 = require("./Receiver");
|
|
8
9
|
class Routes extends core_1.Connector {
|
|
9
10
|
events = new Events();
|
|
10
11
|
boot;
|
|
@@ -21,7 +22,7 @@ class Routes extends core_1.Connector {
|
|
|
21
22
|
const routes = Routes.read();
|
|
22
23
|
const creating = [];
|
|
23
24
|
for (const { event, properties } of routes) {
|
|
24
|
-
const consumer = this.boot.receive(event,
|
|
25
|
+
const consumer = this.boot.receive(event, new Receiver_1.Receiver(event, properties, this.events));
|
|
25
26
|
creating.push(consumer);
|
|
26
27
|
}
|
|
27
28
|
const consumers = await Promise.all(creating);
|
|
@@ -29,25 +30,11 @@ class Routes extends core_1.Connector {
|
|
|
29
30
|
const connecting = consumers.map((consumer) => consumer.connect());
|
|
30
31
|
await Promise.all(connecting);
|
|
31
32
|
this.depends(consumers);
|
|
32
|
-
openspan_1.console.info('Event sources connected', {
|
|
33
|
+
openspan_1.console.info('Event sources connected', { count: creating.length });
|
|
33
34
|
}
|
|
34
35
|
async close() {
|
|
35
36
|
openspan_1.console.info('Event sources disconnected');
|
|
36
37
|
}
|
|
37
|
-
getReceiver(event, properties) {
|
|
38
|
-
return {
|
|
39
|
-
receive: (message) => {
|
|
40
|
-
for (const property of properties) {
|
|
41
|
-
const key = message.payload[property];
|
|
42
|
-
if (key === undefined) {
|
|
43
|
-
openspan_1.console.error('Event does not contain the expected property', { event, property });
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
this.events.push({ key, event, data: message.payload });
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
38
|
}
|
|
52
39
|
exports.Routes = Routes;
|
|
53
40
|
class Events extends node_stream_1.Readable {
|
package/transpiled/Routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../source/Routes.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;AACtC,uCAAkC;AAClC,
|
|
1
|
+
{"version":3,"file":"Routes.js","sourceRoot":"","sources":["../source/Routes.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;AACtC,uCAAkC;AAClC,uCAAwC;AACxC,6CAAwC;AAExC,yCAAqC;AAErC,MAAa,MAAO,SAAQ,gBAAS;IAC5B,MAAM,GAAG,IAAI,MAAM,EAAE,CAAA;IAEX,IAAI,CAAY;IAEjC,YAAoB,IAAgB;QAClC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEO,MAAM,CAAC,IAAI;QACjB,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS;YACxC,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAA;QAEhD,OAAO,IAAA,gBAAM,EAAU,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAClD,CAAC;IAEe,KAAK,CAAC,IAAI;QACxB,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAA;QAC5B,MAAM,QAAQ,GAAG,EAAE,CAAA;QAEnB,KAAK,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,MAAM,EAAE,CAAC;YAC3C,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,mBAAQ,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;YAEvF,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACzB,CAAC;QAED,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;QAE7C,qEAAqE;QACrE,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAA;QAElE,MAAM,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC7B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QAEvB,kBAAO,CAAC,IAAI,CAAC,yBAAyB,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IACrE,CAAC;IAEe,KAAK,CAAC,KAAK;QACzB,kBAAO,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;IAC5C,CAAC;CACF;AA1CD,wBA0CC;AAED,MAAM,MAAO,SAAQ,sBAAQ;IAC3B;QACE,KAAK,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAA;IAC7B,CAAC;IAEe,KAAK;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Dependency, Instances } from '@toa.io/operations';
|
|
2
|
+
export declare const standalone = true;
|
|
3
|
+
export declare function deployment(instances: Instances<Declaration>, annotation?: Declaration): Dependency;
|
|
4
|
+
type Declaration = Record<string, string | string[]>;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deployment = exports.standalone = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const generic_1 = require("@toa.io/generic");
|
|
6
|
+
const Composition_1 = require("./Composition");
|
|
7
|
+
exports.standalone = true;
|
|
8
|
+
function deployment(instances, annotation) {
|
|
9
|
+
const routes = [];
|
|
10
|
+
if (annotation !== undefined)
|
|
11
|
+
routes.push(...parse(annotation));
|
|
12
|
+
for (const instance of instances) {
|
|
13
|
+
const completed = {};
|
|
14
|
+
for (const [key, value] of Object.entries(instance.manifest)) {
|
|
15
|
+
const event = instance.locator.id + '.' + key;
|
|
16
|
+
completed[event] = value;
|
|
17
|
+
}
|
|
18
|
+
routes.push(...parse(completed));
|
|
19
|
+
}
|
|
20
|
+
const service = {
|
|
21
|
+
group: 'realtime',
|
|
22
|
+
name: 'streams',
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
24
|
+
version: require('../package.json').version,
|
|
25
|
+
components: labels(),
|
|
26
|
+
variables: [{
|
|
27
|
+
name: 'TOA_REALTIME',
|
|
28
|
+
value: (0, generic_1.encode)(routes)
|
|
29
|
+
}]
|
|
30
|
+
};
|
|
31
|
+
return { services: [service] };
|
|
32
|
+
}
|
|
33
|
+
exports.deployment = deployment;
|
|
34
|
+
function parse(declaration) {
|
|
35
|
+
const routes = [];
|
|
36
|
+
for (const [event, value] of Object.entries(declaration)) {
|
|
37
|
+
const properties = Array.isArray(value) ? value : [value];
|
|
38
|
+
routes.push({ event, properties });
|
|
39
|
+
}
|
|
40
|
+
return routes;
|
|
41
|
+
}
|
|
42
|
+
function labels() {
|
|
43
|
+
return (0, Composition_1.find)().map((path) => 'realtime-' + (0, node_path_1.basename)(path));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=extension.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../source/extension.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,6CAAwC;AACxC,+CAAoC;AAGvB,QAAA,UAAU,GAAG,IAAI,CAAA;AAE9B,SAAgB,UAAU,CAAE,SAAiC,EAAE,UAAwB;IACrF,MAAM,MAAM,GAAG,EAAE,CAAA;IAEjB,IAAI,UAAU,KAAK,SAAS;QAC1B,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAA;IAEnC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,MAAM,SAAS,GAAgB,EAAE,CAAA;QAEjC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC7D,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,GAAG,GAAG,CAAA;YAE7C,SAAS,CAAC,KAAK,CAAC,GAAG,KAAK,CAAA;QAC1B,CAAC;QAED,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAA;IAClC,CAAC;IAED,MAAM,OAAO,GAAY;QACvB,KAAK,EAAE,UAAU;QACjB,IAAI,EAAE,SAAS;QACf,8DAA8D;QAC9D,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC,OAAO;QAC3C,UAAU,EAAE,MAAM,EAAE;QACpB,SAAS,EAAE,CAAC;gBACV,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,IAAA,gBAAM,EAAC,MAAM,CAAC;aACtB,CAAC;KACH,CAAA;IAED,OAAO,EAAE,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAA;AAChC,CAAC;AA/BD,gCA+BC;AAED,SAAS,KAAK,CAAE,WAAwB;IACtC,MAAM,MAAM,GAAY,EAAE,CAAA;IAE1B,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACzD,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAA;QAEzD,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAA;IACpC,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,MAAM;IACb,OAAO,IAAA,kBAAI,GAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,GAAG,IAAA,oBAAQ,EAAC,IAAI,CAAC,CAAC,CAAA;AAC3D,CAAC"}
|
package/transpiled/index.d.ts
CHANGED
package/transpiled/index.js
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
17
|
exports.Factory = void 0;
|
|
4
18
|
var Factory_1 = require("./Factory");
|
|
5
19
|
Object.defineProperty(exports, "Factory", { enumerable: true, get: function () { return Factory_1.Factory; } });
|
|
20
|
+
__exportStar(require("./extension"), exports);
|
|
6
21
|
//# sourceMappingURL=index.js.map
|
package/transpiled/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qCAAmC;AAA1B,kGAAA,OAAO,OAAA;AAChB,8CAA2B"}
|