@superblocksteam/sdk 1.9.2 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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: Record<string, any>;
26
+ apiPb: Api;
27
27
  name?: string;
28
28
  }
29
29
  export type PushApiWithCommitConfig = {
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 = 10;
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,27 @@
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 = 10;
9
+ class FeatureFlags {
10
+ constructor(flags) {
11
+ this.flags = flags;
12
+ }
13
+ signingEnabled() {
14
+ return this.flags["ui.enable-resource-signing"] ?? false;
15
+ }
16
+ splitLargeApiStepsEnabled() {
17
+ return this.flags["superblocks.git.split.large.steps.enabled"] ?? false;
18
+ }
19
+ splitLargeApiStepsInNewEnabled() {
20
+ return this.flags["superblocks.git.split.large.steps.new.enabled"] ?? false;
21
+ }
22
+ linesForLargeSteps() {
23
+ return (this.flags["superblocks.git.split.large.step.lines"] ??
24
+ exports.DEFAULT_LINES_FOR_LARGE_STEPS);
25
+ }
26
+ }
27
+ exports.FeatureFlags = FeatureFlags;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./client";
2
+ export * from "./flag";
2
3
  export * from "./sdk";
package/dist/index.js CHANGED
@@ -2,4 +2,5 @@
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);
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 { ViewMode } from "./types";
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<import("./types").UserMeDto>;
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,6 +3,7 @@ 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 {
@@ -14,6 +15,13 @@ class SuperblocksSdk {
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,
@@ -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?: any[];
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;
@@ -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";
@@ -31,3 +31,16 @@ var ProfileType;
31
31
  ProfileType["RESERVED"] = "RESERVED";
32
32
  ProfileType["CUSTOM"] = "CUSTOM";
33
33
  })(ProfileType || (exports.ProfileType = ProfileType = {}));
34
+ var LoopType;
35
+ (function (LoopType) {
36
+ LoopType["FOR"] = "TYPE_FOR";
37
+ LoopType["FOR_EACH"] = "TYPE_FOREACH";
38
+ LoopType["WHILE"] = "TYPE_WHILE";
39
+ LoopType["UNSPECIFIED"] = "TYPE_UNSPECIFIED";
40
+ })(LoopType || (exports.LoopType = LoopType = {}));
41
+ var WAIT_TYPE;
42
+ (function (WAIT_TYPE) {
43
+ WAIT_TYPE["ALL"] = "WAIT_ALL";
44
+ WAIT_TYPE["ANY"] = "WAIT_NONE";
45
+ WAIT_TYPE["UNSPECIFIED"] = "WAIT_UNSPECIFIED";
46
+ })(WAIT_TYPE || (exports.WAIT_TYPE = WAIT_TYPE = {}));
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@superblocksteam/sdk",
3
- "version": "1.9.2",
3
+ "version": "1.10.0",
4
4
  "description": "Superblocks JS SDK",
5
5
  "main": "./dist/index.js",
6
6
  "exports": {
7
7
  ".": {
8
- "import": "./dist/sdk.mjs",
8
+ "import": "./dist/sdk.js",
9
9
  "require": "./dist/sdk.js",
10
10
  "types": "./dist/sdk.d.ts"
11
11
  }
@@ -31,7 +31,7 @@
31
31
  "typescript": "^5.1.3"
32
32
  },
33
33
  "dependencies": {
34
- "@superblocksteam/util": "1.9.2",
34
+ "@superblocksteam/util": "1.10.0",
35
35
  "axios": "^1.3.5",
36
36
  "ws": "^8.17.0"
37
37
  },
package/src/client.ts CHANGED
@@ -22,6 +22,7 @@ import { signingEnabled } from "./flag";
22
22
  import { connectToISocketRPCServer, StdISocketRPCClient } from "./socket";
23
23
  import {
24
24
  AgentType,
25
+ Api,
25
26
  ApiWithPb,
26
27
  Page,
27
28
  RemoteCommitDto,
@@ -68,7 +69,7 @@ export type PushMultiPageApplicationWithCommitConfig =
68
69
  };
69
70
 
70
71
  export interface ApiWrapper {
71
- apiPb: Record<string, any>;
72
+ apiPb: Api;
72
73
  name?: string; //@deprecated this attribute is used for getting a name for backends(jobs and workflows) that were never migrated to the new API version.
73
74
  }
74
75
 
package/src/flag.ts CHANGED
@@ -3,3 +3,28 @@ import { FlagBootstrap } from "./types";
3
3
  export const signingEnabled = (flags: FlagBootstrap): boolean => {
4
4
  return flags["ui.enable-resource-signing"] ?? false;
5
5
  };
6
+
7
+ export const DEFAULT_LINES_FOR_LARGE_STEPS = 10;
8
+
9
+ export class FeatureFlags {
10
+ constructor(private flags: FlagBootstrap) {}
11
+
12
+ signingEnabled(): boolean {
13
+ return this.flags["ui.enable-resource-signing"] ?? false;
14
+ }
15
+
16
+ splitLargeApiStepsEnabled(): boolean {
17
+ return this.flags["superblocks.git.split.large.steps.enabled"] ?? false;
18
+ }
19
+
20
+ splitLargeApiStepsInNewEnabled(): boolean {
21
+ return this.flags["superblocks.git.split.large.steps.new.enabled"] ?? false;
22
+ }
23
+
24
+ linesForLargeSteps(): number {
25
+ return (
26
+ this.flags["superblocks.git.split.large.step.lines"] ??
27
+ DEFAULT_LINES_FOR_LARGE_STEPS
28
+ );
29
+ }
30
+ }
package/src/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./client";
2
+ export * from "./flag";
2
3
  export * from "./sdk";
package/src/sdk.ts CHANGED
@@ -21,7 +21,8 @@ import {
21
21
  uploadComponents,
22
22
  validateGitSetup,
23
23
  } from "./client";
24
- import { ViewMode } from "./types";
24
+ import { FeatureFlags } from "./flag";
25
+ import { UserMeDto, ViewMode } from "./types";
25
26
 
26
27
  // Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
27
28
  export * from "./errors";
@@ -41,6 +42,15 @@ export class SuperblocksSdk {
41
42
  this.cliVersion = cliVersion;
42
43
  }
43
44
 
45
+ async getFeatureFlagsForCurrentUser(): Promise<FeatureFlags> {
46
+ const user = await this.fetchCurrentUser();
47
+ return new FeatureFlags(user.flagBootstrap);
48
+ }
49
+
50
+ getFeatureFlagsForUser(user: UserMeDto): FeatureFlags {
51
+ return new FeatureFlags(user.flagBootstrap);
52
+ }
53
+
44
54
  async fetchApplication({
45
55
  applicationId,
46
56
  branch,
@@ -7,6 +7,9 @@ export interface UserMeDto {
7
7
 
8
8
  export interface FlagBootstrap {
9
9
  "ui.enable-resource-signing"?: boolean;
10
+ "superblocks.git.split.large.steps.enabled"?: boolean;
11
+ "superblocks.git.split.large.steps.new.enabled"?: boolean;
12
+ "superblocks.git.split.large.step.lines"?: number;
10
13
  }
11
14
 
12
15
  export type User = {
@@ -116,7 +119,7 @@ export type Api = {
116
119
  };
117
120
  folder?: string;
118
121
  };
119
- blocks?: any[];
122
+ blocks?: Block[];
120
123
  trigger: any;
121
124
  signature?: Signature;
122
125
  };
@@ -127,6 +130,95 @@ export type ApiWithPb = {
127
130
  apiPb: Api;
128
131
  };
129
132
 
133
+ export type Block = {
134
+ name: string;
135
+ step?: Step;
136
+ loop?: Loop;
137
+ tryCatch?: TryCatch;
138
+ conditional?: Conditional;
139
+ parallel?: Parallel;
140
+ stream?: Stream;
141
+ };
142
+
143
+ export type Step = {
144
+ integration: string;
145
+ javascript?: LanguageContent;
146
+ python?: LanguageContent;
147
+ };
148
+
149
+ export type Loop = {
150
+ blocks: Block[];
151
+ range: string;
152
+ type: LoopType;
153
+ variables?: Variables;
154
+ };
155
+
156
+ export enum LoopType {
157
+ FOR = "TYPE_FOR",
158
+ FOR_EACH = "TYPE_FOREACH",
159
+ WHILE = "TYPE_WHILE",
160
+ UNSPECIFIED = "TYPE_UNSPECIFIED",
161
+ }
162
+
163
+ export type TryCatch = {
164
+ try?: Blocks;
165
+ catch?: Blocks;
166
+ finally?: Blocks;
167
+ variables?: Variables;
168
+ };
169
+
170
+ export type Conditional = {
171
+ if?: ConditionalBlockWithCondition;
172
+ elseIf: ConditionalBlockWithCondition[];
173
+ else?: Blocks;
174
+ };
175
+
176
+ export type Blocks = {
177
+ blocks: Block[];
178
+ };
179
+
180
+ export type ConditionalBlockWithCondition = Blocks & {
181
+ condition?: string;
182
+ };
183
+
184
+ export type Parallel = {
185
+ static?: {
186
+ paths: Record<string, Blocks>;
187
+ };
188
+ dynamic?: {
189
+ blocks: Block[];
190
+ variables?: Variables;
191
+ paths?: string;
192
+ };
193
+ poolSize?: number;
194
+ wait?: WAIT_TYPE;
195
+ };
196
+
197
+ export type Stream = {
198
+ trigger?: StreamTrigger;
199
+ process?: Blocks;
200
+ variables?: Variables;
201
+ };
202
+
203
+ export type StreamTrigger = {
204
+ name: string;
205
+ step?: Step;
206
+ };
207
+
208
+ export enum WAIT_TYPE {
209
+ ALL = "WAIT_ALL",
210
+ ANY = "WAIT_NONE",
211
+ UNSPECIFIED = "WAIT_UNSPECIFIED",
212
+ }
213
+
214
+ export type Variables = Record<string, string>;
215
+
216
+ export type LanguageContent = {
217
+ body: Body;
218
+ };
219
+
220
+ export type Body = string | { path: string };
221
+
130
222
  export type Page = {
131
223
  id: string;
132
224
  applicationId: string;