@toa.io/bindings.amqp 0.20.0-dev.3 → 0.20.0-dev.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/package.json +16 -10
  2. package/readme.md +10 -45
  3. package/schemas/annotation.cos.yaml +2 -0
  4. package/source/broadcast.js +0 -5
  5. package/source/communication.js +49 -0
  6. package/source/constants.js +0 -1
  7. package/source/consumer.js +0 -5
  8. package/source/deployment/annotation.test.ts +40 -0
  9. package/source/deployment/annotation.ts +26 -0
  10. package/source/deployment/context.ts +112 -0
  11. package/source/deployment/index.ts +10 -0
  12. package/source/deployment/instance.ts +3 -0
  13. package/source/deployment/sources.ts +44 -0
  14. package/source/deployment.ts +14 -0
  15. package/source/emitter.js +0 -5
  16. package/source/factory.js +22 -30
  17. package/source/index.js +0 -2
  18. package/source/producer.js +0 -6
  19. package/source/receiver.js +0 -6
  20. package/transpiled/broadcast.d.ts +10 -0
  21. package/transpiled/broadcast.js +31 -0
  22. package/transpiled/broadcast.js.map +1 -0
  23. package/transpiled/communication.d.ts +9 -0
  24. package/transpiled/communication.js +37 -0
  25. package/transpiled/communication.js.map +1 -0
  26. package/transpiled/constants.d.ts +1 -0
  27. package/transpiled/constants.js +3 -0
  28. package/transpiled/constants.js.map +1 -0
  29. package/transpiled/consumer.d.ts +9 -0
  30. package/transpiled/consumer.js +23 -0
  31. package/transpiled/consumer.js.map +1 -0
  32. package/transpiled/deployment/annotation.d.ts +10 -0
  33. package/transpiled/deployment/annotation.js +43 -0
  34. package/transpiled/deployment/annotation.js.map +1 -0
  35. package/transpiled/deployment/context.d.ts +7 -0
  36. package/transpiled/deployment/context.js +86 -0
  37. package/transpiled/deployment/context.js.map +1 -0
  38. package/transpiled/deployment/index.d.ts +4 -0
  39. package/transpiled/deployment/index.js +34 -0
  40. package/transpiled/deployment/index.js.map +1 -0
  41. package/transpiled/deployment/instance.d.ts +2 -0
  42. package/transpiled/deployment/instance.js +3 -0
  43. package/transpiled/deployment/instance.js.map +1 -0
  44. package/transpiled/deployment/sources.d.ts +8 -0
  45. package/transpiled/deployment/sources.js +35 -0
  46. package/transpiled/deployment/sources.js.map +1 -0
  47. package/transpiled/deployment.d.ts +4 -0
  48. package/transpiled/deployment.js +38 -0
  49. package/transpiled/deployment.js.map +1 -0
  50. package/transpiled/emitter.d.ts +9 -0
  51. package/transpiled/emitter.js +24 -0
  52. package/transpiled/emitter.js.map +1 -0
  53. package/transpiled/factory.d.ts +13 -0
  54. package/transpiled/factory.js +46 -0
  55. package/transpiled/factory.js.map +1 -0
  56. package/transpiled/index.d.ts +5 -0
  57. package/transpiled/index.js +9 -0
  58. package/transpiled/index.js.map +1 -0
  59. package/transpiled/producer.d.ts +5 -0
  60. package/transpiled/producer.js +31 -0
  61. package/transpiled/producer.js.map +1 -0
  62. package/transpiled/queues.d.ts +6 -0
  63. package/transpiled/queues.js +10 -0
  64. package/transpiled/queues.js.map +1 -0
  65. package/transpiled/receiver.d.ts +5 -0
  66. package/transpiled/receiver.js +34 -0
  67. package/transpiled/receiver.js.map +1 -0
  68. package/tsconfig.json +12 -0
  69. package/source/annotation.js +0 -5
  70. package/source/deployment.js +0 -32
  71. package/source/pointer.js +0 -18
  72. package/test/annotations.test.js +0 -16
  73. package/test/deployment.test.js +0 -36
  74. package/test/factory.test.js +0 -190
  75. package/test/pointer.test.js +0 -59
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+ const { assert } = require('comq');
3
+ const { Connector } = require('@toa.io/core');
4
+ class Communication extends Connector {
5
+ #resolve;
6
+ /** @type {comq.IO} */
7
+ #io;
8
+ constructor(resolve) {
9
+ super();
10
+ this.#resolve = resolve;
11
+ }
12
+ async open() {
13
+ const references = await this.#resolve();
14
+ this.#io = await assert(...references);
15
+ }
16
+ async close() {
17
+ await this.#io.seal();
18
+ }
19
+ async dispose() {
20
+ if (this.#io !== undefined)
21
+ await this.#io.close();
22
+ }
23
+ async reply(queue, process) {
24
+ await this.#io.reply(queue, process);
25
+ }
26
+ async request(queue, request) {
27
+ return this.#io.request(queue, request);
28
+ }
29
+ async emit(exchange, message, properties) {
30
+ await this.#io.emit(exchange, message, properties);
31
+ }
32
+ async consume(exchange, group, consumer) {
33
+ await this.#io.consume(exchange, group, consumer);
34
+ }
35
+ }
36
+ exports.Communication = Communication;
37
+ //# sourceMappingURL=communication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"communication.js","sourceRoot":"","sources":["../source/communication.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAClC,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAE7C,MAAM,aAAc,SAAQ,SAAS;IACnC,QAAQ,CAAA;IAER,sBAAsB;IACtB,GAAG,CAAA;IAEH,YAAa,OAAO;QAClB,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAA;QAExC,IAAI,CAAC,GAAG,GAAG,MAAM,MAAM,CAAC,GAAG,UAAU,CAAC,CAAA;IACxC,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,OAAO;QACX,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;YAAE,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,KAAK,CAAE,KAAK,EAAE,OAAO;QACzB,MAAM,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,KAAK,EAAE,OAAO;QAC3B,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,IAAI,CAAE,QAAQ,EAAE,OAAO,EAAE,UAAU;QACvC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;IACpD,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ;QACtC,MAAM,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;IACnD,CAAC;CACF;AAED,OAAO,CAAC,aAAa,GAAG,aAAa,CAAA"}
@@ -0,0 +1 @@
1
+ export const SYSTEM: "system";
@@ -0,0 +1,3 @@
1
+ 'use strict';
2
+ exports.SYSTEM = 'system';
3
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../source/constants.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @implements {toa.core.bindings.Consumer}
3
+ */
4
+ export class Consumer extends Connector implements toa.core.bindings.Consumer {
5
+ constructor(comm: any, locator: any, endpoint: any);
6
+ request(request: any): Promise<any>;
7
+ #private;
8
+ }
9
+ import { Connector } from "@toa.io/core";
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+ const { Connector } = require('@toa.io/core');
3
+ const { name } = require('./queues');
4
+ /**
5
+ * @implements {toa.core.bindings.Consumer}
6
+ */
7
+ class Consumer extends Connector {
8
+ /** @type {string} */
9
+ #queue;
10
+ /** @type {toa.amqp.Communication} */
11
+ #comm;
12
+ constructor(comm, locator, endpoint) {
13
+ super();
14
+ this.#queue = name(locator, endpoint);
15
+ this.#comm = comm;
16
+ this.depends(comm);
17
+ }
18
+ async request(request) {
19
+ return this.#comm.request(this.#queue, request);
20
+ }
21
+ }
22
+ exports.Consumer = Consumer;
23
+ //# sourceMappingURL=consumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer.js","sourceRoot":"","sources":["../source/consumer.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAM,QAAS,SAAQ,SAAS;IAC9B,qBAAqB;IACrB,MAAM,CAAA;IAEN,qCAAqC;IACrC,KAAK,CAAA;IAEL,YAAa,IAAI,EAAE,OAAO,EAAE,QAAQ;QAClC,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QAEjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,OAAO,CAAE,OAAO;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;CACF;AAED,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { type URIMap } from '@toa.io/pointer';
2
+ export declare function normalize(declaration: string | Declaration): Annotation;
3
+ export interface Annotation {
4
+ context: URIMap;
5
+ sources?: URIMap;
6
+ }
7
+ export interface Declaration {
8
+ context: string | Record<string, string | string[]>;
9
+ sources?: Record<string, string | string[]>;
10
+ }
@@ -0,0 +1,43 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.normalize = void 0;
27
+ const pointer = __importStar(require("@toa.io/pointer"));
28
+ function normalize(declaration) {
29
+ const annotation = expand(declaration);
30
+ const context = pointer.normalize(annotation.context);
31
+ const sources = pointer.normalize(annotation.sources);
32
+ return { context, sources };
33
+ }
34
+ exports.normalize = normalize;
35
+ function expand(declaration) {
36
+ if (typeof declaration === 'string')
37
+ return { context: { '.': [declaration] } };
38
+ else if (Array.isArray(declaration))
39
+ return { context: { '.': declaration } };
40
+ else
41
+ return declaration;
42
+ }
43
+ //# sourceMappingURL=annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.js","sourceRoot":"","sources":["../../source/deployment/annotation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA0C;AAG1C,SAAgB,SAAS,CAAE,WAAiC;IAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA;IACtC,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IAErD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAA;AAC7B,CAAC;AAND,8BAMC;AAED,SAAS,MAAM,CAAE,WAAiC;IAChD,IAAI,OAAO,WAAW,KAAK,QAAQ;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,CAAA;SAC1E,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,EAAE,CAAA;;QACxE,OAAO,WAAW,CAAA;AACzB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { type Dependency } from '@toa.io/operations';
2
+ import { type Locator } from '@toa.io/core';
3
+ import { type Annotation } from './annotation';
4
+ export declare function createDependency(context: Context): Dependency;
5
+ export declare function resolveURIs(locator: Locator): Promise<string[]>;
6
+ type Context = Annotation['context'];
7
+ export {};
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveURIs = exports.createDependency = void 0;
4
+ const generic_1 = require("@toa.io/generic");
5
+ const pointer_1 = require("@toa.io/pointer");
6
+ const dns_1 = require("@toa.io/dns");
7
+ function createDependency(context) {
8
+ const global = [];
9
+ const variables = { global };
10
+ const contextVariables = createVariables(context);
11
+ global.push(...contextVariables);
12
+ return { variables };
13
+ }
14
+ exports.createDependency = createDependency;
15
+ async function resolveURIs(locator) {
16
+ if (process.env.TOA_DEV === '1')
17
+ return ['amqp://developer:secret@localhost'];
18
+ const value = process.env[VARIABLE];
19
+ if (value === undefined)
20
+ throw new Error(`Environment variable ${VARIABLE} is not specified`);
21
+ const map = (0, generic_1.decode)(value);
22
+ const record = (0, pointer_1.resolveRecord)(map, locator.id);
23
+ return await parseRecord(record);
24
+ }
25
+ exports.resolveURIs = resolveURIs;
26
+ function createVariables(context) {
27
+ const variables = [];
28
+ const uris = (0, generic_1.encode)(context);
29
+ const contextVariable = {
30
+ name: VARIABLE,
31
+ value: uris
32
+ };
33
+ const secrets = createSecrets(context);
34
+ variables.push(contextVariable, ...secrets);
35
+ return variables;
36
+ }
37
+ function createSecrets(context) {
38
+ const secrets = [];
39
+ for (const key of Object.keys(context)) {
40
+ const keySecrets = createKeySecrets(key);
41
+ secrets.push(...keySecrets);
42
+ }
43
+ return secrets;
44
+ }
45
+ function createKeySecrets(key) {
46
+ const username = createSecretVariable(key, 'username');
47
+ const password = createSecretVariable(key, 'password');
48
+ return [username, password];
49
+ }
50
+ function createSecretVariable(key, secretKey) {
51
+ const varKey = key === '.' ? '' : key;
52
+ const varName = pointer_1.naming.nameVariable(ID, varKey, secretKey.toUpperCase());
53
+ const secName = pointer_1.naming.nameSecret(ID, key);
54
+ return {
55
+ name: varName,
56
+ secret: {
57
+ name: secName,
58
+ key: secretKey
59
+ }
60
+ };
61
+ }
62
+ async function parseRecord(record) {
63
+ const unique = await (0, dns_1.dedupe)(record.references);
64
+ const urls = new Array(unique.length);
65
+ const key = record.key === '.' ? '' : record.key;
66
+ const username = readEnv(key, 'USERNAME');
67
+ const password = readEnv(key, 'PASSWORD');
68
+ for (let i = 0; i < record.references.length; i++) {
69
+ const url = new URL(record.references[i]);
70
+ url.username = username;
71
+ url.password = password;
72
+ urls[i] = url.href;
73
+ }
74
+ return urls;
75
+ }
76
+ function readEnv(key, name) {
77
+ const variable = pointer_1.naming.nameVariable(ID, key, name);
78
+ const value = process.env[variable];
79
+ if (value === undefined)
80
+ throw new Error(variable + ' is not set');
81
+ else
82
+ return value;
83
+ }
84
+ const ID = 'amqp-context';
85
+ const VARIABLE = 'TOA_AMQP_CONTEXT';
86
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../../source/deployment/context.ts"],"names":[],"mappings":";;;AACA,6CAAgD;AAChD,6CAAuD;AAGvD,qCAAoC;AAGpC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G,CAAA;IAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IACzC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,CAAA;IAEzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACjD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;QAEzC,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACvB,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAA;QAEvB,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,IAAI,CAAA;KACnB;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,OAAO,CAAE,GAAW,EAAE,IAAY;IACzC,MAAM,QAAQ,GAAG,gBAAM,CAAC,YAAY,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,CAAA;IACnD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEnC,IAAI,KAAK,KAAK,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,GAAG,aAAa,CAAC,CAAA;;QAC7D,OAAO,KAAK,CAAA;AACnB,CAAC;AAED,MAAM,EAAE,GAAG,cAAc,CAAA;AACzB,MAAM,QAAQ,GAAG,kBAAkB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { type Dependency } from '@toa.io/operations';
2
+ import { type Declaration } from './annotation';
3
+ import { type Instance } from './instance';
4
+ export declare function deployment(instances: Instance[], declaration: Declaration): Dependency;
@@ -0,0 +1,34 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.deployment = void 0;
27
+ const annotation_1 = require("./annotation");
28
+ const sources = __importStar(require("./sources"));
29
+ function deployment(instances, declaration) {
30
+ const annotation = (0, annotation_1.normalize)(declaration);
31
+ return sources.createDependency(annotation.sources, instances);
32
+ }
33
+ exports.deployment = deployment;
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/deployment/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAA0D;AAC1D,mDAAoC;AAGpC,SAAgB,UAAU,CAAE,SAAqB,EAAE,WAAwB;IACzE,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAA;IAEzC,OAAO,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;AAChE,CAAC;AAJD,gCAIC"}
@@ -0,0 +1,2 @@
1
+ import { type context } from '@toa.io/norm';
2
+ export type Instance = context.Dependency;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../source/deployment/instance.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { type Dependency } from '@toa.io/operations';
2
+ import { type Locator } from '@toa.io/core';
3
+ import { type Instance } from './instance';
4
+ import { type Annotation } from './annotation';
5
+ export declare function createDependency(sources: Sources, instances: Instance[]): Dependency;
6
+ export declare function resolveURIs(locator: Locator, label: string): Promise<string[]>;
7
+ type Sources = Annotation['sources'];
8
+ export {};
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveURIs = exports.createDependency = void 0;
4
+ const pointer_1 = require("@toa.io/pointer");
5
+ function createDependency(sources, instances) {
6
+ const requests = [];
7
+ for (const instance of instances) {
8
+ const request = createRequest(instance);
9
+ if (request !== null)
10
+ requests.push(request);
11
+ }
12
+ const variables = (0, pointer_1.createVariables)(ID, sources, requests);
13
+ return { variables };
14
+ }
15
+ exports.createDependency = createDependency;
16
+ async function resolveURIs(locator, label) {
17
+ return await (0, pointer_1.resolve)(ID, locator.id);
18
+ }
19
+ exports.resolveURIs = resolveURIs;
20
+ function createRequest(instance) {
21
+ const group = instance.locator.label;
22
+ const selectors = createSelectors(instance.component);
23
+ if (selectors === null)
24
+ return null;
25
+ else
26
+ return { group, selectors };
27
+ }
28
+ function createSelectors(component) {
29
+ if (component.receivers === undefined)
30
+ return null;
31
+ const sources = Object.values(component.receivers).map((receiver) => receiver.source);
32
+ return sources.filter((source) => source !== undefined);
33
+ }
34
+ const ID = 'amqp-sources';
35
+ //# sourceMappingURL=sources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sources.js","sourceRoot":"","sources":["../../source/deployment/sources.ts"],"names":[],"mappings":";;;AAAA,6CAAwE;AAOxE,SAAgB,gBAAgB,CAAE,OAAgB,EAAE,SAAqB;IACvE,MAAM,QAAQ,GA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declaration } from './deployment/annotation';
3
+ import { type Instance } from './deployment/instance';
4
+ export declare function deployment(instances: Instance[], declaration: Declaration): Dependency;
@@ -0,0 +1,38 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.deployment = void 0;
27
+ const generic_1 = require("@toa.io/generic");
28
+ const annotation_1 = require("./deployment/annotation");
29
+ const sources = __importStar(require("./deployment/sources"));
30
+ const context = __importStar(require("./deployment/context"));
31
+ function deployment(instances, declaration) {
32
+ const annotation = (0, annotation_1.normalize)(declaration);
33
+ const contextDependency = context.createDependency(annotation.context);
34
+ const sourcesDependency = sources.createDependency(annotation.sources, instances);
35
+ return (0, generic_1.merge)(contextDependency, sourcesDependency);
36
+ }
37
+ exports.deployment = deployment;
38
+ //# sourceMappingURL=deployment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deployment.js","sourceRoot":"","sources":["../source/deployment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,6CAAuC;AACvC,wDAAqE;AACrE,8DAA+C;AAC/C,8DAA+C;AAG/C,SAAgB,UAAU,CAAE,SAAqB,EAAE,WAAwB;IACzE,MAAM,UAAU,GAAG,IAAA,sBAAS,EAAC,WAAW,CAAC,CAAA;IACzC,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IACtE,MAAM,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,CAAA;IAEjF,OAAO,IAAA,eAAK,EAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAA;AACpD,CAAC;AAND,gCAMC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @implements {toa.core.bindings.Emitter}
3
+ */
4
+ export class Emitter extends Connector implements toa.core.bindings.Emitter {
5
+ constructor(comm: any, locator: any, label: any);
6
+ emit(message: any): Promise<void>;
7
+ #private;
8
+ }
9
+ import { Connector } from "@toa.io/core";
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+ const { Connector } = require('@toa.io/core');
3
+ const { name } = require('./queues');
4
+ /**
5
+ * @implements {toa.core.bindings.Emitter}
6
+ */
7
+ class Emitter extends Connector {
8
+ /** @type {string} */
9
+ #exchange;
10
+ /** @type {toa.amqp.Communication} */
11
+ #comm;
12
+ constructor(comm, locator, label) {
13
+ super();
14
+ this.#exchange = name(locator, label);
15
+ this.#comm = comm;
16
+ this.depends(comm);
17
+ }
18
+ async emit(message) {
19
+ await this.#comm.emit(this.#exchange, message, PROPERTIES);
20
+ }
21
+ }
22
+ const PROPERTIES = { headers: { 'toa.io/amqp': '0' } };
23
+ exports.Emitter = Emitter;
24
+ //# sourceMappingURL=emitter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emitter.js","sourceRoot":"","sources":["../source/emitter.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAE7C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAEpC;;GAEG;AACH,MAAM,OAAQ,SAAQ,SAAS;IAC7B,qBAAqB;IACrB,SAAS,CAAA;IAET,qCAAqC;IACrC,KAAK,CAAA;IAEL,YAAa,IAAI,EAAE,OAAO,EAAE,KAAK;QAC/B,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QAEjB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,IAAI,CAAE,OAAO;QACjB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;IAC5D,CAAC;CACF;AAED,MAAM,UAAU,GAAG,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,GAAG,EAAE,EAAE,CAAA;AAEtD,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -0,0 +1,13 @@
1
+ export class Factory {
2
+ producer(locator: any, endpoints: any, component: any): Producer;
3
+ consumer(locator: any, endpoint: any): Consumer;
4
+ emitter(locator: any, label: any): Emitter;
5
+ receiver(locator: any, label: any, group: any, receiver: any): Receiver;
6
+ broadcast(name: any, group: any): Broadcast;
7
+ #private;
8
+ }
9
+ import { Producer } from "./producer";
10
+ import { Consumer } from "./consumer";
11
+ import { Emitter } from "./emitter";
12
+ import { Receiver } from "./receiver";
13
+ import { Broadcast } from "./broadcast";
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+ const { Locator } = require('@toa.io/core');
3
+ const { Producer } = require('./producer');
4
+ const { Consumer } = require('./consumer');
5
+ const { Emitter } = require('./emitter');
6
+ const { Receiver } = require('./receiver');
7
+ const { Broadcast } = require('./broadcast');
8
+ const context = require('./deployment/context');
9
+ const sources = require('./deployment/sources');
10
+ const { SYSTEM } = require('./constants');
11
+ const { Communication } = require('./communication');
12
+ class Factory {
13
+ producer(locator, endpoints, component) {
14
+ const comm = this.#getContext(locator);
15
+ return new Producer(comm, locator, endpoints, component);
16
+ }
17
+ consumer(locator, endpoint) {
18
+ const comm = this.#getContext(locator);
19
+ return new Consumer(comm, locator, endpoint);
20
+ }
21
+ emitter(locator, label) {
22
+ const comm = this.#getContext(locator);
23
+ return new Emitter(comm, locator, label);
24
+ }
25
+ receiver(locator, label, group, receiver) {
26
+ const comm = this.#getSource(locator, label);
27
+ return new Receiver(comm, label, group, receiver);
28
+ }
29
+ broadcast(name, group) {
30
+ const locator = new Locator(name, SYSTEM);
31
+ const comm = this.#getContext(locator);
32
+ return new Broadcast(comm, locator, group);
33
+ }
34
+ #getContext(locator) {
35
+ const resolve = async () => context.resolveURIs(locator);
36
+ return new Communication(resolve);
37
+ }
38
+ #getSource(locator, label) {
39
+ const resolve = (locator.namespace === undefined)
40
+ ? async () => sources.resolveURIs(locator, label)
41
+ : async () => context.resolveURIs(locator);
42
+ return new Communication(resolve);
43
+ }
44
+ }
45
+ exports.Factory = Factory;
46
+ //# sourceMappingURL=factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.js","sourceRoot":"","sources":["../source/factory.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAE3C,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AAC1C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AACxC,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;AA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I,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QACzC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAEtC,OAAO,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;IAC5C,CAAC;IAED,WAAW,CAAE,OAAO;QAClB,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAExD,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAED,UAAU,CAAE,OAAO,EAAE,KAAK;QACxB,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC;YAC/C,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC;YACjD,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAE5C,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;CACF;AAED,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -0,0 +1,5 @@
1
+ /** @type {toa.core.bindings.Properties} */
2
+ export const properties: toa.core.bindings.Properties;
3
+ import { deployment } from "./deployment";
4
+ import { Factory } from "./factory";
5
+ export { deployment, Factory };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+ const { deployment } = require('./deployment');
3
+ const { Factory } = require('./factory');
4
+ /** @type {toa.core.bindings.Properties} */
5
+ const properties = { async: true };
6
+ exports.properties = properties;
7
+ exports.deployment = deployment;
8
+ exports.Factory = Factory;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;AAExC,2CAA2C;AAC3C,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,CAAA;AAElC,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA;AAC/B,OAAO,CAAC,UAAU,GAAG,UAAU,CAAA;AAC/B,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA"}
@@ -0,0 +1,5 @@
1
+ export class Producer extends Connector {
2
+ constructor(comm: any, locator: any, endpoints: any, component: any);
3
+ #private;
4
+ }
5
+ import { Connector } from "@toa.io/core";
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+ const { Connector } = require('@toa.io/core');
3
+ const { name } = require('./queues');
4
+ class Producer extends Connector {
5
+ /** @type {toa.amqp.Communication} */
6
+ #comm;
7
+ /** @type {toa.core.Locator} */
8
+ #locator;
9
+ /** @type {string[]} */
10
+ #endpoints;
11
+ /** @type {toa.core.Component} */
12
+ #component;
13
+ constructor(comm, locator, endpoints, component) {
14
+ super();
15
+ this.#comm = comm;
16
+ this.#locator = locator;
17
+ this.#endpoints = endpoints;
18
+ this.#component = component;
19
+ this.depends(comm);
20
+ this.depends(component);
21
+ }
22
+ async open() {
23
+ await Promise.all(this.#endpoints.map((endpoint) => this.#endpoint(endpoint)));
24
+ }
25
+ async #endpoint(endpoint) {
26
+ const queue = name(this.#locator, endpoint);
27
+ await this.#comm.reply(queue, (request) => this.#component.invoke(endpoint, request));
28
+ }
29
+ }
30
+ exports.Producer = Producer;
31
+ //# sourceMappingURL=producer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"producer.js","sourceRoot":"","sources":["../source/producer.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;AAE7C,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAEpC,MAAM,QAAS,SAAQ,SAAS;IAC9B,qCAAqC;IACrC,KAAK,CAAA;IAEL,+BAA+B;IAC/B,QAAQ,CAAA;IAER,uBAAuB;IACvB,UAAU,CAAA;IAEV,iCAAiC;IACjC,UAAU,CAAA;IAEV,YAAa,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS;QAC9C,KAAK,EAAE,CAAA;QAEP,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAA;QACvB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAC3B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;QAE3B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACzB,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;IAChF,CAAC;IAED,KAAK,CAAC,SAAS,CAAE,QAAQ;QACvB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAE3C,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAA;IACvF,CAAC;CACF;AAED,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAA"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @param {toa.core.Locator} locator
3
+ * @param {string} endpoint
4
+ * @returns {string}
5
+ */
6
+ export function name(locator: toa.core.Locator, endpoint: string): string;
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ const { concat } = require('@toa.io/generic');
3
+ /**
4
+ * @param {toa.core.Locator} locator
5
+ * @param {string} endpoint
6
+ * @returns {string}
7
+ */
8
+ const name = (locator, endpoint) => locator.namespace + '.' + concat(locator.name, '.') + endpoint;
9
+ exports.name = name;
10
+ //# sourceMappingURL=queues.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queues.js","sourceRoot":"","sources":["../source/queues.js"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAEZ,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAE7C;;;;GAIG;AACH,MAAM,IAAI,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE,CACjC,OAAO,CAAC,SAAS,GAAG,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,QAAQ,CAAA;AAEhE,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA"}
@@ -0,0 +1,5 @@
1
+ export class Receiver extends Connector {
2
+ constructor(comm: any, exchange: any, group: any, receiver: any);
3
+ #private;
4
+ }
5
+ import { Connector } from "@toa.io/core";