@superblocksteam/sdk 1.9.3 → 1.11.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/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSanitizedApi = exports.sanitizeV2RequestBody = exports.getAgentUrl = void 0;
3
+ exports.getSanitizedApi = exports.sanitizeV2RequestBody = void 0;
4
+ exports.getAgentUrl = getAgentUrl;
4
5
  const tslib_1 = require("tslib");
5
6
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
7
  const types_1 = require("./types");
@@ -28,7 +29,7 @@ async function getAgentUrl(agents, agentType, profile, healthCheck = true) {
28
29
  try {
29
30
  return await Promise.any(coroutines);
30
31
  }
31
- catch (e) {
32
+ catch {
32
33
  throw new Error("No available agents");
33
34
  }
34
35
  }
@@ -37,7 +38,6 @@ async function getAgentUrl(agents, agentType, profile, healthCheck = true) {
37
38
  return filtered[randomIndex].url;
38
39
  }
39
40
  }
40
- exports.getAgentUrl = getAgentUrl;
41
41
  const sanitizeV2RequestBody = (apiBody) => {
42
42
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
43
43
  const traverseJSON = (obj) => {
package/package.json CHANGED
@@ -1,43 +1,49 @@
1
1
  {
2
2
  "name": "@superblocksteam/sdk",
3
- "version": "1.9.3",
3
+ "version": "1.11.0",
4
4
  "description": "Superblocks JS SDK",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./dist/sdk.js",
9
- "require": "./dist/sdk.js",
10
- "types": "./dist/sdk.d.ts"
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.js",
10
+ "types": "./dist/index.d.ts"
11
11
  }
12
12
  },
13
13
  "types": "./dist/index.d.ts",
14
- "scripts": {
15
- "dev": "tsc --watch",
16
- "build": "tsc --build",
17
- "clean": "npm run clean:build && rm -rf node_modules",
18
- "clean:build": "tsc --build --clean && rm -rf dist tsconfig.tsbuildinfo",
19
- "lint": "eslint . --ext .ts --config .eslintrc.json",
20
- "lint:fix": "eslint . --ext .ts --config .eslintrc.json --fix",
21
- "typecheck": "tsc --noEmit"
22
- },
23
14
  "license": "Superblocks Community Software License",
24
15
  "devDependencies": {
16
+ "@types/lodash": "^4.17.7",
17
+ "@types/node": "^20.11.22",
25
18
  "@types/ws": "^8.5.10",
26
19
  "@typescript-eslint/eslint-plugin": "^5.60.1",
27
20
  "@typescript-eslint/parser": "^5.60.1",
28
21
  "eslint": "^8.48.0",
29
22
  "eslint-plugin-unicorn": "^47.0.0",
30
23
  "prettier": "^2.8.8",
24
+ "tslib": "^2.5.0",
31
25
  "typescript": "^5.1.3"
32
26
  },
33
27
  "dependencies": {
34
- "@superblocksteam/util": "1.9.3",
35
28
  "axios": "^1.3.5",
36
- "ws": "^8.17.0"
29
+ "form-data": "^4.0.0",
30
+ "lodash": "^4.17.21",
31
+ "ws": "^8.17.0",
32
+ "@superblocksteam/util": "1.11.0"
37
33
  },
38
34
  "homepage": "https://www.superblocks.com",
39
35
  "engines": {
40
- "node": ">=16.0.0",
41
- "npm": ">=8.0.0"
36
+ "node": ">=20.0.0",
37
+ "npm": ">=9.0.0"
38
+ },
39
+ "scripts": {
40
+ "dev": "tsc --watch",
41
+ "build": "tsc --build",
42
+ "clean": "npm run clean:build && rm -rf node_modules",
43
+ "clean:build": "tsc --build --clean && rm -rf dist tsconfig.tsbuildinfo",
44
+ "lint": "eslint . --ext .ts --config .eslintrc.json",
45
+ "lint:fix": "eslint . --ext .ts --config .eslintrc.json --fix",
46
+ "typecheck": "tsc --noEmit",
47
+ "check": "pnpm run lint && pnpm run typecheck"
42
48
  }
43
- }
49
+ }
package/src/client.ts CHANGED
@@ -22,6 +22,7 @@ import { signingEnabled } from "./flag";
22
22
  import { connectToISocketRPCServer, StdISocketRPCClient } from "./socket";
23
23
  import {
24
24
  AgentType,
25
+ Api,
25
26
  ApiWithPb,
26
27
  Page,
27
28
  RemoteCommitDto,
@@ -68,7 +69,7 @@ export type PushMultiPageApplicationWithCommitConfig =
68
69
  };
69
70
 
70
71
  export interface ApiWrapper {
71
- apiPb: Record<string, any>;
72
+ apiPb: Api;
72
73
  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.
73
74
  }
74
75
 
@@ -134,20 +135,20 @@ export async function fetchApplication({
134
135
  }): Promise<MultiPageApplicationWrapper | undefined> {
135
136
  if (commitId && viewMode !== "export-commit") {
136
137
  throw new Error(
137
- `If commitId ${commitId} is provided, viewMode cannot be ${viewMode}`
138
+ `If commitId ${commitId} is provided, viewMode cannot be ${viewMode}`,
138
139
  );
139
140
  }
140
141
  try {
141
142
  const serverURL = branch
142
143
  ? new URL(
143
144
  `${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}/branches/${encodeURIComponent(
144
- branch
145
+ branch,
145
146
  )}`,
146
- superblocksBaseUrl
147
+ superblocksBaseUrl,
147
148
  )
148
149
  : new URL(
149
150
  `${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}`,
150
- superblocksBaseUrl
151
+ superblocksBaseUrl,
151
152
  );
152
153
  serverURL.search = new URLSearchParams({
153
154
  viewMode,
@@ -157,7 +158,7 @@ export async function fetchApplication({
157
158
  ? await createSocketConnectionIfNeeded(
158
159
  cliVersion,
159
160
  token,
160
- superblocksBaseUrl
161
+ superblocksBaseUrl,
161
162
  )
162
163
  : undefined;
163
164
  if (socket) {
@@ -182,9 +183,8 @@ export async function fetchApplication({
182
183
  ...injectedHeaders,
183
184
  },
184
185
  };
185
- const serverResponse = await axios<
186
- ResponseWithMeta<MultiPageApplicationWrapper>
187
- >(config);
186
+ const serverResponse =
187
+ await axios<ResponseWithMeta<MultiPageApplicationWrapper>>(config);
188
188
  const data = serverResponse?.data?.data;
189
189
  return data;
190
190
  } catch (e) {
@@ -194,7 +194,7 @@ export async function fetchApplication({
194
194
  throw new Error(
195
195
  `Could not fetch application: ${
196
196
  typeof e === "object" && e && "message" in e ? e.message : e
197
- }`
197
+ }`,
198
198
  );
199
199
  }
200
200
  }
@@ -214,7 +214,7 @@ export async function fetchApplicationBranches({
214
214
  }): Promise<Branches | undefined> {
215
215
  const serverURL = new URL(
216
216
  `public/applications/${applicationId}/branches`,
217
- superblocksBaseUrl
217
+ superblocksBaseUrl,
218
218
  );
219
219
  let serverResponse;
220
220
 
@@ -296,7 +296,7 @@ export async function fetchApplicationWithComponents({
296
296
  const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
297
297
  const componentFileURL = new URL(
298
298
  `${BASE_BUCKETEER_URL}/v1/components/${applicationId}${branchPath}?commit=${commitId}&viewMode=${viewMode}&multiPage=true`,
299
- bucketeerBaseUrl
299
+ bucketeerBaseUrl,
300
300
  ).toString();
301
301
 
302
302
  try {
@@ -317,11 +317,11 @@ export async function fetchApplicationWithComponents({
317
317
  if (
318
318
  !isEqual(
319
319
  applicationWrapper.application.settings,
320
- bucketeerApp.application.settings
320
+ bucketeerApp.application.settings,
321
321
  )
322
322
  ) {
323
323
  throw new Error(
324
- "Application settings fetched from bucketeer do not match the settings fetched from the server"
324
+ "Application settings fetched from bucketeer do not match the settings fetched from the server",
325
325
  );
326
326
  }
327
327
 
@@ -338,14 +338,14 @@ export async function fetchApplications(
338
338
  cliVersion: string,
339
339
  token: string,
340
340
  superblocksBaseUrl: string,
341
- injectedHeaders: Record<string, string> = {}
341
+ injectedHeaders: Record<string, string> = {},
342
342
  ) {
343
343
  try {
344
344
  const config: AxiosRequestConfig = {
345
345
  method: "get",
346
346
  url: new URL(
347
347
  `${BASE_SERVER_PUBLIC_API_URL_V1}/applications`,
348
- superblocksBaseUrl
348
+ superblocksBaseUrl,
349
349
  ).toString(),
350
350
  headers: {
351
351
  Authorization: "Bearer " + token,
@@ -362,8 +362,7 @@ export async function fetchApplications(
362
362
  (e.response?.data?.responseMeta?.message as string) ??
363
363
  JSON.stringify(e.response?.data) ??
364
364
  e.response?.statusText ??
365
- e?.message ??
366
- `${e}`;
365
+ e?.message;
367
366
  } else {
368
367
  message = `${e?.message ? e?.message : e}`;
369
368
  }
@@ -379,19 +378,19 @@ export async function fetchApi(
379
378
  viewMode: ViewMode,
380
379
  branch?: string,
381
380
  commitId?: string,
382
- skipSigningVerification = false
381
+ skipSigningVerification = false,
383
382
  ) {
384
383
  try {
385
384
  const serverURL = branch
386
385
  ? new URL(
387
386
  `${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(
388
- branch
387
+ branch,
389
388
  )}`,
390
- superblocksBaseUrl
389
+ superblocksBaseUrl,
391
390
  )
392
391
  : new URL(
393
392
  `${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}`,
394
- superblocksBaseUrl
393
+ superblocksBaseUrl,
395
394
  );
396
395
  serverURL.search = new URLSearchParams({
397
396
  viewMode,
@@ -401,7 +400,7 @@ export async function fetchApi(
401
400
  ? await createSocketConnectionIfNeeded(
402
401
  cliVersion,
403
402
  token,
404
- superblocksBaseUrl
403
+ superblocksBaseUrl,
405
404
  )
406
405
  : undefined;
407
406
 
@@ -435,7 +434,7 @@ export async function fetchApi(
435
434
  throw new Error(
436
435
  `Could not fetch api: ${
437
436
  typeof e === "object" && e && "message" in e ? e.message : e
438
- }`
437
+ }`,
439
438
  );
440
439
  }
441
440
  }
@@ -443,14 +442,14 @@ export async function fetchApi(
443
442
  export async function fetchApis(
444
443
  cliVersion: string,
445
444
  token: string,
446
- superblocksBaseUrl: string
445
+ superblocksBaseUrl: string,
447
446
  ) {
448
447
  try {
449
448
  const config: AxiosRequestConfig = {
450
449
  method: "get",
451
450
  url: new URL(
452
451
  `${BASE_SERVER_PUBLIC_API_URL_V1}/apis`,
453
- superblocksBaseUrl
452
+ superblocksBaseUrl,
454
453
  ).toString(),
455
454
  headers: {
456
455
  Authorization: "Bearer " + token,
@@ -459,7 +458,7 @@ export async function fetchApis(
459
458
  };
460
459
  const response = await axios(config);
461
460
  return response.data.data.apis;
462
- } catch (e) {
461
+ } catch {
463
462
  throw new Error("Could not fetch apis");
464
463
  }
465
464
  }
@@ -472,7 +471,7 @@ export async function validateGitSetup(
472
471
  localGitRepoState: LocalGitRepoState,
473
472
  token: string,
474
473
  superblocksBaseUrl: string,
475
- injectedHeaders?: Record<string, string>
474
+ injectedHeaders?: Record<string, string>,
476
475
  ) {
477
476
  let resourceName: string | undefined;
478
477
  try {
@@ -497,7 +496,7 @@ export async function validateGitSetup(
497
496
  method: "post",
498
497
  url: new URL(
499
498
  `${BASE_SERVER_PUBLIC_API_URL_V1}/${path}`,
500
- superblocksBaseUrl
499
+ superblocksBaseUrl,
501
500
  ).toString(),
502
501
  headers: {
503
502
  Authorization: "Bearer " + token,
@@ -524,8 +523,7 @@ export async function validateGitSetup(
524
523
  (e.response?.data?.responseMeta?.message as string) ??
525
524
  JSON.stringify(e.response?.data) ??
526
525
  e.response?.statusText ??
527
- e?.message ??
528
- `${e}`;
526
+ e?.message;
529
527
  } else {
530
528
  message = `${e?.message ? e.message : e}`;
531
529
  }
@@ -551,14 +549,14 @@ export async function registerComponents(
551
549
  token: string,
552
550
  superblocksBaseUrl: string,
553
551
  branch: string | null,
554
- injectedHeaders: Record<string, string>
552
+ injectedHeaders: Record<string, string>,
555
553
  ) {
556
554
  try {
557
555
  const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
558
556
  const socket = await createSocketConnectionIfNeeded(
559
557
  cliVersion,
560
558
  token,
561
- superblocksBaseUrl
559
+ superblocksBaseUrl,
562
560
  );
563
561
  if (socket) {
564
562
  const resp = await socket.call.v1.public.application.component.register({
@@ -575,7 +573,7 @@ export async function registerComponents(
575
573
  method: "put",
576
574
  url: new URL(
577
575
  `${BASE_SERVER_PUBLIC_API_URL_V1}/application/${applicationId}${branchPath}/components`,
578
- superblocksBaseUrl
576
+ superblocksBaseUrl,
579
577
  ).toString(),
580
578
  headers: {
581
579
  Authorization: "Bearer " + token,
@@ -596,13 +594,13 @@ export async function registerComponents(
596
594
  throw new Error(
597
595
  `Could not register application components ${
598
596
  message ? "\n" + message : ""
599
- }`
597
+ }`,
600
598
  );
601
599
  }
602
600
  throw new Error(
603
601
  `Could not register application components ${
604
602
  e.message ? "\n" + (e as Error).message : ""
605
- }`
603
+ }`,
606
604
  );
607
605
  }
608
606
  }
@@ -642,10 +640,10 @@ export async function uploadComponents({
642
640
  });
643
641
 
644
642
  const buildFiles: UploadFile[] = uploadFiles.filter((uploadFile) =>
645
- uploadFile.filename.startsWith("dist/")
643
+ uploadFile.filename.startsWith("dist/"),
646
644
  );
647
645
  const srcFiles: UploadFile[] = uploadFiles.filter(
648
- (uploadFile) => !uploadFile.filename.startsWith("dist/")
646
+ (uploadFile) => !uploadFile.filename.startsWith("dist/"),
649
647
  );
650
648
 
651
649
  const formatJSON = JSON.stringify({
@@ -657,7 +655,7 @@ export async function uploadComponents({
657
655
  });
658
656
  const postURL = new URL(
659
657
  `${BASE_BUCKETEER_URL}/v2/components/upload`,
660
- bucketeerBaseUrl
658
+ bucketeerBaseUrl,
661
659
  ).toString();
662
660
 
663
661
  let totalFileSizeMB = 0;
@@ -695,7 +693,7 @@ You can reduce your component bundle size by uploading static assets to a separa
695
693
  const initialSocket = await createSocketConnectionIfNeeded(
696
694
  cliVersion,
697
695
  token,
698
- superblocksBaseUrl
696
+ superblocksBaseUrl,
699
697
  );
700
698
  const socket =
701
699
  initialSocket ??
@@ -721,7 +719,7 @@ You can reduce your component bundle size by uploading static assets to a separa
721
719
  } catch (e: any) {
722
720
  if (e instanceof AxiosError && e.response?.status === 413) {
723
721
  throw new Error(
724
- `Could not upload application components, file size limit exceeded`
722
+ `Could not upload application components, file size limit exceeded`,
725
723
  );
726
724
  } else {
727
725
  let message: string;
@@ -743,14 +741,14 @@ You can reduce your component bundle size by uploading static assets to a separa
743
741
  export async function fetchCurrentUser(
744
742
  cliVersion: string,
745
743
  token: string,
746
- superblocksBaseUrl: string
744
+ superblocksBaseUrl: string,
747
745
  ): Promise<UserMeDto> {
748
746
  try {
749
747
  const config: AxiosRequestConfig = {
750
748
  method: "get",
751
749
  url: new URL(
752
750
  `${BASE_SERVER_PUBLIC_API_URL_V1}/users/me`,
753
- superblocksBaseUrl
751
+ superblocksBaseUrl,
754
752
  ).toString(),
755
753
  headers: {
756
754
  Authorization: "Bearer " + token,
@@ -767,8 +765,7 @@ export async function fetchCurrentUser(
767
765
  (e.response?.data?.responseMeta?.message as string) ??
768
766
  JSON.stringify(e.response?.data) ??
769
767
  e.response?.statusText ??
770
- e?.message ??
771
- `${e}`;
768
+ e?.message;
772
769
  } else {
773
770
  message = `${e?.message ? e?.message : e}`;
774
771
  }
@@ -779,7 +776,7 @@ export async function fetchCurrentUser(
779
776
  export const createSocketConnectionIfNeeded = async (
780
777
  cliVersion: string,
781
778
  token: string,
782
- superblocksBaseUrl: string
779
+ superblocksBaseUrl: string,
783
780
  ): Promise<StdISocketRPCClient | undefined> => {
784
781
  const userMe = await fetchCurrentUser(cliVersion, token, superblocksBaseUrl);
785
782
  const organization = userMe.organizations[0];
@@ -791,7 +788,7 @@ export const createSocketConnectionIfNeeded = async (
791
788
  const agentUrl = await getAgentUrl(
792
789
  userMe.agents,
793
790
  organization.agentType,
794
- profile
791
+ profile,
795
792
  );
796
793
  return await connectToISocketRPCServer({
797
794
  agentUrl,
@@ -823,7 +820,7 @@ export async function pushApplication({
823
820
  throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
824
821
  } else if (status === 409) {
825
822
  throw new CommitAlreadyExistsError(
826
- `Commit ${applicationConfig.commitId} already exists`
823
+ `Commit ${applicationConfig.commitId} already exists`,
827
824
  );
828
825
  }
829
826
  };
@@ -831,7 +828,7 @@ export async function pushApplication({
831
828
  const socket = await createSocketConnectionIfNeeded(
832
829
  cliVersion,
833
830
  token,
834
- superblocksBaseUrl
831
+ superblocksBaseUrl,
835
832
  );
836
833
 
837
834
  if (socket) {
@@ -860,9 +857,9 @@ export async function pushApplication({
860
857
  } else {
861
858
  const serverURL = new URL(
862
859
  `${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}/branches/${encodeURIComponent(
863
- branch
860
+ branch,
864
861
  )}/push`,
865
- superblocksBaseUrl
862
+ superblocksBaseUrl,
866
863
  );
867
864
  const config: AxiosRequestConfig = {
868
865
  method: "post",
@@ -875,16 +872,17 @@ export async function pushApplication({
875
872
  data: applicationConfig,
876
873
  };
877
874
  try {
878
- const serverResponse = await axios<
879
- ResponseWithMeta<RemoteCommitDto | { updated: Date }>
880
- >(config);
875
+ const serverResponse =
876
+ await axios<ResponseWithMeta<RemoteCommitDto | { updated: Date }>>(
877
+ config,
878
+ );
881
879
  return serverResponse?.data?.data;
882
880
  } catch (e) {
883
881
  if (!axios.isAxiosError(e)) {
884
882
  throw e;
885
883
  }
886
884
  handleHttpError(
887
- e.response?.data?.responseMeta?.status ?? e.response?.status
885
+ e.response?.data?.responseMeta?.status ?? e.response?.status,
888
886
  );
889
887
  const message =
890
888
  (e.response?.data?.responseMeta?.message as string) ??
@@ -904,7 +902,7 @@ export async function pushApplication({
904
902
  throw new Error(
905
903
  `Could not push application ${
906
904
  (e as Error).message ? "\n" + (e as Error).message : ""
907
- }`
905
+ }`,
908
906
  );
909
907
  }
910
908
  }
@@ -931,21 +929,21 @@ export async function pushApi({
931
929
  throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
932
930
  } else if (status === 409) {
933
931
  throw new CommitAlreadyExistsError(
934
- `Commit ${apiConfig.commitId} already exists`
932
+ `Commit ${apiConfig.commitId} already exists`,
935
933
  );
936
934
  }
937
935
  };
938
936
  const serverURL = new URL(
939
937
  `${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(
940
- branch
938
+ branch,
941
939
  )}/push`,
942
- superblocksBaseUrl
940
+ superblocksBaseUrl,
943
941
  );
944
942
  try {
945
943
  const socket = await createSocketConnectionIfNeeded(
946
944
  cliVersion,
947
945
  token,
948
- superblocksBaseUrl
946
+ superblocksBaseUrl,
949
947
  );
950
948
  if (socket) {
951
949
  const resp = await socket.call.v1.public.api.pushCommit({
@@ -978,9 +976,10 @@ export async function pushApi({
978
976
  data: apiConfig,
979
977
  };
980
978
  try {
981
- const serverResponse = await axios<
982
- ResponseWithMeta<{ commitId: string } | { updated: Date }>
983
- >(config);
979
+ const serverResponse =
980
+ await axios<
981
+ ResponseWithMeta<{ commitId: string } | { updated: Date }>
982
+ >(config);
984
983
  return serverResponse?.data?.data;
985
984
  } catch (e) {
986
985
  if (!axios.isAxiosError(e)) {
@@ -1005,7 +1004,7 @@ export async function pushApi({
1005
1004
  throw new Error(
1006
1005
  `Could not push api ${
1007
1006
  (e as Error).message ? "\n" + (e as Error).message : ""
1008
- }`
1007
+ }`,
1009
1008
  );
1010
1009
  }
1011
1010
  }
@@ -1033,13 +1032,13 @@ export async function fetchApplicationCommits({
1033
1032
  const serverURL = branch
1034
1033
  ? new URL(
1035
1034
  `${BASE_SERVER_API_URL_V2}/applications/${applicationId}/branches/${encodeURIComponent(
1036
- branch
1035
+ branch,
1037
1036
  )}/commits`,
1038
- superblocksBaseUrl
1037
+ superblocksBaseUrl,
1039
1038
  )
1040
1039
  : new URL(
1041
1040
  `${BASE_SERVER_API_URL_V2}/applications/${applicationId}/commits`,
1042
- superblocksBaseUrl
1041
+ superblocksBaseUrl,
1043
1042
  );
1044
1043
  serverURL.search = new URLSearchParams({
1045
1044
  commitType: "commit",
@@ -1055,9 +1054,8 @@ export async function fetchApplicationCommits({
1055
1054
  ...injectedHeaders,
1056
1055
  },
1057
1056
  };
1058
- const serverResponse = await axios<
1059
- ResponseWithMeta<GetCommitsResponseBody>
1060
- >(config);
1057
+ const serverResponse =
1058
+ await axios<ResponseWithMeta<GetCommitsResponseBody>>(config);
1061
1059
  return serverResponse?.data?.data;
1062
1060
  } catch (e) {
1063
1061
  if (axios.isAxiosError(e) && e.response?.status === 404) {
@@ -1090,13 +1088,13 @@ export async function fetchApiCommits({
1090
1088
  const serverURL = branch
1091
1089
  ? new URL(
1092
1090
  `${BASE_SERVER_API_URL_V3}/apis/${applicationId}/branches/${encodeURIComponent(
1093
- branch
1091
+ branch,
1094
1092
  )}/commits`,
1095
- superblocksBaseUrl
1093
+ superblocksBaseUrl,
1096
1094
  )
1097
1095
  : new URL(
1098
1096
  `${BASE_SERVER_API_URL_V3}/apis/${applicationId}/commits`,
1099
- superblocksBaseUrl
1097
+ superblocksBaseUrl,
1100
1098
  );
1101
1099
  serverURL.search = new URLSearchParams({
1102
1100
  commitType: "commit",
@@ -1112,9 +1110,8 @@ export async function fetchApiCommits({
1112
1110
  ...injectedHeaders,
1113
1111
  },
1114
1112
  };
1115
- const serverResponse = await axios<
1116
- ResponseWithMeta<GetCommitsResponseBody>
1117
- >(config);
1113
+ const serverResponse =
1114
+ await axios<ResponseWithMeta<GetCommitsResponseBody>>(config);
1118
1115
  return serverResponse?.data?.data;
1119
1116
  } catch (e) {
1120
1117
  if (axios.isAxiosError(e) && e.response?.status === 404) {
package/src/flag.ts CHANGED
@@ -3,3 +3,28 @@ import { FlagBootstrap } from "./types";
3
3
  export const signingEnabled = (flags: FlagBootstrap): boolean => {
4
4
  return flags["ui.enable-resource-signing"] ?? false;
5
5
  };
6
+
7
+ export const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
8
+
9
+ export class FeatureFlags {
10
+ constructor(private flags: FlagBootstrap) {}
11
+
12
+ signingEnabled(): boolean {
13
+ return this.flags["ui.enable-resource-signing"] ?? false;
14
+ }
15
+
16
+ splitLargeApiStepsEnabled(): boolean {
17
+ return this.flags["superblocks.git.split.large.steps.enabled"] ?? false;
18
+ }
19
+
20
+ splitLargeApiStepsInNewEnabled(): boolean {
21
+ return this.flags["superblocks.git.split.large.steps.new.enabled"] ?? false;
22
+ }
23
+
24
+ linesForLargeSteps(): number {
25
+ return (
26
+ this.flags["superblocks.git.split.large.step.lines"] ??
27
+ DEFAULT_LINES_FOR_LARGE_STEPS
28
+ );
29
+ }
30
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from "./client";
2
+ export * from "./flag";
2
3
  export * from "./sdk";
4
+ export * from "./types";