@superblocksteam/sdk 1.14.2 → 2.0.3-next.101
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/.mocharc.json +7 -0
- package/.prettierrc +18 -0
- package/dist/cli-replacement/dev.d.mts +19 -0
- package/dist/cli-replacement/dev.d.mts.map +1 -0
- package/dist/cli-replacement/dev.mjs +129 -0
- package/dist/cli-replacement/dev.mjs.map +1 -0
- package/dist/cli-replacement/init.d.ts +14 -0
- package/dist/cli-replacement/init.d.ts.map +1 -0
- package/dist/cli-replacement/init.js +26 -0
- package/dist/cli-replacement/init.js.map +1 -0
- package/dist/client.d.ts +31 -17
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +137 -155
- package/dist/client.js.map +1 -0
- package/dist/dbfs/client.d.ts +6 -0
- package/dist/dbfs/client.d.ts.map +1 -0
- package/dist/dbfs/client.js +117 -0
- package/dist/dbfs/client.js.map +1 -0
- package/dist/dbfs/local.d.ts +15 -0
- package/dist/dbfs/local.d.ts.map +1 -0
- package/dist/dbfs/local.js +126 -0
- package/dist/dbfs/local.js.map +1 -0
- package/dist/dev-utils/custom-build.d.mts +4 -0
- package/dist/dev-utils/custom-build.d.mts.map +1 -0
- package/dist/dev-utils/custom-build.mjs +99 -0
- package/dist/dev-utils/custom-build.mjs.map +1 -0
- package/dist/dev-utils/custom-config.d.mts +2 -0
- package/dist/dev-utils/custom-config.d.mts.map +1 -0
- package/dist/dev-utils/custom-config.mjs +57 -0
- package/dist/dev-utils/custom-config.mjs.map +1 -0
- package/dist/dev-utils/dev-logger.d.mts +8 -0
- package/dist/dev-utils/dev-logger.d.mts.map +1 -0
- package/dist/dev-utils/dev-logger.mjs +25 -0
- package/dist/dev-utils/dev-logger.mjs.map +1 -0
- package/dist/dev-utils/dev-server.d.mts +18 -0
- package/dist/dev-utils/dev-server.d.mts.map +1 -0
- package/dist/dev-utils/dev-server.mjs +265 -0
- package/dist/dev-utils/dev-server.mjs.map +1 -0
- package/dist/dev-utils/dev-tracer.d.ts +3 -0
- package/dist/dev-utils/dev-tracer.d.ts.map +1 -0
- package/dist/dev-utils/dev-tracer.js +28 -0
- package/dist/dev-utils/dev-tracer.js.map +1 -0
- package/dist/dev-utils/vite-plugin-dd-rum.d.mts +10 -0
- package/dist/dev-utils/vite-plugin-dd-rum.d.mts.map +1 -0
- package/dist/dev-utils/vite-plugin-dd-rum.mjs +34 -0
- package/dist/dev-utils/vite-plugin-dd-rum.mjs.map +1 -0
- package/dist/dev-utils/vite-plugin-react-transform.d.mts +7 -0
- package/dist/dev-utils/vite-plugin-react-transform.d.mts.map +1 -0
- package/dist/dev-utils/vite-plugin-react-transform.mjs +110 -0
- package/dist/dev-utils/vite-plugin-react-transform.mjs.map +1 -0
- package/dist/dev-utils/vite-plugin-sb-cdn.d.mts +34 -0
- package/dist/dev-utils/vite-plugin-sb-cdn.d.mts.map +1 -0
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs +720 -0
- package/dist/dev-utils/vite-plugin-sb-cdn.mjs.map +1 -0
- package/dist/errors.d.ts +1 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +4 -9
- package/dist/errors.js.map +1 -0
- package/dist/flag.d.ts +2 -2
- package/dist/flag.d.ts.map +1 -0
- package/dist/flag.js +5 -9
- package/dist/flag.js.map +1 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -20
- package/dist/index.js.map +1 -0
- package/dist/sdk.d.ts +42 -18
- package/dist/sdk.d.ts.map +1 -0
- package/dist/sdk.js +47 -43
- package/dist/sdk.js.map +1 -0
- package/dist/socket/handlers.d.ts +3 -128
- package/dist/socket/handlers.d.ts.map +1 -0
- package/dist/socket/handlers.js +7 -9
- package/dist/socket/handlers.js.map +1 -0
- package/dist/socket/index.d.ts +4 -3
- package/dist/socket/index.d.ts.map +1 -0
- package/dist/socket/index.js +12 -21
- package/dist/socket/index.js.map +1 -0
- package/dist/socket/signing.d.ts +3 -1
- package/dist/socket/signing.d.ts.map +1 -0
- package/dist/socket/signing.js +8 -17
- package/dist/socket/signing.js.map +1 -0
- package/dist/socket/socket.d.ts +3 -2
- package/dist/socket/socket.d.ts.map +1 -0
- package/dist/socket/socket.js +9 -19
- package/dist/socket/socket.js.map +1 -0
- package/dist/types/common.d.ts +2 -103
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +8 -24
- package/dist/types/common.js.map +1 -0
- package/dist/types/index.d.ts +5 -4
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -20
- package/dist/types/index.js.map +1 -0
- package/dist/types/plugin.d.ts +1 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/plugin.js +3 -5
- package/dist/types/plugin.js.map +1 -0
- package/dist/types/signing.d.ts +2 -1
- package/dist/types/signing.d.ts.map +1 -0
- package/dist/types/signing.js +2 -2
- package/dist/types/signing.js.map +1 -0
- package/dist/types/socket.d.ts +1 -0
- package/dist/types/socket.d.ts.map +1 -0
- package/dist/types/socket.js +2 -5
- package/dist/types/socket.js.map +1 -0
- package/dist/utils.d.ts +3 -1
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +14 -23
- package/dist/utils.js.map +1 -0
- package/dist/version-control.d.mts +59 -0
- package/dist/version-control.d.mts.map +1 -0
- package/dist/version-control.mjs +899 -0
- package/dist/version-control.mjs.map +1 -0
- package/eslint.config.js +85 -0
- package/package.json +76 -30
- package/src/cli-replacement/dev.mts +194 -0
- package/src/cli-replacement/init.ts +47 -0
- package/src/client.ts +114 -38
- package/src/dbfs/client.ts +162 -0
- package/src/dbfs/local.ts +163 -0
- package/src/dev-utils/custom-build.mts +113 -0
- package/src/dev-utils/custom-config.mts +66 -0
- package/src/dev-utils/dev-logger.mts +39 -0
- package/src/dev-utils/dev-server.mts +342 -0
- package/src/dev-utils/dev-tracer.ts +31 -0
- package/src/dev-utils/vite-plugin-dd-rum.mts +47 -0
- package/src/dev-utils/vite-plugin-react-transform.mts +130 -0
- package/src/dev-utils/vite-plugin-sb-cdn.mts +988 -0
- package/src/flag.ts +2 -3
- package/src/index.ts +119 -4
- package/src/sdk.ts +91 -17
- package/src/socket/handlers.ts +9 -147
- package/src/socket/index.ts +6 -9
- package/src/socket/signing.ts +7 -8
- package/src/socket/socket.ts +8 -9
- package/src/types/common.ts +2 -119
- package/src/types/index.ts +4 -4
- package/src/types/signing.ts +1 -1
- package/src/types/socket.ts +1 -1
- package/src/utils.ts +5 -6
- package/src/version-control.mts +1351 -0
- package/test/dev-utils/fixture/index.html +12 -0
- package/test/dev-utils/fixture/main.jsx +22 -0
- package/test/dev-utils/fixture/package-lock.json +25 -0
- package/test/dev-utils/fixture/package.json +9 -0
- package/test/dev-utils/vite-plugin-sb-cdn.test.mts +74 -0
- package/test/tsconfig.json +9 -0
- package/test/version-control.test.mts +1412 -0
- package/tsconfig.json +15 -4
- package/tsconfig.tsbuildinfo +1 -1
- package/.eslintrc.json +0 -55
package/dist/client.js
CHANGED
|
@@ -1,68 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.createSocketConnectionIfNeeded = void 0;
|
|
40
|
-
exports.fetchApplication = fetchApplication;
|
|
41
|
-
exports.fetchApplicationBranches = fetchApplicationBranches;
|
|
42
|
-
exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
|
|
43
|
-
exports.fetchApplications = fetchApplications;
|
|
44
|
-
exports.fetchApi = fetchApi;
|
|
45
|
-
exports.fetchApis = fetchApis;
|
|
46
|
-
exports.validateGitSetup = validateGitSetup;
|
|
47
|
-
exports.registerComponents = registerComponents;
|
|
48
|
-
exports.uploadComponents = uploadComponents;
|
|
49
|
-
exports.fetchCurrentUser = fetchCurrentUser;
|
|
50
|
-
exports.pushApplication = pushApplication;
|
|
51
|
-
exports.pushApi = pushApi;
|
|
52
|
-
exports.fetchApplicationCommits = fetchApplicationCommits;
|
|
53
|
-
exports.fetchApiCommits = fetchApiCommits;
|
|
54
|
-
exports.deployApplication = deployApplication;
|
|
55
|
-
exports.deployApi = deployApi;
|
|
56
|
-
const fs = __importStar(require("fs"));
|
|
57
|
-
const util_1 = require("@superblocksteam/util");
|
|
58
|
-
const axios_1 = __importStar(require("axios"));
|
|
59
|
-
const form_data_1 = __importDefault(require("form-data"));
|
|
60
|
-
const lodash_1 = require("lodash");
|
|
61
|
-
const errors_1 = require("./errors");
|
|
62
|
-
const flag_1 = require("./flag");
|
|
63
|
-
const socket_1 = require("./socket");
|
|
64
|
-
const types_1 = require("./types");
|
|
65
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import * as fs from "fs";
|
|
2
|
+
import { Bucketeer, FileDescriptor } from "@superblocksteam/bucketeer-sdk";
|
|
3
|
+
import { ExportViewMode } from "@superblocksteam/shared";
|
|
4
|
+
import { COMPONENT_EVENT_HEADER, ComponentEvent, ForbiddenError, getBucketeerUrlFromSuperblocksUrl, getContentType, NotFoundError, BadRequestError, unreachable, } from "@superblocksteam/util";
|
|
5
|
+
import axios, { AxiosError } from "axios";
|
|
6
|
+
import FormData from "form-data";
|
|
7
|
+
import { isEqual, isEmpty } from "lodash-es";
|
|
8
|
+
import { BranchNotCheckedOutError, CommitAlreadyExistsError, ValidateGitSetupError, } from "./errors.js";
|
|
9
|
+
import { signingEnabled } from "./flag.js";
|
|
10
|
+
import { connectToISocketRPCServer } from "./socket/index.js";
|
|
11
|
+
import { AgentType } from "./types/index.js";
|
|
12
|
+
import { getAgentUrl } from "./utils.js";
|
|
66
13
|
const BASE_BUCKETEER_URL = "api";
|
|
67
14
|
const BASE_SERVER_PUBLIC_API_URL_V1 = "api/v1/public";
|
|
68
15
|
const BASE_SERVER_PUBLIC_API_URL_v2 = "api/v2/public";
|
|
@@ -76,8 +23,8 @@ var ResourceType;
|
|
|
76
23
|
ResourceType["APPLICATION"] = "APPLICATION";
|
|
77
24
|
ResourceType["BACKEND"] = "BACKEND";
|
|
78
25
|
})(ResourceType || (ResourceType = {}));
|
|
79
|
-
async function fetchApplication({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
|
|
80
|
-
if (commitId && viewMode !==
|
|
26
|
+
export async function fetchApplication({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
|
|
27
|
+
if (commitId && viewMode !== ExportViewMode.EXPORT_COMMIT) {
|
|
81
28
|
throw new Error(`If commitId ${commitId} is provided, viewMode cannot be ${viewMode}`);
|
|
82
29
|
}
|
|
83
30
|
try {
|
|
@@ -89,7 +36,7 @@ async function fetchApplication({ cliVersion, applicationId, branch, token, supe
|
|
|
89
36
|
...(commitId ? { commitId } : {}),
|
|
90
37
|
}).toString();
|
|
91
38
|
const socket = !skipSigningVerification
|
|
92
|
-
? await
|
|
39
|
+
? await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl)
|
|
93
40
|
: undefined;
|
|
94
41
|
if (socket) {
|
|
95
42
|
try {
|
|
@@ -114,18 +61,18 @@ async function fetchApplication({ cliVersion, applicationId, branch, token, supe
|
|
|
114
61
|
...injectedHeaders,
|
|
115
62
|
},
|
|
116
63
|
};
|
|
117
|
-
const serverResponse = await (
|
|
64
|
+
const serverResponse = await axios(config);
|
|
118
65
|
const data = serverResponse?.data?.data;
|
|
119
66
|
return data;
|
|
120
67
|
}
|
|
121
68
|
catch (e) {
|
|
122
|
-
if (
|
|
123
|
-
throw new
|
|
69
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
70
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
124
71
|
}
|
|
125
72
|
throw new Error(`Could not fetch application: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
|
|
126
73
|
}
|
|
127
74
|
}
|
|
128
|
-
async function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
|
|
75
|
+
export async function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
|
|
129
76
|
const serverURL = new URL(`public/applications/${applicationId}/branches`, superblocksBaseUrl);
|
|
130
77
|
let serverResponse;
|
|
131
78
|
try {
|
|
@@ -138,17 +85,17 @@ async function fetchApplicationBranches({ cliVersion, applicationId, token, supe
|
|
|
138
85
|
...injectedHeaders,
|
|
139
86
|
},
|
|
140
87
|
};
|
|
141
|
-
serverResponse = await (
|
|
88
|
+
serverResponse = await axios(config);
|
|
142
89
|
}
|
|
143
90
|
catch (e) {
|
|
144
|
-
if (
|
|
145
|
-
throw new
|
|
91
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
92
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
146
93
|
}
|
|
147
94
|
throw new Error(`Could not fetch application branches: ${e.message}`);
|
|
148
95
|
}
|
|
149
96
|
return serverResponse?.data?.data;
|
|
150
97
|
}
|
|
151
|
-
async function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
|
|
98
|
+
export async function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
|
|
152
99
|
const applicationWrapper = await fetchApplication({
|
|
153
100
|
cliVersion,
|
|
154
101
|
applicationId,
|
|
@@ -160,18 +107,37 @@ async function fetchApplicationWithComponents({ cliVersion, applicationId, branc
|
|
|
160
107
|
skipSigningVerification,
|
|
161
108
|
injectedHeaders,
|
|
162
109
|
});
|
|
163
|
-
if (
|
|
110
|
+
if (isEmpty(applicationWrapper)) {
|
|
164
111
|
return;
|
|
165
112
|
}
|
|
113
|
+
if (applicationWrapper.application.devEnvEnabled) {
|
|
114
|
+
return {
|
|
115
|
+
type: "code-mode",
|
|
116
|
+
...applicationWrapper,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return await fetchApplicationWithComponentsFromBucketeer({
|
|
120
|
+
applicationWrapper,
|
|
121
|
+
superblocksBaseUrl,
|
|
122
|
+
applicationId,
|
|
123
|
+
branch,
|
|
124
|
+
commitId,
|
|
125
|
+
viewMode,
|
|
126
|
+
token,
|
|
127
|
+
injectedHeaders,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
async function fetchApplicationWithComponentsFromBucketeer({ applicationWrapper, superblocksBaseUrl, applicationId, branch, commitId, viewMode, token, injectedHeaders, }) {
|
|
166
131
|
// if there are no custom components, just return here without trying to initialize them using bucketeer
|
|
167
|
-
if (
|
|
132
|
+
if (isEmpty(applicationWrapper.application?.settings?.registeredComponents)) {
|
|
168
133
|
return {
|
|
134
|
+
type: "multi-page",
|
|
169
135
|
...applicationWrapper,
|
|
170
136
|
componentFiles: null,
|
|
171
137
|
};
|
|
172
138
|
}
|
|
173
139
|
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
174
|
-
const bucketeerBaseUrl =
|
|
140
|
+
const bucketeerBaseUrl = getBucketeerUrlFromSuperblocksUrl(superblocksBaseUrl);
|
|
175
141
|
// fetch files from bucketeer
|
|
176
142
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
177
143
|
const componentFileURL = new URL(`${BASE_BUCKETEER_URL}/v1/components/${applicationId}${branchPath}?commit=${commitId}&viewMode=${viewMode}&multiPage=true`, bucketeerBaseUrl).toString();
|
|
@@ -185,21 +151,21 @@ async function fetchApplicationWithComponents({ cliVersion, applicationId, branc
|
|
|
185
151
|
...injectedHeaders,
|
|
186
152
|
},
|
|
187
153
|
};
|
|
188
|
-
const bucketeerApp = (await (
|
|
154
|
+
const bucketeerApp = (await axios(config))
|
|
189
155
|
.data;
|
|
190
|
-
if (!
|
|
156
|
+
if (!isEqual(applicationWrapper.application.settings, bucketeerApp.application.settings)) {
|
|
191
157
|
throw new Error("Application settings fetched from bucketeer do not match the settings fetched from the server");
|
|
192
158
|
}
|
|
193
159
|
return bucketeerApp;
|
|
194
160
|
}
|
|
195
161
|
catch (e) {
|
|
196
|
-
if (
|
|
197
|
-
throw new
|
|
162
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
163
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
198
164
|
}
|
|
199
165
|
throw new Error("Could not fetch application");
|
|
200
166
|
}
|
|
201
167
|
}
|
|
202
|
-
async function fetchApplications(cliVersion, token, superblocksBaseUrl, injectedHeaders = {}) {
|
|
168
|
+
export async function fetchApplications(cliVersion, token, superblocksBaseUrl, injectedHeaders = {}) {
|
|
203
169
|
try {
|
|
204
170
|
const config = {
|
|
205
171
|
method: "get",
|
|
@@ -210,12 +176,12 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
|
|
|
210
176
|
...injectedHeaders,
|
|
211
177
|
},
|
|
212
178
|
};
|
|
213
|
-
const response = await (
|
|
179
|
+
const response = await axios(config);
|
|
214
180
|
return response.data.data.applications;
|
|
215
181
|
}
|
|
216
182
|
catch (e) {
|
|
217
183
|
let message;
|
|
218
|
-
if (e instanceof
|
|
184
|
+
if (e instanceof AxiosError) {
|
|
219
185
|
message =
|
|
220
186
|
e.response?.data?.responseMeta?.message ??
|
|
221
187
|
JSON.stringify(e.response?.data) ??
|
|
@@ -228,7 +194,7 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
|
|
|
228
194
|
throw new Error(`Could not fetch applications: ${message}`);
|
|
229
195
|
}
|
|
230
196
|
}
|
|
231
|
-
async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode, branch, commitId, skipSigningVerification = false) {
|
|
197
|
+
export async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode, branch, commitId, skipSigningVerification = false) {
|
|
232
198
|
try {
|
|
233
199
|
const serverURL = branch
|
|
234
200
|
? new URL(`${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(branch)}`, superblocksBaseUrl)
|
|
@@ -238,7 +204,7 @@ async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode,
|
|
|
238
204
|
...(commitId ? { commitId } : {}),
|
|
239
205
|
}).toString();
|
|
240
206
|
const socket = !skipSigningVerification
|
|
241
|
-
? await
|
|
207
|
+
? await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl)
|
|
242
208
|
: undefined;
|
|
243
209
|
if (socket) {
|
|
244
210
|
try {
|
|
@@ -262,18 +228,18 @@ async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode,
|
|
|
262
228
|
[CLI_VERSION_HEADER]: cliVersion,
|
|
263
229
|
},
|
|
264
230
|
};
|
|
265
|
-
const response = await (
|
|
231
|
+
const response = await axios(config);
|
|
266
232
|
return response.data.data;
|
|
267
233
|
}
|
|
268
234
|
}
|
|
269
235
|
catch (e) {
|
|
270
|
-
if (
|
|
271
|
-
throw new
|
|
236
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
237
|
+
throw new NotFoundError(`Api ${apiId} was not found`);
|
|
272
238
|
}
|
|
273
239
|
throw new Error(`Could not fetch api: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
|
|
274
240
|
}
|
|
275
241
|
}
|
|
276
|
-
async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
242
|
+
export async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
277
243
|
try {
|
|
278
244
|
const config = {
|
|
279
245
|
method: "get",
|
|
@@ -283,14 +249,14 @@ async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
|
283
249
|
[CLI_VERSION_HEADER]: cliVersion,
|
|
284
250
|
},
|
|
285
251
|
};
|
|
286
|
-
const response = await (
|
|
252
|
+
const response = await axios(config);
|
|
287
253
|
return response.data.data.apis;
|
|
288
254
|
}
|
|
289
255
|
catch {
|
|
290
256
|
throw new Error("Could not fetch apis");
|
|
291
257
|
}
|
|
292
258
|
}
|
|
293
|
-
async function validateGitSetup(cliVersion, resourceId, resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
|
|
259
|
+
export async function validateGitSetup(cliVersion, resourceId, resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
|
|
294
260
|
let resourceName;
|
|
295
261
|
try {
|
|
296
262
|
const requestBody = {
|
|
@@ -308,7 +274,7 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
308
274
|
break;
|
|
309
275
|
}
|
|
310
276
|
default:
|
|
311
|
-
|
|
277
|
+
unreachable(resourceType);
|
|
312
278
|
}
|
|
313
279
|
const config = {
|
|
314
280
|
method: "post",
|
|
@@ -320,7 +286,7 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
320
286
|
},
|
|
321
287
|
data: requestBody,
|
|
322
288
|
};
|
|
323
|
-
const response = await (
|
|
289
|
+
const response = await axios(config);
|
|
324
290
|
const { validationResult } = response.data.data;
|
|
325
291
|
if (validationResult.errors.length > 0) {
|
|
326
292
|
if (validationResult.resourceName) {
|
|
@@ -334,7 +300,7 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
334
300
|
}
|
|
335
301
|
catch (e) {
|
|
336
302
|
let message;
|
|
337
|
-
if (e instanceof
|
|
303
|
+
if (e instanceof AxiosError) {
|
|
338
304
|
message =
|
|
339
305
|
e.response?.data?.responseMeta?.message ??
|
|
340
306
|
JSON.stringify(e.response?.data) ??
|
|
@@ -348,23 +314,23 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
348
314
|
// TODO(@taha-au @gpoulios-sb) Replace this check with a more robust one that uses error codes once
|
|
349
315
|
// the backend starts returning them as part of the response body
|
|
350
316
|
if (message.includes("Please initialize git locally")) {
|
|
351
|
-
throw new
|
|
317
|
+
throw new ValidateGitSetupError(errorMessage);
|
|
352
318
|
}
|
|
353
319
|
else {
|
|
354
320
|
throw new Error(errorMessage);
|
|
355
321
|
}
|
|
356
322
|
}
|
|
357
323
|
}
|
|
358
|
-
async function registerComponents(cliVersion, applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
|
|
324
|
+
export async function registerComponents(cliVersion, applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
|
|
359
325
|
try {
|
|
360
326
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
361
|
-
const socket = await
|
|
327
|
+
const socket = await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl);
|
|
362
328
|
if (socket) {
|
|
363
329
|
const resp = await socket.call.v1.public.application.component.register({
|
|
364
330
|
applicationId,
|
|
365
331
|
branchName: branch || "",
|
|
366
332
|
cliVersion: cliVersion,
|
|
367
|
-
componentEvent: injectedHeaders[
|
|
333
|
+
componentEvent: injectedHeaders[COMPONENT_EVENT_HEADER],
|
|
368
334
|
components: componentConfigs,
|
|
369
335
|
});
|
|
370
336
|
socket.close();
|
|
@@ -381,12 +347,12 @@ async function registerComponents(cliVersion, applicationId, componentConfigs, t
|
|
|
381
347
|
},
|
|
382
348
|
data: { components: componentConfigs },
|
|
383
349
|
};
|
|
384
|
-
const response = await (
|
|
350
|
+
const response = await axios(config);
|
|
385
351
|
return response.data;
|
|
386
352
|
}
|
|
387
353
|
}
|
|
388
354
|
catch (e) {
|
|
389
|
-
if (e instanceof
|
|
355
|
+
if (e instanceof AxiosError) {
|
|
390
356
|
const message = e.response?.data?.responseMeta?.message ??
|
|
391
357
|
JSON.stringify(e.response?.data) ??
|
|
392
358
|
e.response?.statusText;
|
|
@@ -395,12 +361,12 @@ async function registerComponents(cliVersion, applicationId, componentConfigs, t
|
|
|
395
361
|
throw new Error(`Could not register application components ${e.message ? "\n" + e.message : ""}`);
|
|
396
362
|
}
|
|
397
363
|
}
|
|
398
|
-
async function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
|
|
364
|
+
export async function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
|
|
399
365
|
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
400
|
-
const bucketeerBaseUrl =
|
|
366
|
+
const bucketeerBaseUrl = getBucketeerUrlFromSuperblocksUrl(superblocksBaseUrl);
|
|
401
367
|
// parse files to source and bundled files based on path
|
|
402
368
|
const uploadFiles = files.map((file, ind) => {
|
|
403
|
-
let contentType =
|
|
369
|
+
let contentType = getContentType(file);
|
|
404
370
|
if (contentType.length === 0) {
|
|
405
371
|
contentType = "application/octet-stream"; // default case when we don't know the encoding
|
|
406
372
|
}
|
|
@@ -422,7 +388,7 @@ async function uploadComponents({ cliVersion, applicationId, componentConfigs, f
|
|
|
422
388
|
});
|
|
423
389
|
const postURL = new URL(`${BASE_BUCKETEER_URL}/v2/components/upload`, bucketeerBaseUrl).toString();
|
|
424
390
|
let totalFileSizeMB = 0;
|
|
425
|
-
const formData = new
|
|
391
|
+
const formData = new FormData();
|
|
426
392
|
formData.append("format", formatJSON);
|
|
427
393
|
uploadFiles.forEach((uploadFile) => {
|
|
428
394
|
const uploadFileStats = fs.statSync(uploadFile.filename);
|
|
@@ -443,15 +409,15 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
443
409
|
headers: {
|
|
444
410
|
Authorization: "Bearer " + token,
|
|
445
411
|
[CLI_VERSION_HEADER]: cliVersion,
|
|
446
|
-
[
|
|
412
|
+
[COMPONENT_EVENT_HEADER]: ComponentEvent.UPLOAD,
|
|
447
413
|
[SUPERBLOCKS_URL_HEADER]: superblocksBaseUrl,
|
|
448
414
|
...formHeaders,
|
|
449
415
|
},
|
|
450
416
|
};
|
|
451
|
-
const uploadResponse = await
|
|
452
|
-
const initialSocket = await
|
|
417
|
+
const uploadResponse = await axios.post(postURL, formData, config);
|
|
418
|
+
const initialSocket = await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl);
|
|
453
419
|
const socket = initialSocket ??
|
|
454
|
-
(await
|
|
420
|
+
(await connectToISocketRPCServer({
|
|
455
421
|
agentUrl: undefined,
|
|
456
422
|
superblocksBaseUrl,
|
|
457
423
|
token,
|
|
@@ -465,7 +431,7 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
465
431
|
registeredComponents: componentConfigs,
|
|
466
432
|
cliVersion,
|
|
467
433
|
componentBaseUrl: uploadResponse.data.componentBaseUrl,
|
|
468
|
-
signingRequired: !
|
|
434
|
+
signingRequired: !isEmpty(initialSocket),
|
|
469
435
|
});
|
|
470
436
|
}
|
|
471
437
|
finally {
|
|
@@ -473,12 +439,12 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
473
439
|
}
|
|
474
440
|
}
|
|
475
441
|
catch (e) {
|
|
476
|
-
if (e instanceof
|
|
442
|
+
if (e instanceof AxiosError && e.response?.status === 413) {
|
|
477
443
|
throw new Error(`Could not upload application components, file size limit exceeded`);
|
|
478
444
|
}
|
|
479
445
|
else {
|
|
480
446
|
let message;
|
|
481
|
-
if (e instanceof
|
|
447
|
+
if (e instanceof AxiosError) {
|
|
482
448
|
message = (e.response?.data?.responseMeta?.message ||
|
|
483
449
|
e.response?.data ||
|
|
484
450
|
e.response?.statusText);
|
|
@@ -493,7 +459,7 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
493
459
|
}
|
|
494
460
|
}
|
|
495
461
|
}
|
|
496
|
-
async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
462
|
+
export async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
497
463
|
try {
|
|
498
464
|
const config = {
|
|
499
465
|
method: "get",
|
|
@@ -501,15 +467,15 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
|
501
467
|
headers: {
|
|
502
468
|
Authorization: "Bearer " + token,
|
|
503
469
|
[CLI_VERSION_HEADER]: cliVersion,
|
|
504
|
-
[
|
|
470
|
+
[COMPONENT_EVENT_HEADER]: ComponentEvent.LOGIN,
|
|
505
471
|
},
|
|
506
472
|
};
|
|
507
|
-
const response = await (
|
|
473
|
+
const response = await axios(config);
|
|
508
474
|
return response.data.data;
|
|
509
475
|
}
|
|
510
476
|
catch (e) {
|
|
511
477
|
let message;
|
|
512
|
-
if (e instanceof
|
|
478
|
+
if (e instanceof AxiosError) {
|
|
513
479
|
message =
|
|
514
480
|
e.response?.data?.responseMeta?.message ??
|
|
515
481
|
JSON.stringify(e.response?.data) ??
|
|
@@ -522,32 +488,31 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
|
522
488
|
throw new Error(`Could not fetch current user: ${message}`);
|
|
523
489
|
}
|
|
524
490
|
}
|
|
525
|
-
const createSocketConnectionIfNeeded = async (cliVersion, token, superblocksBaseUrl) => {
|
|
491
|
+
export const createSocketConnectionIfNeeded = async (cliVersion, token, superblocksBaseUrl) => {
|
|
526
492
|
const userMe = await fetchCurrentUser(cliVersion, token, superblocksBaseUrl);
|
|
527
493
|
const organization = userMe.organizations[0];
|
|
528
|
-
if (organization.agentType ==
|
|
529
|
-
|
|
494
|
+
if (organization.agentType == AgentType.ONPREMISE &&
|
|
495
|
+
signingEnabled(userMe.flagBootstrap)) {
|
|
530
496
|
const profile = process.env.SUPERBLOCKS_PROFILE;
|
|
531
|
-
const agentUrl = await
|
|
532
|
-
return await
|
|
497
|
+
const agentUrl = await getAgentUrl(userMe.agents, organization.agentType, profile);
|
|
498
|
+
return await connectToISocketRPCServer({
|
|
533
499
|
agentUrl,
|
|
534
500
|
superblocksBaseUrl,
|
|
535
501
|
token,
|
|
536
502
|
});
|
|
537
503
|
}
|
|
538
504
|
};
|
|
539
|
-
|
|
540
|
-
async function pushApplication({ cliVersion, applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders = {}, }) {
|
|
505
|
+
export async function pushApplication({ cliVersion, applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders = {}, }) {
|
|
541
506
|
const handleHttpError = (status) => {
|
|
542
507
|
if (status === 405) {
|
|
543
|
-
throw new
|
|
508
|
+
throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
544
509
|
}
|
|
545
510
|
else if (status === 409) {
|
|
546
|
-
throw new
|
|
511
|
+
throw new CommitAlreadyExistsError(`Commit ${applicationConfig.commitId} already exists`);
|
|
547
512
|
}
|
|
548
513
|
};
|
|
549
514
|
try {
|
|
550
|
-
const socket = await
|
|
515
|
+
const socket = await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl);
|
|
551
516
|
if (socket) {
|
|
552
517
|
const resp = await socket.call.v2.public.application.pushCommit({
|
|
553
518
|
applicationId,
|
|
@@ -582,11 +547,11 @@ async function pushApplication({ cliVersion, applicationId, token, superblocksBa
|
|
|
582
547
|
data: applicationConfig,
|
|
583
548
|
};
|
|
584
549
|
try {
|
|
585
|
-
const serverResponse = await (
|
|
550
|
+
const serverResponse = await axios(config);
|
|
586
551
|
return serverResponse?.data?.data;
|
|
587
552
|
}
|
|
588
553
|
catch (e) {
|
|
589
|
-
if (!
|
|
554
|
+
if (!axios.isAxiosError(e)) {
|
|
590
555
|
throw e;
|
|
591
556
|
}
|
|
592
557
|
handleHttpError(e.response?.data?.responseMeta?.status ?? e.response?.status);
|
|
@@ -598,26 +563,26 @@ async function pushApplication({ cliVersion, applicationId, token, superblocksBa
|
|
|
598
563
|
}
|
|
599
564
|
}
|
|
600
565
|
catch (e) {
|
|
601
|
-
if (e instanceof
|
|
602
|
-
e instanceof
|
|
566
|
+
if (e instanceof BranchNotCheckedOutError ||
|
|
567
|
+
e instanceof CommitAlreadyExistsError) {
|
|
603
568
|
// Rethrow these exceptions because they will be handled higher up the call stack
|
|
604
569
|
throw e;
|
|
605
570
|
}
|
|
606
571
|
throw new Error(`Could not push application ${e.message ? "\n" + e.message : ""}`);
|
|
607
572
|
}
|
|
608
573
|
}
|
|
609
|
-
async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders = {}, }) {
|
|
574
|
+
export async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders = {}, }) {
|
|
610
575
|
const handleHttpError = (status) => {
|
|
611
576
|
if (status === 405) {
|
|
612
|
-
throw new
|
|
577
|
+
throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
613
578
|
}
|
|
614
579
|
else if (status === 409) {
|
|
615
|
-
throw new
|
|
580
|
+
throw new CommitAlreadyExistsError(`Commit ${apiConfig.commitId} already exists`);
|
|
616
581
|
}
|
|
617
582
|
};
|
|
618
583
|
const serverURL = new URL(`${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(branch)}/push`, superblocksBaseUrl);
|
|
619
584
|
try {
|
|
620
|
-
const socket = await
|
|
585
|
+
const socket = await createSocketConnectionIfNeeded(cliVersion, token, superblocksBaseUrl);
|
|
621
586
|
if (socket) {
|
|
622
587
|
const resp = await socket.call.v1.public.api.pushCommit({
|
|
623
588
|
apiId,
|
|
@@ -649,11 +614,11 @@ async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig
|
|
|
649
614
|
data: apiConfig,
|
|
650
615
|
};
|
|
651
616
|
try {
|
|
652
|
-
const serverResponse = await (
|
|
617
|
+
const serverResponse = await axios(config);
|
|
653
618
|
return serverResponse?.data?.data;
|
|
654
619
|
}
|
|
655
620
|
catch (e) {
|
|
656
|
-
if (!
|
|
621
|
+
if (!axios.isAxiosError(e)) {
|
|
657
622
|
throw e;
|
|
658
623
|
}
|
|
659
624
|
handleHttpError(e.response?.data?.responseMeta?.status);
|
|
@@ -665,15 +630,15 @@ async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig
|
|
|
665
630
|
}
|
|
666
631
|
}
|
|
667
632
|
catch (e) {
|
|
668
|
-
if (e instanceof
|
|
669
|
-
e instanceof
|
|
633
|
+
if (e instanceof BranchNotCheckedOutError ||
|
|
634
|
+
e instanceof CommitAlreadyExistsError) {
|
|
670
635
|
// Rethrow these exceptions because they will be handled higher up the call stack
|
|
671
636
|
throw e;
|
|
672
637
|
}
|
|
673
638
|
throw new Error(`Could not push api ${e.message ? "\n" + e.message : ""}`);
|
|
674
639
|
}
|
|
675
640
|
}
|
|
676
|
-
async function fetchApplicationCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
641
|
+
export async function fetchApplicationCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
677
642
|
try {
|
|
678
643
|
const serverURL = branch
|
|
679
644
|
? new URL(`${BASE_SERVER_API_URL_V2}/applications/${applicationId}/branches/${encodeURIComponent(branch)}/commits`, superblocksBaseUrl)
|
|
@@ -692,17 +657,17 @@ async function fetchApplicationCommits({ cliVersion, applicationId, branch, toke
|
|
|
692
657
|
...injectedHeaders,
|
|
693
658
|
},
|
|
694
659
|
};
|
|
695
|
-
const serverResponse = await (
|
|
660
|
+
const serverResponse = await axios(config);
|
|
696
661
|
return serverResponse?.data?.data;
|
|
697
662
|
}
|
|
698
663
|
catch (e) {
|
|
699
|
-
if (
|
|
700
|
-
throw new
|
|
664
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
665
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
701
666
|
}
|
|
702
667
|
throw new Error("Could not fetch application");
|
|
703
668
|
}
|
|
704
669
|
}
|
|
705
|
-
async function fetchApiCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
670
|
+
export async function fetchApiCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
706
671
|
try {
|
|
707
672
|
const serverURL = branch
|
|
708
673
|
? new URL(`${BASE_SERVER_API_URL_V3}/apis/${applicationId}/branches/${encodeURIComponent(branch)}/commits`, superblocksBaseUrl)
|
|
@@ -721,20 +686,20 @@ async function fetchApiCommits({ cliVersion, applicationId, branch, token, super
|
|
|
721
686
|
...injectedHeaders,
|
|
722
687
|
},
|
|
723
688
|
};
|
|
724
|
-
const serverResponse = await (
|
|
689
|
+
const serverResponse = await axios(config);
|
|
725
690
|
return serverResponse?.data?.data;
|
|
726
691
|
}
|
|
727
692
|
catch (e) {
|
|
728
|
-
if (
|
|
729
|
-
throw new
|
|
693
|
+
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
694
|
+
throw new NotFoundError(`Application ${applicationId} was not found`);
|
|
730
695
|
}
|
|
731
696
|
throw new Error("Could not fetch application");
|
|
732
697
|
}
|
|
733
698
|
}
|
|
734
|
-
async function deployApplication(cliVersion, applicationId, token, superblocksBaseUrl, commitId) {
|
|
699
|
+
export async function deployApplication(cliVersion, applicationId, token, superblocksBaseUrl, commitId) {
|
|
735
700
|
return deployResource(cliVersion, ResourceType.APPLICATION, applicationId, token, superblocksBaseUrl, commitId);
|
|
736
701
|
}
|
|
737
|
-
async function deployApi(cliVersion, apiId, token, superblocksBaseUrl, commitId) {
|
|
702
|
+
export async function deployApi(cliVersion, apiId, token, superblocksBaseUrl, commitId) {
|
|
738
703
|
return deployResource(cliVersion, ResourceType.BACKEND, apiId, token, superblocksBaseUrl, commitId);
|
|
739
704
|
}
|
|
740
705
|
async function deployResource(cliVersion, resourceType, resourceId, token, superblocksBaseUrl, commitId) {
|
|
@@ -760,20 +725,20 @@ async function deployResource(cliVersion, resourceType, resourceId, token, super
|
|
|
760
725
|
commitId: commitId ?? "HEAD",
|
|
761
726
|
},
|
|
762
727
|
};
|
|
763
|
-
const serverResponse = await (
|
|
728
|
+
const serverResponse = await axios(config);
|
|
764
729
|
return serverResponse?.data?.data;
|
|
765
730
|
}
|
|
766
731
|
catch (e) {
|
|
767
732
|
let message;
|
|
768
|
-
if (
|
|
733
|
+
if (axios.isAxiosError(e)) {
|
|
769
734
|
if (e.response?.status === 404) {
|
|
770
|
-
throw new
|
|
735
|
+
throw new NotFoundError(`${e.response?.data?.responseMeta?.message}`);
|
|
771
736
|
}
|
|
772
737
|
else if (e.response?.status === 403) {
|
|
773
|
-
throw new
|
|
738
|
+
throw new ForbiddenError(`${e.response?.data?.responseMeta?.message}`);
|
|
774
739
|
}
|
|
775
740
|
else if (e.response?.status === 400) {
|
|
776
|
-
throw new
|
|
741
|
+
throw new BadRequestError(`${e.response?.data?.responseMeta?.message}`);
|
|
777
742
|
}
|
|
778
743
|
else {
|
|
779
744
|
message =
|
|
@@ -786,3 +751,20 @@ async function deployResource(cliVersion, resourceType, resourceId, token, super
|
|
|
786
751
|
throw new Error(`${e.message}`);
|
|
787
752
|
}
|
|
788
753
|
}
|
|
754
|
+
export async function uploadApplication({ files, scopedJwt, url, cliVersion, }) {
|
|
755
|
+
const fds = filesToFileDescriptors(files);
|
|
756
|
+
const bucketeer = new Bucketeer({
|
|
757
|
+
token: scopedJwt,
|
|
758
|
+
baseUrl: url,
|
|
759
|
+
cliVersion,
|
|
760
|
+
maxTotalFileSizeMB: SUPERBLOCKS_MAX_FILE_SIZE_MB,
|
|
761
|
+
});
|
|
762
|
+
await bucketeer.uploadApplication(fds);
|
|
763
|
+
}
|
|
764
|
+
function filesToFileDescriptors(files) {
|
|
765
|
+
const fds = files.map((file) => {
|
|
766
|
+
return new FileDescriptor(file, fs.createReadStream(file));
|
|
767
|
+
});
|
|
768
|
+
return fds;
|
|
769
|
+
}
|
|
770
|
+
//# sourceMappingURL=client.js.map
|