@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.
- package/README.md +15 -2
- package/build/internal/connector/server/on-connect/make-oauth.mjs +27 -6
- package/build/internal/fetcher/fetcher.d.mts +22 -1
- package/build/internal/fetcher/fetcher.mjs +99 -14
- package/build/internal/fetcher/oauth-fetcher.d.mts +15 -2
- package/build/internal/fetcher/oauth-fetcher.mjs +72 -27
- package/build/internal/util/index.d.mts +8 -0
- package/build/internal/util/index.mjs +13 -1
- package/build/internal/util/jwe/index.mjs +3 -1
- package/build/openapi-to-connector.mjs +5 -2
- package/package.json +9 -4
- package/.prettierrc.cjs +0 -8
- package/MULTI_RESOURCE_GUIDE.md +0 -220
- package/OPENAPI_TO_CONNECTOR.md +0 -346
- package/examples/hello-world/package.json +0 -25
- package/examples/hello-world/src/controller/index.mts +0 -12
- package/examples/hello-world/src/index.mts +0 -6
- package/examples/hello-world/tsconfig.json +0 -27
- package/examples/sample-api.json +0 -325
- package/examples/sample-api.yaml +0 -222
- package/examples/simple-api.json +0 -39
- package/index.js +0 -4
- package/src/builder/index.mts +0 -274
- package/src/builder/runtime-context.mts +0 -129
- package/src/cli.mts +0 -533
- package/src/controller/index.mts +0 -278
- package/src/index.mts +0 -2
- package/src/internal/connector/config.mts +0 -59
- package/src/internal/connector/index.mts +0 -53
- package/src/internal/connector/metrics.mts +0 -34
- package/src/internal/connector/server/index.mts +0 -51
- package/src/internal/connector/server/on-connect/decrypt-config.mts +0 -27
- package/src/internal/connector/server/on-connect/finish-oauth.mts +0 -109
- package/src/internal/connector/server/on-connect/index.mts +0 -162
- package/src/internal/connector/server/on-connect/make-oauth.mts +0 -97
- package/src/internal/connector/server/on-connect/start-oauth.mts +0 -24
- package/src/internal/connector/server/on-message.mts +0 -13
- package/src/internal/dispatcher/index.mts +0 -231
- package/src/internal/fetcher/fetcher.mts +0 -166
- package/src/internal/fetcher/oauth-fetcher.mts +0 -153
- package/src/internal/index.mts +0 -3
- package/src/internal/util/index.mts +0 -52
- package/src/internal/util/jwe/cli.mts +0 -12
- package/src/internal/util/jwe/index.mts +0 -72
- package/src/internal/websocket/config.mjs +0 -109
- package/src/internal/websocket/connection/constants.mjs +0 -25
- package/src/internal/websocket/connection/index.mjs +0 -71
- package/src/internal/websocket/connection/registration.mjs +0 -42
- package/src/internal/websocket/index.mjs +0 -46
- package/src/internal/websocket/transport/durable.mjs +0 -71
- package/src/internal/websocket/transport/index.mjs +0 -194
- package/src/internal/websocket/transport/packet.mjs +0 -54
- package/src/internal/websocket/transport/processor.mjs +0 -66
- package/src/openapi-to-connector.mts +0 -1644
- package/src/testing/fake-aloma.mts +0 -306
- package/src/testing/harness.mts +0 -172
- package/src/testing/index.mts +0 -15
- package/src/testing/keys.mts +0 -19
- package/src/testing/network-guard.mts +0 -57
- package/src/testing/runtime-connector.mts +0 -50
- package/src/testing/vendor-mock.mts +0 -166
- package/src/transform/index.mts +0 -544
- package/test/MUTATION-entry.md +0 -21
- package/test/MUTATION.md +0 -43
- package/test/dispatcher-ctx-forwarding.test.mjs +0 -161
- package/test/fixtures/transform/basic/expected.json +0 -9
- package/test/fixtures/transform/basic/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/basic/src/controller/index.mts +0 -30
- package/test/fixtures/transform/basic/tsconfig.json +0 -1
- package/test/fixtures/transform/interface-param/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/interface-param/src/controller/index.mts +0 -12
- package/test/fixtures/transform/interface-param/tsconfig.json +0 -1
- package/test/fixtures/transform/overloads/expected.json +0 -6
- package/test/fixtures/transform/overloads/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/overloads/src/controller/index.mts +0 -11
- package/test/fixtures/transform/overloads/tsconfig.json +0 -1
- package/test/fixtures/transform/tdd-stub/expected.json +0 -8
- package/test/fixtures/transform/tdd-stub/src/controller/abstract.mts +0 -6
- package/test/fixtures/transform/tdd-stub/src/controller/index.mts +0 -204
- package/test/fixtures/transform/tdd-stub/tsconfig.json +0 -1
- package/test/fixtures/transform/two-exports/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/two-exports/src/controller/index.mts +0 -9
- package/test/fixtures/transform/two-exports/tsconfig.json +0 -1
- package/test/fixtures/transform/type-error/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/type-error/src/controller/index.mts +0 -7
- package/test/fixtures/transform/type-error/tsconfig.json +0 -1
- package/test/fixtures/transform/typed/expected.json +0 -8
- package/test/fixtures/transform/typed/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/typed/src/controller/index.mts +0 -13
- package/test/fixtures/transform/typed/tsconfig.json +0 -1
- package/test/fixtures/transform/visibility/expected.json +0 -9
- package/test/fixtures/transform/visibility/src/controller/abstract.mts +0 -5
- package/test/fixtures/transform/visibility/src/controller/index.mts +0 -19
- package/test/fixtures/transform/visibility/tsconfig.json +0 -1
- package/test/harness-connector-smoke.test.mjs +0 -72
- package/test/harness.test.mjs +0 -375
- package/test/nested-resolver.test.mjs +0 -184
- package/test/openapi-generator-bugs.test.mjs +0 -248
- package/test/openapi-identifier-sanitise.test.mjs +0 -69
- package/test/openapi-nested-paths.test.mjs +0 -100
- package/test/openapi-to-connector.test.mts +0 -225
- package/test/openapi-ts-compilation.test.mjs +0 -178
- package/test/scenarios/README.md +0 -148
- package/test/scenarios/complex/expected/controller.mts +0 -271
- package/test/scenarios/complex/expected/orders-resource.mts +0 -262
- package/test/scenarios/complex/expected/products-resource.mts +0 -237
- package/test/scenarios/complex/specs/orders.json +0 -362
- package/test/scenarios/complex/specs/products.json +0 -308
- package/test/scenarios/simple/expected-controller.mts +0 -60
- package/test/scenarios/simple/simple-api.json +0 -39
- package/test/scenarios.test.mts +0 -294
- package/test/transform.test.mjs +0 -68
- package/test/verify-scenarios.mjs +0 -298
- package/tools/mutation-run-entry.mjs +0 -52
- package/tools/mutation-run.mjs +0 -120
- package/tools/run-tests.mjs +0 -64
- 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};
|