@superblocksteam/sdk 1.3.1 → 1.4.2
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/.eslintrc.json +1 -0
- package/dist/client.d.ts +36 -11
- package/dist/client.js +99 -41
- package/dist/sdk.d.ts +13 -4
- package/dist/sdk.js +27 -11
- package/package.json +2 -2
- package/src/client.ts +183 -36
- package/src/sdk.ts +63 -8
package/.eslintrc.json
CHANGED
package/dist/client.d.ts
CHANGED
|
@@ -14,6 +14,15 @@ export type PushApplicationWithCommitConfig = ApplicationWrapper & {
|
|
|
14
14
|
commitId: string;
|
|
15
15
|
commitMessage: string;
|
|
16
16
|
};
|
|
17
|
+
export interface ApiWrapper {
|
|
18
|
+
apiPb: Record<string, any>;
|
|
19
|
+
name?: string;
|
|
20
|
+
}
|
|
21
|
+
export type PushApiWithCommitConfig = {
|
|
22
|
+
apiPb: Record<string, any>;
|
|
23
|
+
commitId: string;
|
|
24
|
+
commitMessage: string;
|
|
25
|
+
};
|
|
17
26
|
export type Branches = {
|
|
18
27
|
branches: Branch[];
|
|
19
28
|
};
|
|
@@ -21,7 +30,8 @@ export type Branch = {
|
|
|
21
30
|
name: string;
|
|
22
31
|
isDefault: boolean;
|
|
23
32
|
};
|
|
24
|
-
export declare function fetchApplication({ applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders, }: {
|
|
33
|
+
export declare function fetchApplication({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders, }: {
|
|
34
|
+
cliVersion: string;
|
|
25
35
|
applicationId: string;
|
|
26
36
|
branch?: string;
|
|
27
37
|
token: string;
|
|
@@ -29,13 +39,15 @@ export declare function fetchApplication({ applicationId, branch, token, superbl
|
|
|
29
39
|
viewMode: ViewMode;
|
|
30
40
|
injectedHeaders: Record<string, string>;
|
|
31
41
|
}): Promise<ApplicationWrapper | undefined>;
|
|
32
|
-
export declare function fetchApplicationBranches({ applicationId, token, superblocksBaseUrl, injectedHeaders, }: {
|
|
42
|
+
export declare function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders, }: {
|
|
43
|
+
cliVersion: string;
|
|
33
44
|
applicationId: string;
|
|
34
45
|
token: string;
|
|
35
46
|
superblocksBaseUrl: string;
|
|
36
47
|
injectedHeaders: Record<string, string>;
|
|
37
48
|
}): Promise<Branches | undefined>;
|
|
38
|
-
export declare function fetchApplicationWithComponents({ applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders, }: {
|
|
49
|
+
export declare function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders, }: {
|
|
50
|
+
cliVersion: string;
|
|
39
51
|
applicationId: string;
|
|
40
52
|
branch: string;
|
|
41
53
|
token: string;
|
|
@@ -45,14 +57,15 @@ export declare function fetchApplicationWithComponents({ applicationId, branch,
|
|
|
45
57
|
}): Promise<(ApplicationWrapper & {
|
|
46
58
|
componentFiles: any;
|
|
47
59
|
}) | undefined>;
|
|
48
|
-
export declare function fetchApplications(token: string, superblocksBaseUrl: string, injectedHeaders?: Record<string, string>): Promise<any>;
|
|
49
|
-
export declare function fetchApi(apiId: string, token: string, superblocksBaseUrl: string, viewMode: ViewMode): Promise<any>;
|
|
50
|
-
export declare function fetchApis(token: string, superblocksBaseUrl: string): Promise<any>;
|
|
51
|
-
export declare function validateGitSetup(resourceId: string, resourceType:
|
|
60
|
+
export declare function fetchApplications(cliVersion: string, token: string, superblocksBaseUrl: string, injectedHeaders?: Record<string, string>): Promise<any>;
|
|
61
|
+
export declare function fetchApi(cliVersion: string, apiId: string, token: string, superblocksBaseUrl: string, viewMode: ViewMode, branch?: string): Promise<any>;
|
|
62
|
+
export declare function fetchApis(cliVersion: string, token: string, superblocksBaseUrl: string): Promise<any>;
|
|
63
|
+
export declare function validateGitSetup(cliVersion: string, resourceId: string, resourceType: SuperblocksResourceType, event: ComponentEvent, localGitRepoState: LocalGitRepoState, token: string, superblocksBaseUrl: string, injectedHeaders?: Record<string, string>): Promise<{
|
|
52
64
|
branchName: string | null;
|
|
53
65
|
}>;
|
|
54
|
-
export declare function registerComponents(applicationId: string, componentConfigs: Record<string, any>, token: string, superblocksBaseUrl: string, branch: string | null, injectedHeaders?: Record<string, string>): Promise<any>;
|
|
55
|
-
export declare function uploadComponents({ applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }: {
|
|
66
|
+
export declare function registerComponents(cliVersion: string, applicationId: string, componentConfigs: Record<string, any>, token: string, superblocksBaseUrl: string, branch: string | null, injectedHeaders?: Record<string, string>): Promise<any>;
|
|
67
|
+
export declare function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }: {
|
|
68
|
+
cliVersion: string;
|
|
56
69
|
applicationId: string;
|
|
57
70
|
componentConfigs: Record<string, any>;
|
|
58
71
|
files: string[];
|
|
@@ -60,8 +73,9 @@ export declare function uploadComponents({ applicationId, componentConfigs, file
|
|
|
60
73
|
superblocksBaseUrl: string;
|
|
61
74
|
branch: string | null;
|
|
62
75
|
}): Promise<any>;
|
|
63
|
-
export declare function fetchCurrentUser(token: string, superblocksBaseUrl: string): Promise<any>;
|
|
64
|
-
export declare function pushApplication({ applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders, }: {
|
|
76
|
+
export declare function fetchCurrentUser(cliVersion: string, token: string, superblocksBaseUrl: string): Promise<any>;
|
|
77
|
+
export declare function pushApplication({ cliVersion, applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders, }: {
|
|
78
|
+
cliVersion: string;
|
|
65
79
|
applicationId: string;
|
|
66
80
|
token: string;
|
|
67
81
|
superblocksBaseUrl: string;
|
|
@@ -69,3 +83,14 @@ export declare function pushApplication({ applicationId, token, superblocksBaseU
|
|
|
69
83
|
injectedHeaders: Record<string, string>;
|
|
70
84
|
applicationConfig: PushApplicationWithCommitConfig;
|
|
71
85
|
}): Promise<ApplicationWrapper | undefined>;
|
|
86
|
+
export declare function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders, }: {
|
|
87
|
+
cliVersion: string;
|
|
88
|
+
apiId: string;
|
|
89
|
+
token: string;
|
|
90
|
+
superblocksBaseUrl: string;
|
|
91
|
+
apiConfig: PushApiWithCommitConfig;
|
|
92
|
+
branch: string;
|
|
93
|
+
injectedHeaders: Record<string, string>;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
commitId: string;
|
|
96
|
+
} | undefined>;
|
package/dist/client.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pushApplication = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = exports.validateGitSetup = exports.fetchApis = exports.fetchApi = exports.fetchApplications = exports.fetchApplicationWithComponents = exports.fetchApplicationBranches = exports.fetchApplication = void 0;
|
|
3
|
+
exports.pushApi = exports.pushApplication = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = exports.validateGitSetup = exports.fetchApis = exports.fetchApi = exports.fetchApplications = exports.fetchApplicationWithComponents = exports.fetchApplicationBranches = exports.fetchApplication = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const util_1 = require("@superblocksteam/util");
|
|
6
6
|
const axios_1 = require("axios");
|
|
7
7
|
const FormData = require("form-data");
|
|
8
8
|
const lodash_1 = require("lodash");
|
|
9
9
|
const errors_1 = require("./errors");
|
|
10
|
-
const BASE_SERVER_URL = "api/v1";
|
|
11
10
|
const BASE_BUCKETEER_URL = "api/v1";
|
|
11
|
+
const BASE_SERVER_PUBLIC_API_URL = "api/v1/public";
|
|
12
12
|
const SUPERBLOCKS_MAX_FILE_SIZE_MB = 10;
|
|
13
13
|
const CLI_VERSION_HEADER = "x-superblocks-cli-version";
|
|
14
14
|
const SUPERBLOCKS_URL_HEADER = "x-superblocks-url";
|
|
15
|
-
async function fetchApplication({ applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders = {}, }) {
|
|
15
|
+
async function fetchApplication({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders = {}, }) {
|
|
16
16
|
var _a, _b;
|
|
17
17
|
const serverURL = branch
|
|
18
|
-
? new URL(
|
|
19
|
-
: new URL(
|
|
18
|
+
? new URL(`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}/branches/${encodeURIComponent(branch)}?viewMode=${viewMode}`, superblocksBaseUrl)
|
|
19
|
+
: new URL(`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}?viewMode=${viewMode}`, superblocksBaseUrl);
|
|
20
20
|
let serverResponse;
|
|
21
21
|
try {
|
|
22
22
|
const config = {
|
|
@@ -24,6 +24,7 @@ async function fetchApplication({ applicationId, branch, token, superblocksBaseU
|
|
|
24
24
|
url: serverURL.toString(),
|
|
25
25
|
headers: {
|
|
26
26
|
Authorization: "Bearer " + token,
|
|
27
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
27
28
|
...injectedHeaders,
|
|
28
29
|
},
|
|
29
30
|
};
|
|
@@ -38,9 +39,9 @@ async function fetchApplication({ applicationId, branch, token, superblocksBaseU
|
|
|
38
39
|
return (_b = serverResponse === null || serverResponse === void 0 ? void 0 : serverResponse.data) === null || _b === void 0 ? void 0 : _b.data;
|
|
39
40
|
}
|
|
40
41
|
exports.fetchApplication = fetchApplication;
|
|
41
|
-
async function fetchApplicationBranches({ applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
|
|
42
|
+
async function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
|
|
42
43
|
var _a, _b;
|
|
43
|
-
const serverURL = new URL(`
|
|
44
|
+
const serverURL = new URL(`public/applications/${applicationId}/branches`, superblocksBaseUrl);
|
|
44
45
|
let serverResponse;
|
|
45
46
|
try {
|
|
46
47
|
const config = {
|
|
@@ -48,6 +49,7 @@ async function fetchApplicationBranches({ applicationId, token, superblocksBaseU
|
|
|
48
49
|
url: serverURL.toString(),
|
|
49
50
|
headers: {
|
|
50
51
|
Authorization: "Bearer " + token,
|
|
52
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
51
53
|
...injectedHeaders,
|
|
52
54
|
},
|
|
53
55
|
};
|
|
@@ -62,9 +64,10 @@ async function fetchApplicationBranches({ applicationId, token, superblocksBaseU
|
|
|
62
64
|
return (_b = serverResponse === null || serverResponse === void 0 ? void 0 : serverResponse.data) === null || _b === void 0 ? void 0 : _b.data;
|
|
63
65
|
}
|
|
64
66
|
exports.fetchApplicationBranches = fetchApplicationBranches;
|
|
65
|
-
async function fetchApplicationWithComponents({ applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders = {}, }) {
|
|
67
|
+
async function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders = {}, }) {
|
|
66
68
|
var _a, _b, _c;
|
|
67
69
|
const applicationWrapper = await fetchApplication({
|
|
70
|
+
cliVersion,
|
|
68
71
|
applicationId,
|
|
69
72
|
branch,
|
|
70
73
|
token,
|
|
@@ -110,13 +113,15 @@ async function fetchApplicationWithComponents({ applicationId, branch, token, su
|
|
|
110
113
|
}
|
|
111
114
|
}
|
|
112
115
|
exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
|
|
113
|
-
async function fetchApplications(token, superblocksBaseUrl, injectedHeaders = {}) {
|
|
116
|
+
async function fetchApplications(cliVersion, token, superblocksBaseUrl, injectedHeaders = {}) {
|
|
117
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
114
118
|
try {
|
|
115
119
|
const config = {
|
|
116
120
|
method: "get",
|
|
117
|
-
url: new URL(
|
|
121
|
+
url: new URL(`${BASE_SERVER_PUBLIC_API_URL}/applications`, superblocksBaseUrl).toString(),
|
|
118
122
|
headers: {
|
|
119
123
|
Authorization: "Bearer " + token,
|
|
124
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
120
125
|
...injectedHeaders,
|
|
121
126
|
},
|
|
122
127
|
};
|
|
@@ -124,18 +129,30 @@ async function fetchApplications(token, superblocksBaseUrl, injectedHeaders = {}
|
|
|
124
129
|
return response.data.data.applications;
|
|
125
130
|
}
|
|
126
131
|
catch (e) {
|
|
127
|
-
|
|
132
|
+
let message;
|
|
133
|
+
if (e instanceof axios_1.AxiosError) {
|
|
134
|
+
message =
|
|
135
|
+
(_j = (_h = (_f = (_d = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : JSON.stringify((_e = e.response) === null || _e === void 0 ? void 0 : _e.data)) !== null && _f !== void 0 ? _f : (_g = e.response) === null || _g === void 0 ? void 0 : _g.statusText) !== null && _h !== void 0 ? _h : e === null || e === void 0 ? void 0 : e.message) !== null && _j !== void 0 ? _j : `${e}`;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
message = `${(e === null || e === void 0 ? void 0 : e.message) ? e === null || e === void 0 ? void 0 : e.message : e}`;
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`Could not fetch applications: ${message}`);
|
|
128
141
|
}
|
|
129
142
|
}
|
|
130
143
|
exports.fetchApplications = fetchApplications;
|
|
131
|
-
async function fetchApi(apiId, token, superblocksBaseUrl, viewMode) {
|
|
144
|
+
async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode, branch) {
|
|
132
145
|
var _a;
|
|
133
146
|
try {
|
|
147
|
+
const serverURL = branch
|
|
148
|
+
? new URL(`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}/branches/${encodeURIComponent(branch)}?viewMode=${viewMode}`, superblocksBaseUrl)
|
|
149
|
+
: new URL(`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}?viewMode=${viewMode}`, superblocksBaseUrl);
|
|
134
150
|
const config = {
|
|
135
151
|
method: "get",
|
|
136
|
-
url: new URL(
|
|
152
|
+
url: new URL(serverURL, superblocksBaseUrl).toString(),
|
|
137
153
|
headers: {
|
|
138
154
|
Authorization: "Bearer " + token,
|
|
155
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
139
156
|
},
|
|
140
157
|
};
|
|
141
158
|
const response = await (0, axios_1.default)(config);
|
|
@@ -149,30 +166,28 @@ async function fetchApi(apiId, token, superblocksBaseUrl, viewMode) {
|
|
|
149
166
|
}
|
|
150
167
|
}
|
|
151
168
|
exports.fetchApi = fetchApi;
|
|
152
|
-
async function fetchApis(token, superblocksBaseUrl) {
|
|
169
|
+
async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
153
170
|
try {
|
|
154
171
|
const config = {
|
|
155
172
|
method: "get",
|
|
156
|
-
url: new URL(
|
|
173
|
+
url: new URL(`${BASE_SERVER_PUBLIC_API_URL}/apis`, superblocksBaseUrl).toString(),
|
|
157
174
|
headers: {
|
|
158
175
|
Authorization: "Bearer " + token,
|
|
176
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
159
177
|
},
|
|
160
178
|
};
|
|
161
179
|
const response = await (0, axios_1.default)(config);
|
|
162
|
-
return response.data.data;
|
|
180
|
+
return response.data.data.apis;
|
|
163
181
|
}
|
|
164
182
|
catch (e) {
|
|
165
183
|
throw new Error("Could not fetch apis");
|
|
166
184
|
}
|
|
167
185
|
}
|
|
168
186
|
exports.fetchApis = fetchApis;
|
|
169
|
-
async function validateGitSetup(resourceId,
|
|
170
|
-
// TODO: change the type to `SuperblocksResourceType` once we support other resource types
|
|
171
|
-
resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
|
|
187
|
+
async function validateGitSetup(cliVersion, resourceId, resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
|
|
172
188
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
173
189
|
let resourceName;
|
|
174
190
|
try {
|
|
175
|
-
const [rootSettings] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
176
191
|
const requestBody = {
|
|
177
192
|
event,
|
|
178
193
|
gitState: localGitRepoState,
|
|
@@ -180,7 +195,11 @@ resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeade
|
|
|
180
195
|
let path;
|
|
181
196
|
switch (resourceType) {
|
|
182
197
|
case "APPLICATION": {
|
|
183
|
-
path = `/
|
|
198
|
+
path = `/application/${resourceId}/validate-git-setup`;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "BACKEND": {
|
|
202
|
+
path = `/api/${resourceId}/validate-git-setup`;
|
|
184
203
|
break;
|
|
185
204
|
}
|
|
186
205
|
default:
|
|
@@ -188,10 +207,10 @@ resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeade
|
|
|
188
207
|
}
|
|
189
208
|
const config = {
|
|
190
209
|
method: "post",
|
|
191
|
-
url: new URL(`${
|
|
210
|
+
url: new URL(`${BASE_SERVER_PUBLIC_API_URL}/${path}`, superblocksBaseUrl).toString(),
|
|
192
211
|
headers: {
|
|
193
212
|
Authorization: "Bearer " + token,
|
|
194
|
-
[CLI_VERSION_HEADER]:
|
|
213
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
195
214
|
...injectedHeaders,
|
|
196
215
|
},
|
|
197
216
|
data: requestBody,
|
|
@@ -221,17 +240,16 @@ resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeade
|
|
|
221
240
|
}
|
|
222
241
|
}
|
|
223
242
|
exports.validateGitSetup = validateGitSetup;
|
|
224
|
-
async function registerComponents(applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
|
|
243
|
+
async function registerComponents(cliVersion, applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
|
|
225
244
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
226
245
|
try {
|
|
227
|
-
const [rootSettings] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
228
246
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
229
247
|
const config = {
|
|
230
248
|
method: "put",
|
|
231
|
-
url: new URL(`${
|
|
249
|
+
url: new URL(`${BASE_SERVER_PUBLIC_API_URL}/application/${applicationId}${branchPath}/components`, superblocksBaseUrl).toString(),
|
|
232
250
|
headers: {
|
|
233
251
|
Authorization: "Bearer " + token,
|
|
234
|
-
[CLI_VERSION_HEADER]:
|
|
252
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
235
253
|
...injectedHeaders,
|
|
236
254
|
},
|
|
237
255
|
data: { components: componentConfigs },
|
|
@@ -248,7 +266,7 @@ async function registerComponents(applicationId, componentConfigs, token, superb
|
|
|
248
266
|
}
|
|
249
267
|
}
|
|
250
268
|
exports.registerComponents = registerComponents;
|
|
251
|
-
async function uploadComponents({ applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
|
|
269
|
+
async function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
|
|
252
270
|
var _a, _b, _c, _d, _e, _f;
|
|
253
271
|
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
254
272
|
const bucketeerBaseUrl = (0, util_1.getBucketeerUrlFromSuperblocksUrl)(superblocksBaseUrl);
|
|
@@ -293,11 +311,10 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
293
311
|
}
|
|
294
312
|
const formHeaders = formData.getHeaders();
|
|
295
313
|
try {
|
|
296
|
-
const [rootSettings] = await (0, util_1.getSuperblocksMonorepoConfigJson)(true);
|
|
297
314
|
const config = {
|
|
298
315
|
headers: {
|
|
299
316
|
Authorization: "Bearer " + token,
|
|
300
|
-
[CLI_VERSION_HEADER]:
|
|
317
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
301
318
|
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.UPLOAD,
|
|
302
319
|
[SUPERBLOCKS_URL_HEADER]: superblocksBaseUrl,
|
|
303
320
|
...formHeaders,
|
|
@@ -313,10 +330,9 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
313
330
|
else {
|
|
314
331
|
let message;
|
|
315
332
|
if (e instanceof axios_1.AxiosError) {
|
|
316
|
-
message =
|
|
317
|
-
((
|
|
318
|
-
|
|
319
|
-
((_f = e.response) === null || _f === void 0 ? void 0 : _f.statusText);
|
|
333
|
+
message = (((_d = (_c = (_b = e.response) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.responseMeta) === null || _d === void 0 ? void 0 : _d.message) ||
|
|
334
|
+
((_e = e.response) === null || _e === void 0 ? void 0 : _e.data) ||
|
|
335
|
+
((_f = e.response) === null || _f === void 0 ? void 0 : _f.statusText));
|
|
320
336
|
}
|
|
321
337
|
else {
|
|
322
338
|
message = e.message;
|
|
@@ -329,13 +345,15 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
329
345
|
}
|
|
330
346
|
}
|
|
331
347
|
exports.uploadComponents = uploadComponents;
|
|
332
|
-
async function fetchCurrentUser(token, superblocksBaseUrl) {
|
|
348
|
+
async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
349
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
333
350
|
try {
|
|
334
351
|
const config = {
|
|
335
352
|
method: "get",
|
|
336
|
-
url: new URL(
|
|
353
|
+
url: new URL(`${BASE_SERVER_PUBLIC_API_URL}/users/me`, superblocksBaseUrl).toString(),
|
|
337
354
|
headers: {
|
|
338
355
|
Authorization: "Bearer " + token,
|
|
356
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
339
357
|
[util_1.COMPONENT_EVENT_HEADER]: util_1.ComponentEvent.LOGIN,
|
|
340
358
|
},
|
|
341
359
|
};
|
|
@@ -343,14 +361,21 @@ async function fetchCurrentUser(token, superblocksBaseUrl) {
|
|
|
343
361
|
return response.data.data.user;
|
|
344
362
|
}
|
|
345
363
|
catch (e) {
|
|
346
|
-
|
|
364
|
+
let message;
|
|
365
|
+
if (e instanceof axios_1.AxiosError) {
|
|
366
|
+
message =
|
|
367
|
+
(_j = (_h = (_f = (_d = (_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.message) !== null && _d !== void 0 ? _d : JSON.stringify((_e = e.response) === null || _e === void 0 ? void 0 : _e.data)) !== null && _f !== void 0 ? _f : (_g = e.response) === null || _g === void 0 ? void 0 : _g.statusText) !== null && _h !== void 0 ? _h : e === null || e === void 0 ? void 0 : e.message) !== null && _j !== void 0 ? _j : `${e}`;
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
message = `${(e === null || e === void 0 ? void 0 : e.message) ? e === null || e === void 0 ? void 0 : e.message : e}`;
|
|
371
|
+
}
|
|
372
|
+
throw new Error(`Could not fetch current user: ${message}`);
|
|
347
373
|
}
|
|
348
374
|
}
|
|
349
375
|
exports.fetchCurrentUser = fetchCurrentUser;
|
|
350
|
-
async function pushApplication({ applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders = {}, }) {
|
|
376
|
+
async function pushApplication({ cliVersion, applicationId, token, superblocksBaseUrl, applicationConfig, branch, injectedHeaders = {}, }) {
|
|
351
377
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
352
|
-
const
|
|
353
|
-
const serverURL = new URL(`${BASE_SERVER_URL}/public/applications/${applicationId}/branches/${encodeURIComponent(branch)}/push`, superblocksBaseUrl);
|
|
378
|
+
const serverURL = new URL(`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}/branches/${encodeURIComponent(branch)}/push`, superblocksBaseUrl);
|
|
354
379
|
let serverResponse;
|
|
355
380
|
try {
|
|
356
381
|
const config = {
|
|
@@ -358,7 +383,7 @@ async function pushApplication({ applicationId, token, superblocksBaseUrl, appli
|
|
|
358
383
|
url: serverURL.toString(),
|
|
359
384
|
headers: {
|
|
360
385
|
Authorization: "Bearer " + token,
|
|
361
|
-
[CLI_VERSION_HEADER]:
|
|
386
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
362
387
|
...injectedHeaders,
|
|
363
388
|
},
|
|
364
389
|
data: applicationConfig,
|
|
@@ -382,3 +407,36 @@ async function pushApplication({ applicationId, token, superblocksBaseUrl, appli
|
|
|
382
407
|
return (_o = serverResponse === null || serverResponse === void 0 ? void 0 : serverResponse.data) === null || _o === void 0 ? void 0 : _o.data;
|
|
383
408
|
}
|
|
384
409
|
exports.pushApplication = pushApplication;
|
|
410
|
+
async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders = {}, }) {
|
|
411
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
412
|
+
const serverURL = new URL(`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}/branches/${encodeURIComponent(branch)}/push`, superblocksBaseUrl);
|
|
413
|
+
let serverResponse;
|
|
414
|
+
try {
|
|
415
|
+
const config = {
|
|
416
|
+
method: "post",
|
|
417
|
+
url: serverURL.toString(),
|
|
418
|
+
headers: {
|
|
419
|
+
Authorization: "Bearer " + token,
|
|
420
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
421
|
+
...injectedHeaders,
|
|
422
|
+
},
|
|
423
|
+
data: apiConfig,
|
|
424
|
+
};
|
|
425
|
+
serverResponse = await (0, axios_1.default)(config);
|
|
426
|
+
}
|
|
427
|
+
catch (e) {
|
|
428
|
+
if (axios_1.default.isAxiosError(e)) {
|
|
429
|
+
if (((_c = (_b = (_a = e.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.responseMeta) === null || _c === void 0 ? void 0 : _c.status) === 405) {
|
|
430
|
+
throw new errors_1.BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
431
|
+
}
|
|
432
|
+
else if (((_f = (_e = (_d = e.response) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.responseMeta) === null || _f === void 0 ? void 0 : _f.status) === 409) {
|
|
433
|
+
throw new errors_1.CommitAlreadyExistsError(`Commit ${apiConfig.commitId} already exists`);
|
|
434
|
+
}
|
|
435
|
+
const message = (_m = (_k = (_j = (_h = (_g = e.response) === null || _g === void 0 ? void 0 : _g.data) === null || _h === void 0 ? void 0 : _h.responseMeta) === null || _j === void 0 ? void 0 : _j.message) !== null && _k !== void 0 ? _k : JSON.stringify((_l = e.response) === null || _l === void 0 ? void 0 : _l.data)) !== null && _m !== void 0 ? _m : (_o = e.response) === null || _o === void 0 ? void 0 : _o.statusText;
|
|
436
|
+
throw new Error(`Could not push api ${message ? "\n" + message : ""}`);
|
|
437
|
+
}
|
|
438
|
+
throw new Error(`Could not push api ${e.message ? "\n" + e.message : ""}`);
|
|
439
|
+
}
|
|
440
|
+
return (_p = serverResponse === null || serverResponse === void 0 ? void 0 : serverResponse.data) === null || _p === void 0 ? void 0 : _p.data;
|
|
441
|
+
}
|
|
442
|
+
exports.pushApi = pushApi;
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ComponentEvent, LocalGitRepoState, SuperblocksResourceType } from "@superblocksteam/util";
|
|
2
|
-
import { ViewMode, PushApplicationWithCommitConfig } from "./client";
|
|
2
|
+
import { ViewMode, PushApplicationWithCommitConfig, PushApiWithCommitConfig } from "./client";
|
|
3
3
|
export * from "./errors";
|
|
4
4
|
export declare class SuperblocksSdk {
|
|
5
5
|
token: string;
|
|
6
6
|
superblocksBaseUrl: string;
|
|
7
|
-
|
|
7
|
+
cliVersion: string;
|
|
8
|
+
constructor(accessToken: string, superblocksBaseUrl: string, cliVersion: string);
|
|
8
9
|
fetchApplication({ applicationId, branch, headers, viewMode, }: {
|
|
9
10
|
applicationId: string;
|
|
10
11
|
branch?: string;
|
|
@@ -21,9 +22,9 @@ export declare class SuperblocksSdk {
|
|
|
21
22
|
componentFiles: any;
|
|
22
23
|
}) | undefined>;
|
|
23
24
|
fetchApplications(headers?: Record<string, string>): Promise<any>;
|
|
24
|
-
fetchApi(apiId: string, viewMode?: ViewMode): Promise<any>;
|
|
25
|
+
fetchApi(apiId: string, viewMode?: ViewMode, branch?: string): Promise<any>;
|
|
25
26
|
fetchApis(): Promise<any>;
|
|
26
|
-
validateGitSetup(resourceId: string, resourceType:
|
|
27
|
+
validateGitSetup(resourceId: string, resourceType: SuperblocksResourceType, event: ComponentEvent, localGitRepoState: LocalGitRepoState, injectedHeaders?: Record<string, string>): Promise<{
|
|
27
28
|
branchName: string | null;
|
|
28
29
|
}>;
|
|
29
30
|
registerComponents(applicationId: string, componentConfigs: Record<string, any>, branch: string | null, injectedHeaders?: Record<string, string>): Promise<any>;
|
|
@@ -35,4 +36,12 @@ export declare class SuperblocksSdk {
|
|
|
35
36
|
branch: string;
|
|
36
37
|
headers?: Record<string, string>;
|
|
37
38
|
}): Promise<import("./client").ApplicationWrapper | undefined>;
|
|
39
|
+
pushApi({ apiId, apiConfig, branch, headers, }: {
|
|
40
|
+
apiId: string;
|
|
41
|
+
apiConfig: PushApiWithCommitConfig;
|
|
42
|
+
branch: string;
|
|
43
|
+
headers?: Record<string, string>;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
commitId: string;
|
|
46
|
+
} | undefined>;
|
|
38
47
|
}
|
package/dist/sdk.js
CHANGED
|
@@ -6,14 +6,17 @@ const client_1 = require("./client");
|
|
|
6
6
|
// Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
|
|
7
7
|
tslib_1.__exportStar(require("./errors"), exports);
|
|
8
8
|
class SuperblocksSdk {
|
|
9
|
-
constructor(accessToken, superblocksBaseUrl) {
|
|
9
|
+
constructor(accessToken, superblocksBaseUrl, cliVersion) {
|
|
10
10
|
this.token = "";
|
|
11
11
|
this.superblocksBaseUrl = "";
|
|
12
|
+
this.cliVersion = "";
|
|
12
13
|
this.token = accessToken;
|
|
13
14
|
this.superblocksBaseUrl = superblocksBaseUrl;
|
|
15
|
+
this.cliVersion = cliVersion;
|
|
14
16
|
}
|
|
15
17
|
async fetchApplication({ applicationId, branch, headers = {}, viewMode = "export-live", }) {
|
|
16
18
|
return (0, client_1.fetchApplication)({
|
|
19
|
+
cliVersion: this.cliVersion,
|
|
17
20
|
applicationId,
|
|
18
21
|
branch,
|
|
19
22
|
token: this.token,
|
|
@@ -24,6 +27,7 @@ class SuperblocksSdk {
|
|
|
24
27
|
}
|
|
25
28
|
async fetchApplicationBranches(applicationId, headers = {}) {
|
|
26
29
|
return (0, client_1.fetchApplicationBranches)({
|
|
30
|
+
cliVersion: this.cliVersion,
|
|
27
31
|
applicationId,
|
|
28
32
|
token: this.token,
|
|
29
33
|
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
@@ -32,6 +36,7 @@ class SuperblocksSdk {
|
|
|
32
36
|
}
|
|
33
37
|
async fetchApplicationWithComponents({ applicationId, branch, headers = {}, viewMode = "export-live", }) {
|
|
34
38
|
return (0, client_1.fetchApplicationWithComponents)({
|
|
39
|
+
cliVersion: this.cliVersion,
|
|
35
40
|
applicationId,
|
|
36
41
|
branch,
|
|
37
42
|
token: this.token,
|
|
@@ -41,24 +46,23 @@ class SuperblocksSdk {
|
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
48
|
async fetchApplications(headers) {
|
|
44
|
-
return (0, client_1.fetchApplications)(this.token, this.superblocksBaseUrl, headers);
|
|
49
|
+
return (0, client_1.fetchApplications)(this.cliVersion, this.token, this.superblocksBaseUrl, headers);
|
|
45
50
|
}
|
|
46
|
-
async fetchApi(apiId, viewMode = "export-live") {
|
|
47
|
-
return (0, client_1.fetchApi)(apiId, this.token, this.superblocksBaseUrl, viewMode);
|
|
51
|
+
async fetchApi(apiId, viewMode = "export-live", branch) {
|
|
52
|
+
return (0, client_1.fetchApi)(this.cliVersion, apiId, this.token, this.superblocksBaseUrl, viewMode, branch);
|
|
48
53
|
}
|
|
49
54
|
async fetchApis() {
|
|
50
|
-
return (0, client_1.fetchApis)(this.token, this.superblocksBaseUrl);
|
|
55
|
+
return (0, client_1.fetchApis)(this.cliVersion, this.token, this.superblocksBaseUrl);
|
|
51
56
|
}
|
|
52
|
-
async validateGitSetup(resourceId,
|
|
53
|
-
|
|
54
|
-
resourceType, event, localGitRepoState, injectedHeaders) {
|
|
55
|
-
return (0, client_1.validateGitSetup)(resourceId, resourceType, event, localGitRepoState, this.token, this.superblocksBaseUrl, injectedHeaders);
|
|
57
|
+
async validateGitSetup(resourceId, resourceType, event, localGitRepoState, injectedHeaders) {
|
|
58
|
+
return (0, client_1.validateGitSetup)(this.cliVersion, resourceId, resourceType, event, localGitRepoState, this.token, this.superblocksBaseUrl, injectedHeaders);
|
|
56
59
|
}
|
|
57
60
|
async registerComponents(applicationId, componentConfigs, branch, injectedHeaders) {
|
|
58
|
-
return (0, client_1.registerComponents)(applicationId, componentConfigs, this.token, this.superblocksBaseUrl, branch, injectedHeaders);
|
|
61
|
+
return (0, client_1.registerComponents)(this.cliVersion, applicationId, componentConfigs, this.token, this.superblocksBaseUrl, branch, injectedHeaders);
|
|
59
62
|
}
|
|
60
63
|
async uploadComponents(applicationId, componentConfigs, files, branch) {
|
|
61
64
|
return (0, client_1.uploadComponents)({
|
|
65
|
+
cliVersion: this.cliVersion,
|
|
62
66
|
applicationId,
|
|
63
67
|
componentConfigs,
|
|
64
68
|
files,
|
|
@@ -68,10 +72,11 @@ class SuperblocksSdk {
|
|
|
68
72
|
});
|
|
69
73
|
}
|
|
70
74
|
async fetchCurrentUser() {
|
|
71
|
-
return (0, client_1.fetchCurrentUser)(this.token, this.superblocksBaseUrl);
|
|
75
|
+
return (0, client_1.fetchCurrentUser)(this.cliVersion, this.token, this.superblocksBaseUrl);
|
|
72
76
|
}
|
|
73
77
|
async pushApplication({ applicationId, applicationConfig, branch, headers = {}, }) {
|
|
74
78
|
return (0, client_1.pushApplication)({
|
|
79
|
+
cliVersion: this.cliVersion,
|
|
75
80
|
applicationId,
|
|
76
81
|
token: this.token,
|
|
77
82
|
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
@@ -80,5 +85,16 @@ class SuperblocksSdk {
|
|
|
80
85
|
applicationConfig,
|
|
81
86
|
});
|
|
82
87
|
}
|
|
88
|
+
async pushApi({ apiId, apiConfig, branch, headers = {}, }) {
|
|
89
|
+
return (0, client_1.pushApi)({
|
|
90
|
+
cliVersion: this.cliVersion,
|
|
91
|
+
apiId,
|
|
92
|
+
apiConfig,
|
|
93
|
+
token: this.token,
|
|
94
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
95
|
+
branch,
|
|
96
|
+
injectedHeaders: headers,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
83
99
|
}
|
|
84
100
|
exports.SuperblocksSdk = SuperblocksSdk;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Superblocks JS SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"typescript": "^5.1.3"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@superblocksteam/util": "1.
|
|
33
|
+
"@superblocksteam/util": "1.4.2",
|
|
34
34
|
"axios": "^1.3.5"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://www.superblocks.com",
|
package/src/client.ts
CHANGED
|
@@ -2,7 +2,6 @@ import * as fs from "fs";
|
|
|
2
2
|
import {
|
|
3
3
|
ComponentEvent,
|
|
4
4
|
getBucketeerUrlFromSuperblocksUrl,
|
|
5
|
-
getSuperblocksMonorepoConfigJson,
|
|
6
5
|
getContentType,
|
|
7
6
|
COMPONENT_EVENT_HEADER,
|
|
8
7
|
NotFoundError,
|
|
@@ -16,8 +15,8 @@ import * as FormData from "form-data";
|
|
|
16
15
|
import { isEmpty } from "lodash";
|
|
17
16
|
import { BranchNotCheckedOutError, CommitAlreadyExistsError } from "./errors";
|
|
18
17
|
|
|
19
|
-
const BASE_SERVER_URL = "api/v1";
|
|
20
18
|
const BASE_BUCKETEER_URL = "api/v1";
|
|
19
|
+
const BASE_SERVER_PUBLIC_API_URL = "api/v1/public";
|
|
21
20
|
|
|
22
21
|
const SUPERBLOCKS_MAX_FILE_SIZE_MB = 10;
|
|
23
22
|
|
|
@@ -43,6 +42,17 @@ export type PushApplicationWithCommitConfig = ApplicationWrapper & {
|
|
|
43
42
|
commitMessage: string;
|
|
44
43
|
};
|
|
45
44
|
|
|
45
|
+
export interface ApiWrapper {
|
|
46
|
+
apiPb: Record<string, any>;
|
|
47
|
+
name?: string; //@deprecated this attribute is used for getting a name for backends(jobs and workflows) that were never migrated to the new API version.
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type PushApiWithCommitConfig = {
|
|
51
|
+
apiPb: Record<string, any>;
|
|
52
|
+
commitId: string;
|
|
53
|
+
commitMessage: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
46
56
|
export type Branches = {
|
|
47
57
|
branches: Branch[];
|
|
48
58
|
};
|
|
@@ -55,6 +65,7 @@ export type Branch = {
|
|
|
55
65
|
type ResponseWithMeta<T> = { responseMeta: unknown; data: T };
|
|
56
66
|
|
|
57
67
|
export async function fetchApplication({
|
|
68
|
+
cliVersion,
|
|
58
69
|
applicationId,
|
|
59
70
|
branch,
|
|
60
71
|
token,
|
|
@@ -62,6 +73,7 @@ export async function fetchApplication({
|
|
|
62
73
|
viewMode,
|
|
63
74
|
injectedHeaders = {},
|
|
64
75
|
}: {
|
|
76
|
+
cliVersion: string;
|
|
65
77
|
applicationId: string;
|
|
66
78
|
branch?: string;
|
|
67
79
|
token: string;
|
|
@@ -71,11 +83,13 @@ export async function fetchApplication({
|
|
|
71
83
|
}): Promise<ApplicationWrapper | undefined> {
|
|
72
84
|
const serverURL = branch
|
|
73
85
|
? new URL(
|
|
74
|
-
|
|
86
|
+
`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}/branches/${encodeURIComponent(
|
|
87
|
+
branch
|
|
88
|
+
)}?viewMode=${viewMode}`,
|
|
75
89
|
superblocksBaseUrl
|
|
76
90
|
)
|
|
77
91
|
: new URL(
|
|
78
|
-
|
|
92
|
+
`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}?viewMode=${viewMode}`,
|
|
79
93
|
superblocksBaseUrl
|
|
80
94
|
);
|
|
81
95
|
|
|
@@ -87,6 +101,7 @@ export async function fetchApplication({
|
|
|
87
101
|
url: serverURL.toString(),
|
|
88
102
|
headers: {
|
|
89
103
|
Authorization: "Bearer " + token,
|
|
104
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
90
105
|
...injectedHeaders,
|
|
91
106
|
},
|
|
92
107
|
};
|
|
@@ -102,18 +117,20 @@ export async function fetchApplication({
|
|
|
102
117
|
}
|
|
103
118
|
|
|
104
119
|
export async function fetchApplicationBranches({
|
|
120
|
+
cliVersion,
|
|
105
121
|
applicationId,
|
|
106
122
|
token,
|
|
107
123
|
superblocksBaseUrl,
|
|
108
124
|
injectedHeaders = {},
|
|
109
125
|
}: {
|
|
126
|
+
cliVersion: string;
|
|
110
127
|
applicationId: string;
|
|
111
128
|
token: string;
|
|
112
129
|
superblocksBaseUrl: string;
|
|
113
130
|
injectedHeaders: Record<string, string>;
|
|
114
131
|
}): Promise<Branches | undefined> {
|
|
115
132
|
const serverURL = new URL(
|
|
116
|
-
`
|
|
133
|
+
`public/applications/${applicationId}/branches`,
|
|
117
134
|
superblocksBaseUrl
|
|
118
135
|
);
|
|
119
136
|
let serverResponse;
|
|
@@ -124,6 +141,7 @@ export async function fetchApplicationBranches({
|
|
|
124
141
|
url: serverURL.toString(),
|
|
125
142
|
headers: {
|
|
126
143
|
Authorization: "Bearer " + token,
|
|
144
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
127
145
|
...injectedHeaders,
|
|
128
146
|
},
|
|
129
147
|
};
|
|
@@ -139,6 +157,7 @@ export async function fetchApplicationBranches({
|
|
|
139
157
|
}
|
|
140
158
|
|
|
141
159
|
export async function fetchApplicationWithComponents({
|
|
160
|
+
cliVersion,
|
|
142
161
|
applicationId,
|
|
143
162
|
branch,
|
|
144
163
|
token,
|
|
@@ -146,6 +165,7 @@ export async function fetchApplicationWithComponents({
|
|
|
146
165
|
viewMode,
|
|
147
166
|
injectedHeaders = {},
|
|
148
167
|
}: {
|
|
168
|
+
cliVersion: string;
|
|
149
169
|
applicationId: string;
|
|
150
170
|
branch: string;
|
|
151
171
|
token: string;
|
|
@@ -154,6 +174,7 @@ export async function fetchApplicationWithComponents({
|
|
|
154
174
|
injectedHeaders: Record<string, string>;
|
|
155
175
|
}): Promise<(ApplicationWrapper & { componentFiles: any }) | undefined> {
|
|
156
176
|
const applicationWrapper = await fetchApplication({
|
|
177
|
+
cliVersion,
|
|
157
178
|
applicationId,
|
|
158
179
|
branch,
|
|
159
180
|
token,
|
|
@@ -208,6 +229,7 @@ export async function fetchApplicationWithComponents({
|
|
|
208
229
|
}
|
|
209
230
|
|
|
210
231
|
export async function fetchApplications(
|
|
232
|
+
cliVersion: string,
|
|
211
233
|
token: string,
|
|
212
234
|
superblocksBaseUrl: string,
|
|
213
235
|
injectedHeaders: Record<string, string> = {}
|
|
@@ -215,34 +237,61 @@ export async function fetchApplications(
|
|
|
215
237
|
try {
|
|
216
238
|
const config: AxiosRequestConfig = {
|
|
217
239
|
method: "get",
|
|
218
|
-
url: new URL(
|
|
240
|
+
url: new URL(
|
|
241
|
+
`${BASE_SERVER_PUBLIC_API_URL}/applications`,
|
|
242
|
+
superblocksBaseUrl
|
|
243
|
+
).toString(),
|
|
219
244
|
headers: {
|
|
220
245
|
Authorization: "Bearer " + token,
|
|
246
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
221
247
|
...injectedHeaders,
|
|
222
248
|
},
|
|
223
249
|
};
|
|
224
250
|
const response = await axios(config);
|
|
225
251
|
return response.data.data.applications;
|
|
226
|
-
} catch (e) {
|
|
227
|
-
|
|
252
|
+
} catch (e: any) {
|
|
253
|
+
let message: string;
|
|
254
|
+
if (e instanceof AxiosError) {
|
|
255
|
+
message =
|
|
256
|
+
(e.response?.data?.responseMeta?.message as string) ??
|
|
257
|
+
JSON.stringify(e.response?.data) ??
|
|
258
|
+
e.response?.statusText ??
|
|
259
|
+
e?.message ??
|
|
260
|
+
`${e}`;
|
|
261
|
+
} else {
|
|
262
|
+
message = `${e?.message ? e?.message : e}`;
|
|
263
|
+
}
|
|
264
|
+
throw new Error(`Could not fetch applications: ${message}`);
|
|
228
265
|
}
|
|
229
266
|
}
|
|
230
267
|
|
|
231
268
|
export async function fetchApi(
|
|
269
|
+
cliVersion: string,
|
|
232
270
|
apiId: string,
|
|
233
271
|
token: string,
|
|
234
272
|
superblocksBaseUrl: string,
|
|
235
|
-
viewMode: ViewMode
|
|
273
|
+
viewMode: ViewMode,
|
|
274
|
+
branch?: string
|
|
236
275
|
) {
|
|
237
276
|
try {
|
|
277
|
+
const serverURL = branch
|
|
278
|
+
? new URL(
|
|
279
|
+
`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}/branches/${encodeURIComponent(
|
|
280
|
+
branch
|
|
281
|
+
)}?viewMode=${viewMode}`,
|
|
282
|
+
superblocksBaseUrl
|
|
283
|
+
)
|
|
284
|
+
: new URL(
|
|
285
|
+
`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}?viewMode=${viewMode}`,
|
|
286
|
+
superblocksBaseUrl
|
|
287
|
+
);
|
|
288
|
+
|
|
238
289
|
const config: AxiosRequestConfig = {
|
|
239
290
|
method: "get",
|
|
240
|
-
url: new URL(
|
|
241
|
-
`/api/v3/apis/${apiId}?viewMode=${viewMode}`,
|
|
242
|
-
superblocksBaseUrl
|
|
243
|
-
).toString(),
|
|
291
|
+
url: new URL(serverURL, superblocksBaseUrl).toString(),
|
|
244
292
|
headers: {
|
|
245
293
|
Authorization: "Bearer " + token,
|
|
294
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
246
295
|
},
|
|
247
296
|
};
|
|
248
297
|
const response = await axios(config);
|
|
@@ -255,26 +304,34 @@ export async function fetchApi(
|
|
|
255
304
|
}
|
|
256
305
|
}
|
|
257
306
|
|
|
258
|
-
export async function fetchApis(
|
|
307
|
+
export async function fetchApis(
|
|
308
|
+
cliVersion: string,
|
|
309
|
+
token: string,
|
|
310
|
+
superblocksBaseUrl: string
|
|
311
|
+
) {
|
|
259
312
|
try {
|
|
260
313
|
const config: AxiosRequestConfig = {
|
|
261
314
|
method: "get",
|
|
262
|
-
url: new URL(
|
|
315
|
+
url: new URL(
|
|
316
|
+
`${BASE_SERVER_PUBLIC_API_URL}/apis`,
|
|
317
|
+
superblocksBaseUrl
|
|
318
|
+
).toString(),
|
|
263
319
|
headers: {
|
|
264
320
|
Authorization: "Bearer " + token,
|
|
321
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
265
322
|
},
|
|
266
323
|
};
|
|
267
324
|
const response = await axios(config);
|
|
268
|
-
return response.data.data;
|
|
325
|
+
return response.data.data.apis;
|
|
269
326
|
} catch (e) {
|
|
270
327
|
throw new Error("Could not fetch apis");
|
|
271
328
|
}
|
|
272
329
|
}
|
|
273
330
|
|
|
274
331
|
export async function validateGitSetup(
|
|
332
|
+
cliVersion: string,
|
|
275
333
|
resourceId: string,
|
|
276
|
-
|
|
277
|
-
resourceType: Exclude<SuperblocksResourceType, "BACKEND">,
|
|
334
|
+
resourceType: SuperblocksResourceType,
|
|
278
335
|
event: ComponentEvent,
|
|
279
336
|
localGitRepoState: LocalGitRepoState,
|
|
280
337
|
token: string,
|
|
@@ -283,7 +340,6 @@ export async function validateGitSetup(
|
|
|
283
340
|
) {
|
|
284
341
|
let resourceName: string | undefined;
|
|
285
342
|
try {
|
|
286
|
-
const [rootSettings] = await getSuperblocksMonorepoConfigJson(true);
|
|
287
343
|
const requestBody: ValidateGitSetupRequestBody = {
|
|
288
344
|
event,
|
|
289
345
|
gitState: localGitRepoState,
|
|
@@ -291,7 +347,11 @@ export async function validateGitSetup(
|
|
|
291
347
|
let path: string;
|
|
292
348
|
switch (resourceType) {
|
|
293
349
|
case "APPLICATION": {
|
|
294
|
-
path = `/
|
|
350
|
+
path = `/application/${resourceId}/validate-git-setup`;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
case "BACKEND": {
|
|
354
|
+
path = `/api/${resourceId}/validate-git-setup`;
|
|
295
355
|
break;
|
|
296
356
|
}
|
|
297
357
|
default:
|
|
@@ -299,10 +359,13 @@ export async function validateGitSetup(
|
|
|
299
359
|
}
|
|
300
360
|
const config: AxiosRequestConfig = {
|
|
301
361
|
method: "post",
|
|
302
|
-
url: new URL(
|
|
362
|
+
url: new URL(
|
|
363
|
+
`${BASE_SERVER_PUBLIC_API_URL}/${path}`,
|
|
364
|
+
superblocksBaseUrl
|
|
365
|
+
).toString(),
|
|
303
366
|
headers: {
|
|
304
367
|
Authorization: "Bearer " + token,
|
|
305
|
-
[CLI_VERSION_HEADER]:
|
|
368
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
306
369
|
...injectedHeaders,
|
|
307
370
|
},
|
|
308
371
|
data: requestBody,
|
|
@@ -339,6 +402,7 @@ export async function validateGitSetup(
|
|
|
339
402
|
}
|
|
340
403
|
|
|
341
404
|
export async function registerComponents(
|
|
405
|
+
cliVersion: string,
|
|
342
406
|
applicationId: string,
|
|
343
407
|
componentConfigs: Record<string, any>,
|
|
344
408
|
token: string,
|
|
@@ -347,17 +411,16 @@ export async function registerComponents(
|
|
|
347
411
|
injectedHeaders?: Record<string, string>
|
|
348
412
|
) {
|
|
349
413
|
try {
|
|
350
|
-
const [rootSettings] = await getSuperblocksMonorepoConfigJson(true);
|
|
351
414
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
352
415
|
const config: AxiosRequestConfig = {
|
|
353
416
|
method: "put",
|
|
354
417
|
url: new URL(
|
|
355
|
-
`${
|
|
418
|
+
`${BASE_SERVER_PUBLIC_API_URL}/application/${applicationId}${branchPath}/components`,
|
|
356
419
|
superblocksBaseUrl
|
|
357
420
|
).toString(),
|
|
358
421
|
headers: {
|
|
359
422
|
Authorization: "Bearer " + token,
|
|
360
|
-
[CLI_VERSION_HEADER]:
|
|
423
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
361
424
|
...injectedHeaders,
|
|
362
425
|
},
|
|
363
426
|
data: { components: componentConfigs },
|
|
@@ -385,6 +448,7 @@ export async function registerComponents(
|
|
|
385
448
|
}
|
|
386
449
|
|
|
387
450
|
export async function uploadComponents({
|
|
451
|
+
cliVersion,
|
|
388
452
|
applicationId,
|
|
389
453
|
componentConfigs,
|
|
390
454
|
files,
|
|
@@ -392,6 +456,7 @@ export async function uploadComponents({
|
|
|
392
456
|
superblocksBaseUrl,
|
|
393
457
|
branch,
|
|
394
458
|
}: {
|
|
459
|
+
cliVersion: string;
|
|
395
460
|
applicationId: string;
|
|
396
461
|
componentConfigs: Record<string, any>;
|
|
397
462
|
files: string[];
|
|
@@ -455,11 +520,10 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
455
520
|
const formHeaders = formData.getHeaders();
|
|
456
521
|
|
|
457
522
|
try {
|
|
458
|
-
const [rootSettings] = await getSuperblocksMonorepoConfigJson(true);
|
|
459
523
|
const config: AxiosRequestConfig = {
|
|
460
524
|
headers: {
|
|
461
525
|
Authorization: "Bearer " + token,
|
|
462
|
-
[CLI_VERSION_HEADER]:
|
|
526
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
463
527
|
[COMPONENT_EVENT_HEADER]: ComponentEvent.UPLOAD,
|
|
464
528
|
[SUPERBLOCKS_URL_HEADER]: superblocksBaseUrl,
|
|
465
529
|
...formHeaders,
|
|
@@ -477,10 +541,9 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
477
541
|
} else {
|
|
478
542
|
let message: string;
|
|
479
543
|
if (e instanceof AxiosError) {
|
|
480
|
-
message =
|
|
481
|
-
e.response?.data?.responseMeta?.message ||
|
|
544
|
+
message = (e.response?.data?.responseMeta?.message ||
|
|
482
545
|
e.response?.data ||
|
|
483
|
-
e.response?.statusText;
|
|
546
|
+
e.response?.statusText) as string;
|
|
484
547
|
} else {
|
|
485
548
|
message = e.message as string;
|
|
486
549
|
}
|
|
@@ -493,26 +556,43 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
493
556
|
}
|
|
494
557
|
|
|
495
558
|
export async function fetchCurrentUser(
|
|
559
|
+
cliVersion: string,
|
|
496
560
|
token: string,
|
|
497
561
|
superblocksBaseUrl: string
|
|
498
562
|
) {
|
|
499
563
|
try {
|
|
500
564
|
const config: AxiosRequestConfig = {
|
|
501
565
|
method: "get",
|
|
502
|
-
url: new URL(
|
|
566
|
+
url: new URL(
|
|
567
|
+
`${BASE_SERVER_PUBLIC_API_URL}/users/me`,
|
|
568
|
+
superblocksBaseUrl
|
|
569
|
+
).toString(),
|
|
503
570
|
headers: {
|
|
504
571
|
Authorization: "Bearer " + token,
|
|
572
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
505
573
|
[COMPONENT_EVENT_HEADER]: ComponentEvent.LOGIN,
|
|
506
574
|
},
|
|
507
575
|
};
|
|
508
576
|
const response = await axios(config);
|
|
509
577
|
return response.data.data.user;
|
|
510
|
-
} catch (e) {
|
|
511
|
-
|
|
578
|
+
} catch (e: any) {
|
|
579
|
+
let message: string;
|
|
580
|
+
if (e instanceof AxiosError) {
|
|
581
|
+
message =
|
|
582
|
+
(e.response?.data?.responseMeta?.message as string) ??
|
|
583
|
+
JSON.stringify(e.response?.data) ??
|
|
584
|
+
e.response?.statusText ??
|
|
585
|
+
e?.message ??
|
|
586
|
+
`${e}`;
|
|
587
|
+
} else {
|
|
588
|
+
message = `${e?.message ? e?.message : e}`;
|
|
589
|
+
}
|
|
590
|
+
throw new Error(`Could not fetch current user: ${message}`);
|
|
512
591
|
}
|
|
513
592
|
}
|
|
514
593
|
|
|
515
594
|
export async function pushApplication({
|
|
595
|
+
cliVersion,
|
|
516
596
|
applicationId,
|
|
517
597
|
token,
|
|
518
598
|
superblocksBaseUrl,
|
|
@@ -520,6 +600,7 @@ export async function pushApplication({
|
|
|
520
600
|
branch,
|
|
521
601
|
injectedHeaders = {},
|
|
522
602
|
}: {
|
|
603
|
+
cliVersion: string;
|
|
523
604
|
applicationId: string;
|
|
524
605
|
token: string;
|
|
525
606
|
superblocksBaseUrl: string;
|
|
@@ -527,9 +608,8 @@ export async function pushApplication({
|
|
|
527
608
|
injectedHeaders: Record<string, string>;
|
|
528
609
|
applicationConfig: PushApplicationWithCommitConfig;
|
|
529
610
|
}): Promise<ApplicationWrapper | undefined> {
|
|
530
|
-
const [rootSettings] = await getSuperblocksMonorepoConfigJson(true);
|
|
531
611
|
const serverURL = new URL(
|
|
532
|
-
`${
|
|
612
|
+
`${BASE_SERVER_PUBLIC_API_URL}/applications/${applicationId}/branches/${encodeURIComponent(
|
|
533
613
|
branch
|
|
534
614
|
)}/push`,
|
|
535
615
|
superblocksBaseUrl
|
|
@@ -542,7 +622,7 @@ export async function pushApplication({
|
|
|
542
622
|
url: serverURL.toString(),
|
|
543
623
|
headers: {
|
|
544
624
|
Authorization: "Bearer " + token,
|
|
545
|
-
[CLI_VERSION_HEADER]:
|
|
625
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
546
626
|
...injectedHeaders,
|
|
547
627
|
},
|
|
548
628
|
data: applicationConfig,
|
|
@@ -579,3 +659,70 @@ export async function pushApplication({
|
|
|
579
659
|
|
|
580
660
|
return serverResponse?.data?.data;
|
|
581
661
|
}
|
|
662
|
+
|
|
663
|
+
export async function pushApi({
|
|
664
|
+
cliVersion,
|
|
665
|
+
apiId,
|
|
666
|
+
token,
|
|
667
|
+
superblocksBaseUrl,
|
|
668
|
+
apiConfig,
|
|
669
|
+
branch,
|
|
670
|
+
injectedHeaders = {},
|
|
671
|
+
}: {
|
|
672
|
+
cliVersion: string;
|
|
673
|
+
apiId: string;
|
|
674
|
+
token: string;
|
|
675
|
+
superblocksBaseUrl: string;
|
|
676
|
+
apiConfig: PushApiWithCommitConfig;
|
|
677
|
+
branch: string;
|
|
678
|
+
injectedHeaders: Record<string, string>;
|
|
679
|
+
}): Promise<{ commitId: string } | undefined> {
|
|
680
|
+
const serverURL = new URL(
|
|
681
|
+
`${BASE_SERVER_PUBLIC_API_URL}/apis/${apiId}/branches/${encodeURIComponent(
|
|
682
|
+
branch
|
|
683
|
+
)}/push`,
|
|
684
|
+
superblocksBaseUrl
|
|
685
|
+
);
|
|
686
|
+
let serverResponse;
|
|
687
|
+
|
|
688
|
+
try {
|
|
689
|
+
const config: AxiosRequestConfig = {
|
|
690
|
+
method: "post",
|
|
691
|
+
url: serverURL.toString(),
|
|
692
|
+
headers: {
|
|
693
|
+
Authorization: "Bearer " + token,
|
|
694
|
+
[CLI_VERSION_HEADER]: cliVersion,
|
|
695
|
+
...injectedHeaders,
|
|
696
|
+
},
|
|
697
|
+
data: apiConfig,
|
|
698
|
+
};
|
|
699
|
+
serverResponse = await axios<ResponseWithMeta<{ commitId: string }>>(
|
|
700
|
+
config
|
|
701
|
+
);
|
|
702
|
+
} catch (e) {
|
|
703
|
+
if (axios.isAxiosError(e)) {
|
|
704
|
+
if (e.response?.data?.responseMeta?.status === 405) {
|
|
705
|
+
throw new BranchNotCheckedOutError(
|
|
706
|
+
`Branch ${branch} is not checked out`
|
|
707
|
+
);
|
|
708
|
+
} else if (e.response?.data?.responseMeta?.status === 409) {
|
|
709
|
+
throw new CommitAlreadyExistsError(
|
|
710
|
+
`Commit ${apiConfig.commitId} already exists`
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
const message: string =
|
|
714
|
+
(e.response?.data?.responseMeta?.message as string) ??
|
|
715
|
+
JSON.stringify(e.response?.data) ??
|
|
716
|
+
e.response?.statusText;
|
|
717
|
+
|
|
718
|
+
throw new Error(`Could not push api ${message ? "\n" + message : ""}`);
|
|
719
|
+
}
|
|
720
|
+
throw new Error(
|
|
721
|
+
`Could not push api ${
|
|
722
|
+
(e as Error).message ? "\n" + (e as Error).message : ""
|
|
723
|
+
}`
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
return serverResponse?.data?.data;
|
|
728
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -16,6 +16,8 @@ import {
|
|
|
16
16
|
pushApplication,
|
|
17
17
|
PushApplicationWithCommitConfig,
|
|
18
18
|
fetchApplicationBranches,
|
|
19
|
+
PushApiWithCommitConfig,
|
|
20
|
+
pushApi,
|
|
19
21
|
validateGitSetup,
|
|
20
22
|
} from "./client";
|
|
21
23
|
|
|
@@ -25,10 +27,16 @@ export * from "./errors";
|
|
|
25
27
|
export class SuperblocksSdk {
|
|
26
28
|
token = "";
|
|
27
29
|
superblocksBaseUrl = "";
|
|
30
|
+
cliVersion = "";
|
|
28
31
|
|
|
29
|
-
constructor(
|
|
32
|
+
constructor(
|
|
33
|
+
accessToken: string,
|
|
34
|
+
superblocksBaseUrl: string,
|
|
35
|
+
cliVersion: string
|
|
36
|
+
) {
|
|
30
37
|
this.token = accessToken;
|
|
31
38
|
this.superblocksBaseUrl = superblocksBaseUrl;
|
|
39
|
+
this.cliVersion = cliVersion;
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
async fetchApplication({
|
|
@@ -43,6 +51,7 @@ export class SuperblocksSdk {
|
|
|
43
51
|
viewMode?: ViewMode;
|
|
44
52
|
}) {
|
|
45
53
|
return fetchApplication({
|
|
54
|
+
cliVersion: this.cliVersion,
|
|
46
55
|
applicationId,
|
|
47
56
|
branch,
|
|
48
57
|
token: this.token,
|
|
@@ -54,6 +63,7 @@ export class SuperblocksSdk {
|
|
|
54
63
|
|
|
55
64
|
async fetchApplicationBranches(applicationId: string, headers = {}) {
|
|
56
65
|
return fetchApplicationBranches({
|
|
66
|
+
cliVersion: this.cliVersion,
|
|
57
67
|
applicationId,
|
|
58
68
|
token: this.token,
|
|
59
69
|
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
@@ -73,6 +83,7 @@ export class SuperblocksSdk {
|
|
|
73
83
|
viewMode?: ViewMode;
|
|
74
84
|
}) {
|
|
75
85
|
return fetchApplicationWithComponents({
|
|
86
|
+
cliVersion: this.cliVersion,
|
|
76
87
|
applicationId,
|
|
77
88
|
branch,
|
|
78
89
|
token: this.token,
|
|
@@ -83,26 +94,42 @@ export class SuperblocksSdk {
|
|
|
83
94
|
}
|
|
84
95
|
|
|
85
96
|
async fetchApplications(headers?: Record<string, string>) {
|
|
86
|
-
return fetchApplications(
|
|
97
|
+
return fetchApplications(
|
|
98
|
+
this.cliVersion,
|
|
99
|
+
this.token,
|
|
100
|
+
this.superblocksBaseUrl,
|
|
101
|
+
headers
|
|
102
|
+
);
|
|
87
103
|
}
|
|
88
104
|
|
|
89
|
-
async fetchApi(
|
|
90
|
-
|
|
105
|
+
async fetchApi(
|
|
106
|
+
apiId: string,
|
|
107
|
+
viewMode: ViewMode = "export-live",
|
|
108
|
+
branch?: string
|
|
109
|
+
) {
|
|
110
|
+
return fetchApi(
|
|
111
|
+
this.cliVersion,
|
|
112
|
+
apiId,
|
|
113
|
+
this.token,
|
|
114
|
+
this.superblocksBaseUrl,
|
|
115
|
+
viewMode,
|
|
116
|
+
branch
|
|
117
|
+
);
|
|
91
118
|
}
|
|
92
119
|
|
|
93
120
|
async fetchApis() {
|
|
94
|
-
return fetchApis(this.token, this.superblocksBaseUrl);
|
|
121
|
+
return fetchApis(this.cliVersion, this.token, this.superblocksBaseUrl);
|
|
95
122
|
}
|
|
96
123
|
|
|
97
124
|
async validateGitSetup(
|
|
98
125
|
resourceId: string,
|
|
99
|
-
|
|
100
|
-
resourceType: Exclude<SuperblocksResourceType, "BACKEND">,
|
|
126
|
+
resourceType: SuperblocksResourceType,
|
|
101
127
|
event: ComponentEvent,
|
|
102
128
|
localGitRepoState: LocalGitRepoState,
|
|
103
129
|
injectedHeaders?: Record<string, string>
|
|
104
130
|
) {
|
|
105
131
|
return validateGitSetup(
|
|
132
|
+
this.cliVersion,
|
|
106
133
|
resourceId,
|
|
107
134
|
resourceType,
|
|
108
135
|
event,
|
|
@@ -120,6 +147,7 @@ export class SuperblocksSdk {
|
|
|
120
147
|
injectedHeaders?: Record<string, string>
|
|
121
148
|
) {
|
|
122
149
|
return registerComponents(
|
|
150
|
+
this.cliVersion,
|
|
123
151
|
applicationId,
|
|
124
152
|
componentConfigs,
|
|
125
153
|
this.token,
|
|
@@ -136,6 +164,7 @@ export class SuperblocksSdk {
|
|
|
136
164
|
branch: string | null
|
|
137
165
|
) {
|
|
138
166
|
return uploadComponents({
|
|
167
|
+
cliVersion: this.cliVersion,
|
|
139
168
|
applicationId,
|
|
140
169
|
componentConfigs,
|
|
141
170
|
files,
|
|
@@ -146,7 +175,11 @@ export class SuperblocksSdk {
|
|
|
146
175
|
}
|
|
147
176
|
|
|
148
177
|
async fetchCurrentUser() {
|
|
149
|
-
return fetchCurrentUser(
|
|
178
|
+
return fetchCurrentUser(
|
|
179
|
+
this.cliVersion,
|
|
180
|
+
this.token,
|
|
181
|
+
this.superblocksBaseUrl
|
|
182
|
+
);
|
|
150
183
|
}
|
|
151
184
|
|
|
152
185
|
async pushApplication({
|
|
@@ -161,6 +194,7 @@ export class SuperblocksSdk {
|
|
|
161
194
|
headers?: Record<string, string>;
|
|
162
195
|
}) {
|
|
163
196
|
return pushApplication({
|
|
197
|
+
cliVersion: this.cliVersion,
|
|
164
198
|
applicationId,
|
|
165
199
|
token: this.token,
|
|
166
200
|
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
@@ -169,4 +203,25 @@ export class SuperblocksSdk {
|
|
|
169
203
|
applicationConfig,
|
|
170
204
|
});
|
|
171
205
|
}
|
|
206
|
+
async pushApi({
|
|
207
|
+
apiId,
|
|
208
|
+
apiConfig,
|
|
209
|
+
branch,
|
|
210
|
+
headers = {},
|
|
211
|
+
}: {
|
|
212
|
+
apiId: string;
|
|
213
|
+
apiConfig: PushApiWithCommitConfig;
|
|
214
|
+
branch: string;
|
|
215
|
+
headers?: Record<string, string>;
|
|
216
|
+
}) {
|
|
217
|
+
return pushApi({
|
|
218
|
+
cliVersion: this.cliVersion,
|
|
219
|
+
apiId,
|
|
220
|
+
apiConfig,
|
|
221
|
+
token: this.token,
|
|
222
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
223
|
+
branch,
|
|
224
|
+
injectedHeaders: headers,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
172
227
|
}
|