@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 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.js CHANGED
@@ -1,6 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchApiCommits = exports.fetchApplicationCommits = exports.pushApi = exports.pushApplication = exports.createSocketConnectionIfNeeded = exports.fetchCurrentUser = exports.uploadComponents = exports.registerComponents = exports.validateGitSetup = exports.fetchApis = exports.fetchApi = exports.fetchApplications = exports.fetchApplicationWithComponents = exports.fetchApplicationBranches = exports.fetchApplication = void 0;
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 (e) {
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,6 +1,6 @@
1
1
  import { FlagBootstrap } from "./types";
2
2
  export declare const signingEnabled: (flags: FlagBootstrap) => boolean;
3
- export declare const DEFAULT_LINES_FOR_LARGE_STEPS = 10;
3
+ export declare const DEFAULT_LINES_FOR_LARGE_STEPS = 1;
4
4
  export declare class FeatureFlags {
5
5
  private flags;
6
6
  constructor(flags: FlagBootstrap);
package/dist/flag.js CHANGED
@@ -5,8 +5,9 @@ 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 = 10;
8
+ exports.DEFAULT_LINES_FOR_LARGE_STEPS = 1;
9
9
  class FeatureFlags {
10
+ flags;
10
11
  constructor(flags) {
11
12
  this.flags = flags;
12
13
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from "./client";
2
2
  export * from "./flag";
3
3
  export * from "./sdk";
4
+ export * from "./types";
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./client"), exports);
5
5
  tslib_1.__exportStar(require("./flag"), exports);
6
6
  tslib_1.__exportStar(require("./sdk"), exports);
7
+ tslib_1.__exportStar(require("./types"), exports);
package/dist/sdk.js CHANGED
@@ -7,10 +7,10 @@ const flag_1 = require("./flag");
7
7
  // Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
8
8
  tslib_1.__exportStar(require("./errors"), exports);
9
9
  class SuperblocksSdk {
10
+ token = "";
11
+ superblocksBaseUrl = "";
12
+ cliVersion = "";
10
13
  constructor(accessToken, superblocksBaseUrl, cliVersion) {
11
- this.token = "";
12
- this.superblocksBaseUrl = "";
13
- this.cliVersion = "";
14
14
  this.token = accessToken;
15
15
  this.superblocksBaseUrl = superblocksBaseUrl;
16
16
  this.cliVersion = cliVersion;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRequestHandlers = void 0;
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;
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.connectWebSocket = exports.connectISocket = exports.ISocketWithClientAuth = exports.connectToISocketRPCServer = void 0;
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;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyResources = exports.signResource = void 0;
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);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createISocketClient = exports.ISocket = void 0;
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;
@@ -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;
@@ -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;
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.10.0",
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.10.0",
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
+ }