@ones-open/cli 1.0.1-27659.1892 → 1.0.1-5596.1908
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/index.cjs +125 -59
- package/dist/index.js +126 -60
- package/dist/types/actions/install/index.d.ts.map +1 -1
- package/dist/types/actions/tunnel/tunnel-client.d.ts +6 -3
- package/dist/types/actions/tunnel/tunnel-client.d.ts.map +1 -1
- package/dist/types/common/error/enums.d.ts +12 -11
- package/dist/types/common/error/enums.d.ts.map +1 -1
- package/dist/types/common/request/types.d.ts +7 -0
- package/dist/types/common/request/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -85,17 +85,18 @@ var ErrorCode = ((ErrorCode2) => {
|
|
|
85
85
|
ErrorCode2[ErrorCode2["UNKNOWN_ERROR"] = createOnesApp.ErrorCode.UNKNOWN_ERROR] = "UNKNOWN_ERROR";
|
|
86
86
|
ErrorCode2[ErrorCode2["COMMAND_ERROR"] = createOnesApp.ErrorCode.COMMAND_ERROR] = "COMMAND_ERROR";
|
|
87
87
|
ErrorCode2[ErrorCode2["TEMPLATE_NOT_FOUND"] = createOnesApp.ErrorCode.TEMPLATE_NOT_FOUND] = "TEMPLATE_NOT_FOUND";
|
|
88
|
-
ErrorCode2["
|
|
89
|
-
ErrorCode2["
|
|
90
|
-
ErrorCode2["
|
|
91
|
-
ErrorCode2["
|
|
92
|
-
ErrorCode2["
|
|
93
|
-
ErrorCode2["
|
|
94
|
-
ErrorCode2["
|
|
95
|
-
ErrorCode2["
|
|
96
|
-
ErrorCode2["
|
|
97
|
-
ErrorCode2["
|
|
98
|
-
ErrorCode2["
|
|
88
|
+
ErrorCode2[ErrorCode2["MISSING_PROJECT_PATH"] = createOnesApp.ErrorCode.MISSING_PROJECT_PATH] = "MISSING_PROJECT_PATH";
|
|
89
|
+
ErrorCode2["MISSING_BASE_URL"] = "E04";
|
|
90
|
+
ErrorCode2["MISSING_PORT"] = "E05";
|
|
91
|
+
ErrorCode2["INCORRECT_BASE_URL"] = "E06";
|
|
92
|
+
ErrorCode2["INCORRECT_PORT"] = "E07";
|
|
93
|
+
ErrorCode2["APP_PACKAGE_JSON_PARSE_ERROR"] = "E08";
|
|
94
|
+
ErrorCode2["APP_MANIFEST_JSON_PARSE_ERROR"] = "E09";
|
|
95
|
+
ErrorCode2["BUILD_SCRIPT_NOT_FOUND"] = "E10";
|
|
96
|
+
ErrorCode2["DEV_SCRIPT_NOT_FOUND"] = "E11";
|
|
97
|
+
ErrorCode2["STORE_PERMISSION"] = "E12";
|
|
98
|
+
ErrorCode2["HOSTED_TOKEN_REQUEST_FAILED"] = "E13";
|
|
99
|
+
ErrorCode2["HOSTED_TOKEN_EMPTY"] = "E14";
|
|
99
100
|
return ErrorCode2;
|
|
100
101
|
})(ErrorCode || {});
|
|
101
102
|
const getPublicPath = () => {
|
|
@@ -521,17 +522,17 @@ class TunnelClient {
|
|
|
521
522
|
return url.toString();
|
|
522
523
|
}
|
|
523
524
|
parseMessage(data) {
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
const message = JSON.parse(payload);
|
|
527
|
-
if (!message) {
|
|
528
|
-
return null;
|
|
529
|
-
}
|
|
530
|
-
return message;
|
|
531
|
-
} catch (error) {
|
|
532
|
-
console.error("Invalid tunnel message:", error);
|
|
525
|
+
const buffer = this.toBuffer(data);
|
|
526
|
+
if (!buffer) {
|
|
533
527
|
return null;
|
|
534
528
|
}
|
|
529
|
+
if (buffer.length >= 4) {
|
|
530
|
+
const binary = this.parseBinaryEnvelope(buffer);
|
|
531
|
+
if (binary) {
|
|
532
|
+
return binary;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
return this.parseJSONEnvelope(buffer.toString());
|
|
535
536
|
}
|
|
536
537
|
async handleMessage(message) {
|
|
537
538
|
const request = this.getRequestPayload(message);
|
|
@@ -539,7 +540,6 @@ class TunnelClient {
|
|
|
539
540
|
return;
|
|
540
541
|
}
|
|
541
542
|
if (request.path === ONES_CLI_MANIFEST_PATH) {
|
|
542
|
-
var _this$ws5;
|
|
543
543
|
const appManifest = getAppManifestJSON().app;
|
|
544
544
|
const baseURL = await buildTunnelUrl();
|
|
545
545
|
const reply = {
|
|
@@ -555,19 +555,17 @@ class TunnelClient {
|
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
557
|
};
|
|
558
|
-
|
|
558
|
+
this.sendBinaryEnvelope(reply);
|
|
559
559
|
return;
|
|
560
560
|
}
|
|
561
561
|
try {
|
|
562
|
-
var _this$ws6;
|
|
563
562
|
const response = await this.forwardRequest(request);
|
|
564
563
|
const reply = {
|
|
565
564
|
id: message.id,
|
|
566
565
|
payload: response
|
|
567
566
|
};
|
|
568
|
-
|
|
567
|
+
this.sendBinaryEnvelope(reply);
|
|
569
568
|
} catch (error) {
|
|
570
|
-
var _this$ws7;
|
|
571
569
|
const reply = {
|
|
572
570
|
id: message.id,
|
|
573
571
|
payload: {
|
|
@@ -578,7 +576,7 @@ class TunnelClient {
|
|
|
578
576
|
body: "agent request error"
|
|
579
577
|
}
|
|
580
578
|
};
|
|
581
|
-
|
|
579
|
+
this.sendBinaryEnvelope(reply);
|
|
582
580
|
}
|
|
583
581
|
}
|
|
584
582
|
getRequestPayload(message) {
|
|
@@ -596,40 +594,25 @@ class TunnelClient {
|
|
|
596
594
|
url.searchParams.set(key, value);
|
|
597
595
|
});
|
|
598
596
|
}
|
|
599
|
-
const headers = this.normalizeHeaders(payload.headers);
|
|
600
|
-
const body = this.normalizeBody(payload.body);
|
|
601
597
|
const response = await axios.request({
|
|
602
598
|
url: url.toString(),
|
|
603
599
|
method: payload.method,
|
|
604
|
-
headers,
|
|
605
|
-
data: body,
|
|
606
|
-
responseType: "
|
|
600
|
+
headers: payload.headers,
|
|
601
|
+
data: payload.body,
|
|
602
|
+
responseType: "arraybuffer",
|
|
607
603
|
validateStatus: () => true
|
|
608
604
|
});
|
|
605
|
+
const responseBytes = Buffer.from(response.data);
|
|
609
606
|
return {
|
|
610
607
|
status: response.status,
|
|
611
608
|
headers: this.collectHeaders(response.headers),
|
|
612
|
-
body:
|
|
609
|
+
body: responseBytes
|
|
613
610
|
};
|
|
614
611
|
}
|
|
615
|
-
normalizeHeaders(headers) {
|
|
616
|
-
if (!headers) {
|
|
617
|
-
return void 0;
|
|
618
|
-
}
|
|
619
|
-
const normalized = {};
|
|
620
|
-
Object.entries(headers).forEach((_ref2) => {
|
|
621
|
-
let [key, values] = _ref2;
|
|
622
|
-
if (!values || values.length === 0) {
|
|
623
|
-
return;
|
|
624
|
-
}
|
|
625
|
-
normalized[key] = values.join(",");
|
|
626
|
-
});
|
|
627
|
-
return normalized;
|
|
628
|
-
}
|
|
629
612
|
collectHeaders(headers) {
|
|
630
613
|
const collected = {};
|
|
631
|
-
Object.entries(headers).forEach((
|
|
632
|
-
let [key, value] =
|
|
614
|
+
Object.entries(headers).forEach((_ref2) => {
|
|
615
|
+
let [key, value] = _ref2;
|
|
633
616
|
if (Array.isArray(value)) {
|
|
634
617
|
collected[key] = value.map((item) => String(item));
|
|
635
618
|
return;
|
|
@@ -640,24 +623,87 @@ class TunnelClient {
|
|
|
640
623
|
});
|
|
641
624
|
return collected;
|
|
642
625
|
}
|
|
643
|
-
|
|
626
|
+
sendBinaryEnvelope(envelope) {
|
|
627
|
+
var _this$ws5;
|
|
628
|
+
const encoded = this.encodeBinaryEnvelope(envelope);
|
|
629
|
+
(_this$ws5 = this.ws) === null || _this$ws5 === void 0 || _this$ws5.send(encoded);
|
|
630
|
+
}
|
|
631
|
+
encodeBinaryEnvelope(envelope) {
|
|
632
|
+
var _envelope$payload;
|
|
633
|
+
const payload = (_envelope$payload = envelope.payload) !== null && _envelope$payload !== void 0 ? _envelope$payload : {};
|
|
634
|
+
const body = this.toBodyBuffer(payload.body);
|
|
635
|
+
const metaPayload = {
|
|
636
|
+
...payload
|
|
637
|
+
};
|
|
638
|
+
delete metaPayload.body;
|
|
639
|
+
const meta = Buffer.from(JSON.stringify({
|
|
640
|
+
id: envelope.id,
|
|
641
|
+
payload: metaPayload
|
|
642
|
+
}), "utf8");
|
|
643
|
+
const header = Buffer.allocUnsafe(4);
|
|
644
|
+
header.writeUInt32BE(meta.length, 0);
|
|
645
|
+
return Buffer.concat([header, meta, body]);
|
|
646
|
+
}
|
|
647
|
+
toBodyBuffer(body) {
|
|
644
648
|
if (body === void 0 || body === null) {
|
|
645
|
-
return
|
|
649
|
+
return Buffer.alloc(0);
|
|
646
650
|
}
|
|
647
|
-
if (
|
|
651
|
+
if (Buffer.isBuffer(body)) {
|
|
648
652
|
return body;
|
|
649
653
|
}
|
|
650
|
-
|
|
654
|
+
if (body instanceof ArrayBuffer) {
|
|
655
|
+
return Buffer.from(body);
|
|
656
|
+
}
|
|
657
|
+
if (ArrayBuffer.isView(body)) {
|
|
658
|
+
return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
659
|
+
}
|
|
660
|
+
if (typeof body === "string") {
|
|
661
|
+
return Buffer.from(body, "utf8");
|
|
662
|
+
}
|
|
663
|
+
return Buffer.from(JSON.stringify(body), "utf8");
|
|
651
664
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
665
|
+
parseBinaryEnvelope(buffer) {
|
|
666
|
+
const metaLength = buffer.readUInt32BE(0);
|
|
667
|
+
if (metaLength <= 0 || 4 + metaLength > buffer.length) {
|
|
668
|
+
return null;
|
|
655
669
|
}
|
|
670
|
+
const metaRaw = buffer.subarray(4, 4 + metaLength).toString("utf8");
|
|
656
671
|
try {
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
672
|
+
const envelope = JSON.parse(metaRaw);
|
|
673
|
+
if (!(envelope !== null && envelope !== void 0 && envelope.payload)) {
|
|
674
|
+
return envelope;
|
|
675
|
+
}
|
|
676
|
+
const body = buffer.subarray(4 + metaLength);
|
|
677
|
+
envelope.payload.body = body;
|
|
678
|
+
return envelope;
|
|
679
|
+
} catch (error) {
|
|
680
|
+
console.error("Invalid binary tunnel message:", error);
|
|
681
|
+
return null;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
parseJSONEnvelope(payload) {
|
|
685
|
+
try {
|
|
686
|
+
const message = JSON.parse(payload);
|
|
687
|
+
if (!message) {
|
|
688
|
+
return null;
|
|
689
|
+
}
|
|
690
|
+
return message;
|
|
691
|
+
} catch (error) {
|
|
692
|
+
console.error("Invalid tunnel message:", error);
|
|
693
|
+
return null;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
toBuffer(data) {
|
|
697
|
+
if (Buffer.isBuffer(data)) {
|
|
698
|
+
return data;
|
|
699
|
+
}
|
|
700
|
+
if (Array.isArray(data)) {
|
|
701
|
+
return Buffer.concat(data);
|
|
702
|
+
}
|
|
703
|
+
if (data instanceof ArrayBuffer) {
|
|
704
|
+
return Buffer.from(data);
|
|
660
705
|
}
|
|
706
|
+
return null;
|
|
661
707
|
}
|
|
662
708
|
}
|
|
663
709
|
const getPath = (path, map2) => {
|
|
@@ -959,7 +1005,7 @@ const login = async function() {
|
|
|
959
1005
|
const port = await getPort({
|
|
960
1006
|
port: config2.defaultPort.login
|
|
961
1007
|
});
|
|
962
|
-
const uuid$1 = uuid.
|
|
1008
|
+
const uuid$1 = uuid.v4();
|
|
963
1009
|
const search = new URLSearchParams();
|
|
964
1010
|
search.set("redirect_path", "/developer/cli");
|
|
965
1011
|
search.set("redirect_url", `http://localhost:${port}`);
|
|
@@ -1100,7 +1146,27 @@ const install = async function() {
|
|
|
1100
1146
|
await invokeTunnel(getConfig().defaultPort.tunnel);
|
|
1101
1147
|
const result = await invokeInstall();
|
|
1102
1148
|
if (result.code === "OK") {
|
|
1149
|
+
var _appList$data$0$insta, _appList$data;
|
|
1103
1150
|
console.log("App installed successfully!");
|
|
1151
|
+
const appID = getAppManifestJSON().app.id;
|
|
1152
|
+
const appList = await fetchAppList(appID);
|
|
1153
|
+
const installationID = (_appList$data$0$insta = (_appList$data = appList.data) === null || _appList$data === void 0 || (_appList$data = _appList$data[0]) === null || _appList$data === void 0 ? void 0 : _appList$data.installation_id) !== null && _appList$data$0$insta !== void 0 ? _appList$data$0$insta : "";
|
|
1154
|
+
if (installationID) {
|
|
1155
|
+
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
1156
|
+
const tokenInfo = await fetchTokenInfo();
|
|
1157
|
+
const orgUUID = (_tokenInfo$org$uuid = (_tokenInfo$org = tokenInfo.org) === null || _tokenInfo$org === void 0 ? void 0 : _tokenInfo$org.uuid) !== null && _tokenInfo$org$uuid !== void 0 ? _tokenInfo$org$uuid : "";
|
|
1158
|
+
const teamUUID = (_tokenInfo$teams$0$uu = (_tokenInfo$teams = tokenInfo.teams) === null || _tokenInfo$teams === void 0 || (_tokenInfo$teams = _tokenInfo$teams[0]) === null || _tokenInfo$teams === void 0 ? void 0 : _tokenInfo$teams.uuid) !== null && _tokenInfo$teams$0$uu !== void 0 ? _tokenInfo$teams$0$uu : "";
|
|
1159
|
+
const isOrgVisible = (_tokenInfo$org$visibi = (_tokenInfo$org2 = tokenInfo.org) === null || _tokenInfo$org2 === void 0 ? void 0 : _tokenInfo$org2.visibility) !== null && _tokenInfo$org$visibi !== void 0 ? _tokenInfo$org$visibi : false;
|
|
1160
|
+
const baseURL = await getBaseURL();
|
|
1161
|
+
if (isOrgVisible && orgUUID) {
|
|
1162
|
+
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
1163
|
+
console.log(`See App detail: ${url}`);
|
|
1164
|
+
}
|
|
1165
|
+
if (!isOrgVisible && teamUUID) {
|
|
1166
|
+
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
1167
|
+
console.log(`See App detail: ${url}`);
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1104
1170
|
} else {
|
|
1105
1171
|
console.error(result);
|
|
1106
1172
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import http from "node:http";
|
|
|
20
20
|
import ora from "ora";
|
|
21
21
|
import open from "open";
|
|
22
22
|
import getPort from "get-port";
|
|
23
|
-
import {
|
|
23
|
+
import { v4 } from "uuid";
|
|
24
24
|
const en = {
|
|
25
25
|
"desc.ones": "cli for ones",
|
|
26
26
|
"desc.build": "build the application",
|
|
@@ -82,17 +82,18 @@ var ErrorCode = ((ErrorCode2) => {
|
|
|
82
82
|
ErrorCode2[ErrorCode2["UNKNOWN_ERROR"] = ErrorCode$1.UNKNOWN_ERROR] = "UNKNOWN_ERROR";
|
|
83
83
|
ErrorCode2[ErrorCode2["COMMAND_ERROR"] = ErrorCode$1.COMMAND_ERROR] = "COMMAND_ERROR";
|
|
84
84
|
ErrorCode2[ErrorCode2["TEMPLATE_NOT_FOUND"] = ErrorCode$1.TEMPLATE_NOT_FOUND] = "TEMPLATE_NOT_FOUND";
|
|
85
|
-
ErrorCode2["
|
|
86
|
-
ErrorCode2["
|
|
87
|
-
ErrorCode2["
|
|
88
|
-
ErrorCode2["
|
|
89
|
-
ErrorCode2["
|
|
90
|
-
ErrorCode2["
|
|
91
|
-
ErrorCode2["
|
|
92
|
-
ErrorCode2["
|
|
93
|
-
ErrorCode2["
|
|
94
|
-
ErrorCode2["
|
|
95
|
-
ErrorCode2["
|
|
85
|
+
ErrorCode2[ErrorCode2["MISSING_PROJECT_PATH"] = ErrorCode$1.MISSING_PROJECT_PATH] = "MISSING_PROJECT_PATH";
|
|
86
|
+
ErrorCode2["MISSING_BASE_URL"] = "E04";
|
|
87
|
+
ErrorCode2["MISSING_PORT"] = "E05";
|
|
88
|
+
ErrorCode2["INCORRECT_BASE_URL"] = "E06";
|
|
89
|
+
ErrorCode2["INCORRECT_PORT"] = "E07";
|
|
90
|
+
ErrorCode2["APP_PACKAGE_JSON_PARSE_ERROR"] = "E08";
|
|
91
|
+
ErrorCode2["APP_MANIFEST_JSON_PARSE_ERROR"] = "E09";
|
|
92
|
+
ErrorCode2["BUILD_SCRIPT_NOT_FOUND"] = "E10";
|
|
93
|
+
ErrorCode2["DEV_SCRIPT_NOT_FOUND"] = "E11";
|
|
94
|
+
ErrorCode2["STORE_PERMISSION"] = "E12";
|
|
95
|
+
ErrorCode2["HOSTED_TOKEN_REQUEST_FAILED"] = "E13";
|
|
96
|
+
ErrorCode2["HOSTED_TOKEN_EMPTY"] = "E14";
|
|
96
97
|
return ErrorCode2;
|
|
97
98
|
})(ErrorCode || {});
|
|
98
99
|
const getPublicPath = () => {
|
|
@@ -518,17 +519,17 @@ class TunnelClient {
|
|
|
518
519
|
return url.toString();
|
|
519
520
|
}
|
|
520
521
|
parseMessage(data) {
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
const message = JSON.parse(payload);
|
|
524
|
-
if (!message) {
|
|
525
|
-
return null;
|
|
526
|
-
}
|
|
527
|
-
return message;
|
|
528
|
-
} catch (error) {
|
|
529
|
-
console.error("Invalid tunnel message:", error);
|
|
522
|
+
const buffer = this.toBuffer(data);
|
|
523
|
+
if (!buffer) {
|
|
530
524
|
return null;
|
|
531
525
|
}
|
|
526
|
+
if (buffer.length >= 4) {
|
|
527
|
+
const binary = this.parseBinaryEnvelope(buffer);
|
|
528
|
+
if (binary) {
|
|
529
|
+
return binary;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
return this.parseJSONEnvelope(buffer.toString());
|
|
532
533
|
}
|
|
533
534
|
async handleMessage(message) {
|
|
534
535
|
const request = this.getRequestPayload(message);
|
|
@@ -536,7 +537,6 @@ class TunnelClient {
|
|
|
536
537
|
return;
|
|
537
538
|
}
|
|
538
539
|
if (request.path === ONES_CLI_MANIFEST_PATH) {
|
|
539
|
-
var _this$ws5;
|
|
540
540
|
const appManifest = getAppManifestJSON().app;
|
|
541
541
|
const baseURL = await buildTunnelUrl();
|
|
542
542
|
const reply = {
|
|
@@ -552,19 +552,17 @@ class TunnelClient {
|
|
|
552
552
|
}
|
|
553
553
|
}
|
|
554
554
|
};
|
|
555
|
-
|
|
555
|
+
this.sendBinaryEnvelope(reply);
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
558
|
try {
|
|
559
|
-
var _this$ws6;
|
|
560
559
|
const response = await this.forwardRequest(request);
|
|
561
560
|
const reply = {
|
|
562
561
|
id: message.id,
|
|
563
562
|
payload: response
|
|
564
563
|
};
|
|
565
|
-
|
|
564
|
+
this.sendBinaryEnvelope(reply);
|
|
566
565
|
} catch (error) {
|
|
567
|
-
var _this$ws7;
|
|
568
566
|
const reply = {
|
|
569
567
|
id: message.id,
|
|
570
568
|
payload: {
|
|
@@ -575,7 +573,7 @@ class TunnelClient {
|
|
|
575
573
|
body: "agent request error"
|
|
576
574
|
}
|
|
577
575
|
};
|
|
578
|
-
|
|
576
|
+
this.sendBinaryEnvelope(reply);
|
|
579
577
|
}
|
|
580
578
|
}
|
|
581
579
|
getRequestPayload(message) {
|
|
@@ -593,40 +591,25 @@ class TunnelClient {
|
|
|
593
591
|
url.searchParams.set(key, value);
|
|
594
592
|
});
|
|
595
593
|
}
|
|
596
|
-
const headers = this.normalizeHeaders(payload.headers);
|
|
597
|
-
const body = this.normalizeBody(payload.body);
|
|
598
594
|
const response = await axios.request({
|
|
599
595
|
url: url.toString(),
|
|
600
596
|
method: payload.method,
|
|
601
|
-
headers,
|
|
602
|
-
data: body,
|
|
603
|
-
responseType: "
|
|
597
|
+
headers: payload.headers,
|
|
598
|
+
data: payload.body,
|
|
599
|
+
responseType: "arraybuffer",
|
|
604
600
|
validateStatus: () => true
|
|
605
601
|
});
|
|
602
|
+
const responseBytes = Buffer.from(response.data);
|
|
606
603
|
return {
|
|
607
604
|
status: response.status,
|
|
608
605
|
headers: this.collectHeaders(response.headers),
|
|
609
|
-
body:
|
|
606
|
+
body: responseBytes
|
|
610
607
|
};
|
|
611
608
|
}
|
|
612
|
-
normalizeHeaders(headers) {
|
|
613
|
-
if (!headers) {
|
|
614
|
-
return void 0;
|
|
615
|
-
}
|
|
616
|
-
const normalized = {};
|
|
617
|
-
Object.entries(headers).forEach((_ref2) => {
|
|
618
|
-
let [key, values] = _ref2;
|
|
619
|
-
if (!values || values.length === 0) {
|
|
620
|
-
return;
|
|
621
|
-
}
|
|
622
|
-
normalized[key] = values.join(",");
|
|
623
|
-
});
|
|
624
|
-
return normalized;
|
|
625
|
-
}
|
|
626
609
|
collectHeaders(headers) {
|
|
627
610
|
const collected = {};
|
|
628
|
-
Object.entries(headers).forEach((
|
|
629
|
-
let [key, value] =
|
|
611
|
+
Object.entries(headers).forEach((_ref2) => {
|
|
612
|
+
let [key, value] = _ref2;
|
|
630
613
|
if (Array.isArray(value)) {
|
|
631
614
|
collected[key] = value.map((item) => String(item));
|
|
632
615
|
return;
|
|
@@ -637,24 +620,87 @@ class TunnelClient {
|
|
|
637
620
|
});
|
|
638
621
|
return collected;
|
|
639
622
|
}
|
|
640
|
-
|
|
623
|
+
sendBinaryEnvelope(envelope) {
|
|
624
|
+
var _this$ws5;
|
|
625
|
+
const encoded = this.encodeBinaryEnvelope(envelope);
|
|
626
|
+
(_this$ws5 = this.ws) === null || _this$ws5 === void 0 || _this$ws5.send(encoded);
|
|
627
|
+
}
|
|
628
|
+
encodeBinaryEnvelope(envelope) {
|
|
629
|
+
var _envelope$payload;
|
|
630
|
+
const payload = (_envelope$payload = envelope.payload) !== null && _envelope$payload !== void 0 ? _envelope$payload : {};
|
|
631
|
+
const body = this.toBodyBuffer(payload.body);
|
|
632
|
+
const metaPayload = {
|
|
633
|
+
...payload
|
|
634
|
+
};
|
|
635
|
+
delete metaPayload.body;
|
|
636
|
+
const meta = Buffer.from(JSON.stringify({
|
|
637
|
+
id: envelope.id,
|
|
638
|
+
payload: metaPayload
|
|
639
|
+
}), "utf8");
|
|
640
|
+
const header = Buffer.allocUnsafe(4);
|
|
641
|
+
header.writeUInt32BE(meta.length, 0);
|
|
642
|
+
return Buffer.concat([header, meta, body]);
|
|
643
|
+
}
|
|
644
|
+
toBodyBuffer(body) {
|
|
641
645
|
if (body === void 0 || body === null) {
|
|
642
|
-
return
|
|
646
|
+
return Buffer.alloc(0);
|
|
643
647
|
}
|
|
644
|
-
if (
|
|
648
|
+
if (Buffer.isBuffer(body)) {
|
|
645
649
|
return body;
|
|
646
650
|
}
|
|
647
|
-
|
|
651
|
+
if (body instanceof ArrayBuffer) {
|
|
652
|
+
return Buffer.from(body);
|
|
653
|
+
}
|
|
654
|
+
if (ArrayBuffer.isView(body)) {
|
|
655
|
+
return Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
656
|
+
}
|
|
657
|
+
if (typeof body === "string") {
|
|
658
|
+
return Buffer.from(body, "utf8");
|
|
659
|
+
}
|
|
660
|
+
return Buffer.from(JSON.stringify(body), "utf8");
|
|
648
661
|
}
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
662
|
+
parseBinaryEnvelope(buffer) {
|
|
663
|
+
const metaLength = buffer.readUInt32BE(0);
|
|
664
|
+
if (metaLength <= 0 || 4 + metaLength > buffer.length) {
|
|
665
|
+
return null;
|
|
652
666
|
}
|
|
667
|
+
const metaRaw = buffer.subarray(4, 4 + metaLength).toString("utf8");
|
|
653
668
|
try {
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
669
|
+
const envelope = JSON.parse(metaRaw);
|
|
670
|
+
if (!(envelope !== null && envelope !== void 0 && envelope.payload)) {
|
|
671
|
+
return envelope;
|
|
672
|
+
}
|
|
673
|
+
const body = buffer.subarray(4 + metaLength);
|
|
674
|
+
envelope.payload.body = body;
|
|
675
|
+
return envelope;
|
|
676
|
+
} catch (error) {
|
|
677
|
+
console.error("Invalid binary tunnel message:", error);
|
|
678
|
+
return null;
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
parseJSONEnvelope(payload) {
|
|
682
|
+
try {
|
|
683
|
+
const message = JSON.parse(payload);
|
|
684
|
+
if (!message) {
|
|
685
|
+
return null;
|
|
686
|
+
}
|
|
687
|
+
return message;
|
|
688
|
+
} catch (error) {
|
|
689
|
+
console.error("Invalid tunnel message:", error);
|
|
690
|
+
return null;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
toBuffer(data) {
|
|
694
|
+
if (Buffer.isBuffer(data)) {
|
|
695
|
+
return data;
|
|
696
|
+
}
|
|
697
|
+
if (Array.isArray(data)) {
|
|
698
|
+
return Buffer.concat(data);
|
|
699
|
+
}
|
|
700
|
+
if (data instanceof ArrayBuffer) {
|
|
701
|
+
return Buffer.from(data);
|
|
657
702
|
}
|
|
703
|
+
return null;
|
|
658
704
|
}
|
|
659
705
|
}
|
|
660
706
|
const getPath = (path, map2) => {
|
|
@@ -956,7 +1002,7 @@ const login = async function() {
|
|
|
956
1002
|
const port = await getPort({
|
|
957
1003
|
port: config2.defaultPort.login
|
|
958
1004
|
});
|
|
959
|
-
const uuid =
|
|
1005
|
+
const uuid = v4();
|
|
960
1006
|
const search = new URLSearchParams();
|
|
961
1007
|
search.set("redirect_path", "/developer/cli");
|
|
962
1008
|
search.set("redirect_url", `http://localhost:${port}`);
|
|
@@ -1097,7 +1143,27 @@ const install = async function() {
|
|
|
1097
1143
|
await invokeTunnel(getConfig().defaultPort.tunnel);
|
|
1098
1144
|
const result = await invokeInstall();
|
|
1099
1145
|
if (result.code === "OK") {
|
|
1146
|
+
var _appList$data$0$insta, _appList$data;
|
|
1100
1147
|
console.log("App installed successfully!");
|
|
1148
|
+
const appID = getAppManifestJSON().app.id;
|
|
1149
|
+
const appList = await fetchAppList(appID);
|
|
1150
|
+
const installationID = (_appList$data$0$insta = (_appList$data = appList.data) === null || _appList$data === void 0 || (_appList$data = _appList$data[0]) === null || _appList$data === void 0 ? void 0 : _appList$data.installation_id) !== null && _appList$data$0$insta !== void 0 ? _appList$data$0$insta : "";
|
|
1151
|
+
if (installationID) {
|
|
1152
|
+
var _tokenInfo$org$uuid, _tokenInfo$org, _tokenInfo$teams$0$uu, _tokenInfo$teams, _tokenInfo$org$visibi, _tokenInfo$org2;
|
|
1153
|
+
const tokenInfo = await fetchTokenInfo();
|
|
1154
|
+
const orgUUID = (_tokenInfo$org$uuid = (_tokenInfo$org = tokenInfo.org) === null || _tokenInfo$org === void 0 ? void 0 : _tokenInfo$org.uuid) !== null && _tokenInfo$org$uuid !== void 0 ? _tokenInfo$org$uuid : "";
|
|
1155
|
+
const teamUUID = (_tokenInfo$teams$0$uu = (_tokenInfo$teams = tokenInfo.teams) === null || _tokenInfo$teams === void 0 || (_tokenInfo$teams = _tokenInfo$teams[0]) === null || _tokenInfo$teams === void 0 ? void 0 : _tokenInfo$teams.uuid) !== null && _tokenInfo$teams$0$uu !== void 0 ? _tokenInfo$teams$0$uu : "";
|
|
1156
|
+
const isOrgVisible = (_tokenInfo$org$visibi = (_tokenInfo$org2 = tokenInfo.org) === null || _tokenInfo$org2 === void 0 ? void 0 : _tokenInfo$org2.visibility) !== null && _tokenInfo$org$visibi !== void 0 ? _tokenInfo$org$visibi : false;
|
|
1157
|
+
const baseURL = await getBaseURL();
|
|
1158
|
+
if (isOrgVisible && orgUUID) {
|
|
1159
|
+
const url = `${baseURL}/project/#/org/${orgUUID}/setting/app_manager/platform_app/${installationID}`;
|
|
1160
|
+
console.log(`See App detail: ${url}`);
|
|
1161
|
+
}
|
|
1162
|
+
if (!isOrgVisible && teamUUID) {
|
|
1163
|
+
const url = `${baseURL}/project/#/team/${teamUUID}/team_setting/app_manager/platform_app/${installationID}`;
|
|
1164
|
+
console.log(`See App detail: ${url}`);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1101
1167
|
} else {
|
|
1102
1168
|
console.error(result);
|
|
1103
1169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/install/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/actions/install/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,KAAK,EAA2B,qBAAqB,EAAE,MAAM,WAAW,CAAA;AAE/E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEzC,eAAO,MAAM,OAAO,GAAU,GAAG,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,kBAgC7E,CAAA"}
|
|
@@ -12,9 +12,12 @@ export declare class TunnelClient {
|
|
|
12
12
|
private handleMessage;
|
|
13
13
|
private getRequestPayload;
|
|
14
14
|
private forwardRequest;
|
|
15
|
-
private normalizeHeaders;
|
|
16
15
|
private collectHeaders;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
16
|
+
private sendBinaryEnvelope;
|
|
17
|
+
private encodeBinaryEnvelope;
|
|
18
|
+
private toBodyBuffer;
|
|
19
|
+
private parseBinaryEnvelope;
|
|
20
|
+
private parseJSONEnvelope;
|
|
21
|
+
private toBuffer;
|
|
19
22
|
}
|
|
20
23
|
//# sourceMappingURL=tunnel-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tunnel-client.d.ts","sourceRoot":"","sources":["../../../../src/actions/tunnel/tunnel-client.ts"],"names":[],"mappings":"AA4BA,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAQ;gBAEf,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAO5E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B9B,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;YAcN,aAAa;IA4C3B,OAAO,CAAC,iBAAiB;YAQX,cAAc;
|
|
1
|
+
{"version":3,"file":"tunnel-client.d.ts","sourceRoot":"","sources":["../../../../src/actions/tunnel/tunnel-client.ts"],"names":[],"mappings":"AA4BA,qBAAa,YAAY;IACvB,OAAO,CAAC,EAAE,CAAyB;IACnC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAQ;gBAEf,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;IAO5E,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B9B,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,YAAY;YAcN,aAAa;IA4C3B,OAAO,CAAC,iBAAiB;YAQX,cAAc;IAyB5B,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,kBAAkB;IAK1B,OAAO,CAAC,oBAAoB;IAW5B,OAAO,CAAC,YAAY;IAmBpB,OAAO,CAAC,mBAAmB;IAoB3B,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,QAAQ;CAYjB"}
|
|
@@ -2,16 +2,17 @@ export declare enum ErrorCode {
|
|
|
2
2
|
UNKNOWN_ERROR = "E00",
|
|
3
3
|
COMMAND_ERROR = "E01",
|
|
4
4
|
TEMPLATE_NOT_FOUND = "E02",
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
MISSING_PROJECT_PATH = "E03",
|
|
6
|
+
MISSING_BASE_URL = "E04",
|
|
7
|
+
MISSING_PORT = "E05",
|
|
8
|
+
INCORRECT_BASE_URL = "E06",
|
|
9
|
+
INCORRECT_PORT = "E07",
|
|
10
|
+
APP_PACKAGE_JSON_PARSE_ERROR = "E08",
|
|
11
|
+
APP_MANIFEST_JSON_PARSE_ERROR = "E09",
|
|
12
|
+
BUILD_SCRIPT_NOT_FOUND = "E10",
|
|
13
|
+
DEV_SCRIPT_NOT_FOUND = "E11",
|
|
14
|
+
STORE_PERMISSION = "E12",
|
|
15
|
+
HOSTED_TOKEN_REQUEST_FAILED = "E13",
|
|
16
|
+
HOSTED_TOKEN_EMPTY = "E14"
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/common/error/enums.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,aAAa,QAAgC;IAC7C,aAAa,QAAgC;IAC7C,kBAAkB,QAAqC;IACvD,gBAAgB,QAAQ;IACxB,YAAY,QAAQ;IACpB,kBAAkB,QAAQ;IAC1B,cAAc,QAAQ;IACtB,4BAA4B,QAAQ;IACpC,6BAA6B,QAAQ;IACrC,sBAAsB,QAAQ;IAC9B,oBAAoB,QAAQ;IAC5B,gBAAgB,QAAQ;IACxB,2BAA2B,QAAQ;IACnC,kBAAkB,QAAQ;CAC3B"}
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../../../src/common/error/enums.ts"],"names":[],"mappings":"AAEA,oBAAY,SAAS;IACnB,aAAa,QAAgC;IAC7C,aAAa,QAAgC;IAC7C,kBAAkB,QAAqC;IACvD,oBAAoB,QAAuC;IAC3D,gBAAgB,QAAQ;IACxB,YAAY,QAAQ;IACpB,kBAAkB,QAAQ;IAC1B,cAAc,QAAQ;IACtB,4BAA4B,QAAQ;IACpC,6BAA6B,QAAQ;IACrC,sBAAsB,QAAQ;IAC9B,oBAAoB,QAAQ;IAC5B,gBAAgB,QAAQ;IACxB,2BAA2B,QAAQ;IACnC,kBAAkB,QAAQ;CAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/common/request/types.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kB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AClE;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,OAAO,CAAC,yBAAyB,CAAC,CAAA;CACvC;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAA;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACrC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ones-open/cli",
|
|
3
|
-
"version": "1.0.1-
|
|
3
|
+
"version": "1.0.1-5596.1908+bda51547",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"chalk": "^5.0.1",
|
|
63
63
|
"commander": "~9.4.0",
|
|
64
64
|
"cosmiconfig": "^8.3.6",
|
|
65
|
-
"create-ones-app": "1.0.1-
|
|
65
|
+
"create-ones-app": "1.0.1-5596.1908+bda51547",
|
|
66
66
|
"env-paths": "3.0.0",
|
|
67
67
|
"execa": "^6.1.0",
|
|
68
68
|
"fs-extra": "^11.3.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"ws": "^8.18.3",
|
|
76
76
|
"zod": "^3.22.2"
|
|
77
77
|
},
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "bda515471866b99030cb0f5bc6f2253d3977956b"
|
|
79
79
|
}
|