@whitewall/blip-sdk 0.0.9 → 0.0.10
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/client.js +40 -26
- package/dist/client.js.map +1 -1
- package/dist/index.js +33 -7
- package/dist/index.js.map +1 -1
- package/dist/namespaces/account.js +193 -179
- package/dist/namespaces/account.js.map +1 -1
- package/dist/namespaces/builder.d.ts +6 -3
- package/dist/namespaces/builder.js +33 -16
- package/dist/namespaces/builder.js.map +1 -1
- package/dist/namespaces/desk.js +113 -99
- package/dist/namespaces/desk.js.map +1 -1
- package/dist/namespaces/media.js +25 -11
- package/dist/namespaces/media.js.map +1 -1
- package/dist/namespaces/namespace.js +63 -49
- package/dist/namespaces/namespace.js.map +1 -1
- package/dist/namespaces/scheduler.js +47 -33
- package/dist/namespaces/scheduler.js.map +1 -1
- package/dist/namespaces/whatsapp.js +115 -101
- package/dist/namespaces/whatsapp.js.map +1 -1
- package/dist/sender/bliperror.js +22 -8
- package/dist/sender/bliperror.js.map +1 -1
- package/dist/sender/httpsender.js +58 -44
- package/dist/sender/httpsender.js.map +1 -1
- package/dist/sender/sender.js +12 -1
- package/dist/types/account.js +12 -1
- package/dist/types/command.js +12 -1
- package/dist/types/desk.js +23 -10
- package/dist/types/desk.js.map +1 -1
- package/dist/types/envelope.js +12 -1
- package/dist/types/index.js +32 -6
- package/dist/types/index.js.map +1 -1
- package/dist/types/message.js +21 -5
- package/dist/types/message.js.map +1 -1
- package/dist/types/node.js +37 -23
- package/dist/types/node.js.map +1 -1
- package/dist/utils/odata.js +87 -72
- package/dist/utils/odata.js.map +1 -1
- package/dist/utils/random.js +17 -3
- package/dist/utils/random.js.map +1 -1
- package/dist/utils/uri.js +49 -34
- package/dist/utils/uri.js.map +1 -1
- package/package.json +1 -2
|
@@ -1,109 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super(sender, 'postmaster@wa.gw.msging.net');
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
6
5
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../utils/uri.js", "./namespace.js"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.WhatsAppNamespace = void 0;
|
|
13
|
+
const uri_js_1 = require("../utils/uri.js");
|
|
14
|
+
const namespace_js_1 = require("./namespace.js");
|
|
15
|
+
class WhatsAppNamespace extends namespace_js_1.Namespace {
|
|
16
|
+
constructor(sender) {
|
|
17
|
+
super(sender, 'postmaster@wa.gw.msging.net');
|
|
18
|
+
}
|
|
19
|
+
async phoneToIdentity(phoneNumber) {
|
|
20
|
+
const fixedPhoneNumber = phoneNumber[0] !== '+' ? `+${phoneNumber}` : phoneNumber;
|
|
21
|
+
try {
|
|
22
|
+
const result = await this.sendCommand({
|
|
23
|
+
method: 'get',
|
|
24
|
+
uri: (0, uri_js_1.uri) `/accounts/${fixedPhoneNumber}`,
|
|
25
|
+
}, {
|
|
26
|
+
ownerIdentity: 'wa.gw.msging.net',
|
|
27
|
+
});
|
|
28
|
+
return result.alternativeAccount;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
return `${phoneNumber}@wa.gw.msging.net`;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async getMessageTemplates(opts) {
|
|
35
|
+
return this.sendCommand({
|
|
11
36
|
method: 'get',
|
|
12
|
-
uri: uri `/
|
|
37
|
+
uri: (0, uri_js_1.uri) `/message-templates`,
|
|
13
38
|
}, {
|
|
14
|
-
|
|
39
|
+
collection: true,
|
|
40
|
+
...opts,
|
|
15
41
|
});
|
|
16
|
-
return result.alternativeAccount;
|
|
17
42
|
}
|
|
18
|
-
|
|
19
|
-
return
|
|
43
|
+
async createFlow(name, category, opts) {
|
|
44
|
+
return this.sendCommand({
|
|
45
|
+
method: 'set',
|
|
46
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows`,
|
|
47
|
+
type: 'application/json',
|
|
48
|
+
resource: {
|
|
49
|
+
name,
|
|
50
|
+
categories: [category],
|
|
51
|
+
},
|
|
52
|
+
}, opts);
|
|
53
|
+
}
|
|
54
|
+
async updateFlowName(id, name, opts) {
|
|
55
|
+
return this.sendCommand({
|
|
56
|
+
method: 'set',
|
|
57
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/${id}`,
|
|
58
|
+
type: 'application/json',
|
|
59
|
+
resource: {
|
|
60
|
+
name,
|
|
61
|
+
},
|
|
62
|
+
}, opts);
|
|
63
|
+
}
|
|
64
|
+
async updateFlowJson(id, json, opts) {
|
|
65
|
+
return this.sendCommand({
|
|
66
|
+
method: 'set',
|
|
67
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/flow-json/${id}`,
|
|
68
|
+
type: 'application/json',
|
|
69
|
+
resource: JSON.parse(json),
|
|
70
|
+
}, opts);
|
|
71
|
+
}
|
|
72
|
+
async updateFlowsPublicKey(publicKey, opts) {
|
|
73
|
+
return this.sendCommand({
|
|
74
|
+
method: 'set',
|
|
75
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/public-key/upload`,
|
|
76
|
+
type: 'application/json',
|
|
77
|
+
resource: {
|
|
78
|
+
business_public_key: publicKey,
|
|
79
|
+
},
|
|
80
|
+
}, opts);
|
|
81
|
+
}
|
|
82
|
+
async getFlows(opts) {
|
|
83
|
+
const { data } = await this.sendCommand({
|
|
84
|
+
method: 'get',
|
|
85
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows`,
|
|
86
|
+
}, opts);
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
async getFlow(id, opts) {
|
|
90
|
+
return this.sendCommand({
|
|
91
|
+
method: 'get',
|
|
92
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/${id}`,
|
|
93
|
+
}, opts);
|
|
94
|
+
}
|
|
95
|
+
async publishFlow(id, opts) {
|
|
96
|
+
return this.sendCommand({
|
|
97
|
+
method: 'get',
|
|
98
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/publish/${id}`,
|
|
99
|
+
}, opts);
|
|
100
|
+
}
|
|
101
|
+
async deprecateFlow(id, opts) {
|
|
102
|
+
return this.sendCommand({
|
|
103
|
+
method: 'get',
|
|
104
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/deprecate/${id}`,
|
|
105
|
+
}, opts);
|
|
106
|
+
}
|
|
107
|
+
async getFlowAssets(id, opts) {
|
|
108
|
+
const { data } = await this.sendCommand({
|
|
109
|
+
method: 'get',
|
|
110
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/assets/${id}`,
|
|
111
|
+
}, opts);
|
|
112
|
+
return data;
|
|
113
|
+
}
|
|
114
|
+
async deleteFlow(id, opts) {
|
|
115
|
+
return this.sendCommand({
|
|
116
|
+
method: 'delete',
|
|
117
|
+
uri: (0, uri_js_1.uri) `/whatsapp-flows/${id}`,
|
|
118
|
+
}, opts);
|
|
20
119
|
}
|
|
21
120
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
method: 'get',
|
|
25
|
-
uri: uri `/message-templates`,
|
|
26
|
-
}, {
|
|
27
|
-
collection: true,
|
|
28
|
-
...opts,
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
async createFlow(name, category, opts) {
|
|
32
|
-
return this.sendCommand({
|
|
33
|
-
method: 'set',
|
|
34
|
-
uri: uri `/whatsapp-flows`,
|
|
35
|
-
type: 'application/json',
|
|
36
|
-
resource: {
|
|
37
|
-
name,
|
|
38
|
-
categories: [category],
|
|
39
|
-
},
|
|
40
|
-
}, opts);
|
|
41
|
-
}
|
|
42
|
-
async updateFlowName(id, name, opts) {
|
|
43
|
-
return this.sendCommand({
|
|
44
|
-
method: 'set',
|
|
45
|
-
uri: uri `/whatsapp-flows/${id}`,
|
|
46
|
-
type: 'application/json',
|
|
47
|
-
resource: {
|
|
48
|
-
name,
|
|
49
|
-
},
|
|
50
|
-
}, opts);
|
|
51
|
-
}
|
|
52
|
-
async updateFlowJson(id, json, opts) {
|
|
53
|
-
return this.sendCommand({
|
|
54
|
-
method: 'set',
|
|
55
|
-
uri: uri `/whatsapp-flows/flow-json/${id}`,
|
|
56
|
-
type: 'application/json',
|
|
57
|
-
resource: JSON.parse(json),
|
|
58
|
-
}, opts);
|
|
59
|
-
}
|
|
60
|
-
async updateFlowsPublicKey(publicKey, opts) {
|
|
61
|
-
return this.sendCommand({
|
|
62
|
-
method: 'set',
|
|
63
|
-
uri: uri `/whatsapp-flows/public-key/upload`,
|
|
64
|
-
type: 'application/json',
|
|
65
|
-
resource: {
|
|
66
|
-
business_public_key: publicKey,
|
|
67
|
-
},
|
|
68
|
-
}, opts);
|
|
69
|
-
}
|
|
70
|
-
async getFlows(opts) {
|
|
71
|
-
const { data } = await this.sendCommand({
|
|
72
|
-
method: 'get',
|
|
73
|
-
uri: uri `/whatsapp-flows`,
|
|
74
|
-
}, opts);
|
|
75
|
-
return data;
|
|
76
|
-
}
|
|
77
|
-
async getFlow(id, opts) {
|
|
78
|
-
return this.sendCommand({
|
|
79
|
-
method: 'get',
|
|
80
|
-
uri: uri `/whatsapp-flows/${id}`,
|
|
81
|
-
}, opts);
|
|
82
|
-
}
|
|
83
|
-
async publishFlow(id, opts) {
|
|
84
|
-
return this.sendCommand({
|
|
85
|
-
method: 'get',
|
|
86
|
-
uri: uri `/whatsapp-flows/publish/${id}`,
|
|
87
|
-
}, opts);
|
|
88
|
-
}
|
|
89
|
-
async deprecateFlow(id, opts) {
|
|
90
|
-
return this.sendCommand({
|
|
91
|
-
method: 'get',
|
|
92
|
-
uri: uri `/whatsapp-flows/deprecate/${id}`,
|
|
93
|
-
}, opts);
|
|
94
|
-
}
|
|
95
|
-
async getFlowAssets(id, opts) {
|
|
96
|
-
const { data } = await this.sendCommand({
|
|
97
|
-
method: 'get',
|
|
98
|
-
uri: uri `/whatsapp-flows/assets/${id}`,
|
|
99
|
-
}, opts);
|
|
100
|
-
return data;
|
|
101
|
-
}
|
|
102
|
-
async deleteFlow(id, opts) {
|
|
103
|
-
return this.sendCommand({
|
|
104
|
-
method: 'delete',
|
|
105
|
-
uri: uri `/whatsapp-flows/${id}`,
|
|
106
|
-
}, opts);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
121
|
+
exports.WhatsAppNamespace = WhatsAppNamespace;
|
|
122
|
+
});
|
|
109
123
|
//# sourceMappingURL=whatsapp.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whatsapp.js","sourceRoot":"","sources":["../../src/namespaces/whatsapp.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"whatsapp.js","sourceRoot":"","sources":["../../src/namespaces/whatsapp.ts"],"names":[],"mappings":";;;;;;;;;;;;IACA,4CAAqC;IACrC,iDAA0D;IAW1D,MAAa,iBAAkB,SAAQ,wBAAS;QAC5C,YAAY,MAAc;YACtB,KAAK,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAA;QAChD,CAAC;QAEM,KAAK,CAAC,eAAe,CAAC,WAAmB;YAC5C,MAAM,gBAAgB,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,WAAW,CAAA;YAEjF,IAAI,CAAC;gBACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAMjC;oBACI,MAAM,EAAE,KAAK;oBACb,GAAG,EAAE,IAAA,YAAG,EAAA,aAAa,gBAAgB,EAAE;iBAC1C,EACD;oBACI,aAAa,EAAE,kBAA8B;iBAChD,CACJ,CAAA;gBAED,OAAO,MAAM,CAAC,kBAA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AAI,CAAC,WAAW,CACnC;gBACI,MAAM,EAAE,KAAK;gBACb,GAAG,EAAE,IAAA,YAAG,EAAA,0BAA0B,EAAE,EAAE;aACzC,EACD,IAAI,CACP,CAAA;YACD,OAAO,IAAI,CAAA;QACf,CAAC;QAEM,KAAK,CAAC,UAAU,CAAC,EAAU,EAAE,IAAqB;YACrD,OAAO,IAAI,CAAC,WAAW,CACnB;gBACI,MAAM,EAAE,QAAQ;gBAChB,GAAG,EAAE,IAAA,YAAG,EAAA,mBAAmB,EAAE,EAAE;aAClC,EACD,IAAI,CACP,CAAA;QACL,CAAC;KACJ;IAzKD,8CAyKC"}
|
package/dist/sender/bliperror.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
super(`Blip command for ${uri} failed: ${description}`);
|
|
6
|
-
this.uri = uri;
|
|
7
|
-
this.code = code;
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
8
5
|
}
|
|
9
|
-
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BlipError = void 0;
|
|
13
|
+
class BlipError extends Error {
|
|
14
|
+
uri;
|
|
15
|
+
code;
|
|
16
|
+
constructor(uri, code, description) {
|
|
17
|
+
super(`Blip command for ${uri} failed: ${description}`);
|
|
18
|
+
this.uri = uri;
|
|
19
|
+
this.code = code;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.BlipError = BlipError;
|
|
23
|
+
});
|
|
10
24
|
//# sourceMappingURL=bliperror.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bliperror.js","sourceRoot":"","sources":["../../src/sender/bliperror.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bliperror.js","sourceRoot":"","sources":["../../src/sender/bliperror.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,MAAa,SAAU,SAAQ,KAAK;QACJ;QAA6B;QAAzD,YAA4B,GAAW,EAAkB,IAAY,EAAE,WAAmB;YACtF,KAAK,CAAC,oBAAoB,GAAG,YAAY,WAAW,EAAE,CAAC,CAAA;YAD/B,QAAG,GAAH,GAAG,CAAQ;YAAkB,SAAI,GAAJ,IAAI,CAAQ;QAErE,CAAC;KACJ;IAJD,8BAIC"}
|
|
@@ -1,52 +1,66 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
tenantId;
|
|
6
|
-
constructor(token, tenantId) {
|
|
7
|
-
this.token = token;
|
|
8
|
-
this.tenantId = tenantId;
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
method: 'POST',
|
|
13
|
-
headers: {
|
|
14
|
-
'Content-Type': 'application/json',
|
|
15
|
-
'Authorization': `Key ${this.token}`,
|
|
16
|
-
},
|
|
17
|
-
body: JSON.stringify(message),
|
|
18
|
-
});
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
throw new Error('Failed to send message: ' + response.statusText);
|
|
21
|
-
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./bliperror.js", "../types/index.js"], factory);
|
|
22
8
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.HttpSender = void 0;
|
|
13
|
+
const bliperror_js_1 = require("./bliperror.js");
|
|
14
|
+
const index_js_1 = require("../types/index.js");
|
|
15
|
+
class HttpSender {
|
|
16
|
+
token;
|
|
17
|
+
tenantId;
|
|
18
|
+
constructor(token, tenantId) {
|
|
19
|
+
this.token = token;
|
|
20
|
+
this.tenantId = tenantId;
|
|
34
21
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
async sendMessage(message) {
|
|
23
|
+
const response = await fetch(`https://${this.tenantId}.http.msging.net/messages`, {
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: {
|
|
26
|
+
'Content-Type': 'application/json',
|
|
27
|
+
'Authorization': `Key ${this.token}`,
|
|
28
|
+
},
|
|
29
|
+
body: JSON.stringify(message),
|
|
30
|
+
});
|
|
31
|
+
if (!response.ok) {
|
|
32
|
+
throw new Error('Failed to send message: ' + response.statusText);
|
|
33
|
+
}
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
async sendCommand(command) {
|
|
36
|
+
const response = await fetch(`https://${this.tenantId}.http.msging.net/commands`, {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
headers: {
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
'Authorization': `Key ${this.token}`,
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify(command),
|
|
43
|
+
});
|
|
44
|
+
if (!response.ok) {
|
|
45
|
+
throw new Error('Failed to send command: ' + response.statusText);
|
|
46
|
+
}
|
|
47
|
+
const result = await response.json();
|
|
48
|
+
if (result.status === 'failure') {
|
|
49
|
+
throw new bliperror_js_1.BlipError(command.uri, result.reason.code, result.reason.description);
|
|
50
|
+
}
|
|
51
|
+
else if (result.status === 'success') {
|
|
52
|
+
return result.resource;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
throw new Error('Unexpected response status: ' + result.status);
|
|
56
|
+
}
|
|
41
57
|
}
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
static login(botIdentityOrIdentifier, accessKey, tenantId) {
|
|
59
|
+
const botIdentity = index_js_1.Node.isValid(botIdentityOrIdentifier) ? botIdentityOrIdentifier : botIdentityOrIdentifier + '@msging.net';
|
|
60
|
+
const token = btoa(botIdentity + ':' + atob(accessKey));
|
|
61
|
+
return new HttpSender(token, tenantId);
|
|
44
62
|
}
|
|
45
63
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const token = btoa(botIdentity + ':' + atob(accessKey));
|
|
49
|
-
return new HttpSender(token, tenantId);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
64
|
+
exports.HttpSender = HttpSender;
|
|
65
|
+
});
|
|
52
66
|
//# sourceMappingURL=httpsender.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpsender.js","sourceRoot":"","sources":["../../src/sender/httpsender.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"httpsender.js","sourceRoot":"","sources":["../../src/sender/httpsender.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,iDAA0C;IAE1C,gDAAmH;IAEnH,MAAa,UAAU;QAEE;QACA;QAFrB,YACqB,KAAa,EACb,QAAgB;YADhB,UAAK,GAAL,KAAK,CAAQ;YACb,aAAQ,GAAR,QAAQ,CAAQ;QAClC,CAAC;QAEG,KAAK,CAAC,WAAW,CAA4B,OAAsB;YACtE,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,IAAI,CAAC,QAAQ,2BAA2B,EAAE;gBAC9E,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACL,cAAc,EAAE,kBAAkB;oBAClC,eAAe,EAAE,OAAO,IAAI,CAAC,KAAK,EAAE;iBACvC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;aAChC,CAAC,CAAA;YAEF,IAAI,CAAC,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AAC,CAAC,uBAAuB,GAAG,aAAa,CAAA;YAC7H,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,GAAG,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAA;YACvD,OAAO,IAAI,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;QAC1C,CAAC;KACJ;IAlDD,gCAkDC"}
|
package/dist/sender/sender.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
2
13
|
//# sourceMappingURL=sender.js.map
|
package/dist/types/account.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
2
13
|
//# sourceMappingURL=account.js.map
|
package/dist/types/command.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
2
13
|
//# sourceMappingURL=command.js.map
|
package/dist/types/desk.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
(
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DayOfWeek = void 0;
|
|
13
|
+
var DayOfWeek;
|
|
14
|
+
(function (DayOfWeek) {
|
|
15
|
+
DayOfWeek["Sunday"] = "Sunday";
|
|
16
|
+
DayOfWeek["Monday"] = "Monday";
|
|
17
|
+
DayOfWeek["Tuesday"] = "Tuesday";
|
|
18
|
+
DayOfWeek["Wednesday"] = "Wednesday";
|
|
19
|
+
DayOfWeek["Thursday"] = "Thursday";
|
|
20
|
+
DayOfWeek["Friday"] = "Friday";
|
|
21
|
+
DayOfWeek["Saturday"] = "Saturday";
|
|
22
|
+
})(DayOfWeek || (exports.DayOfWeek = DayOfWeek = {}));
|
|
23
|
+
});
|
|
11
24
|
//# sourceMappingURL=desk.js.map
|
package/dist/types/desk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"desk.js","sourceRoot":"","sources":["../../src/types/desk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"desk.js","sourceRoot":"","sources":["../../src/types/desk.ts"],"names":[],"mappings":";;;;;;;;;;;;IAeA,IAAY,SAQX;IARD,WAAY,SAAS;QACjB,8BAAiB,CAAA;QACjB,8BAAiB,CAAA;QACjB,gCAAmB,CAAA;QACnB,oCAAuB,CAAA;QACvB,kCAAqB,CAAA;QACrB,8BAAiB,CAAA;QACjB,kCAAqB,CAAA;IACzB,CAAC,EARW,SAAS,yBAAT,SAAS,QAQpB"}
|
package/dist/types/envelope.js
CHANGED
|
@@ -1,2 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
});
|
|
2
13
|
//# sourceMappingURL=envelope.js.map
|
package/dist/types/index.js
CHANGED
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2
|
+
if (k2 === undefined) k2 = k;
|
|
3
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
6
|
+
}
|
|
7
|
+
Object.defineProperty(o, k2, desc);
|
|
8
|
+
}) : (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
o[k2] = m[k];
|
|
11
|
+
}));
|
|
12
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
|
+
};
|
|
15
|
+
(function (factory) {
|
|
16
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
17
|
+
var v = factory(require, exports);
|
|
18
|
+
if (v !== undefined) module.exports = v;
|
|
19
|
+
}
|
|
20
|
+
else if (typeof define === "function" && define.amd) {
|
|
21
|
+
define(["require", "exports", "./node.js", "./envelope.js", "./message.js", "./command.js", "./desk.js", "./account.js"], factory);
|
|
22
|
+
}
|
|
23
|
+
})(function (require, exports) {
|
|
24
|
+
"use strict";
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
__exportStar(require("./node.js"), exports);
|
|
27
|
+
__exportStar(require("./envelope.js"), exports);
|
|
28
|
+
__exportStar(require("./message.js"), exports);
|
|
29
|
+
__exportStar(require("./command.js"), exports);
|
|
30
|
+
__exportStar(require("./desk.js"), exports);
|
|
31
|
+
__exportStar(require("./account.js"), exports);
|
|
32
|
+
});
|
|
7
33
|
//# sourceMappingURL=index.js.map
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;IAAA,4CAAyB;IACzB,gDAA6B;IAC7B,+CAA4B;IAC5B,+CAA4B;IAC5B,4CAAyB;IACzB,+CAA4B"}
|
package/dist/types/message.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.messageToDocument = exports.isDocumentOfType = exports.isMessageOfType = void 0;
|
|
13
|
+
const isMessageOfType = (message, type) => message.type === type;
|
|
14
|
+
exports.isMessageOfType = isMessageOfType;
|
|
15
|
+
const isDocumentOfType = (document, type) => document.type === type;
|
|
16
|
+
exports.isDocumentOfType = isDocumentOfType;
|
|
17
|
+
const messageToDocument = (message) => ({
|
|
18
|
+
type: message.type,
|
|
19
|
+
value: message.content,
|
|
20
|
+
});
|
|
21
|
+
exports.messageToDocument = messageToDocument;
|
|
6
22
|
});
|
|
7
23
|
//# sourceMappingURL=message.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/types/message.ts"],"names":[],"mappings":";;;;;;;;;;;;IAsFO,MAAM,eAAe,GAAG,CAA4B,OAAuB,EAAE,IAAU,EAA4B,EAAE,CACxH,OAAO,CAAC,IAAI,KAAK,IAAI,CAAA;IADZ,QAAA,eAAe,mBACH;IAElB,MAAM,gBAAgB,GAAG,CAA4B,QAAyB,EAAE,IAAU,EAA8B,EAAE,CAC7H,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAA;IADb,QAAA,gBAAgB,oBACH;IAEnB,MAAM,iBAAiB,GAAG,CAA4B,OAAgD,EAAkB,EAAE,CAAC,CAAC;QAC/H,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,KAAK,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAA;IAHW,QAAA,iBAAiB,qBAG5B"}
|