@superblocksteam/sdk 1.2.0 → 1.2.1
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.d.ts +0 -6
- package/dist/client.js +4 -17
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +17 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +3 -0
- package/package.json +2 -2
- package/src/client.ts +1 -14
- package/src/errors.ts +13 -0
- package/src/sdk.ts +3 -0
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
export type ViewMode = "export-deployed" | "export-latest" | "export-live";
|
|
2
|
-
export declare class BranchNotCheckedOutError extends Error {
|
|
3
|
-
constructor(message: string);
|
|
4
|
-
}
|
|
5
|
-
export declare class CommitAlreadyExistsError extends Error {
|
|
6
|
-
constructor(message: string);
|
|
7
|
-
}
|
|
8
2
|
export interface UploadFile {
|
|
9
3
|
name: string;
|
|
10
4
|
filename: string;
|
package/dist/client.js
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pushApplication = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = exports.fetchApis = exports.fetchApi = exports.fetchApplications = exports.fetchApplicationWithComponents = exports.fetchApplicationBranches = exports.fetchApplication =
|
|
3
|
+
exports.pushApplication = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = 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
|
+
const errors_1 = require("./errors");
|
|
9
10
|
const BASE_SERVER_URL = "api/v1";
|
|
10
11
|
const BASE_BUCKETEER_URL = "api/v1";
|
|
11
12
|
const SUPERBLOCKS_MAX_FILE_SIZE_MB = 10;
|
|
12
13
|
const CLI_VERSION_HEADER = "x-superblocks-cli-version";
|
|
13
14
|
const SUPERBLOCKS_URL_HEADER = "x-superblocks-url";
|
|
14
|
-
class BranchNotCheckedOutError extends Error {
|
|
15
|
-
constructor(message) {
|
|
16
|
-
super(message);
|
|
17
|
-
this.name = "BranchNotCheckedOutError";
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.BranchNotCheckedOutError = BranchNotCheckedOutError;
|
|
21
|
-
class CommitAlreadyExistsError extends Error {
|
|
22
|
-
constructor(message) {
|
|
23
|
-
super(message);
|
|
24
|
-
this.name = "CommitAlreadyExistsError";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
exports.CommitAlreadyExistsError = CommitAlreadyExistsError;
|
|
28
15
|
async function fetchApplication({ applicationId, branch, token, superblocksBaseUrl, viewMode, injectedHeaders = {}, }) {
|
|
29
16
|
var _a, _b;
|
|
30
17
|
const serverURL = new URL(`api/v2/applications/${applicationId}/branches/${branch}?viewMode=${viewMode}`, superblocksBaseUrl);
|
|
@@ -324,10 +311,10 @@ async function pushApplication({ applicationId, token, superblocksBaseUrl, appli
|
|
|
324
311
|
if (axios_1.default.isAxiosError(e)) {
|
|
325
312
|
const respCode = (_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.status) !== null && _d !== void 0 ? _d : (_e = e.response) === null || _e === void 0 ? void 0 : _e.status;
|
|
326
313
|
if (respCode === 405) {
|
|
327
|
-
throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
314
|
+
throw new errors_1.BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
328
315
|
}
|
|
329
316
|
else if (respCode === 409) {
|
|
330
|
-
throw new CommitAlreadyExistsError(`Commit ${applicationConfig.commitId} already exists`);
|
|
317
|
+
throw new errors_1.CommitAlreadyExistsError(`Commit ${applicationConfig.commitId} already exists`);
|
|
331
318
|
}
|
|
332
319
|
const message = (_l = (_j = (_h = (_g = (_f = e.response) === null || _f === void 0 ? void 0 : _f.data) === null || _g === void 0 ? void 0 : _g.responseMeta) === null || _h === void 0 ? void 0 : _h.message) !== null && _j !== void 0 ? _j : JSON.stringify((_k = e.response) === null || _k === void 0 ? void 0 : _k.data)) !== null && _l !== void 0 ? _l : (_m = e.response) === null || _m === void 0 ? void 0 : _m.statusText;
|
|
333
320
|
throw new Error(`Could not push application ${message ? "\n" + message : ""}`);
|
package/dist/errors.d.ts
ADDED
package/dist/errors.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommitAlreadyExistsError = exports.BranchNotCheckedOutError = void 0;
|
|
4
|
+
class BranchNotCheckedOutError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "BranchNotCheckedOutError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.BranchNotCheckedOutError = BranchNotCheckedOutError;
|
|
11
|
+
class CommitAlreadyExistsError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = "CommitAlreadyExistsError";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.CommitAlreadyExistsError = CommitAlreadyExistsError;
|
package/dist/sdk.d.ts
CHANGED
package/dist/sdk.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SuperblocksSdk = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const client_1 = require("./client");
|
|
6
|
+
// Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
|
|
7
|
+
tslib_1.__exportStar(require("./errors"), exports);
|
|
5
8
|
class SuperblocksSdk {
|
|
6
9
|
constructor(accessToken, superblocksBaseUrl) {
|
|
7
10
|
this.token = "";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superblocksteam/sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
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.2.
|
|
33
|
+
"@superblocksteam/util": "1.2.1",
|
|
34
34
|
"axios": "^1.3.5"
|
|
35
35
|
},
|
|
36
36
|
"homepage": "https://www.superblocks.com",
|
package/src/client.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
import axios, { AxiosError, AxiosRequestConfig } from "axios";
|
|
11
11
|
import * as FormData from "form-data";
|
|
12
12
|
import { isEmpty } from "lodash";
|
|
13
|
+
import { BranchNotCheckedOutError, CommitAlreadyExistsError } from "./errors";
|
|
13
14
|
|
|
14
15
|
const BASE_SERVER_URL = "api/v1";
|
|
15
16
|
const BASE_BUCKETEER_URL = "api/v1";
|
|
@@ -21,20 +22,6 @@ const SUPERBLOCKS_URL_HEADER = "x-superblocks-url";
|
|
|
21
22
|
|
|
22
23
|
export type ViewMode = "export-deployed" | "export-latest" | "export-live";
|
|
23
24
|
|
|
24
|
-
export class BranchNotCheckedOutError extends Error {
|
|
25
|
-
constructor(message: string) {
|
|
26
|
-
super(message);
|
|
27
|
-
this.name = "BranchNotCheckedOutError";
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export class CommitAlreadyExistsError extends Error {
|
|
32
|
-
constructor(message: string) {
|
|
33
|
-
super(message);
|
|
34
|
-
this.name = "CommitAlreadyExistsError";
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
25
|
export interface UploadFile {
|
|
39
26
|
name: string;
|
|
40
27
|
filename: string;
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class BranchNotCheckedOutError extends Error {
|
|
2
|
+
constructor(message: string) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "BranchNotCheckedOutError";
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class CommitAlreadyExistsError extends Error {
|
|
9
|
+
constructor(message: string) {
|
|
10
|
+
super(message);
|
|
11
|
+
this.name = "CommitAlreadyExistsError";
|
|
12
|
+
}
|
|
13
|
+
}
|
package/src/sdk.ts
CHANGED
|
@@ -13,6 +13,9 @@ import {
|
|
|
13
13
|
fetchApplicationBranches,
|
|
14
14
|
} from "./client";
|
|
15
15
|
|
|
16
|
+
// Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
|
|
17
|
+
export * from "./errors";
|
|
18
|
+
|
|
16
19
|
export class SuperblocksSdk {
|
|
17
20
|
token = "";
|
|
18
21
|
superblocksBaseUrl = "";
|