@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/LICENSE.txt +87 -0
- package/dist/client.d.ts +2 -2
- package/dist/client.js +19 -22
- package/dist/flag.d.ts +9 -0
- package/dist/flag.js +22 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/sdk.d.ts +5 -2
- package/dist/sdk.js +11 -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.d.ts +80 -1
- package/dist/types/common.js +19 -1
- package/dist/types/socket.js +2 -0
- package/dist/utils.js +3 -3
- package/package.json +24 -18
- package/src/client.ts +73 -76
- package/src/flag.ts +25 -0
- package/src/index.ts +2 -0
- package/src/sdk.ts +20 -10
- package/src/socket/handlers.ts +4 -4
- package/src/socket/index.ts +8 -8
- package/src/socket/socket.ts +21 -19
- package/src/types/common.ts +93 -1
- package/src/types/socket.ts +8 -8
- package/src/utils.ts +6 -6
- package/tsconfig.json +1 -1
- package/tsconfig.tsbuildinfo +1 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Superblocks Community Software License
|
|
2
|
+
|
|
3
|
+
This Superblocks Community License Agreement (the “Agreement”) sets forth the terms on which DayZero
|
|
4
|
+
Software, Inc. d/b/a Superblocks (“Superblocks”) makes available certain software made available by Superblocks
|
|
5
|
+
under this Agreement (the “Software”). BY INSTALLING, DOWNLOADING, ACCESSING, USING OR
|
|
6
|
+
DISTRIBUTING ANY OF THE SOFTWARE, YOU AGREE TO THE TERMS AND CONDITIONS OF THIS
|
|
7
|
+
AGREEMENT.IF YOU DO NOT AGREE TO SUCH TERMS AND CONDITIONS, YOU MUST NOT USE THE
|
|
8
|
+
SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU
|
|
9
|
+
REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE
|
|
10
|
+
TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. “Licensee” means you,
|
|
11
|
+
an individual, or the entity on whose behalf you are receiving the Software.
|
|
12
|
+
|
|
13
|
+
1. LICENSE GRANT AND CONDITIONS.
|
|
14
|
+
|
|
15
|
+
1.1 License. Subject to the terms and conditions of this Agreement, Superblocks hereby grants to Licensee a
|
|
16
|
+
non-exclusive, royalty-free, worldwide, non-transferable, non-sublicenseable license during the term of this
|
|
17
|
+
Agreement to: (a) use the Software; (b) prepare modifications and derivative works of the Software; (c)
|
|
18
|
+
distribute the Software (including without limitation in source code or object code form); and (d) reproduce
|
|
19
|
+
copies of the Software (the “License”). Licensee is not granted the right to, and Licensee shall not, exercise the
|
|
20
|
+
License for an Excluded Purpose. For purposes of this Agreement, “Excluded Purpose” means making
|
|
21
|
+
available any software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar online
|
|
22
|
+
service that competes with Superblocks’ products or services.
|
|
23
|
+
|
|
24
|
+
1.2 Conditions. In consideration of the License, Licensee’s distribution of the Software is subject to the
|
|
25
|
+
following conditions:
|
|
26
|
+
|
|
27
|
+
a. Licensee must cause any Software modified by Licensee to carry prominent notices stating that Licensee
|
|
28
|
+
modified the Software.
|
|
29
|
+
b. On each Software copy, Licensee shall reproduce and not remove or alter all Superblocks or third party
|
|
30
|
+
copyright or other proprietary notices contained in the Software, and Licensee must provide the notice
|
|
31
|
+
below with each copy.
|
|
32
|
+
|
|
33
|
+
“This software is made available by DayZero Software, Inc. d/b/a Superblocks, under the terms of the
|
|
34
|
+
Superblocks Community License Agreement. © 2022 DayZero Software, Inc.”
|
|
35
|
+
|
|
36
|
+
1.3 Licensee Modifications. Licensee may add its own copyright notices to modifications made by Licensee
|
|
37
|
+
and may provide additional or different license terms and conditions for use, reproduction, or distribution of
|
|
38
|
+
Licensee’s modifications. While redistributing the Software or modifications thereof, Licensee may choose to
|
|
39
|
+
offer, for a fee or free of charge, support, warranty, indemnity, or other obligations. Licensee, and not
|
|
40
|
+
Superblocks, will be responsible for any such obligations.
|
|
41
|
+
|
|
42
|
+
1.4 No Sublicensing. The License does not include the right to sublicense the Software, however, each recipient
|
|
43
|
+
to which Licensee provides the Software may exercise the Licenses so long as such recipient agrees to the terms
|
|
44
|
+
and conditions of this Agreement.
|
|
45
|
+
|
|
46
|
+
2. TERM AND TERMINATION. This Agreement will continue unless and until earlier terminated as set forth
|
|
47
|
+
herein. If Licensee breaches any of its conditions or obligations under this Agreement, this Agreement will
|
|
48
|
+
terminate automatically and the License will terminate automatically and permanently.
|
|
49
|
+
|
|
50
|
+
3. INTELLECTUAL PROPERTY. As between the parties, Superblocks will retain all right, title, and interest in
|
|
51
|
+
the Software, and all intellectual property rights therein. Superblocks hereby reserves all rights not expressly
|
|
52
|
+
granted to Licensee in this Agreement. Superblocks hereby reserves all rights in its trademarks and service
|
|
53
|
+
marks, and no licenses therein are granted in this Agreement.
|
|
54
|
+
|
|
55
|
+
4. DISCLAIMER. SUPERBLOCKS HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND
|
|
56
|
+
CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY
|
|
57
|
+
DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
|
|
58
|
+
PURPOSE, WITH RESPECT TO THE SOFTWARE.
|
|
59
|
+
|
|
60
|
+
5. LIMITATION OF LIABILITY. SUPERBLOCKS WILL NOT BE LIABLE FOR ANY DAMAGES OF
|
|
61
|
+
ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL,
|
|
62
|
+
SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY
|
|
63
|
+
THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT. THE FOREGOING SHALL APPLY TO
|
|
64
|
+
THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
65
|
+
|
|
66
|
+
6. GENERAL.
|
|
67
|
+
|
|
68
|
+
6.1 Governing Law. This Agreement will be governed by and interpreted in accordance with the laws of the
|
|
69
|
+
state of California, without reference to its conflict of laws principles. If Licensee is located within the United
|
|
70
|
+
States, all disputes arising out of this Agreement are subject to the exclusive jurisdiction of courts located in San
|
|
71
|
+
Mateo County, California. USA. If Licensee is located outside of the United States, any dispute, controversy or
|
|
72
|
+
claim arising out of or relating to this Agreement will be referred to and finally determined by arbitration in
|
|
73
|
+
accordance with the JAMS International Arbitration Rules. The tribunal will consist of one neutral arbitrator.
|
|
74
|
+
The place of arbitration will be Palo Alto, California. The language to be used in the arbitral proceedings will be
|
|
75
|
+
English. Judgment upon the award rendered by the arbitrator may be entered in any court having jurisdiction
|
|
76
|
+
thereof.
|
|
77
|
+
|
|
78
|
+
6.2. Assignment. Licensee may not assign its rights under this Agreement to any third party. Superblocks may
|
|
79
|
+
freely assign its rights under this Agreement to any third party.
|
|
80
|
+
|
|
81
|
+
6.3. Other. This Agreement is the entire agreement between the parties regarding the subject matter hereof.
|
|
82
|
+
No amendment or modification of this Agreement will be valid or binding upon the parties unless made in
|
|
83
|
+
writing and signed by the duly authorized representatives of both parties. In the event that any provision,
|
|
84
|
+
including without limitation any condition, of this Agreement is held to be unenforceable, this Agreement and
|
|
85
|
+
all licenses and rights granted hereunder will immediately terminate. Waiver by Superblocks of a breach of any
|
|
86
|
+
provision of this Agreement or the failure by Superblocks to exercise any right hereunder will not be construed
|
|
87
|
+
as a waiver of any subsequent breach of that right or as a waiver of any other right.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentEvent, LocalGitRepoState, SuperblocksResourceType } from "@superblocksteam/util";
|
|
2
2
|
import { StdISocketRPCClient } from "./socket";
|
|
3
|
-
import { ApiWithPb, Page, RemoteCommitDto, UserMeDto, ViewMode } from "./types";
|
|
3
|
+
import { Api, ApiWithPb, Page, RemoteCommitDto, UserMeDto, ViewMode } from "./types";
|
|
4
4
|
export interface UploadFile {
|
|
5
5
|
name: string;
|
|
6
6
|
filename: string;
|
|
@@ -23,7 +23,7 @@ export type PushMultiPageApplicationWithCommitConfig = MultiPageApplicationWrapp
|
|
|
23
23
|
skipCommit: boolean;
|
|
24
24
|
};
|
|
25
25
|
export interface ApiWrapper {
|
|
26
|
-
apiPb:
|
|
26
|
+
apiPb: Api;
|
|
27
27
|
name?: string;
|
|
28
28
|
}
|
|
29
29
|
export type PushApiWithCommitConfig = {
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createSocketConnectionIfNeeded = void 0;
|
|
4
|
+
exports.fetchApplication = fetchApplication;
|
|
5
|
+
exports.fetchApplicationBranches = fetchApplicationBranches;
|
|
6
|
+
exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
|
|
7
|
+
exports.fetchApplications = fetchApplications;
|
|
8
|
+
exports.fetchApi = fetchApi;
|
|
9
|
+
exports.fetchApis = fetchApis;
|
|
10
|
+
exports.validateGitSetup = validateGitSetup;
|
|
11
|
+
exports.registerComponents = registerComponents;
|
|
12
|
+
exports.uploadComponents = uploadComponents;
|
|
13
|
+
exports.fetchCurrentUser = fetchCurrentUser;
|
|
14
|
+
exports.pushApplication = pushApplication;
|
|
15
|
+
exports.pushApi = pushApi;
|
|
16
|
+
exports.fetchApplicationCommits = fetchApplicationCommits;
|
|
17
|
+
exports.fetchApiCommits = fetchApiCommits;
|
|
4
18
|
const tslib_1 = require("tslib");
|
|
5
19
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
20
|
const util_1 = require("@superblocksteam/util");
|
|
@@ -69,7 +83,6 @@ async function fetchApplication({ cliVersion, applicationId, branch, token, supe
|
|
|
69
83
|
throw new Error(`Could not fetch application: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
|
-
exports.fetchApplication = fetchApplication;
|
|
73
86
|
async function fetchApplicationBranches({ cliVersion, applicationId, token, superblocksBaseUrl, injectedHeaders = {}, }) {
|
|
74
87
|
const serverURL = new URL(`public/applications/${applicationId}/branches`, superblocksBaseUrl);
|
|
75
88
|
let serverResponse;
|
|
@@ -93,7 +106,6 @@ async function fetchApplicationBranches({ cliVersion, applicationId, token, supe
|
|
|
93
106
|
}
|
|
94
107
|
return serverResponse?.data?.data;
|
|
95
108
|
}
|
|
96
|
-
exports.fetchApplicationBranches = fetchApplicationBranches;
|
|
97
109
|
async function fetchApplicationWithComponents({ cliVersion, applicationId, branch, token, superblocksBaseUrl, viewMode, commitId, skipSigningVerification = false, injectedHeaders = {}, }) {
|
|
98
110
|
const applicationWrapper = await fetchApplication({
|
|
99
111
|
cliVersion,
|
|
@@ -145,7 +157,6 @@ async function fetchApplicationWithComponents({ cliVersion, applicationId, branc
|
|
|
145
157
|
throw new Error("Could not fetch application");
|
|
146
158
|
}
|
|
147
159
|
}
|
|
148
|
-
exports.fetchApplicationWithComponents = fetchApplicationWithComponents;
|
|
149
160
|
async function fetchApplications(cliVersion, token, superblocksBaseUrl, injectedHeaders = {}) {
|
|
150
161
|
try {
|
|
151
162
|
const config = {
|
|
@@ -167,8 +178,7 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
|
|
|
167
178
|
e.response?.data?.responseMeta?.message ??
|
|
168
179
|
JSON.stringify(e.response?.data) ??
|
|
169
180
|
e.response?.statusText ??
|
|
170
|
-
e?.message
|
|
171
|
-
`${e}`;
|
|
181
|
+
e?.message;
|
|
172
182
|
}
|
|
173
183
|
else {
|
|
174
184
|
message = `${e?.message ? e?.message : e}`;
|
|
@@ -176,7 +186,6 @@ async function fetchApplications(cliVersion, token, superblocksBaseUrl, injected
|
|
|
176
186
|
throw new Error(`Could not fetch applications: ${message}`);
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
|
-
exports.fetchApplications = fetchApplications;
|
|
180
189
|
async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode, branch, commitId, skipSigningVerification = false) {
|
|
181
190
|
try {
|
|
182
191
|
const serverURL = branch
|
|
@@ -222,7 +231,6 @@ async function fetchApi(cliVersion, apiId, token, superblocksBaseUrl, viewMode,
|
|
|
222
231
|
throw new Error(`Could not fetch api: ${typeof e === "object" && e && "message" in e ? e.message : e}`);
|
|
223
232
|
}
|
|
224
233
|
}
|
|
225
|
-
exports.fetchApi = fetchApi;
|
|
226
234
|
async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
227
235
|
try {
|
|
228
236
|
const config = {
|
|
@@ -236,11 +244,10 @@ async function fetchApis(cliVersion, token, superblocksBaseUrl) {
|
|
|
236
244
|
const response = await (0, axios_1.default)(config);
|
|
237
245
|
return response.data.data.apis;
|
|
238
246
|
}
|
|
239
|
-
catch
|
|
247
|
+
catch {
|
|
240
248
|
throw new Error("Could not fetch apis");
|
|
241
249
|
}
|
|
242
250
|
}
|
|
243
|
-
exports.fetchApis = fetchApis;
|
|
244
251
|
async function validateGitSetup(cliVersion, resourceId, resourceType, event, localGitRepoState, token, superblocksBaseUrl, injectedHeaders) {
|
|
245
252
|
let resourceName;
|
|
246
253
|
try {
|
|
@@ -290,8 +297,7 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
290
297
|
e.response?.data?.responseMeta?.message ??
|
|
291
298
|
JSON.stringify(e.response?.data) ??
|
|
292
299
|
e.response?.statusText ??
|
|
293
|
-
e?.message
|
|
294
|
-
`${e}`;
|
|
300
|
+
e?.message;
|
|
295
301
|
}
|
|
296
302
|
else {
|
|
297
303
|
message = `${e?.message ? e.message : e}`;
|
|
@@ -307,7 +313,6 @@ async function validateGitSetup(cliVersion, resourceId, resourceType, event, loc
|
|
|
307
313
|
}
|
|
308
314
|
}
|
|
309
315
|
}
|
|
310
|
-
exports.validateGitSetup = validateGitSetup;
|
|
311
316
|
async function registerComponents(cliVersion, applicationId, componentConfigs, token, superblocksBaseUrl, branch, injectedHeaders) {
|
|
312
317
|
try {
|
|
313
318
|
const branchPath = branch ? `/branches/${encodeURIComponent(branch)}` : "";
|
|
@@ -348,7 +353,6 @@ async function registerComponents(cliVersion, applicationId, componentConfigs, t
|
|
|
348
353
|
throw new Error(`Could not register application components ${e.message ? "\n" + e.message : ""}`);
|
|
349
354
|
}
|
|
350
355
|
}
|
|
351
|
-
exports.registerComponents = registerComponents;
|
|
352
356
|
async function uploadComponents({ cliVersion, applicationId, componentConfigs, files, token, superblocksBaseUrl, branch, }) {
|
|
353
357
|
superblocksBaseUrl = superblocksBaseUrl.replace(/\/$/, "");
|
|
354
358
|
const bucketeerBaseUrl = (0, util_1.getBucketeerUrlFromSuperblocksUrl)(superblocksBaseUrl);
|
|
@@ -447,7 +451,6 @@ You can reduce your component bundle size by uploading static assets to a separa
|
|
|
447
451
|
}
|
|
448
452
|
}
|
|
449
453
|
}
|
|
450
|
-
exports.uploadComponents = uploadComponents;
|
|
451
454
|
async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
452
455
|
try {
|
|
453
456
|
const config = {
|
|
@@ -469,8 +472,7 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
|
469
472
|
e.response?.data?.responseMeta?.message ??
|
|
470
473
|
JSON.stringify(e.response?.data) ??
|
|
471
474
|
e.response?.statusText ??
|
|
472
|
-
e?.message
|
|
473
|
-
`${e}`;
|
|
475
|
+
e?.message;
|
|
474
476
|
}
|
|
475
477
|
else {
|
|
476
478
|
message = `${e?.message ? e?.message : e}`;
|
|
@@ -478,7 +480,6 @@ async function fetchCurrentUser(cliVersion, token, superblocksBaseUrl) {
|
|
|
478
480
|
throw new Error(`Could not fetch current user: ${message}`);
|
|
479
481
|
}
|
|
480
482
|
}
|
|
481
|
-
exports.fetchCurrentUser = fetchCurrentUser;
|
|
482
483
|
const createSocketConnectionIfNeeded = async (cliVersion, token, superblocksBaseUrl) => {
|
|
483
484
|
const userMe = await fetchCurrentUser(cliVersion, token, superblocksBaseUrl);
|
|
484
485
|
const organization = userMe.organizations[0];
|
|
@@ -563,7 +564,6 @@ async function pushApplication({ cliVersion, applicationId, token, superblocksBa
|
|
|
563
564
|
throw new Error(`Could not push application ${e.message ? "\n" + e.message : ""}`);
|
|
564
565
|
}
|
|
565
566
|
}
|
|
566
|
-
exports.pushApplication = pushApplication;
|
|
567
567
|
async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig, branch, injectedHeaders = {}, }) {
|
|
568
568
|
const handleHttpError = (status) => {
|
|
569
569
|
if (status === 405) {
|
|
@@ -631,7 +631,6 @@ async function pushApi({ cliVersion, apiId, token, superblocksBaseUrl, apiConfig
|
|
|
631
631
|
throw new Error(`Could not push api ${e.message ? "\n" + e.message : ""}`);
|
|
632
632
|
}
|
|
633
633
|
}
|
|
634
|
-
exports.pushApi = pushApi;
|
|
635
634
|
async function fetchApplicationCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
636
635
|
try {
|
|
637
636
|
const serverURL = branch
|
|
@@ -661,7 +660,6 @@ async function fetchApplicationCommits({ cliVersion, applicationId, branch, toke
|
|
|
661
660
|
throw new Error("Could not fetch application");
|
|
662
661
|
}
|
|
663
662
|
}
|
|
664
|
-
exports.fetchApplicationCommits = fetchApplicationCommits;
|
|
665
663
|
async function fetchApiCommits({ cliVersion, applicationId, branch, token, superblocksBaseUrl, injectedHeaders = {}, limit, offset, }) {
|
|
666
664
|
try {
|
|
667
665
|
const serverURL = branch
|
|
@@ -691,4 +689,3 @@ async function fetchApiCommits({ cliVersion, applicationId, branch, token, super
|
|
|
691
689
|
throw new Error("Could not fetch application");
|
|
692
690
|
}
|
|
693
691
|
}
|
|
694
|
-
exports.fetchApiCommits = fetchApiCommits;
|
package/dist/flag.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import { FlagBootstrap } from "./types";
|
|
2
2
|
export declare const signingEnabled: (flags: FlagBootstrap) => boolean;
|
|
3
|
+
export declare const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
|
|
4
|
+
export declare class FeatureFlags {
|
|
5
|
+
private flags;
|
|
6
|
+
constructor(flags: FlagBootstrap);
|
|
7
|
+
signingEnabled(): boolean;
|
|
8
|
+
splitLargeApiStepsEnabled(): boolean;
|
|
9
|
+
splitLargeApiStepsInNewEnabled(): boolean;
|
|
10
|
+
linesForLargeSteps(): number;
|
|
11
|
+
}
|
package/dist/flag.js
CHANGED
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.signingEnabled = void 0;
|
|
3
|
+
exports.FeatureFlags = exports.DEFAULT_LINES_FOR_LARGE_STEPS = exports.signingEnabled = void 0;
|
|
4
4
|
const signingEnabled = (flags) => {
|
|
5
5
|
return flags["ui.enable-resource-signing"] ?? false;
|
|
6
6
|
};
|
|
7
7
|
exports.signingEnabled = signingEnabled;
|
|
8
|
+
exports.DEFAULT_LINES_FOR_LARGE_STEPS = 1;
|
|
9
|
+
class FeatureFlags {
|
|
10
|
+
flags;
|
|
11
|
+
constructor(flags) {
|
|
12
|
+
this.flags = flags;
|
|
13
|
+
}
|
|
14
|
+
signingEnabled() {
|
|
15
|
+
return this.flags["ui.enable-resource-signing"] ?? false;
|
|
16
|
+
}
|
|
17
|
+
splitLargeApiStepsEnabled() {
|
|
18
|
+
return this.flags["superblocks.git.split.large.steps.enabled"] ?? false;
|
|
19
|
+
}
|
|
20
|
+
splitLargeApiStepsInNewEnabled() {
|
|
21
|
+
return this.flags["superblocks.git.split.large.steps.new.enabled"] ?? false;
|
|
22
|
+
}
|
|
23
|
+
linesForLargeSteps() {
|
|
24
|
+
return (this.flags["superblocks.git.split.large.step.lines"] ??
|
|
25
|
+
exports.DEFAULT_LINES_FOR_LARGE_STEPS);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.FeatureFlags = FeatureFlags;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./client"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./flag"), exports);
|
|
5
6
|
tslib_1.__exportStar(require("./sdk"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./types"), exports);
|
package/dist/sdk.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ComponentEvent, LocalGitRepoState, SuperblocksResourceType } from "@superblocksteam/util";
|
|
2
2
|
import { PushApiWithCommitConfig, PushMultiPageApplicationWithCommitConfig } from "./client";
|
|
3
|
-
import {
|
|
3
|
+
import { FeatureFlags } from "./flag";
|
|
4
|
+
import { UserMeDto, ViewMode } from "./types";
|
|
4
5
|
export * from "./errors";
|
|
5
6
|
export declare class SuperblocksSdk {
|
|
6
7
|
token: string;
|
|
7
8
|
superblocksBaseUrl: string;
|
|
8
9
|
cliVersion: string;
|
|
9
10
|
constructor(accessToken: string, superblocksBaseUrl: string, cliVersion: string);
|
|
11
|
+
getFeatureFlagsForCurrentUser(): Promise<FeatureFlags>;
|
|
12
|
+
getFeatureFlagsForUser(user: UserMeDto): FeatureFlags;
|
|
10
13
|
fetchApplication({ applicationId, branch, headers, viewMode, skipSigningVerification, }: {
|
|
11
14
|
applicationId: string;
|
|
12
15
|
branch?: string;
|
|
@@ -53,7 +56,7 @@ export declare class SuperblocksSdk {
|
|
|
53
56
|
}>;
|
|
54
57
|
registerComponents(applicationId: string, componentConfigs: Record<string, any>, branch: string | null, injectedHeaders: Record<string, string>): Promise<any>;
|
|
55
58
|
uploadComponents(applicationId: string, componentConfigs: Record<string, any>, files: string[], branch: string | null): Promise<void>;
|
|
56
|
-
fetchCurrentUser(): Promise<
|
|
59
|
+
fetchCurrentUser(): Promise<UserMeDto>;
|
|
57
60
|
pushApplication({ applicationId, applicationConfig, branch, headers, }: {
|
|
58
61
|
applicationId: string;
|
|
59
62
|
applicationConfig: PushMultiPageApplicationWithCommitConfig;
|
package/dist/sdk.js
CHANGED
|
@@ -3,17 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SuperblocksSdk = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const client_1 = require("./client");
|
|
6
|
+
const flag_1 = require("./flag");
|
|
6
7
|
// Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
|
|
7
8
|
tslib_1.__exportStar(require("./errors"), exports);
|
|
8
9
|
class SuperblocksSdk {
|
|
10
|
+
token = "";
|
|
11
|
+
superblocksBaseUrl = "";
|
|
12
|
+
cliVersion = "";
|
|
9
13
|
constructor(accessToken, superblocksBaseUrl, cliVersion) {
|
|
10
|
-
this.token = "";
|
|
11
|
-
this.superblocksBaseUrl = "";
|
|
12
|
-
this.cliVersion = "";
|
|
13
14
|
this.token = accessToken;
|
|
14
15
|
this.superblocksBaseUrl = superblocksBaseUrl;
|
|
15
16
|
this.cliVersion = cliVersion;
|
|
16
17
|
}
|
|
18
|
+
async getFeatureFlagsForCurrentUser() {
|
|
19
|
+
const user = await this.fetchCurrentUser();
|
|
20
|
+
return new flag_1.FeatureFlags(user.flagBootstrap);
|
|
21
|
+
}
|
|
22
|
+
getFeatureFlagsForUser(user) {
|
|
23
|
+
return new flag_1.FeatureFlags(user.flagBootstrap);
|
|
24
|
+
}
|
|
17
25
|
async fetchApplication({ applicationId, branch, headers = {}, viewMode = "export-live", skipSigningVerification = false, }) {
|
|
18
26
|
return (0, client_1.fetchApplication)({
|
|
19
27
|
cliVersion: this.cliVersion,
|
package/dist/socket/handlers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRequestHandlers =
|
|
3
|
+
exports.createRequestHandlers = createRequestHandlers;
|
|
4
4
|
const signing_1 = require("./signing");
|
|
5
5
|
function createRequestHandlers({ agentUrl, token, }) {
|
|
6
6
|
const requestHandlers = {
|
|
@@ -94,4 +94,3 @@ function createRequestHandlers({ agentUrl, token, }) {
|
|
|
94
94
|
};
|
|
95
95
|
return requestHandlers;
|
|
96
96
|
}
|
|
97
|
-
exports.createRequestHandlers = createRequestHandlers;
|
package/dist/socket/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ISocketWithClientAuth = void 0;
|
|
4
|
+
exports.connectToISocketRPCServer = connectToISocketRPCServer;
|
|
5
|
+
exports.connectISocket = connectISocket;
|
|
6
|
+
exports.connectWebSocket = connectWebSocket;
|
|
4
7
|
const tslib_1 = require("tslib");
|
|
5
8
|
const ws_1 = tslib_1.__importDefault(require("ws"));
|
|
6
9
|
const handlers_1 = require("./handlers");
|
|
@@ -25,18 +28,18 @@ async function connectToISocketRPCServer({ superblocksBaseUrl, agentUrl, token,
|
|
|
25
28
|
wsUrl.hostname = "127.0.0.1";
|
|
26
29
|
}
|
|
27
30
|
return await connectISocket(wsUrl.href, authorization, requestHandlers, [], {
|
|
28
|
-
connectionTimeoutInSeconds: 6 * 60,
|
|
31
|
+
connectionTimeoutInSeconds: 6 * 60, // 6 minutes
|
|
29
32
|
noResponseTimeoutInSeconds: 5 * 60, // 5 minutes
|
|
30
33
|
});
|
|
31
34
|
}
|
|
32
|
-
exports.connectToISocketRPCServer = connectToISocketRPCServer;
|
|
33
35
|
// a subclass of ISocket that sends an auth token on the first request
|
|
34
36
|
// this is useful for client-side sockets that need to authenticate
|
|
35
37
|
// TODO(george): if we start using this for long-lived connections, we should add a way to refresh the token
|
|
36
38
|
class ISocketWithClientAuth extends socket_1.ISocket {
|
|
39
|
+
authorization;
|
|
40
|
+
hasSentAuth = false;
|
|
37
41
|
constructor(ws, authorization, requestHandlers, globalMiddlewares, timeouts) {
|
|
38
42
|
super(ws, requestHandlers, globalMiddlewares, timeouts);
|
|
39
|
-
this.hasSentAuth = false;
|
|
40
43
|
this.authorization = authorization;
|
|
41
44
|
}
|
|
42
45
|
// override `request` from the base class to send `authorization` when appropriate
|
|
@@ -54,7 +57,6 @@ async function connectISocket(wsUrl, authorization, requestHandlers, globalMiddl
|
|
|
54
57
|
const isocket = new ISocketWithClientAuth(ws, authorization, requestHandlers, globalMiddlewares, timeouts);
|
|
55
58
|
return (0, socket_1.createISocketClient)(isocket);
|
|
56
59
|
}
|
|
57
|
-
exports.connectISocket = connectISocket;
|
|
58
60
|
function connectWebSocket(wsUrl) {
|
|
59
61
|
return new Promise((resolve, reject) => {
|
|
60
62
|
const ws = new ws_1.default(wsUrl);
|
|
@@ -70,4 +72,3 @@ function connectWebSocket(wsUrl) {
|
|
|
70
72
|
});
|
|
71
73
|
});
|
|
72
74
|
}
|
|
73
|
-
exports.connectWebSocket = connectWebSocket;
|
package/dist/socket/signing.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.signResource = signResource;
|
|
4
|
+
exports.verifyResources = verifyResources;
|
|
4
5
|
const tslib_1 = require("tslib");
|
|
5
6
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
7
|
const utils_1 = require("../utils");
|
|
@@ -24,7 +25,6 @@ async function signResource({ token, branchName, resource, agentUrl, }) {
|
|
|
24
25
|
});
|
|
25
26
|
return resp.signature;
|
|
26
27
|
}
|
|
27
|
-
exports.signResource = signResource;
|
|
28
28
|
async function verifyResources({ agentUrl, token, branchName, resources, }) {
|
|
29
29
|
await callAgent({
|
|
30
30
|
baseUrl: agentUrl,
|
|
@@ -48,7 +48,6 @@ async function verifyResources({ agentUrl, token, branchName, resources, }) {
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
exports.verifyResources = verifyResources;
|
|
52
51
|
async function callAgent({ baseUrl, path, method, token, data, }) {
|
|
53
52
|
try {
|
|
54
53
|
const url = new URL(path, baseUrl);
|
package/dist/socket/socket.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ISocket = void 0;
|
|
4
|
+
exports.createISocketClient = createISocketClient;
|
|
4
5
|
const types_1 = require("../types");
|
|
5
6
|
/**
|
|
6
7
|
* ISocket is a class that wraps a WebSocket connection and provides a simple interface for sending and receiving messages.
|
|
@@ -16,8 +17,17 @@ const types_1 = require("../types");
|
|
|
16
17
|
* It is expected that timeouts should be relatively sorted in the order of connection timeout > request timeout > no response timeout.
|
|
17
18
|
*/
|
|
18
19
|
class ISocket {
|
|
20
|
+
ws;
|
|
21
|
+
requestHandlers;
|
|
22
|
+
globalMiddlewares;
|
|
23
|
+
responseHandler = new Map();
|
|
24
|
+
peerAuthorization;
|
|
25
|
+
nxtRequestId;
|
|
26
|
+
connectionTimeout;
|
|
27
|
+
// pino library not available in shared
|
|
28
|
+
logger;
|
|
29
|
+
timeouts;
|
|
19
30
|
constructor(ws, requestHandlers, globalMiddlewares, timeouts, logger) {
|
|
20
|
-
this.responseHandler = new Map();
|
|
21
31
|
this.ws = ws;
|
|
22
32
|
this.requestHandlers = requestHandlers;
|
|
23
33
|
this.globalMiddlewares = globalMiddlewares;
|
|
@@ -29,6 +39,7 @@ class ISocket {
|
|
|
29
39
|
this.ws.addEventListener("message",
|
|
30
40
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
31
41
|
async (event) => {
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
32
43
|
const eventData = JSON.parse(event.data.toString());
|
|
33
44
|
return this.handleMessage(eventData);
|
|
34
45
|
});
|
|
@@ -125,6 +136,7 @@ class ISocket {
|
|
|
125
136
|
const requestId = ++this.nxtRequestId;
|
|
126
137
|
this.responseHandler.set(requestId, {
|
|
127
138
|
resolve: (result) => resolve(result),
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
|
|
128
140
|
reject: (error) => reject(error),
|
|
129
141
|
});
|
|
130
142
|
const toSend = {
|
|
@@ -247,4 +259,3 @@ function createISocketClient(socket) {
|
|
|
247
259
|
call: createIsocketProxy(socket, undefined),
|
|
248
260
|
};
|
|
249
261
|
}
|
|
250
|
-
exports.createISocketClient = createISocketClient;
|
package/dist/types/common.d.ts
CHANGED
|
@@ -6,6 +6,9 @@ export interface UserMeDto {
|
|
|
6
6
|
}
|
|
7
7
|
export interface FlagBootstrap {
|
|
8
8
|
"ui.enable-resource-signing"?: boolean;
|
|
9
|
+
"superblocks.git.split.large.steps.enabled"?: boolean;
|
|
10
|
+
"superblocks.git.split.large.steps.new.enabled"?: boolean;
|
|
11
|
+
"superblocks.git.split.large.step.lines"?: number;
|
|
9
12
|
}
|
|
10
13
|
export type User = {
|
|
11
14
|
id: string;
|
|
@@ -91,7 +94,7 @@ export type Api = {
|
|
|
91
94
|
};
|
|
92
95
|
folder?: string;
|
|
93
96
|
};
|
|
94
|
-
blocks?:
|
|
97
|
+
blocks?: Block[];
|
|
95
98
|
trigger: any;
|
|
96
99
|
signature?: Signature;
|
|
97
100
|
};
|
|
@@ -100,6 +103,82 @@ export type ApiWithPb = {
|
|
|
100
103
|
pageId?: string;
|
|
101
104
|
apiPb: Api;
|
|
102
105
|
};
|
|
106
|
+
export type Block = {
|
|
107
|
+
name: string;
|
|
108
|
+
step?: Step;
|
|
109
|
+
loop?: Loop;
|
|
110
|
+
tryCatch?: TryCatch;
|
|
111
|
+
conditional?: Conditional;
|
|
112
|
+
parallel?: Parallel;
|
|
113
|
+
stream?: Stream;
|
|
114
|
+
};
|
|
115
|
+
export type Step = {
|
|
116
|
+
integration: string;
|
|
117
|
+
javascript?: LanguageContent;
|
|
118
|
+
python?: LanguageContent;
|
|
119
|
+
};
|
|
120
|
+
export type Loop = {
|
|
121
|
+
blocks: Block[];
|
|
122
|
+
range: string;
|
|
123
|
+
type: LoopType;
|
|
124
|
+
variables?: Variables;
|
|
125
|
+
};
|
|
126
|
+
export declare enum LoopType {
|
|
127
|
+
FOR = "TYPE_FOR",
|
|
128
|
+
FOR_EACH = "TYPE_FOREACH",
|
|
129
|
+
WHILE = "TYPE_WHILE",
|
|
130
|
+
UNSPECIFIED = "TYPE_UNSPECIFIED"
|
|
131
|
+
}
|
|
132
|
+
export type TryCatch = {
|
|
133
|
+
try?: Blocks;
|
|
134
|
+
catch?: Blocks;
|
|
135
|
+
finally?: Blocks;
|
|
136
|
+
variables?: Variables;
|
|
137
|
+
};
|
|
138
|
+
export type Conditional = {
|
|
139
|
+
if?: ConditionalBlockWithCondition;
|
|
140
|
+
elseIf: ConditionalBlockWithCondition[];
|
|
141
|
+
else?: Blocks;
|
|
142
|
+
};
|
|
143
|
+
export type Blocks = {
|
|
144
|
+
blocks: Block[];
|
|
145
|
+
};
|
|
146
|
+
export type ConditionalBlockWithCondition = Blocks & {
|
|
147
|
+
condition?: string;
|
|
148
|
+
};
|
|
149
|
+
export type Parallel = {
|
|
150
|
+
static?: {
|
|
151
|
+
paths: Record<string, Blocks>;
|
|
152
|
+
};
|
|
153
|
+
dynamic?: {
|
|
154
|
+
blocks: Block[];
|
|
155
|
+
variables?: Variables;
|
|
156
|
+
paths?: string;
|
|
157
|
+
};
|
|
158
|
+
poolSize?: number;
|
|
159
|
+
wait?: WAIT_TYPE;
|
|
160
|
+
};
|
|
161
|
+
export type Stream = {
|
|
162
|
+
trigger?: StreamTrigger;
|
|
163
|
+
process?: Blocks;
|
|
164
|
+
variables?: Variables;
|
|
165
|
+
};
|
|
166
|
+
export type StreamTrigger = {
|
|
167
|
+
name: string;
|
|
168
|
+
step?: Step;
|
|
169
|
+
};
|
|
170
|
+
export declare enum WAIT_TYPE {
|
|
171
|
+
ALL = "WAIT_ALL",
|
|
172
|
+
ANY = "WAIT_NONE",
|
|
173
|
+
UNSPECIFIED = "WAIT_UNSPECIFIED"
|
|
174
|
+
}
|
|
175
|
+
export type Variables = Record<string, string>;
|
|
176
|
+
export type LanguageContent = {
|
|
177
|
+
body: Body;
|
|
178
|
+
};
|
|
179
|
+
export type Body = string | {
|
|
180
|
+
path: string;
|
|
181
|
+
};
|
|
103
182
|
export type Page = {
|
|
104
183
|
id: string;
|
|
105
184
|
applicationId: string;
|
package/dist/types/common.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProfileType = exports.Profile = exports.AgentType = exports.AgentStatus = void 0;
|
|
3
|
+
exports.WAIT_TYPE = exports.LoopType = exports.ProfileType = exports.Profile = exports.AgentType = exports.AgentStatus = void 0;
|
|
4
4
|
var AgentStatus;
|
|
5
5
|
(function (AgentStatus) {
|
|
6
6
|
AgentStatus["ACTIVE"] = "Active";
|
|
@@ -17,6 +17,11 @@ var AgentType;
|
|
|
17
17
|
AgentType[AgentType["ONPREMISE"] = 2] = "ONPREMISE";
|
|
18
18
|
})(AgentType || (exports.AgentType = AgentType = {}));
|
|
19
19
|
class Profile {
|
|
20
|
+
id;
|
|
21
|
+
key;
|
|
22
|
+
displayName;
|
|
23
|
+
description;
|
|
24
|
+
type;
|
|
20
25
|
constructor({ id, key, displayName, description, type, }) {
|
|
21
26
|
this.id = id;
|
|
22
27
|
this.key = key;
|
|
@@ -31,3 +36,16 @@ var ProfileType;
|
|
|
31
36
|
ProfileType["RESERVED"] = "RESERVED";
|
|
32
37
|
ProfileType["CUSTOM"] = "CUSTOM";
|
|
33
38
|
})(ProfileType || (exports.ProfileType = ProfileType = {}));
|
|
39
|
+
var LoopType;
|
|
40
|
+
(function (LoopType) {
|
|
41
|
+
LoopType["FOR"] = "TYPE_FOR";
|
|
42
|
+
LoopType["FOR_EACH"] = "TYPE_FOREACH";
|
|
43
|
+
LoopType["WHILE"] = "TYPE_WHILE";
|
|
44
|
+
LoopType["UNSPECIFIED"] = "TYPE_UNSPECIFIED";
|
|
45
|
+
})(LoopType || (exports.LoopType = LoopType = {}));
|
|
46
|
+
var WAIT_TYPE;
|
|
47
|
+
(function (WAIT_TYPE) {
|
|
48
|
+
WAIT_TYPE["ALL"] = "WAIT_ALL";
|
|
49
|
+
WAIT_TYPE["ANY"] = "WAIT_NONE";
|
|
50
|
+
WAIT_TYPE["UNSPECIFIED"] = "WAIT_UNSPECIFIED";
|
|
51
|
+
})(WAIT_TYPE || (exports.WAIT_TYPE = WAIT_TYPE = {}));
|
package/dist/types/socket.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SocketErrorException = void 0;
|
|
4
4
|
/** The exception type can be thrown to cause the default error handler to write a raw error response to the socket */
|
|
5
5
|
class SocketErrorException extends Error {
|
|
6
|
+
code;
|
|
7
|
+
message;
|
|
6
8
|
constructor(code, message) {
|
|
7
9
|
super(message);
|
|
8
10
|
this.code = code;
|