@aloma.io/integration-sdk 3.8.69 → 3.8.71

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 (117) hide show
  1. package/README.md +15 -2
  2. package/build/internal/connector/server/on-connect/make-oauth.mjs +27 -6
  3. package/build/internal/fetcher/fetcher.d.mts +22 -1
  4. package/build/internal/fetcher/fetcher.mjs +99 -14
  5. package/build/internal/fetcher/oauth-fetcher.d.mts +15 -2
  6. package/build/internal/fetcher/oauth-fetcher.mjs +72 -27
  7. package/build/internal/util/index.d.mts +8 -0
  8. package/build/internal/util/index.mjs +13 -1
  9. package/build/internal/util/jwe/index.mjs +3 -1
  10. package/build/openapi-to-connector.mjs +5 -2
  11. package/package.json +9 -4
  12. package/.prettierrc.cjs +0 -8
  13. package/MULTI_RESOURCE_GUIDE.md +0 -220
  14. package/OPENAPI_TO_CONNECTOR.md +0 -346
  15. package/examples/hello-world/package.json +0 -25
  16. package/examples/hello-world/src/controller/index.mts +0 -12
  17. package/examples/hello-world/src/index.mts +0 -6
  18. package/examples/hello-world/tsconfig.json +0 -27
  19. package/examples/sample-api.json +0 -325
  20. package/examples/sample-api.yaml +0 -222
  21. package/examples/simple-api.json +0 -39
  22. package/index.js +0 -4
  23. package/src/builder/index.mts +0 -274
  24. package/src/builder/runtime-context.mts +0 -129
  25. package/src/cli.mts +0 -533
  26. package/src/controller/index.mts +0 -278
  27. package/src/index.mts +0 -2
  28. package/src/internal/connector/config.mts +0 -59
  29. package/src/internal/connector/index.mts +0 -53
  30. package/src/internal/connector/metrics.mts +0 -34
  31. package/src/internal/connector/server/index.mts +0 -51
  32. package/src/internal/connector/server/on-connect/decrypt-config.mts +0 -27
  33. package/src/internal/connector/server/on-connect/finish-oauth.mts +0 -109
  34. package/src/internal/connector/server/on-connect/index.mts +0 -162
  35. package/src/internal/connector/server/on-connect/make-oauth.mts +0 -97
  36. package/src/internal/connector/server/on-connect/start-oauth.mts +0 -24
  37. package/src/internal/connector/server/on-message.mts +0 -13
  38. package/src/internal/dispatcher/index.mts +0 -231
  39. package/src/internal/fetcher/fetcher.mts +0 -166
  40. package/src/internal/fetcher/oauth-fetcher.mts +0 -153
  41. package/src/internal/index.mts +0 -3
  42. package/src/internal/util/index.mts +0 -52
  43. package/src/internal/util/jwe/cli.mts +0 -12
  44. package/src/internal/util/jwe/index.mts +0 -72
  45. package/src/internal/websocket/config.mjs +0 -109
  46. package/src/internal/websocket/connection/constants.mjs +0 -25
  47. package/src/internal/websocket/connection/index.mjs +0 -71
  48. package/src/internal/websocket/connection/registration.mjs +0 -42
  49. package/src/internal/websocket/index.mjs +0 -46
  50. package/src/internal/websocket/transport/durable.mjs +0 -71
  51. package/src/internal/websocket/transport/index.mjs +0 -194
  52. package/src/internal/websocket/transport/packet.mjs +0 -54
  53. package/src/internal/websocket/transport/processor.mjs +0 -66
  54. package/src/openapi-to-connector.mts +0 -1644
  55. package/src/testing/fake-aloma.mts +0 -306
  56. package/src/testing/harness.mts +0 -172
  57. package/src/testing/index.mts +0 -15
  58. package/src/testing/keys.mts +0 -19
  59. package/src/testing/network-guard.mts +0 -57
  60. package/src/testing/runtime-connector.mts +0 -50
  61. package/src/testing/vendor-mock.mts +0 -166
  62. package/src/transform/index.mts +0 -544
  63. package/test/MUTATION-entry.md +0 -21
  64. package/test/MUTATION.md +0 -43
  65. package/test/dispatcher-ctx-forwarding.test.mjs +0 -161
  66. package/test/fixtures/transform/basic/expected.json +0 -9
  67. package/test/fixtures/transform/basic/src/controller/abstract.mts +0 -5
  68. package/test/fixtures/transform/basic/src/controller/index.mts +0 -30
  69. package/test/fixtures/transform/basic/tsconfig.json +0 -1
  70. package/test/fixtures/transform/interface-param/src/controller/abstract.mts +0 -5
  71. package/test/fixtures/transform/interface-param/src/controller/index.mts +0 -12
  72. package/test/fixtures/transform/interface-param/tsconfig.json +0 -1
  73. package/test/fixtures/transform/overloads/expected.json +0 -6
  74. package/test/fixtures/transform/overloads/src/controller/abstract.mts +0 -5
  75. package/test/fixtures/transform/overloads/src/controller/index.mts +0 -11
  76. package/test/fixtures/transform/overloads/tsconfig.json +0 -1
  77. package/test/fixtures/transform/tdd-stub/expected.json +0 -8
  78. package/test/fixtures/transform/tdd-stub/src/controller/abstract.mts +0 -6
  79. package/test/fixtures/transform/tdd-stub/src/controller/index.mts +0 -204
  80. package/test/fixtures/transform/tdd-stub/tsconfig.json +0 -1
  81. package/test/fixtures/transform/two-exports/src/controller/abstract.mts +0 -5
  82. package/test/fixtures/transform/two-exports/src/controller/index.mts +0 -9
  83. package/test/fixtures/transform/two-exports/tsconfig.json +0 -1
  84. package/test/fixtures/transform/type-error/src/controller/abstract.mts +0 -5
  85. package/test/fixtures/transform/type-error/src/controller/index.mts +0 -7
  86. package/test/fixtures/transform/type-error/tsconfig.json +0 -1
  87. package/test/fixtures/transform/typed/expected.json +0 -8
  88. package/test/fixtures/transform/typed/src/controller/abstract.mts +0 -5
  89. package/test/fixtures/transform/typed/src/controller/index.mts +0 -13
  90. package/test/fixtures/transform/typed/tsconfig.json +0 -1
  91. package/test/fixtures/transform/visibility/expected.json +0 -9
  92. package/test/fixtures/transform/visibility/src/controller/abstract.mts +0 -5
  93. package/test/fixtures/transform/visibility/src/controller/index.mts +0 -19
  94. package/test/fixtures/transform/visibility/tsconfig.json +0 -1
  95. package/test/harness-connector-smoke.test.mjs +0 -72
  96. package/test/harness.test.mjs +0 -375
  97. package/test/nested-resolver.test.mjs +0 -184
  98. package/test/openapi-generator-bugs.test.mjs +0 -248
  99. package/test/openapi-identifier-sanitise.test.mjs +0 -69
  100. package/test/openapi-nested-paths.test.mjs +0 -100
  101. package/test/openapi-to-connector.test.mts +0 -225
  102. package/test/openapi-ts-compilation.test.mjs +0 -178
  103. package/test/scenarios/README.md +0 -148
  104. package/test/scenarios/complex/expected/controller.mts +0 -271
  105. package/test/scenarios/complex/expected/orders-resource.mts +0 -262
  106. package/test/scenarios/complex/expected/products-resource.mts +0 -237
  107. package/test/scenarios/complex/specs/orders.json +0 -362
  108. package/test/scenarios/complex/specs/products.json +0 -308
  109. package/test/scenarios/simple/expected-controller.mts +0 -60
  110. package/test/scenarios/simple/simple-api.json +0 -39
  111. package/test/scenarios.test.mts +0 -294
  112. package/test/transform.test.mjs +0 -68
  113. package/test/verify-scenarios.mjs +0 -298
  114. package/tools/mutation-run-entry.mjs +0 -52
  115. package/tools/mutation-run.mjs +0 -120
  116. package/tools/run-tests.mjs +0 -64
  117. package/tsconfig.json +0 -27
@@ -1,194 +0,0 @@
1
- import {init} from '@paralleldrive/cuid2';
2
- import C from '../connection/constants.mjs';
3
- const cuid = init({length: 32});
4
-
5
- import WebSocket from 'ws';
6
- import {DurableWebsocket} from './durable.mjs';
7
- import {Callback, Packet} from './packet.mjs';
8
-
9
- const cleanInterval = 45 * 1000;
10
- const pingInterval = 30 * 1000;
11
-
12
- class Transport {
13
- constructor({config, onMessage, onConnect}) {
14
- var local = this;
15
-
16
- this.config = config;
17
- this.callbacks = {};
18
- this.running = true;
19
- this.pinger = null;
20
- this.cleaner = setInterval(() => local.clean(), cleanInterval);
21
-
22
- this.acks = [];
23
- this.packets = [];
24
- this.onConnect = onConnect;
25
- this._onMessage = onMessage;
26
- }
27
-
28
- schedule() {
29
- var local = this;
30
-
31
- setTimeout(() => local.schedule0(), 0);
32
- }
33
-
34
- schedule0() {
35
- var local = this,
36
- packets = [],
37
- packet;
38
-
39
- if (!local.packets.length || !local.connected) return;
40
-
41
- while ((packet = local.packets.shift())) {
42
- packets.push(packet.data);
43
- }
44
-
45
- if (!packets.length) return;
46
-
47
- try {
48
- local.ws.send(JSON.stringify({p: packets}));
49
- } catch (e) {
50
- console.log('could not send packets ', e);
51
- packets.forEach((packet) => local.packets.unshift(packet));
52
- }
53
- }
54
-
55
- async start(ondisconnect) {
56
- var local = this,
57
- config = local.config;
58
-
59
- if (local._leaving) return;
60
-
61
- local.close();
62
-
63
- this.running = true;
64
-
65
- const ws = (local.ws = new WebSocket(config.wsUrl(), ['connector'], C.augmentRequest({headers: {}}, config)));
66
-
67
- ws.onPing = function () {
68
- clearTimeout(this.pingTimeout);
69
- this.pingTimeout = setTimeout(() => {
70
- if (local.running) ws.terminate();
71
- }, 30000 + 15000);
72
- };
73
-
74
- ws.on('open', () => {
75
- console.log('transport connected');
76
- local.connected = true;
77
- ws.onPing();
78
- local.pinger = setInterval(() => ws.ping(() => null), pingInterval);
79
-
80
- local.onConnect(local);
81
- });
82
-
83
- ws.on('message', (message) => {
84
- setTimeout(() => local.onMessages(JSON.parse(message)), 0);
85
- });
86
-
87
- ws.on('ping', () => ws.onPing());
88
-
89
- ws.on('error', (message) => {
90
- console.log('error:', message);
91
- });
92
-
93
- ws.on('close', (message) => {
94
- local.connected = false;
95
- clearInterval(local.pinger);
96
-
97
- if (local.running) ondisconnect();
98
- });
99
- }
100
-
101
- newDurableWebsocket({endpoint, secret, onConnect, onMessage}) {
102
- return new DurableWebsocket({endpoint, secret, onConnect, onMessage});
103
- }
104
-
105
- send(packet) {
106
- if (!packet) return;
107
-
108
- this.packets.push(packet);
109
- this.schedule();
110
- }
111
-
112
- onMessages(msgs) {
113
- var local = this;
114
-
115
- msgs.p?.forEach((item) => {
116
- local.onMessage(item);
117
- });
118
- }
119
-
120
- onMessage(data) {
121
- if (!data) return;
122
-
123
- const packet = new Packet(data);
124
-
125
- if (packet.cb() && this.callbacks[packet.cb()]) {
126
- try {
127
- this.callbacks[packet.cb()].cb(packet.args());
128
- } catch (e) {
129
- console.log('error processing packet', e, packet);
130
- } finally {
131
- delete this.callbacks[packet.cb()];
132
- }
133
-
134
- return;
135
- }
136
-
137
- return this._onMessage(packet, this);
138
- }
139
-
140
- newPacket(data, cb, cbKey) {
141
- const packet = new Packet({...data});
142
-
143
- if (cb) {
144
- this.callbacks[cbKey || packet.id()] = new Callback({cb});
145
- packet.cb(cbKey || packet.id());
146
- }
147
-
148
- return packet;
149
- }
150
-
151
- clean() {
152
- var local = this;
153
- const cbs = {...this.callbacks},
154
- then = Date.now() - 5 * 60 * 1000;
155
-
156
- Object.keys(cbs).forEach((key) => {
157
- const cb = cbs[key];
158
- if (!cb) return;
159
-
160
- if (cb.created < then) {
161
- console.log('callback timeout', key);
162
-
163
- try {
164
- cb.cb({error: 'timeout'});
165
- } catch (e) {
166
- console.log('error while callback', key, cb, e);
167
- }
168
-
169
- delete local.callbacks[key];
170
- }
171
- });
172
- }
173
-
174
- leaving() {
175
- this._leaving = true;
176
- this.running = false;
177
- }
178
-
179
- close() {
180
- clearInterval(this.pinger);
181
- clearInterval(this.cleaner);
182
-
183
- this.running = false;
184
- this.connected = false;
185
-
186
- try {
187
- local.ws.terminate();
188
- } catch (e) {
189
- // blank
190
- }
191
- }
192
- }
193
-
194
- export {Transport};
@@ -1,54 +0,0 @@
1
- import {init} from '@paralleldrive/cuid2';
2
- const cuid = init({length: 32});
3
-
4
- class Packet {
5
- constructor(data = {}) {
6
- this.data = data;
7
- this.data.id ||= cuid();
8
- }
9
-
10
- id() {
11
- return this.data.id;
12
- }
13
-
14
- cb(what) {
15
- if (what) {
16
- this.data.c = what;
17
- }
18
-
19
- return this.data.c;
20
- }
21
-
22
- method(what) {
23
- if (what) {
24
- this.data.m = what;
25
- }
26
-
27
- return this.data.m;
28
- }
29
-
30
- event(what) {
31
- if (what) {
32
- this.data.e = what;
33
- }
34
-
35
- return this.data.e;
36
- }
37
-
38
- args(what) {
39
- if (what) {
40
- this.data.a = what;
41
- }
42
-
43
- return this.data.a;
44
- }
45
- }
46
-
47
- class Callback {
48
- constructor({cb}) {
49
- this.cb = cb;
50
- this.created = Date.now();
51
- }
52
- }
53
-
54
- export {Callback, Packet};
@@ -1,66 +0,0 @@
1
- import {Packet, Callback} from './packet.mjs';
2
-
3
- class Processor {
4
- constructor({transport, processPacket}) {
5
- var local = this;
6
-
7
- this.transport = transport;
8
- this._processPacket = processPacket;
9
- }
10
-
11
- async onMessages(what) {
12
- var local = this;
13
- const messages = what.p;
14
-
15
- const packets = messages.map((message) => {
16
- const packet = new Packet(message);
17
- local.transport.acks.push(packet.id());
18
-
19
- return local.processPacket(packet);
20
- });
21
-
22
- await Promise.all(packets);
23
- }
24
-
25
- async processPacket(packet) {
26
- var local = this;
27
-
28
- if (packet.args().packet) {
29
- await local.processPacket0(local.transport.newPacket(packet.args().packet), packet);
30
- } else {
31
- await local.processPacket0(packet, packet);
32
- }
33
- }
34
-
35
- async processPacket0(packet, original) {
36
- var local = this,
37
- callbacks = local.transport.callbacks;
38
-
39
- if (packet.cb() && callbacks[packet.cb()]) {
40
- try {
41
- callbacks[packet.cb()](packet.args());
42
- } catch (e) {
43
- console.log('error in callback', callbacks[packet.cb()], packet);
44
- }
45
-
46
- delete local.transport.callbacks[packet.cb()];
47
- } else if (packet.event()) {
48
- console.log('handle event packet', packet);
49
- } else {
50
- try {
51
- const result = await local._processPacket(packet);
52
- const reply = local.transport.newPacket({});
53
-
54
- reply.method('connector.reply');
55
- reply.cb(original.cb());
56
- reply.args({...result});
57
-
58
- local.transport.send(reply);
59
- } catch (e) {
60
- console.log('error processing packet', e, packet);
61
- }
62
- }
63
- }
64
- }
65
-
66
- export {Processor};