@superblocksteam/sdk 1.6.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +10 -5
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +8 -1
- package/package.json +2 -2
- package/src/client.ts +18 -13
- package/src/errors.ts +7 -0
package/dist/client.js
CHANGED
|
@@ -247,9 +247,17 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
247
247
|
`${e}`;
|
|
248
248
|
}
|
|
249
249
|
else {
|
|
250
|
-
message = `${e?.message ? e
|
|
250
|
+
message = `${e?.message ? e.message : e}`;
|
|
251
|
+
}
|
|
252
|
+
const errorMessage = `Could not validate your git setup against Superblocks for the ${resourceType.toLowerCase()} ${resourceName ?? resourceId}${message ? "\n" + message : ""}`;
|
|
253
|
+
// TODO(@taha-au @gpoulios-sb) Replace this check with a more robust one that uses error codes once
|
|
254
|
+
// the backend starts returning them as part of the response body
|
|
255
|
+
if (message.includes("Please initialize git locally")) {
|
|
256
|
+
throw new errors_1.ValidateGitSetupError(errorMessage);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
throw new Error(errorMessage);
|
|
251
260
|
}
|
|
252
|
-
throw new Error(`Could not validate your git setup against Superblocks for the ${resourceType.toLowerCase()} ${resourceName ?? resourceId}${message ? "\n" + message : ""}`);
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
263
|
exports.validateGitSetup = validateGitSetup;
|
|
@@ -604,6 +612,3 @@ async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig
|
|
|
604
612
|
}
|
|
605
613
|
}
|
|
606
614
|
exports.pushApi = pushApi;
|
|
607
|
-
function isMultiPageApplicationWrapper(data) {
|
|
608
|
-
return data.pages !== undefined;
|
|
609
|
-
}
|
package/dist/errors.d.ts
CHANGED
package/dist/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommitAlreadyExistsError = exports.BranchNotCheckedOutError = void 0;
|
|
3
|
+
exports.ValidateGitSetupError = exports.CommitAlreadyExistsError = exports.BranchNotCheckedOutError = void 0;
|
|
4
4
|
class BranchNotCheckedOutError extends Error {
|
|
5
5
|
constructor(message) {
|
|
6
6
|
super(message);
|
|
@@ -15,3 +15,10 @@ class CommitAlreadyExistsError extends Error {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.CommitAlreadyExistsError = CommitAlreadyExistsError;
|
|
18
|
+
class ValidateGitSetupError extends Error {
|
|
19
|
+
constructor(message) {
|
|
20
|
+
super(message);
|
|
21
|
+
this.name = "ValidateGitSetupError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.ValidateGitSetupError = ValidateGitSetupError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "Superblocks JS SDK",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"typescript": "^5.1.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@superblocksteam/util": "1.
|
|
34
|
+
"@superblocksteam/util": "1.7.0",
|
|
35
35
|
"axios": "^1.3.5",
|
|
36
36
|
"isomorphic-ws": "^5.0.0"
|
|
37
37
|
},
|
package/src/client.ts
CHANGED
|
@@ -13,7 +13,11 @@ import {
|
|
|
13
13
|
import axios, { AxiosError, AxiosRequestConfig } from "axios";
|
|
14
14
|
import FormData from "form-data";
|
|
15
15
|
import { isEmpty } from "lodash";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
BranchNotCheckedOutError,
|
|
18
|
+
CommitAlreadyExistsError,
|
|
19
|
+
ValidateGitSetupError,
|
|
20
|
+
} from "./errors";
|
|
17
21
|
import { signingEnabled } from "./flag";
|
|
18
22
|
import { connectToISocketRPCServer } from "./socket";
|
|
19
23
|
import {
|
|
@@ -428,13 +432,20 @@ export async function validateGitSetup(
|
|
|
428
432
|
e?.message ??
|
|
429
433
|
`${e}`;
|
|
430
434
|
} else {
|
|
431
|
-
message = `${e?.message ? e
|
|
435
|
+
message = `${e?.message ? e.message : e}`;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
const errorMessage = `Could not validate your git setup against Superblocks for the ${resourceType.toLowerCase()} ${
|
|
439
|
+
resourceName ?? resourceId
|
|
440
|
+
}${message ? "\n" + message : ""}`;
|
|
441
|
+
|
|
442
|
+
// TODO(@taha-au @gpoulios-sb) Replace this check with a more robust one that uses error codes once
|
|
443
|
+
// the backend starts returning them as part of the response body
|
|
444
|
+
if (message.includes("Please initialize git locally")) {
|
|
445
|
+
throw new ValidateGitSetupError(errorMessage);
|
|
446
|
+
} else {
|
|
447
|
+
throw new Error(errorMessage);
|
|
432
448
|
}
|
|
433
|
-
throw new Error(
|
|
434
|
-
`Could not validate your git setup against Superblocks for the ${resourceType.toLowerCase()} ${
|
|
435
|
-
resourceName ?? resourceId
|
|
436
|
-
}${message ? "\n" + message : ""}`
|
|
437
|
-
);
|
|
438
449
|
}
|
|
439
450
|
}
|
|
440
451
|
|
|
@@ -939,9 +950,3 @@ export async function pushApi({
|
|
|
939
950
|
);
|
|
940
951
|
}
|
|
941
952
|
}
|
|
942
|
-
|
|
943
|
-
function isMultiPageApplicationWrapper(
|
|
944
|
-
data: ApplicationWrapper | MultiPageApplicationWrapper
|
|
945
|
-
): data is MultiPageApplicationWrapper {
|
|
946
|
-
return (data as MultiPageApplicationWrapper).pages !== undefined;
|
|
947
|
-
}
|
package/src/errors.ts
CHANGED
|
@@ -11,3 +11,10 @@ export class CommitAlreadyExistsError extends Error {
|
|
|
11
11
|
this.name = "CommitAlreadyExistsError";
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
export class ValidateGitSetupError extends Error {
|
|
16
|
+
constructor(message: string) {
|
|
17
|
+
super(message);
|
|
18
|
+
this.name = "ValidateGitSetupError";
|
|
19
|
+
}
|
|
20
|
+
}
|