@whitewall/blip-sdk 0.0.128 → 0.0.129
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/cjs/namespaces/account.js +96 -0
- package/dist/cjs/namespaces/account.js.map +1 -1
- package/dist/cjs/types/flow.js +3 -0
- package/dist/cjs/types/flow.js.map +1 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/esm/namespaces/account.js +96 -0
- package/dist/esm/namespaces/account.js.map +1 -1
- package/dist/esm/types/flow.js +2 -0
- package/dist/esm/types/flow.js.map +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/types/namespaces/account.d.ts +11 -1
- package/dist/types/namespaces/account.d.ts.map +1 -1
- package/dist/types/types/flow.d.ts +208 -0
- package/dist/types/types/flow.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/sender/customgateway.js +0 -31
- package/dist/cjs/sender/customgateway.js.map +0 -1
- package/dist/cjs/sender/httpsender.js +0 -92
- package/dist/cjs/sender/httpsender.js.map +0 -1
- package/dist/cjs/sender/portal/communication.js +0 -60
- package/dist/cjs/sender/portal/communication.js.map +0 -1
- package/dist/cjs/sender/portal/pluginsender.js +0 -47
- package/dist/cjs/sender/portal/pluginsender.js.map +0 -1
- package/dist/cjs/utils/collection.js +0 -17
- package/dist/cjs/utils/collection.js.map +0 -1
- package/dist/esm/sender/customgateway.js +0 -27
- package/dist/esm/sender/customgateway.js.map +0 -1
- package/dist/esm/sender/httpsender.js +0 -88
- package/dist/esm/sender/httpsender.js.map +0 -1
- package/dist/esm/sender/portal/communication.js +0 -56
- package/dist/esm/sender/portal/communication.js.map +0 -1
- package/dist/esm/sender/portal/pluginsender.js +0 -43
- package/dist/esm/sender/portal/pluginsender.js.map +0 -1
- package/dist/esm/utils/collection.js +0 -13
- package/dist/esm/utils/collection.js.map +0 -1
- package/dist/types/sender/customgateway.d.ts +0 -9
- package/dist/types/sender/customgateway.d.ts.map +0 -1
- package/dist/types/sender/httpsender.d.ts +0 -13
- package/dist/types/sender/httpsender.d.ts.map +0 -1
- package/dist/types/sender/portal/communication.d.ts +0 -7
- package/dist/types/sender/portal/communication.d.ts.map +0 -1
- package/dist/types/sender/portal/pluginsender.d.ts +0 -14
- package/dist/types/sender/portal/pluginsender.d.ts.map +0 -1
- package/dist/types/utils/collection.d.ts +0 -7
- package/dist/types/utils/collection.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CustomGatewayHttpSender = void 0;
|
|
4
|
-
const index_js_1 = require("../types/index.js");
|
|
5
|
-
class CustomGatewayHttpSender {
|
|
6
|
-
constructor(botIdentityOrIdentifier, password) {
|
|
7
|
-
const botIdentity = index_js_1.Node.isValid(botIdentityOrIdentifier)
|
|
8
|
-
? botIdentityOrIdentifier
|
|
9
|
-
: `${botIdentityOrIdentifier}@msging.net`;
|
|
10
|
-
this.token = btoa(`${botIdentity}:${password}`);
|
|
11
|
-
}
|
|
12
|
-
token;
|
|
13
|
-
async sendMessage(message) {
|
|
14
|
-
const response = await fetch('https://custom.gw.msging.net/messages', {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
headers: {
|
|
17
|
-
'Content-Type': 'application/json',
|
|
18
|
-
Authorization: `Basic ${this.token}`,
|
|
19
|
-
},
|
|
20
|
-
body: JSON.stringify(message),
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
throw new Error(`Failed to send message: ${response.statusText}`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
sendCommand() {
|
|
27
|
-
throw new Error('Custom gateway clients cannot send commands');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.CustomGatewayHttpSender = CustomGatewayHttpSender;
|
|
31
|
-
//# sourceMappingURL=customgateway.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customgateway.js","sourceRoot":"","sources":["../../../src/sender/customgateway.ts"],"names":[],"mappings":";;;AAAA,gDAAgF;AAGhF,MAAa,uBAAuB;IAChC,YAAY,uBAA+B,EAAE,QAAgB;QACzD,MAAM,WAAW,GAAG,eAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC;YACrD,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,GAAG,uBAAuB,aAAa,CAAA;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,WAAW,IAAI,QAAQ,EAAE,CAAC,CAAA;IACnD,CAAC;IAEgB,KAAK,CAAQ;IAEvB,KAAK,CAAC,WAAW,CAAyC,OAAsB;QACnF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;YAClE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;aACvC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAChC,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QACrE,CAAC;IACL,CAAC;IAED,WAAW;QACP,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAClE,CAAC;CACJ;AA5BD,0DA4BC"}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpSender = void 0;
|
|
4
|
-
const index_js_1 = require("../types/index.js");
|
|
5
|
-
const bliperror_js_1 = require("./bliperror.js");
|
|
6
|
-
class HttpSender {
|
|
7
|
-
token;
|
|
8
|
-
baseurl;
|
|
9
|
-
constructor(token, tenantId) {
|
|
10
|
-
this.token = token.startsWith('Key ') ? token.slice(4) : token;
|
|
11
|
-
const prefix = tenantId ? `${tenantId}.` : '';
|
|
12
|
-
this.baseurl = `https://${prefix}http.msging.net`;
|
|
13
|
-
}
|
|
14
|
-
async sendMessage(message) {
|
|
15
|
-
await this.throttle('message');
|
|
16
|
-
const response = await fetch(`${this.baseurl}/messages`, {
|
|
17
|
-
method: 'POST',
|
|
18
|
-
headers: {
|
|
19
|
-
'Content-Type': 'application/json',
|
|
20
|
-
Authorization: `Key ${this.token}`,
|
|
21
|
-
},
|
|
22
|
-
body: JSON.stringify(message),
|
|
23
|
-
});
|
|
24
|
-
if (!response.ok) {
|
|
25
|
-
throw new Error(`Failed to send message: ${response.statusText}`);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
async sendCommand(command) {
|
|
29
|
-
await this.throttle('command');
|
|
30
|
-
const response = await fetch(`${this.baseurl}/commands`, {
|
|
31
|
-
method: 'POST',
|
|
32
|
-
headers: {
|
|
33
|
-
'Content-Type': 'application/json',
|
|
34
|
-
Authorization: `Key ${this.token}`,
|
|
35
|
-
},
|
|
36
|
-
body: JSON.stringify(command),
|
|
37
|
-
});
|
|
38
|
-
if (!response.ok) {
|
|
39
|
-
throw new Error(`Failed to send command: ${response.statusText}`);
|
|
40
|
-
}
|
|
41
|
-
const result = await response.json();
|
|
42
|
-
if (result.status === 'failure') {
|
|
43
|
-
throw new bliperror_js_1.BlipError(command.uri, result.reason.code, result.reason.description);
|
|
44
|
-
}
|
|
45
|
-
else if (result.status === 'success') {
|
|
46
|
-
return result.resource;
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
throw new Error(`Unexpected response status: ${result.status}`);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
static login(botIdentityOrIdentifier, accessKey, tenantId) {
|
|
53
|
-
const botIdentity = index_js_1.Node.isValid(botIdentityOrIdentifier)
|
|
54
|
-
? botIdentityOrIdentifier
|
|
55
|
-
: `${botIdentityOrIdentifier}@msging.net`;
|
|
56
|
-
const token = btoa(`${botIdentity}:${atob(accessKey)}`);
|
|
57
|
-
return new HttpSender(token, tenantId);
|
|
58
|
-
}
|
|
59
|
-
sent = {
|
|
60
|
-
message: {
|
|
61
|
-
max: 50,
|
|
62
|
-
started: 0,
|
|
63
|
-
count: 0,
|
|
64
|
-
},
|
|
65
|
-
command: {
|
|
66
|
-
max: 200,
|
|
67
|
-
started: 0,
|
|
68
|
-
count: 0,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
async throttle(type) {
|
|
72
|
-
const throughput = this.sent[type].max * 0.8;
|
|
73
|
-
const timeToReset = 2000;
|
|
74
|
-
while (true) {
|
|
75
|
-
const elapsed = Date.now() - this.sent[type].started;
|
|
76
|
-
if (elapsed >= timeToReset) {
|
|
77
|
-
this.sent[type].started = Date.now();
|
|
78
|
-
this.sent[type].count = 0;
|
|
79
|
-
}
|
|
80
|
-
if (this.sent[type].count < throughput) {
|
|
81
|
-
this.sent[type].count++;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
const wait = timeToReset - elapsed;
|
|
86
|
-
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
exports.HttpSender = HttpSender;
|
|
92
|
-
//# sourceMappingURL=httpsender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpsender.js","sourceRoot":"","sources":["../../../src/sender/httpsender.ts"],"names":[],"mappings":";;;AAAA,gDAQ0B;AAC1B,iDAA0C;AAG1C,MAAa,UAAU;IACF,KAAK,CAAQ;IACb,OAAO,CAAQ;IAEhC,YAAY,KAAa,EAAE,QAAiB;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG,WAAW,MAAM,iBAAiB,CAAA;IACrD,CAAC;IAEM,KAAK,CAAC,WAAW,CAA4B,OAAsB;QACtE,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QAC9B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,EAAE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AAI,CAAC,CAAC,KAAK,GAAG,UAAU,EAAE,CAAC;gBACrC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,CAAA;gBACvB,MAAK;YACT,CAAC;iBAAM,CAAC;gBACJ,MAAM,IAAI,GAAG,WAAW,GAAG,OAAO,CAAA;gBAClC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;YAC7D,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AA5FD,gCA4FC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.startChannel = void 0;
|
|
4
|
-
const random_js_1 = require("../../utils/random.js");
|
|
5
|
-
const startChannel = () => {
|
|
6
|
-
const caller = window.name ?? (0, random_js_1.randomId)();
|
|
7
|
-
const waitingMessages = {};
|
|
8
|
-
const messageHandler = ({ data }) => {
|
|
9
|
-
const deferred = waitingMessages[data?.trackingProperties?.id];
|
|
10
|
-
if (deferred) {
|
|
11
|
-
if (data.message?.caller === caller) {
|
|
12
|
-
// This is a echo message, ignore it
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (data.error) {
|
|
16
|
-
deferred.reject(JSON.parse(data.error));
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
deferred.resolve(data.response);
|
|
20
|
-
}
|
|
21
|
-
delete waitingMessages[data.trackingProperties.id];
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
window.addEventListener('message', messageHandler);
|
|
25
|
-
let isDestroyed = false;
|
|
26
|
-
return {
|
|
27
|
-
post: (action, content, options) => {
|
|
28
|
-
if (isDestroyed) {
|
|
29
|
-
throw new Error('Channel is destroyed');
|
|
30
|
-
}
|
|
31
|
-
const id = (0, random_js_1.randomId)();
|
|
32
|
-
let promise;
|
|
33
|
-
if (options?.fireAndForget) {
|
|
34
|
-
promise = Promise.resolve();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
const deferred = Promise.withResolvers();
|
|
38
|
-
waitingMessages[id] = { reject: deferred.reject, resolve: deferred.resolve };
|
|
39
|
-
promise = deferred.promise;
|
|
40
|
-
}
|
|
41
|
-
window.parent.postMessage({
|
|
42
|
-
message: {
|
|
43
|
-
action: `blipEvent:${action}`,
|
|
44
|
-
content,
|
|
45
|
-
caller,
|
|
46
|
-
},
|
|
47
|
-
trackingProperties: {
|
|
48
|
-
id,
|
|
49
|
-
},
|
|
50
|
-
}, '*');
|
|
51
|
-
return promise;
|
|
52
|
-
},
|
|
53
|
-
destroy: () => {
|
|
54
|
-
window.removeEventListener('message', messageHandler);
|
|
55
|
-
isDestroyed = true;
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
exports.startChannel = startChannel;
|
|
60
|
-
//# sourceMappingURL=communication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication.js","sourceRoot":"","sources":["../../../../src/sender/portal/communication.ts"],"names":[],"mappings":";;;AAAA,qDAAgD;AAEzC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,IAAI,IAAA,oBAAQ,GAAE,CAAA;IAExC,MAAM,eAAe,GAA8E,EAAE,CAAA;IACrG,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAgB,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAA;QAC9D,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;gBAClC,oCAAoC;gBACpC,OAAM;YACV,CAAC;YAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,QAAQ,CAAC,MAAM,CAAC,IAAI,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,mBAAmB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;YACrD,WAAW,GAAG,IAAI,CAAA;QACtB,CAAC;KACJ,CAAA;AACL,CAAC,CAAA;AA9DY,QAAA,YAAY,gBA8DxB"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PortalPluginSender = void 0;
|
|
4
|
-
const index_js_1 = require("../../index.js");
|
|
5
|
-
const communication_js_1 = require("./communication.js");
|
|
6
|
-
class PortalPluginSender {
|
|
7
|
-
channel;
|
|
8
|
-
constructor() {
|
|
9
|
-
this.channel = (0, communication_js_1.startChannel)();
|
|
10
|
-
}
|
|
11
|
-
async sendMessage(message) {
|
|
12
|
-
await this.sendCommand({
|
|
13
|
-
id: message.id,
|
|
14
|
-
uri: '/schedules',
|
|
15
|
-
method: 'set',
|
|
16
|
-
type: 'application/vnd.iris.schedule+json',
|
|
17
|
-
resource: {
|
|
18
|
-
message,
|
|
19
|
-
when: new Date().toISOString(),
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
async sendCommand(command) {
|
|
24
|
-
try {
|
|
25
|
-
return await this.channel.post('sendCommand', {
|
|
26
|
-
command,
|
|
27
|
-
destination: command.to?.includes('msging.net') ? 'MessagingHubService' : 'BlipService',
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
catch (err) {
|
|
31
|
-
if (err && typeof err === 'object' && 'code' in err && 'description' in err) {
|
|
32
|
-
const knownerror = err;
|
|
33
|
-
throw new index_js_1.BlipError(command.uri, knownerror.code, knownerror.description);
|
|
34
|
-
}
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
static check(blipClient) {
|
|
39
|
-
const isPluginSender = blipClient.sender instanceof PortalPluginSender;
|
|
40
|
-
if (!isPluginSender) {
|
|
41
|
-
throw new Error('This command is only allowed for plugin senders');
|
|
42
|
-
}
|
|
43
|
-
return blipClient.sender;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
exports.PortalPluginSender = PortalPluginSender;
|
|
47
|
-
//# sourceMappingURL=pluginsender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pluginsender.js","sourceRoot":"","sources":["../../../../src/sender/portal/pluginsender.ts"],"names":[],"mappings":";;;AAAA,6CAQuB;AACvB,yDAAiD;AAEjD,MAAa,kBAAkB;IACX,OAAO,CAAA;IAEvB;QACI,IAAI,CAAC,OAAO,GAAG,IAAA,+BAAY,GAAE,CAAA;IACjC,CAAC;IAEM,KAAK,CAAC,WAAW,CAA4B,OAAsB;QACtE,MAAM,IAAI,CAAC,WAAW,CAAC;YACnB,EAAE,EAAE,OAAO,CAAC,EAAE;YACd,GAAG,EAAE,YAAY;YACjB,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,oCAAoC;YAC1C,QAAQ,EAAE;gBACN,OAAO;gBACP,IAAI,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;aACjC;SACJ,CAAC,CAAA;IACN,CAAC;IAEM,KAAK,CAAC,WAAW,CAAC,OAAgC;QACrD,IAAI,CAAC;YACD,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE;gBAC1C,OAAO;gBACP,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,aAAa;aAC1F,CAAC,CAAA;QACN,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,aAAa,IAAI,GAAG,EAAE,CAAC;gBAC1E,MAAM,UAAU,GAAG,GAA4C,CAAA;gBAC/D,MAAM,IAAI,oBAAS,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;YAC7E,CAAC;YAED,MAAM,GAAG,CAAA;QACb,CAAC;IACL,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,UAAsB;QACtC,MAAM,cAAc,GAAG,UAAU,CAAC,MAAM,YAAY,kBAAkB,CAAA;QACtE,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QACtE,CAAC;QACD,OAAO,UAAU,CAAC,MAAM,CAAA;IAC5B,CAAC;CACJ;AA3CD,gDA2CC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BlipCollection = void 0;
|
|
4
|
-
class BlipCollection extends Array {
|
|
5
|
-
total;
|
|
6
|
-
type;
|
|
7
|
-
constructor(total, type, items) {
|
|
8
|
-
super(...items);
|
|
9
|
-
this.total = total;
|
|
10
|
-
this.type = type;
|
|
11
|
-
}
|
|
12
|
-
static is(collection) {
|
|
13
|
-
return collection instanceof BlipCollection;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.BlipCollection = BlipCollection;
|
|
17
|
-
//# sourceMappingURL=collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/utils/collection.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAkB,SAAQ,KAAQ;IAC3C,KAAK,CAAQ;IACb,IAAI,CAAQ;IAEZ,YAAY,KAAa,EAAE,IAAY,EAAE,KAAe;QACpD,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;IAEM,MAAM,CAAC,EAAE,CAAI,UAAoB;QACpC,OAAO,UAAU,YAAY,cAAc,CAAA;IAC/C,CAAC;CACJ;AAbD,wCAaC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Node } from '../types/index.js';
|
|
2
|
-
export class CustomGatewayHttpSender {
|
|
3
|
-
constructor(botIdentityOrIdentifier, password) {
|
|
4
|
-
const botIdentity = Node.isValid(botIdentityOrIdentifier)
|
|
5
|
-
? botIdentityOrIdentifier
|
|
6
|
-
: `${botIdentityOrIdentifier}@msging.net`;
|
|
7
|
-
this.token = btoa(`${botIdentity}:${password}`);
|
|
8
|
-
}
|
|
9
|
-
token;
|
|
10
|
-
async sendMessage(message) {
|
|
11
|
-
const response = await fetch('https://custom.gw.msging.net/messages', {
|
|
12
|
-
method: 'POST',
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
Authorization: `Basic ${this.token}`,
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify(message),
|
|
18
|
-
});
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
throw new Error(`Failed to send message: ${response.statusText}`);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
sendCommand() {
|
|
24
|
-
throw new Error('Custom gateway clients cannot send commands');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=customgateway.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customgateway.js","sourceRoot":"","sources":["../../../src/sender/customgateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,IAAI,EAAE,MAAM,mBAAmB,CAAA;AAGhF,MAAM,OAAO,uBAAuB;IAChC,YAAY,uBAA+B,EAAE,QAAgB;QACzD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAuB,CAAC;YACrD,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,GAAG,uBAAuB,aAAa,CAAA;QAC7C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,WAAW,IAAI,QAAQ,EAAE,CAAC,CAAA;IACnD,CAAC;IAEgB,KAAK,CAAQ;IAEvB,KAAK,CAAC,WAAW,CAAyC,OAAsB;QACnF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,uCAAuC,EAAE;YAClE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,SAAS,IAAI,CAAC,KAAK,EAAE;aACvC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;SAChC,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,2BAA2B,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAA;QACrE,CAAC;IACL,CAAC;IAED,WAAW;QACP,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;IAClE,CAAC;CACJ"}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { Node, } from '../types/index.js';
|
|
2
|
-
import { BlipError } from './bliperror.js';
|
|
3
|
-
export class HttpSender {
|
|
4
|
-
token;
|
|
5
|
-
baseurl;
|
|
6
|
-
constructor(token, tenantId) {
|
|
7
|
-
this.token = token.startsWith('Key ') ? token.slice(4) : token;
|
|
8
|
-
const prefix = tenantId ? `${tenantId}.` : '';
|
|
9
|
-
this.baseurl = `https://${prefix}http.msging.net`;
|
|
10
|
-
}
|
|
11
|
-
async sendMessage(message) {
|
|
12
|
-
await this.throttle('message');
|
|
13
|
-
const response = await fetch(`${this.baseurl}/messages`, {
|
|
14
|
-
method: 'POST',
|
|
15
|
-
headers: {
|
|
16
|
-
'Content-Type': 'application/json',
|
|
17
|
-
Authorization: `Key ${this.token}`,
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(message),
|
|
20
|
-
});
|
|
21
|
-
if (!response.ok) {
|
|
22
|
-
throw new Error(`Failed to send message: ${response.statusText}`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
async sendCommand(command) {
|
|
26
|
-
await this.throttle('command');
|
|
27
|
-
const response = await fetch(`${this.baseurl}/commands`, {
|
|
28
|
-
method: 'POST',
|
|
29
|
-
headers: {
|
|
30
|
-
'Content-Type': 'application/json',
|
|
31
|
-
Authorization: `Key ${this.token}`,
|
|
32
|
-
},
|
|
33
|
-
body: JSON.stringify(command),
|
|
34
|
-
});
|
|
35
|
-
if (!response.ok) {
|
|
36
|
-
throw new Error(`Failed to send command: ${response.statusText}`);
|
|
37
|
-
}
|
|
38
|
-
const result = await response.json();
|
|
39
|
-
if (result.status === 'failure') {
|
|
40
|
-
throw new BlipError(command.uri, result.reason.code, result.reason.description);
|
|
41
|
-
}
|
|
42
|
-
else if (result.status === 'success') {
|
|
43
|
-
return result.resource;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
throw new Error(`Unexpected response status: ${result.status}`);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
static login(botIdentityOrIdentifier, accessKey, tenantId) {
|
|
50
|
-
const botIdentity = Node.isValid(botIdentityOrIdentifier)
|
|
51
|
-
? botIdentityOrIdentifier
|
|
52
|
-
: `${botIdentityOrIdentifier}@msging.net`;
|
|
53
|
-
const token = btoa(`${botIdentity}:${atob(accessKey)}`);
|
|
54
|
-
return new HttpSender(token, tenantId);
|
|
55
|
-
}
|
|
56
|
-
sent = {
|
|
57
|
-
message: {
|
|
58
|
-
max: 50,
|
|
59
|
-
started: 0,
|
|
60
|
-
count: 0,
|
|
61
|
-
},
|
|
62
|
-
command: {
|
|
63
|
-
max: 200,
|
|
64
|
-
started: 0,
|
|
65
|
-
count: 0,
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
async throttle(type) {
|
|
69
|
-
const throughput = this.sent[type].max * 0.8;
|
|
70
|
-
const timeToReset = 2000;
|
|
71
|
-
while (true) {
|
|
72
|
-
const elapsed = Date.now() - this.sent[type].started;
|
|
73
|
-
if (elapsed >= timeToReset) {
|
|
74
|
-
this.sent[type].started = Date.now();
|
|
75
|
-
this.sent[type].count = 0;
|
|
76
|
-
}
|
|
77
|
-
if (this.sent[type].count < throughput) {
|
|
78
|
-
this.sent[type].count++;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
const wait = timeToReset - elapsed;
|
|
83
|
-
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
//# sourceMappingURL=httpsender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpsender.js","sourceRoot":"","sources":["../../../src/sender/httpsender.ts"],"names":[],"mappings":"AAAA,OAAO,EAOH,IAAI,GACP,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG1C,MAAM,OAAO,UAAU;IACF,KAAK,CAAQ;IACb,OAAO,CAAQ;IAEhC,YAAY,KAAa,EAAE,QAAiB;QACxC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;QAC9D,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,QAAQ,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;QAC7C,IAAI,CAAC,OAAO,GAAG,WAAW,MAAM,iBAAiB,CAAA;IACrD,CAAC;IAEM,KAAK,CAAC,WAAW,CAA4B,OAAsB;QACtE,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;QAC9B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,WAAW,EAAE;YACrD,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;gBAClC,aAAa,EAAE,OAAO,IAAI,CAAC,KAAK,EAAE;aACrC;YACD,IAAI,EAAE,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AM,CAAC;gBACJ,MAAM,IAAI,GAAG,WAAW,GAAG,OAAO,CAAA;gBAClC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;YAC7D,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { randomId } from '../../utils/random.js';
|
|
2
|
-
export const startChannel = () => {
|
|
3
|
-
const caller = window.name ?? randomId();
|
|
4
|
-
const waitingMessages = {};
|
|
5
|
-
const messageHandler = ({ data }) => {
|
|
6
|
-
const deferred = waitingMessages[data?.trackingProperties?.id];
|
|
7
|
-
if (deferred) {
|
|
8
|
-
if (data.message?.caller === caller) {
|
|
9
|
-
// This is a echo message, ignore it
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (data.error) {
|
|
13
|
-
deferred.reject(JSON.parse(data.error));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
deferred.resolve(data.response);
|
|
17
|
-
}
|
|
18
|
-
delete waitingMessages[data.trackingProperties.id];
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
window.addEventListener('message', messageHandler);
|
|
22
|
-
let isDestroyed = false;
|
|
23
|
-
return {
|
|
24
|
-
post: (action, content, options) => {
|
|
25
|
-
if (isDestroyed) {
|
|
26
|
-
throw new Error('Channel is destroyed');
|
|
27
|
-
}
|
|
28
|
-
const id = randomId();
|
|
29
|
-
let promise;
|
|
30
|
-
if (options?.fireAndForget) {
|
|
31
|
-
promise = Promise.resolve();
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const deferred = Promise.withResolvers();
|
|
35
|
-
waitingMessages[id] = { reject: deferred.reject, resolve: deferred.resolve };
|
|
36
|
-
promise = deferred.promise;
|
|
37
|
-
}
|
|
38
|
-
window.parent.postMessage({
|
|
39
|
-
message: {
|
|
40
|
-
action: `blipEvent:${action}`,
|
|
41
|
-
content,
|
|
42
|
-
caller,
|
|
43
|
-
},
|
|
44
|
-
trackingProperties: {
|
|
45
|
-
id,
|
|
46
|
-
},
|
|
47
|
-
}, '*');
|
|
48
|
-
return promise;
|
|
49
|
-
},
|
|
50
|
-
destroy: () => {
|
|
51
|
-
window.removeEventListener('message', messageHandler);
|
|
52
|
-
isDestroyed = true;
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
//# sourceMappingURL=communication.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication.js","sourceRoot":"","sources":["../../../../src/sender/portal/communication.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAEhD,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,IAAI,QAAQ,EAAE,CAAA;IAExC,MAAM,eAAe,GAA8E,EAAE,CAAA;IACrG,MAAM,cAAc,GAAG,CAAC,EAAE,IAAI,EAAgB,EAAE,EAAE;QAC9C,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,kBAAkB,EAAE,EAAE,CAAC,CAAA;QAC9D,IAAI,QAAQ,EAAE,CAAC;YACX,IAAI,IAAI,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,EAAE,CAAC;gBAClC,oCAAoC;gBACpC,OAAM;YACV,CAAC;YAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;YAC3C,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACnC,CAAC;YAED,OAAO,eAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAA;QACtD,CAAC;IACL,CAAC,CAAA;IACD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IAElD,IAAI,WAAW,GAAG,KAAK,CAAA;IACvB,OAAO;QACH,IAAI,EAAE,CAAI,MAAc,EAAE,OAAgB,EAAE,OAAoC,EAAE,EAAE;YAChF,IAAI,WAAW,EAAE,CAAC;gBACd,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;YAC3C,CAAC;YAED,MAAM,EAAE,GAAG,QAAQ,EAAE,CAAA;YAErB,IAAI,OAAyB,CAAA;YAC7B,IAAI,OAAO,EAAE,aAAa,EAAE,CAAC;gBACzB,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAA;YAC/B,CAAC;iBAAM,CAAC;gBACJ,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE,CAAA;gBACxC,eAAe,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE,CAAA;gBAC5E,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;YAC9B,CAAC;YAED,MAAM,CAAC,MAAM,CAAC,WAAW,CACrB;gBACI,OAAO,EAAE;oBACL,MAAM,EAAE,aAAa,MAAM,EAAE;oBAC7B,OAAO;oBACP,MAAM;iBACT;gBACD,kBAAkB,EAAE;oBAChB,EAAE;iBACL;aACJ,EACD,GAAG,CACN,CAAA;YAED,OAAO,OAAqB,CAAA;QAChC,CAAC;QACD,OAAO,EAAE,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;YACrD,WAAW,GAAG,IAAI,CAAA;QACtB,CAAC;KACJ,CAAA;AACL,CAAC,CAAA"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { BlipError, } from '../../index.js';
|
|
2
|
-
import { startChannel } from './communication.js';
|
|
3
|
-
export class PortalPluginSender {
|
|
4
|
-
channel;
|
|
5
|
-
constructor() {
|
|
6
|
-
this.channel = startChannel();
|
|
7
|
-
}
|
|
8
|
-
async sendMessage(message) {
|
|
9
|
-
await this.sendCommand({
|
|
10
|
-
id: message.id,
|
|
11
|
-
uri: '/schedules',
|
|
12
|
-
method: 'set',
|
|
13
|
-
type: 'application/vnd.iris.schedule+json',
|
|
14
|
-
resource: {
|
|
15
|
-
message,
|
|
16
|
-
when: new Date().toISOString(),
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async sendCommand(command) {
|
|
21
|
-
try {
|
|
22
|
-
return await this.channel.post('sendCommand', {
|
|
23
|
-
command,
|
|
24
|
-
destination: command.to?.includes('msging.net') ? 'MessagingHubService' : 'BlipService',
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
if (err && typeof err === 'object' && 'code' in err && 'description' in err) {
|
|
29
|
-
const knownerror = err;
|
|
30
|
-
throw new BlipError(command.uri, knownerror.code, knownerror.description);
|
|
31
|
-
}
|
|
32
|
-
throw err;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
static check(blipClient) {
|
|
36
|
-
const isPluginSender = blipClient.sender instanceof PortalPluginSender;
|
|
37
|
-
if (!isPluginSender) {
|
|
38
|
-
throw new Error('This command is only allowed for plugin senders');
|
|
39
|
-
}
|
|
40
|
-
return blipClient.sender;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=pluginsender.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pluginsender.js","sourceRoot":"","sources":["../../../../src/sender/portal/pluginsender.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,SAAS,GAMZ,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEjD,MAAM,OAAO,kBAAkB;IACX,OAAO,CAAA;IAEvB;QACI,IAAI,CAAC,OAAO,GAAG,YAAY,EAAE,CAAA;IACjC,C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export class BlipCollection extends Array {
|
|
2
|
-
total;
|
|
3
|
-
type;
|
|
4
|
-
constructor(total, type, items) {
|
|
5
|
-
super(...items);
|
|
6
|
-
this.total = total;
|
|
7
|
-
this.type = type;
|
|
8
|
-
}
|
|
9
|
-
static is(collection) {
|
|
10
|
-
return collection instanceof BlipCollection;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../src/utils/collection.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,cAAkB,SAAQ,KAAQ;IAC3C,KAAK,CAAQ;IACb,IAAI,CAAQ;IAEZ,YAAY,KAAa,EAAE,IAAY,EAAE,KAAe;QACpD,KAAK,CAAC,GAAG,KAAK,CAAC,CAAA;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;IAEM,MAAM,CAAC,EAAE,CAAI,UAAoB;QACpC,OAAO,UAAU,YAAY,cAAc,CAAA;IAC/C,CAAC;CACJ"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type Message, type MessageTypesContent } from '../types/index.js';
|
|
2
|
-
import type { Sender } from './sender.js';
|
|
3
|
-
export declare class CustomGatewayHttpSender implements Sender {
|
|
4
|
-
constructor(botIdentityOrIdentifier: string, password: string);
|
|
5
|
-
private readonly token;
|
|
6
|
-
sendMessage<Type extends keyof MessageTypesContent>(message: Message<Type>): Promise<void>;
|
|
7
|
-
sendCommand(): Promise<unknown>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=customgateway.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"customgateway.d.ts","sourceRoot":"","sources":["../../../src/sender/customgateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,mBAAmB,EAAQ,MAAM,mBAAmB,CAAA;AAChF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,qBAAa,uBAAwB,YAAW,MAAM;gBACtC,uBAAuB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAO7D,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAEjB,WAAW,CAAC,IAAI,SAAS,MAAM,mBAAmB,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAevG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;CAGlC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type Command, type CommandMethods, type Identity, type Message, type MessageTypes } from '../types/index.js';
|
|
2
|
-
import type { Sender } from './sender.js';
|
|
3
|
-
export declare class HttpSender implements Sender {
|
|
4
|
-
private readonly token;
|
|
5
|
-
private readonly baseurl;
|
|
6
|
-
constructor(token: string, tenantId?: string);
|
|
7
|
-
sendMessage<Type extends MessageTypes>(message: Message<Type>): Promise<void>;
|
|
8
|
-
sendCommand(command: Command<CommandMethods>): Promise<unknown>;
|
|
9
|
-
static login(botIdentityOrIdentifier: string | Identity, accessKey: string, tenantId: string): HttpSender;
|
|
10
|
-
private sent;
|
|
11
|
-
private throttle;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=httpsender.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"httpsender.d.ts","sourceRoot":"","sources":["../../../src/sender/httpsender.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,cAAc,EAEnB,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,YAAY,EAEpB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEzC,qBAAa,UAAW,YAAW,MAAM;IACrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAQ;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAQ;gBAEpB,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;IAM/B,WAAW,CAAC,IAAI,SAAS,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB7E,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;WAyB9D,KAAK,CAAC,uBAAuB,EAAE,MAAM,GAAG,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU;IAQhH,OAAO,CAAC,IAAI,CAWX;YACa,QAAQ;CAqBzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication.d.ts","sourceRoot":"","sources":["../../../../src/sender/portal/communication.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY;WAyBV,CAAC,UAAU,MAAM,WAAW,OAAO,YAAY;QAAE,aAAa,EAAE,OAAO,CAAA;KAAE,KA8B1D,OAAO,CAAC,CAAC,CAAC;;CAOvC,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { type BlipClient, type Command, type CommandMethods, type Message, type MessageTypes, type Sender } from '../../index.js';
|
|
2
|
-
export declare class PortalPluginSender implements Sender {
|
|
3
|
-
readonly channel: {
|
|
4
|
-
post: <T>(action: string, content: unknown, options?: {
|
|
5
|
-
fireAndForget: boolean;
|
|
6
|
-
}) => Promise<T>;
|
|
7
|
-
destroy: () => void;
|
|
8
|
-
};
|
|
9
|
-
constructor();
|
|
10
|
-
sendMessage<Type extends MessageTypes>(message: Message<Type>): Promise<void>;
|
|
11
|
-
sendCommand(command: Command<CommandMethods>): Promise<unknown>;
|
|
12
|
-
static check(blipClient: BlipClient): PortalPluginSender;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=pluginsender.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pluginsender.d.ts","sourceRoot":"","sources":["../../../../src/sender/portal/pluginsender.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,KAAK,UAAU,EAEf,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,MAAM,EACd,MAAM,gBAAgB,CAAA;AAGvB,qBAAa,kBAAmB,YAAW,MAAM;IAC7C,SAAgB,OAAO;;;;;MAAA;;IAMV,WAAW,CAAC,IAAI,SAAS,YAAY,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC;IAa7D,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;WAgB9D,KAAK,CAAC,UAAU,EAAE,UAAU,GAAG,kBAAkB;CAOlE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare class BlipCollection<T> extends Array<T> {
|
|
2
|
-
total: number;
|
|
3
|
-
type: string;
|
|
4
|
-
constructor(total: number, type: string, items: Array<T>);
|
|
5
|
-
static is<T>(collection: Array<T>): collection is BlipCollection<T>;
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../../src/utils/collection.ts"],"names":[],"mappings":"AAAA,qBAAa,cAAc,CAAC,CAAC,CAAE,SAAQ,KAAK,CAAC,CAAC,CAAC;IAC3C,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;gBAEA,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;WAM1C,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,UAAU,IAAI,cAAc,CAAC,CAAC,CAAC;CAG7E"}
|