@open-wa/wa-automate 4.23.13 → 4.23.14
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.
@@ -97,6 +97,10 @@ export declare enum STATE {
|
|
97
97
|
*/
|
98
98
|
DISCONNECTED = "DISCONNECTED"
|
99
99
|
}
|
100
|
+
export declare type EasyApiResponse = {
|
101
|
+
success: boolean;
|
102
|
+
response: any;
|
103
|
+
};
|
100
104
|
export * from './config';
|
101
105
|
export * from './media';
|
102
106
|
export * from './aliases';
|
package/dist/api/model/index.js
CHANGED
@@ -115,7 +115,6 @@ var STATE;
|
|
115
115
|
*/
|
116
116
|
STATE["DISCONNECTED"] = "DISCONNECTED";
|
117
117
|
})(STATE = exports.STATE || (exports.STATE = {}));
|
118
|
-
;
|
119
118
|
__exportStar(require("./config"), exports);
|
120
119
|
__exportStar(require("./media"), exports);
|
121
120
|
__exportStar(require("./aliases"), exports);
|
package/dist/cli/collections.js
CHANGED
@@ -1,4 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
+
}) : (function(o, m, k, k2) {
|
6
|
+
if (k2 === undefined) k2 = k;
|
7
|
+
o[k2] = m[k];
|
8
|
+
}));
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
+
}) : function(o, v) {
|
12
|
+
o["default"] = v;
|
13
|
+
});
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
+
if (mod && mod.__esModule) return mod;
|
16
|
+
var result = {};
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
+
__setModuleDefault(result, mod);
|
19
|
+
return result;
|
20
|
+
};
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -12,14 +31,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
32
|
};
|
14
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
-
exports.generateCollections = exports.collections = void 0;
|
34
|
+
exports.getTypeSchemas = exports.generateCollections = exports.collections = void 0;
|
16
35
|
const __1 = require("..");
|
17
36
|
const postman_2_swagger_1 = __importDefault(require("postman-2-swagger"));
|
18
37
|
const fs_extra_1 = require("fs-extra");
|
38
|
+
const typeconv_1 = require("typeconv");
|
39
|
+
const fs = __importStar(require("fs"));
|
40
|
+
const glob_promise_1 = __importDefault(require("glob-promise"));
|
19
41
|
exports.collections = {};
|
20
42
|
const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void 0, function* () {
|
21
43
|
let swCol = null;
|
22
44
|
let pmCol = null;
|
45
|
+
const _types = yield exports.getTypeSchemas();
|
23
46
|
spinner.info('Generating Swagger Spec');
|
24
47
|
pmCol = yield __1.generatePostmanJson(config);
|
25
48
|
spinner.succeed(`Postman collection generated: open-wa-${config.sessionId}.postman_collection.json`);
|
@@ -40,6 +63,9 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
40
63
|
"description": "Documentation",
|
41
64
|
"url": swCol.paths[p].post.documentationUrl
|
42
65
|
};
|
66
|
+
swCol.paths[p].post.responses['200'].schema = {
|
67
|
+
"$ref": "#/components/schemas/EasyApiResponse"
|
68
|
+
};
|
43
69
|
swCol.paths[p].post.requestBody = {
|
44
70
|
"description": path.summary,
|
45
71
|
"content": {
|
@@ -55,20 +81,20 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
55
81
|
});
|
56
82
|
delete swCol.swagger;
|
57
83
|
swCol.openapi = "3.0.3";
|
84
|
+
swCol.components = {};
|
85
|
+
swCol.components.schemas = _types;
|
58
86
|
swCol.externalDocs = {
|
59
87
|
"description": "Find more info here",
|
60
88
|
"url": "https://openwa.dev/"
|
61
89
|
};
|
62
90
|
if (config.key) {
|
63
|
-
swCol.components = {
|
64
|
-
"securitySchemes": {
|
91
|
+
swCol.components = Object.assign(Object.assign({}, swCol.components), { "securitySchemes": {
|
65
92
|
"api_key": {
|
66
93
|
"type": "apiKey",
|
67
94
|
"name": "api_key",
|
68
95
|
"in": "header"
|
69
96
|
}
|
70
|
-
}
|
71
|
-
};
|
97
|
+
} });
|
72
98
|
swCol.security = [
|
73
99
|
{
|
74
100
|
"api_key": []
|
@@ -86,3 +112,22 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
86
112
|
return;
|
87
113
|
});
|
88
114
|
exports.generateCollections = generateCollections;
|
115
|
+
const getTypeSchemas = () => __awaiter(void 0, void 0, void 0, function* () {
|
116
|
+
const reader = typeconv_1.getTypeScriptReader();
|
117
|
+
const writer = typeconv_1.getOpenApiWriter({ format: 'json', title: 'My API', version: 'v3.0.3' });
|
118
|
+
const { convert } = typeconv_1.makeConverter(reader, writer, {
|
119
|
+
simplify: true
|
120
|
+
});
|
121
|
+
const s = (yield Promise.all([...(yield glob_promise_1.default('../**/*.d.ts')), ...(yield glob_promise_1.default('../**/message.js')), ...(yield glob_promise_1.default('../**/chat.js'))])).filter(f => !f.includes('node_modules'));
|
122
|
+
const res = {};
|
123
|
+
yield Promise.all(s.map((x) => __awaiter(void 0, void 0, void 0, function* () {
|
124
|
+
var _a, _b;
|
125
|
+
const { data } = yield convert({ data: fs.readFileSync(x, 'utf8') });
|
126
|
+
const schemas = (_b = (_a = JSON.parse(data)) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.schemas;
|
127
|
+
Object.keys(schemas).forEach(k => {
|
128
|
+
res[k] = schemas[k];
|
129
|
+
});
|
130
|
+
})));
|
131
|
+
return res;
|
132
|
+
});
|
133
|
+
exports.getTypeSchemas = getTypeSchemas;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.23.
|
3
|
+
"version": "4.23.14",
|
4
4
|
"licenseCheckUrl": "https://openwa.dev/license-check",
|
5
5
|
"brokenMethodReportUrl": "https://openwa.dev/report-bm",
|
6
6
|
"patches": "https://cdn.openwa.dev/patches.json",
|
@@ -120,6 +120,7 @@
|
|
120
120
|
"find-up": "^5.0.0",
|
121
121
|
"fs-extra": "^10.0.0",
|
122
122
|
"get-port": "^5.1.1",
|
123
|
+
"glob-promise": "^4.2.2",
|
123
124
|
"hasha": "^5.2.0",
|
124
125
|
"image-type": "^4.1.0",
|
125
126
|
"is-url-superb": "^5.0.0",
|
@@ -157,6 +158,7 @@
|
|
157
158
|
"ts-json-schema-generator": "^0.95.0",
|
158
159
|
"ts-morph": "^12.0.0",
|
159
160
|
"type-fest": "^1.1.1",
|
161
|
+
"typeconv": "^1.7.0",
|
160
162
|
"update-notifier": "^5.0.0",
|
161
163
|
"uuid": "^8.3.2",
|
162
164
|
"uuid-apikey": "^1.4.6",
|