@superblocksteam/sdk 1.10.0 → 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/LICENSE.txt +87 -0
- package/dist/client.js +19 -22
- package/dist/flag.d.ts +1 -1
- package/dist/flag.js +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/sdk.js +3 -3
- package/dist/socket/handlers.js +1 -2
- package/dist/socket/index.js +7 -6
- package/dist/socket/signing.js +2 -3
- package/dist/socket/socket.js +14 -3
- package/dist/types/common.js +5 -0
- package/dist/types/socket.js +2 -0
- package/dist/utils.js +3 -3
- package/package.json +24 -18
- package/src/client.ts +71 -75
- package/src/flag.ts +1 -1
- package/src/index.ts +1 -0
- package/src/sdk.ts +9 -9
- package/src/socket/handlers.ts +4 -4
- package/src/socket/index.ts +8 -8
- package/src/socket/socket.ts +21 -19
- package/src/types/socket.ts +8 -8
- package/src/utils.ts +6 -6
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -0
package/src/client.ts
CHANGED
|
@@ -135,20 +135,20 @@ export async function fetchApplication({
|
|
|
135
135
|
}): Promise<MultiPageApplicationWrapper | undefined> {
|
|
136
136
|
if (commitId && viewMode !== "export-commit") {
|
|
137
137
|
throw new Error(
|
|
138
|
-
`If commitId ${commitId} is provided, viewMode cannot be ${viewMode}
|
|
138
|
+
`If commitId ${commitId} is provided, viewMode cannot be ${viewMode}`,
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
try {
|
|
142
142
|
const serverURL = branch
|
|
143
143
|
? new URL(
|
|
144
144
|
`${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}/branches/${encodeURIComponent(
|
|
145
|
-
branch
|
|
145
|
+
branch,
|
|
146
146
|
)}`,
|
|
147
|
-
superblocksBaseUrl
|
|
147
|
+
superblocksBaseUrl,
|
|
148
148
|
)
|
|
149
149
|
: new URL(
|
|
150
150
|
`${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}`,
|
|
151
|
-
superblocksBaseUrl
|
|
151
|
+
superblocksBaseUrl,
|
|
152
152
|
);
|
|
153
153
|
serverURL.search = new URLSearchParams({
|
|
154
154
|
viewMode,
|
|
@@ -158,7 +158,7 @@ export async function fetchApplication({
|
|
|
158
158
|
? await createSocketConnectionIfNeeded(
|
|
159
159
|
cliVersion,
|
|
160
160
|
token,
|
|
161
|
-
superblocksBaseUrl
|
|
161
|
+
superblocksBaseUrl,
|
|
162
162
|
)
|
|
163
163
|
: undefined;
|
|
164
164
|
if (socket) {
|
|
@@ -183,9 +183,8 @@ export async function fetchApplication({
|
|
|
183
183
|
...injectedHeaders,
|
|
184
184
|
},
|
|
185
185
|
};
|
|
186
|
-
const serverResponse =
|
|
187
|
-
ResponseWithMeta<MultiPageApplicationWrapper
|
|
188
|
-
>(config);
|
|
186
|
+
const serverResponse =
|
|
187
|
+
await axios<ResponseWithMeta<MultiPageApplicationWrapper>>(config);
|
|
189
188
|
const data = serverResponse?.data?.data;
|
|
190
189
|
return data;
|
|
191
190
|
} catch (e) {
|
|
@@ -195,7 +194,7 @@ export async function fetchApplication({
|
|
|
195
194
|
throw new Error(
|
|
196
195
|
`Could not fetch application: ${
|
|
197
196
|
typeof e === "object" && e && "message" in e ? e.message : e
|
|
198
|
-
}
|
|
197
|
+
}`,
|
|
199
198
|
);
|
|
200
199
|
}
|
|
201
200
|
}
|
|
@@ -215,7 +214,7 @@ export async function fetchApplicationBranches({
|
|
|
215
214
|
}): Promise<Branches | undefined> {
|
|
216
215
|
const serverURL = new URL(
|
|
217
216
|
`public/applications/${applicationId}/branches`,
|
|
218
|
-
superblocksBaseUrl
|
|
217
|
+
superblocksBaseUrl,
|
|
219
218
|
);
|
|
220
219
|
let serverResponse;
|
|
221
220
|
|
|
@@ -297,7 +296,7 @@ export async function fetchApplicationWithComponents({
|
|
|
297
296
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
298
297
|
const componentFileURL = new URL(
|
|
299
298
|
`${BASE_BUCKETEER_URL}/v1/components/${applicationId}${branchPath}?commit=${commitId}&viewMode=${viewMode}&multiPage=true`,
|
|
300
|
-
bucketeerBaseUrl
|
|
299
|
+
bucketeerBaseUrl,
|
|
301
300
|
).toString();
|
|
302
301
|
|
|
303
302
|
try {
|
|
@@ -318,11 +317,11 @@ export async function fetchApplicationWithComponents({
|
|
|
318
317
|
if (
|
|
319
318
|
!isEqual(
|
|
320
319
|
applicationWrapper.application.settings,
|
|
321
|
-
bucketeerApp.application.settings
|
|
320
|
+
bucketeerApp.application.settings,
|
|
322
321
|
)
|
|
323
322
|
) {
|
|
324
323
|
throw new Error(
|
|
325
|
-
"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",
|
|
326
325
|
);
|
|
327
326
|
}
|
|
328
327
|
|
|
@@ -339,14 +338,14 @@ export async function fetchApplications(
|
|
|
339
338
|
cliVersion: string,
|
|
340
339
|
token: string,
|
|
341
340
|
superblocksBaseUrl: string,
|
|
342
|
-
injectedHeaders: Record<string, string> = {}
|
|
341
|
+
injectedHeaders: Record<string, string> = {},
|
|
343
342
|
) {
|
|
344
343
|
try {
|
|
345
344
|
const config: AxiosRequestConfig = {
|
|
346
345
|
method: "get",
|
|
347
346
|
url: new URL(
|
|
348
347
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/applications`,
|
|
349
|
-
superblocksBaseUrl
|
|
348
|
+
superblocksBaseUrl,
|
|
350
349
|
).toString(),
|
|
351
350
|
headers: {
|
|
352
351
|
Authorization: "Bearer " + token,
|
|
@@ -363,8 +362,7 @@ export async function fetchApplications(
|
|
|
363
362
|
(e.response?.data?.responseMeta?.message as string) ??
|
|
364
363
|
JSON.stringify(e.response?.data) ??
|
|
365
364
|
e.response?.statusText ??
|
|
366
|
-
e?.message
|
|
367
|
-
`${e}`;
|
|
365
|
+
e?.message;
|
|
368
366
|
} else {
|
|
369
367
|
message = `${e?.message ? e?.message : e}`;
|
|
370
368
|
}
|
|
@@ -380,19 +378,19 @@ export async function fetchApi(
|
|
|
380
378
|
viewMode: ViewMode,
|
|
381
379
|
branch?: string,
|
|
382
380
|
commitId?: string,
|
|
383
|
-
skipSigningVerification = false
|
|
381
|
+
skipSigningVerification = false,
|
|
384
382
|
) {
|
|
385
383
|
try {
|
|
386
384
|
const serverURL = branch
|
|
387
385
|
? new URL(
|
|
388
386
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(
|
|
389
|
-
branch
|
|
387
|
+
branch,
|
|
390
388
|
)}`,
|
|
391
|
-
superblocksBaseUrl
|
|
389
|
+
superblocksBaseUrl,
|
|
392
390
|
)
|
|
393
391
|
: new URL(
|
|
394
392
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}`,
|
|
395
|
-
superblocksBaseUrl
|
|
393
|
+
superblocksBaseUrl,
|
|
396
394
|
);
|
|
397
395
|
serverURL.search = new URLSearchParams({
|
|
398
396
|
viewMode,
|
|
@@ -402,7 +400,7 @@ export async function fetchApi(
|
|
|
402
400
|
? await createSocketConnectionIfNeeded(
|
|
403
401
|
cliVersion,
|
|
404
402
|
token,
|
|
405
|
-
superblocksBaseUrl
|
|
403
|
+
superblocksBaseUrl,
|
|
406
404
|
)
|
|
407
405
|
: undefined;
|
|
408
406
|
|
|
@@ -436,7 +434,7 @@ export async function fetchApi(
|
|
|
436
434
|
throw new Error(
|
|
437
435
|
`Could not fetch api: ${
|
|
438
436
|
typeof e === "object" && e && "message" in e ? e.message : e
|
|
439
|
-
}
|
|
437
|
+
}`,
|
|
440
438
|
);
|
|
441
439
|
}
|
|
442
440
|
}
|
|
@@ -444,14 +442,14 @@ export async function fetchApi(
|
|
|
444
442
|
export async function fetchApis(
|
|
445
443
|
cliVersion: string,
|
|
446
444
|
token: string,
|
|
447
|
-
superblocksBaseUrl: string
|
|
445
|
+
superblocksBaseUrl: string,
|
|
448
446
|
) {
|
|
449
447
|
try {
|
|
450
448
|
const config: AxiosRequestConfig = {
|
|
451
449
|
method: "get",
|
|
452
450
|
url: new URL(
|
|
453
451
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/apis`,
|
|
454
|
-
superblocksBaseUrl
|
|
452
|
+
superblocksBaseUrl,
|
|
455
453
|
).toString(),
|
|
456
454
|
headers: {
|
|
457
455
|
Authorization: "Bearer " + token,
|
|
@@ -460,7 +458,7 @@ export async function fetchApis(
|
|
|
460
458
|
};
|
|
461
459
|
const response = await axios(config);
|
|
462
460
|
return response.data.data.apis;
|
|
463
|
-
} catch
|
|
461
|
+
} catch {
|
|
464
462
|
throw new Error("Could not fetch apis");
|
|
465
463
|
}
|
|
466
464
|
}
|
|
@@ -473,7 +471,7 @@ export async function validateGitSetup(
|
|
|
473
471
|
localGitRepoState: LocalGitRepoState,
|
|
474
472
|
token: string,
|
|
475
473
|
superblocksBaseUrl: string,
|
|
476
|
-
injectedHeaders?: Record<string, string
|
|
474
|
+
injectedHeaders?: Record<string, string>,
|
|
477
475
|
) {
|
|
478
476
|
let resourceName: string | undefined;
|
|
479
477
|
try {
|
|
@@ -498,7 +496,7 @@ export async function validateGitSetup(
|
|
|
498
496
|
method: "post",
|
|
499
497
|
url: new URL(
|
|
500
498
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/${path}`,
|
|
501
|
-
superblocksBaseUrl
|
|
499
|
+
superblocksBaseUrl,
|
|
502
500
|
).toString(),
|
|
503
501
|
headers: {
|
|
504
502
|
Authorization: "Bearer " + token,
|
|
@@ -525,8 +523,7 @@ export async function validateGitSetup(
|
|
|
525
523
|
(e.response?.data?.responseMeta?.message as string) ??
|
|
526
524
|
JSON.stringify(e.response?.data) ??
|
|
527
525
|
e.response?.statusText ??
|
|
528
|
-
e?.message
|
|
529
|
-
`${e}`;
|
|
526
|
+
e?.message;
|
|
530
527
|
} else {
|
|
531
528
|
message = `${e?.message ? e.message : e}`;
|
|
532
529
|
}
|
|
@@ -552,14 +549,14 @@ export async function registerComponents(
|
|
|
552
549
|
token: string,
|
|
553
550
|
superblocksBaseUrl: string,
|
|
554
551
|
branch: string | null,
|
|
555
|
-
injectedHeaders: Record<string, string
|
|
552
|
+
injectedHeaders: Record<string, string>,
|
|
556
553
|
) {
|
|
557
554
|
try {
|
|
558
555
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
559
556
|
const socket = await createSocketConnectionIfNeeded(
|
|
560
557
|
cliVersion,
|
|
561
558
|
token,
|
|
562
|
-
superblocksBaseUrl
|
|
559
|
+
superblocksBaseUrl,
|
|
563
560
|
);
|
|
564
561
|
if (socket) {
|
|
565
562
|
const resp = await socket.call.v1.public.application.component.register({
|
|
@@ -576,7 +573,7 @@ export async function registerComponents(
|
|
|
576
573
|
method: "put",
|
|
577
574
|
url: new URL(
|
|
578
575
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/application/${applicationId}${branchPath}/components`,
|
|
579
|
-
superblocksBaseUrl
|
|
576
|
+
superblocksBaseUrl,
|
|
580
577
|
).toString(),
|
|
581
578
|
headers: {
|
|
582
579
|
Authorization: "Bearer " + token,
|
|
@@ -597,13 +594,13 @@ export async function registerComponents(
|
|
|
597
594
|
throw new Error(
|
|
598
595
|
`Could not register application components ${
|
|
599
596
|
message ? "\n" + message : ""
|
|
600
|
-
}
|
|
597
|
+
}`,
|
|
601
598
|
);
|
|
602
599
|
}
|
|
603
600
|
throw new Error(
|
|
604
601
|
`Could not register application components ${
|
|
605
602
|
e.message ? "\n" + (e as Error).message : ""
|
|
606
|
-
}
|
|
603
|
+
}`,
|
|
607
604
|
);
|
|
608
605
|
}
|
|
609
606
|
}
|
|
@@ -643,10 +640,10 @@ export async function uploadComponents({
|
|
|
643
640
|
});
|
|
644
641
|
|
|
645
642
|
const buildFiles: UploadFile[] = uploadFiles.filter((uploadFile) =>
|
|
646
|
-
uploadFile.filename.startsWith("dist/")
|
|
643
|
+
uploadFile.filename.startsWith("dist/"),
|
|
647
644
|
);
|
|
648
645
|
const srcFiles: UploadFile[] = uploadFiles.filter(
|
|
649
|
-
(uploadFile) => !uploadFile.filename.startsWith("dist/")
|
|
646
|
+
(uploadFile) => !uploadFile.filename.startsWith("dist/"),
|
|
650
647
|
);
|
|
651
648
|
|
|
652
649
|
const formatJSON = JSON.stringify({
|
|
@@ -658,7 +655,7 @@ export async function uploadComponents({
|
|
|
658
655
|
});
|
|
659
656
|
const postURL = new URL(
|
|
660
657
|
`${BASE_BUCKETEER_URL}/v2/components/upload`,
|
|
661
|
-
bucketeerBaseUrl
|
|
658
|
+
bucketeerBaseUrl,
|
|
662
659
|
).toString();
|
|
663
660
|
|
|
664
661
|
let totalFileSizeMB = 0;
|
|
@@ -696,7 +693,7 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
696
693
|
const initialSocket = await createSocketConnectionIfNeeded(
|
|
697
694
|
cliVersion,
|
|
698
695
|
token,
|
|
699
|
-
superblocksBaseUrl
|
|
696
|
+
superblocksBaseUrl,
|
|
700
697
|
);
|
|
701
698
|
const socket =
|
|
702
699
|
initialSocket ??
|
|
@@ -722,7 +719,7 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
722
719
|
} catch (e: any) {
|
|
723
720
|
if (e instanceof AxiosError && e.response?.status === 413) {
|
|
724
721
|
throw new Error(
|
|
725
|
-
`Could not upload application components, file size limit exceeded
|
|
722
|
+
`Could not upload application components, file size limit exceeded`,
|
|
726
723
|
);
|
|
727
724
|
} else {
|
|
728
725
|
let message: string;
|
|
@@ -744,14 +741,14 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
744
741
|
export async function fetchCurrentUser(
|
|
745
742
|
cliVersion: string,
|
|
746
743
|
token: string,
|
|
747
|
-
superblocksBaseUrl: string
|
|
744
|
+
superblocksBaseUrl: string,
|
|
748
745
|
): Promise<UserMeDto> {
|
|
749
746
|
try {
|
|
750
747
|
const config: AxiosRequestConfig = {
|
|
751
748
|
method: "get",
|
|
752
749
|
url: new URL(
|
|
753
750
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/users/me`,
|
|
754
|
-
superblocksBaseUrl
|
|
751
|
+
superblocksBaseUrl,
|
|
755
752
|
).toString(),
|
|
756
753
|
headers: {
|
|
757
754
|
Authorization: "Bearer " + token,
|
|
@@ -768,8 +765,7 @@ export async function fetchCurrentUser(
|
|
|
768
765
|
(e.response?.data?.responseMeta?.message as string) ??
|
|
769
766
|
JSON.stringify(e.response?.data) ??
|
|
770
767
|
e.response?.statusText ??
|
|
771
|
-
e?.message
|
|
772
|
-
`${e}`;
|
|
768
|
+
e?.message;
|
|
773
769
|
} else {
|
|
774
770
|
message = `${e?.message ? e?.message : e}`;
|
|
775
771
|
}
|
|
@@ -780,7 +776,7 @@ export async function fetchCurrentUser(
|
|
|
780
776
|
export const createSocketConnectionIfNeeded = async (
|
|
781
777
|
cliVersion: string,
|
|
782
778
|
token: string,
|
|
783
|
-
superblocksBaseUrl: string
|
|
779
|
+
superblocksBaseUrl: string,
|
|
784
780
|
): Promise<StdISocketRPCClient | undefined> => {
|
|
785
781
|
const userMe = await fetchCurrentUser(cliVersion, token, superblocksBaseUrl);
|
|
786
782
|
const organization = userMe.organizations[0];
|
|
@@ -792,7 +788,7 @@ export const createSocketConnectionIfNeeded = async (
|
|
|
792
788
|
const agentUrl = await getAgentUrl(
|
|
793
789
|
userMe.agents,
|
|
794
790
|
organization.agentType,
|
|
795
|
-
profile
|
|
791
|
+
profile,
|
|
796
792
|
);
|
|
797
793
|
return await connectToISocketRPCServer({
|
|
798
794
|
agentUrl,
|
|
@@ -824,7 +820,7 @@ export async function pushApplication({
|
|
|
824
820
|
throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
825
821
|
} else if (status === 409) {
|
|
826
822
|
throw new CommitAlreadyExistsError(
|
|
827
|
-
`Commit ${applicationConfig.commitId} already exists
|
|
823
|
+
`Commit ${applicationConfig.commitId} already exists`,
|
|
828
824
|
);
|
|
829
825
|
}
|
|
830
826
|
};
|
|
@@ -832,7 +828,7 @@ export async function pushApplication({
|
|
|
832
828
|
const socket = await createSocketConnectionIfNeeded(
|
|
833
829
|
cliVersion,
|
|
834
830
|
token,
|
|
835
|
-
superblocksBaseUrl
|
|
831
|
+
superblocksBaseUrl,
|
|
836
832
|
);
|
|
837
833
|
|
|
838
834
|
if (socket) {
|
|
@@ -861,9 +857,9 @@ export async function pushApplication({
|
|
|
861
857
|
} else {
|
|
862
858
|
const serverURL = new URL(
|
|
863
859
|
`${BASE_SERVER_PUBLIC_API_URL_v2}/applications/${applicationId}/branches/${encodeURIComponent(
|
|
864
|
-
branch
|
|
860
|
+
branch,
|
|
865
861
|
)}/push`,
|
|
866
|
-
superblocksBaseUrl
|
|
862
|
+
superblocksBaseUrl,
|
|
867
863
|
);
|
|
868
864
|
const config: AxiosRequestConfig = {
|
|
869
865
|
method: "post",
|
|
@@ -876,16 +872,17 @@ export async function pushApplication({
|
|
|
876
872
|
data: applicationConfig,
|
|
877
873
|
};
|
|
878
874
|
try {
|
|
879
|
-
const serverResponse =
|
|
880
|
-
ResponseWithMeta<RemoteCommitDto | { updated: Date }
|
|
881
|
-
|
|
875
|
+
const serverResponse =
|
|
876
|
+
await axios<ResponseWithMeta<RemoteCommitDto | { updated: Date }>>(
|
|
877
|
+
config,
|
|
878
|
+
);
|
|
882
879
|
return serverResponse?.data?.data;
|
|
883
880
|
} catch (e) {
|
|
884
881
|
if (!axios.isAxiosError(e)) {
|
|
885
882
|
throw e;
|
|
886
883
|
}
|
|
887
884
|
handleHttpError(
|
|
888
|
-
e.response?.data?.responseMeta?.status ?? e.response?.status
|
|
885
|
+
e.response?.data?.responseMeta?.status ?? e.response?.status,
|
|
889
886
|
);
|
|
890
887
|
const message =
|
|
891
888
|
(e.response?.data?.responseMeta?.message as string) ??
|
|
@@ -905,7 +902,7 @@ export async function pushApplication({
|
|
|
905
902
|
throw new Error(
|
|
906
903
|
`Could not push application ${
|
|
907
904
|
(e as Error).message ? "\n" + (e as Error).message : ""
|
|
908
|
-
}
|
|
905
|
+
}`,
|
|
909
906
|
);
|
|
910
907
|
}
|
|
911
908
|
}
|
|
@@ -932,21 +929,21 @@ export async function pushApi({
|
|
|
932
929
|
throw new BranchNotCheckedOutError(`Branch ${branch} is not checked out`);
|
|
933
930
|
} else if (status === 409) {
|
|
934
931
|
throw new CommitAlreadyExistsError(
|
|
935
|
-
`Commit ${apiConfig.commitId} already exists
|
|
932
|
+
`Commit ${apiConfig.commitId} already exists`,
|
|
936
933
|
);
|
|
937
934
|
}
|
|
938
935
|
};
|
|
939
936
|
const serverURL = new URL(
|
|
940
937
|
`${BASE_SERVER_PUBLIC_API_URL_V1}/apis/${apiId}/branches/${encodeURIComponent(
|
|
941
|
-
branch
|
|
938
|
+
branch,
|
|
942
939
|
)}/push`,
|
|
943
|
-
superblocksBaseUrl
|
|
940
|
+
superblocksBaseUrl,
|
|
944
941
|
);
|
|
945
942
|
try {
|
|
946
943
|
const socket = await createSocketConnectionIfNeeded(
|
|
947
944
|
cliVersion,
|
|
948
945
|
token,
|
|
949
|
-
superblocksBaseUrl
|
|
946
|
+
superblocksBaseUrl,
|
|
950
947
|
);
|
|
951
948
|
if (socket) {
|
|
952
949
|
const resp = await socket.call.v1.public.api.pushCommit({
|
|
@@ -979,9 +976,10 @@ export async function pushApi({
|
|
|
979
976
|
data: apiConfig,
|
|
980
977
|
};
|
|
981
978
|
try {
|
|
982
|
-
const serverResponse =
|
|
983
|
-
|
|
984
|
-
|
|
979
|
+
const serverResponse =
|
|
980
|
+
await axios<
|
|
981
|
+
ResponseWithMeta<{ commitId: string } | { updated: Date }>
|
|
982
|
+
>(config);
|
|
985
983
|
return serverResponse?.data?.data;
|
|
986
984
|
} catch (e) {
|
|
987
985
|
if (!axios.isAxiosError(e)) {
|
|
@@ -1006,7 +1004,7 @@ export async function pushApi({
|
|
|
1006
1004
|
throw new Error(
|
|
1007
1005
|
`Could not push api ${
|
|
1008
1006
|
(e as Error).message ? "\n" + (e as Error).message : ""
|
|
1009
|
-
}
|
|
1007
|
+
}`,
|
|
1010
1008
|
);
|
|
1011
1009
|
}
|
|
1012
1010
|
}
|
|
@@ -1034,13 +1032,13 @@ export async function fetchApplicationCommits({
|
|
|
1034
1032
|
const serverURL = branch
|
|
1035
1033
|
? new URL(
|
|
1036
1034
|
`${BASE_SERVER_API_URL_V2}/applications/${applicationId}/branches/${encodeURIComponent(
|
|
1037
|
-
branch
|
|
1035
|
+
branch,
|
|
1038
1036
|
)}/commits`,
|
|
1039
|
-
superblocksBaseUrl
|
|
1037
|
+
superblocksBaseUrl,
|
|
1040
1038
|
)
|
|
1041
1039
|
: new URL(
|
|
1042
1040
|
`${BASE_SERVER_API_URL_V2}/applications/${applicationId}/commits`,
|
|
1043
|
-
superblocksBaseUrl
|
|
1041
|
+
superblocksBaseUrl,
|
|
1044
1042
|
);
|
|
1045
1043
|
serverURL.search = new URLSearchParams({
|
|
1046
1044
|
commitType: "commit",
|
|
@@ -1056,9 +1054,8 @@ export async function fetchApplicationCommits({
|
|
|
1056
1054
|
...injectedHeaders,
|
|
1057
1055
|
},
|
|
1058
1056
|
};
|
|
1059
|
-
const serverResponse =
|
|
1060
|
-
ResponseWithMeta<GetCommitsResponseBody
|
|
1061
|
-
>(config);
|
|
1057
|
+
const serverResponse =
|
|
1058
|
+
await axios<ResponseWithMeta<GetCommitsResponseBody>>(config);
|
|
1062
1059
|
return serverResponse?.data?.data;
|
|
1063
1060
|
} catch (e) {
|
|
1064
1061
|
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
|
@@ -1091,13 +1088,13 @@ export async function fetchApiCommits({
|
|
|
1091
1088
|
const serverURL = branch
|
|
1092
1089
|
? new URL(
|
|
1093
1090
|
`${BASE_SERVER_API_URL_V3}/apis/${applicationId}/branches/${encodeURIComponent(
|
|
1094
|
-
branch
|
|
1091
|
+
branch,
|
|
1095
1092
|
)}/commits`,
|
|
1096
|
-
superblocksBaseUrl
|
|
1093
|
+
superblocksBaseUrl,
|
|
1097
1094
|
)
|
|
1098
1095
|
: new URL(
|
|
1099
1096
|
`${BASE_SERVER_API_URL_V3}/apis/${applicationId}/commits`,
|
|
1100
|
-
superblocksBaseUrl
|
|
1097
|
+
superblocksBaseUrl,
|
|
1101
1098
|
);
|
|
1102
1099
|
serverURL.search = new URLSearchParams({
|
|
1103
1100
|
commitType: "commit",
|
|
@@ -1113,9 +1110,8 @@ export async function fetchApiCommits({
|
|
|
1113
1110
|
...injectedHeaders,
|
|
1114
1111
|
},
|
|
1115
1112
|
};
|
|
1116
|
-
const serverResponse =
|
|
1117
|
-
ResponseWithMeta<GetCommitsResponseBody
|
|
1118
|
-
>(config);
|
|
1113
|
+
const serverResponse =
|
|
1114
|
+
await axios<ResponseWithMeta<GetCommitsResponseBody>>(config);
|
|
1119
1115
|
return serverResponse?.data?.data;
|
|
1120
1116
|
} catch (e) {
|
|
1121
1117
|
if (axios.isAxiosError(e) && e.response?.status === 404) {
|
package/src/flag.ts
CHANGED
|
@@ -4,7 +4,7 @@ export const signingEnabled = (flags: FlagBootstrap): boolean => {
|
|
|
4
4
|
return flags["ui.enable-resource-signing"] ?? false;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export const DEFAULT_LINES_FOR_LARGE_STEPS =
|
|
7
|
+
export const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
|
|
8
8
|
|
|
9
9
|
export class FeatureFlags {
|
|
10
10
|
constructor(private flags: FlagBootstrap) {}
|
package/src/index.ts
CHANGED
package/src/sdk.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class SuperblocksSdk {
|
|
|
35
35
|
constructor(
|
|
36
36
|
accessToken: string,
|
|
37
37
|
superblocksBaseUrl: string,
|
|
38
|
-
cliVersion: string
|
|
38
|
+
cliVersion: string,
|
|
39
39
|
) {
|
|
40
40
|
this.token = accessToken;
|
|
41
41
|
this.superblocksBaseUrl = superblocksBaseUrl;
|
|
@@ -169,7 +169,7 @@ export class SuperblocksSdk {
|
|
|
169
169
|
this.cliVersion,
|
|
170
170
|
this.token,
|
|
171
171
|
this.superblocksBaseUrl,
|
|
172
|
-
headers
|
|
172
|
+
headers,
|
|
173
173
|
);
|
|
174
174
|
}
|
|
175
175
|
|
|
@@ -194,7 +194,7 @@ export class SuperblocksSdk {
|
|
|
194
194
|
viewMode,
|
|
195
195
|
branch,
|
|
196
196
|
commitId,
|
|
197
|
-
skipSigningVerification
|
|
197
|
+
skipSigningVerification,
|
|
198
198
|
);
|
|
199
199
|
}
|
|
200
200
|
|
|
@@ -207,7 +207,7 @@ export class SuperblocksSdk {
|
|
|
207
207
|
resourceType: SuperblocksResourceType,
|
|
208
208
|
event: ComponentEvent,
|
|
209
209
|
localGitRepoState: LocalGitRepoState,
|
|
210
|
-
injectedHeaders?: Record<string, string
|
|
210
|
+
injectedHeaders?: Record<string, string>,
|
|
211
211
|
) {
|
|
212
212
|
return validateGitSetup(
|
|
213
213
|
this.cliVersion,
|
|
@@ -217,7 +217,7 @@ export class SuperblocksSdk {
|
|
|
217
217
|
localGitRepoState,
|
|
218
218
|
this.token,
|
|
219
219
|
this.superblocksBaseUrl,
|
|
220
|
-
injectedHeaders
|
|
220
|
+
injectedHeaders,
|
|
221
221
|
);
|
|
222
222
|
}
|
|
223
223
|
|
|
@@ -225,7 +225,7 @@ export class SuperblocksSdk {
|
|
|
225
225
|
applicationId: string,
|
|
226
226
|
componentConfigs: Record<string, any>,
|
|
227
227
|
branch: string | null,
|
|
228
|
-
injectedHeaders: Record<string, string
|
|
228
|
+
injectedHeaders: Record<string, string>,
|
|
229
229
|
) {
|
|
230
230
|
return registerComponents(
|
|
231
231
|
this.cliVersion,
|
|
@@ -234,7 +234,7 @@ export class SuperblocksSdk {
|
|
|
234
234
|
this.token,
|
|
235
235
|
this.superblocksBaseUrl,
|
|
236
236
|
branch,
|
|
237
|
-
injectedHeaders
|
|
237
|
+
injectedHeaders,
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
|
|
@@ -242,7 +242,7 @@ export class SuperblocksSdk {
|
|
|
242
242
|
applicationId: string,
|
|
243
243
|
componentConfigs: Record<string, any>,
|
|
244
244
|
files: string[],
|
|
245
|
-
branch: string | null
|
|
245
|
+
branch: string | null,
|
|
246
246
|
) {
|
|
247
247
|
return uploadComponents({
|
|
248
248
|
cliVersion: this.cliVersion,
|
|
@@ -259,7 +259,7 @@ export class SuperblocksSdk {
|
|
|
259
259
|
return fetchCurrentUser(
|
|
260
260
|
this.cliVersion,
|
|
261
261
|
this.token,
|
|
262
|
-
this.superblocksBaseUrl
|
|
262
|
+
this.superblocksBaseUrl,
|
|
263
263
|
);
|
|
264
264
|
}
|
|
265
265
|
|
package/src/socket/handlers.ts
CHANGED
|
@@ -181,7 +181,7 @@ export function createRequestHandlers({
|
|
|
181
181
|
}) => {
|
|
182
182
|
if (!agentUrl) {
|
|
183
183
|
throw new Error(
|
|
184
|
-
"Agent url not specified. This shouldn't happen."
|
|
184
|
+
"Agent url not specified. This shouldn't happen.",
|
|
185
185
|
);
|
|
186
186
|
}
|
|
187
187
|
const signature = await signResource({
|
|
@@ -209,7 +209,7 @@ export function createRequestHandlers({
|
|
|
209
209
|
for (const { apiPb } of toSign) {
|
|
210
210
|
if (!agentUrl) {
|
|
211
211
|
throw new Error(
|
|
212
|
-
"Agent url not specified. This shouldn't happen."
|
|
212
|
+
"Agent url not specified. This shouldn't happen.",
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
215
|
const signature = await signResource({
|
|
@@ -234,7 +234,7 @@ export function createRequestHandlers({
|
|
|
234
234
|
try {
|
|
235
235
|
if (!agentUrl) {
|
|
236
236
|
throw new Error(
|
|
237
|
-
"Agent url not specified. This shouldn't happen."
|
|
237
|
+
"Agent url not specified. This shouldn't happen.",
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
await verifyResources({
|
|
@@ -268,7 +268,7 @@ export function createRequestHandlers({
|
|
|
268
268
|
try {
|
|
269
269
|
if (!agentUrl) {
|
|
270
270
|
throw new Error(
|
|
271
|
-
"Agent url not specified. This shouldn't happen."
|
|
271
|
+
"Agent url not specified. This shouldn't happen.",
|
|
272
272
|
);
|
|
273
273
|
}
|
|
274
274
|
await verifyResources({
|
package/src/socket/index.ts
CHANGED
|
@@ -50,7 +50,7 @@ export async function connectToISocketRPCServer({
|
|
|
50
50
|
{
|
|
51
51
|
connectionTimeoutInSeconds: 6 * 60, // 6 minutes
|
|
52
52
|
noResponseTimeoutInSeconds: 5 * 60, // 5 minutes
|
|
53
|
-
}
|
|
53
|
+
},
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -60,7 +60,7 @@ export async function connectToISocketRPCServer({
|
|
|
60
60
|
export class ISocketWithClientAuth<
|
|
61
61
|
ImplementedMethods,
|
|
62
62
|
CallableMethods,
|
|
63
|
-
RequestContext extends RequestContextBase
|
|
63
|
+
RequestContext extends RequestContextBase,
|
|
64
64
|
> extends ISocket<ImplementedMethods, CallableMethods, RequestContext> {
|
|
65
65
|
private readonly authorization?: string;
|
|
66
66
|
private hasSentAuth = false;
|
|
@@ -74,7 +74,7 @@ export class ISocketWithClientAuth<
|
|
|
74
74
|
RequestContext
|
|
75
75
|
>,
|
|
76
76
|
globalMiddlewares: GenericMiddleware<CallableMethods, RequestContext>[],
|
|
77
|
-
timeouts?: SocketTimeouts
|
|
77
|
+
timeouts?: SocketTimeouts,
|
|
78
78
|
) {
|
|
79
79
|
super(ws, requestHandlers, globalMiddlewares, timeouts);
|
|
80
80
|
this.authorization = authorization;
|
|
@@ -83,14 +83,14 @@ export class ISocketWithClientAuth<
|
|
|
83
83
|
// override `request` from the base class to send `authorization` when appropriate
|
|
84
84
|
async request<Params, Result>(
|
|
85
85
|
method: string,
|
|
86
|
-
params: Params
|
|
86
|
+
params: Params,
|
|
87
87
|
): Promise<Result> {
|
|
88
88
|
// only send `authorization` on the first request
|
|
89
89
|
const authorization = this.hasSentAuth ? undefined : this.authorization;
|
|
90
90
|
const result = await super.request<Params, Result>(
|
|
91
91
|
method,
|
|
92
92
|
params,
|
|
93
|
-
authorization
|
|
93
|
+
authorization,
|
|
94
94
|
);
|
|
95
95
|
this.hasSentAuth = true;
|
|
96
96
|
return result;
|
|
@@ -100,7 +100,7 @@ export class ISocketWithClientAuth<
|
|
|
100
100
|
export async function connectISocket<
|
|
101
101
|
CallableMethods,
|
|
102
102
|
ImplementedMethods,
|
|
103
|
-
RequestContext extends RequestContextBase = RequestContextBase
|
|
103
|
+
RequestContext extends RequestContextBase = RequestContextBase,
|
|
104
104
|
>(
|
|
105
105
|
wsUrl: string,
|
|
106
106
|
authorization: string | undefined,
|
|
@@ -110,7 +110,7 @@ export async function connectISocket<
|
|
|
110
110
|
RequestContext
|
|
111
111
|
>,
|
|
112
112
|
globalMiddlewares: GenericMiddleware<CallableMethods, RequestContext>[],
|
|
113
|
-
timeouts?: SocketTimeouts
|
|
113
|
+
timeouts?: SocketTimeouts,
|
|
114
114
|
): Promise<ISocketClient<CallableMethods>> {
|
|
115
115
|
const ws = await connectWebSocket(wsUrl);
|
|
116
116
|
const isocket = new ISocketWithClientAuth(
|
|
@@ -118,7 +118,7 @@ export async function connectISocket<
|
|
|
118
118
|
authorization,
|
|
119
119
|
requestHandlers,
|
|
120
120
|
globalMiddlewares,
|
|
121
|
-
timeouts
|
|
121
|
+
timeouts,
|
|
122
122
|
);
|
|
123
123
|
return createISocketClient(isocket);
|
|
124
124
|
}
|