@superblocksteam/sdk 2.0.118-next.0 → 2.0.118

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.
Files changed (79) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/dist/cli-replacement/dev.d.mts +0 -6
  3. package/dist/cli-replacement/dev.d.mts.map +1 -1
  4. package/dist/cli-replacement/dev.mjs +0 -1
  5. package/dist/cli-replacement/dev.mjs.map +1 -1
  6. package/dist/client.d.ts +6 -67
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +0 -94
  9. package/dist/client.js.map +1 -1
  10. package/dist/dev-utils/dev-server-persist.test.mjs +17 -117
  11. package/dist/dev-utils/dev-server-persist.test.mjs.map +1 -1
  12. package/dist/dev-utils/dev-server.d.mts +1 -19
  13. package/dist/dev-utils/dev-server.d.mts.map +1 -1
  14. package/dist/dev-utils/dev-server.mjs +28 -296
  15. package/dist/dev-utils/dev-server.mjs.map +1 -1
  16. package/dist/flag.d.ts +1 -1
  17. package/dist/flag.d.ts.map +1 -1
  18. package/dist/flag.js +3 -3
  19. package/dist/flag.js.map +1 -1
  20. package/dist/index.d.ts +3 -4
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +2 -3
  23. package/dist/index.js.map +1 -1
  24. package/dist/sdk.d.ts +1 -8
  25. package/dist/sdk.d.ts.map +1 -1
  26. package/dist/sdk.js +1 -24
  27. package/dist/sdk.js.map +1 -1
  28. package/dist/sdk.test.js +1 -102
  29. package/dist/sdk.test.js.map +1 -1
  30. package/dist/telemetry/index.d.ts +1 -2
  31. package/dist/telemetry/index.d.ts.map +1 -1
  32. package/dist/telemetry/index.js +1 -8
  33. package/dist/telemetry/index.js.map +1 -1
  34. package/dist/telemetry/logging.d.ts +2 -1
  35. package/dist/telemetry/logging.d.ts.map +1 -1
  36. package/dist/telemetry/logging.js +1 -1
  37. package/dist/telemetry/logging.js.map +1 -1
  38. package/dist/types/common.d.ts +1 -1
  39. package/dist/types/common.d.ts.map +1 -1
  40. package/dist/version-control.d.mts.map +1 -1
  41. package/dist/version-control.mjs +19 -14
  42. package/dist/version-control.mjs.map +1 -1
  43. package/eslint.config.js +0 -6
  44. package/package.json +8 -8
  45. package/src/cli-replacement/dev.mts +0 -8
  46. package/src/client.ts +6 -189
  47. package/src/dev-utils/dev-server-persist.test.mts +19 -170
  48. package/src/dev-utils/dev-server.mts +32 -366
  49. package/src/flag.ts +4 -4
  50. package/src/index.ts +1 -19
  51. package/src/sdk.test.ts +6 -145
  52. package/src/sdk.ts +0 -36
  53. package/src/telemetry/index.ts +1 -9
  54. package/src/telemetry/logging.ts +2 -2
  55. package/src/types/common.ts +1 -1
  56. package/src/version-control.mts +30 -11
  57. package/test/version-control.test.mts +2 -0
  58. package/tsconfig.tsbuildinfo +1 -1
  59. package/turbo.json +0 -1
  60. package/dist/dev-utils/dedupe-async.d.ts +0 -16
  61. package/dist/dev-utils/dedupe-async.d.ts.map +0 -1
  62. package/dist/dev-utils/dedupe-async.js +0 -27
  63. package/dist/dev-utils/dedupe-async.js.map +0 -1
  64. package/dist/dev-utils/dedupe-async.test.d.ts +0 -2
  65. package/dist/dev-utils/dedupe-async.test.d.ts.map +0 -1
  66. package/dist/dev-utils/dedupe-async.test.js +0 -120
  67. package/dist/dev-utils/dedupe-async.test.js.map +0 -1
  68. package/dist/dev-utils/dev-server-metrics.d.mts +0 -95
  69. package/dist/dev-utils/dev-server-metrics.d.mts.map +0 -1
  70. package/dist/dev-utils/dev-server-metrics.mjs +0 -193
  71. package/dist/dev-utils/dev-server-metrics.mjs.map +0 -1
  72. package/dist/telemetry/memory-metrics.d.ts +0 -3
  73. package/dist/telemetry/memory-metrics.d.ts.map +0 -1
  74. package/dist/telemetry/memory-metrics.js +0 -59
  75. package/dist/telemetry/memory-metrics.js.map +0 -1
  76. package/src/dev-utils/dedupe-async.test.ts +0 -151
  77. package/src/dev-utils/dedupe-async.ts +0 -45
  78. package/src/dev-utils/dev-server-metrics.mts +0 -252
  79. package/src/telemetry/memory-metrics.ts +0 -90
package/src/index.ts CHANGED
@@ -7,18 +7,13 @@ export {
7
7
  type CodeModeApplicationWrapper,
8
8
  type CreateApplicationResult,
9
9
  type CurrentBranch,
10
- type BillingUsageLimitsResponse,
11
10
  type DailyUsageRow,
12
11
  type GetCommitsResponseBody,
13
12
  type IntegrationFilters,
14
13
  type IntegrationSummary,
15
14
  type MultiPageApplicationWrapper,
16
15
  type MultiPageApplicationWrapperWithComponents,
17
- type OrgCreditLimit,
18
16
  type PlanSummary,
19
- type UpdateOrgBillingUsageLimitRequest,
20
- type UpdateUserBillingUsageLimitRequest,
21
- type UserCreditLimit,
22
17
  type UsageRecordRow,
23
18
  } from "./client.js";
24
19
 
@@ -70,12 +65,6 @@ export { AUTO_UPGRADE_EXIT_CODE } from "./cli-replacement/automatic-upgrades.js"
70
65
  export { RESTART_EXIT_CODE } from "./dev-utils/dev-server.mjs";
71
66
 
72
67
  export { createDevServer, preWarmViteCache } from "./dev-utils/dev-server.mjs";
73
- export {
74
- devServerMetrics,
75
- type DevServerEndpoint,
76
- type DevServerFailureType,
77
- type WarmActivationOutcome,
78
- } from "./dev-utils/dev-server-metrics.mjs";
79
68
 
80
69
  export { TokenManager } from "./dev-utils/token-manager.js";
81
70
 
@@ -112,12 +101,7 @@ export {
112
101
  type PackageJsonSnapshotReadResult,
113
102
  } from "./cli-replacement/package-json-snapshot.mjs";
114
103
 
115
- export {
116
- getErrorMeta,
117
- getLogger,
118
- type ErrorMeta,
119
- type Logger,
120
- } from "./telemetry/logging.js";
104
+ export { getLogger } from "./telemetry/logging.js";
121
105
 
122
106
  export {
123
107
  AuthHotReloadServer,
@@ -127,7 +111,5 @@ export {
127
111
  export {
128
112
  configureTelemetry,
129
113
  deploymentType,
130
- getMeter,
131
- getTracer,
132
114
  isCloudPrem,
133
115
  } from "./telemetry/index.js";
package/src/sdk.test.ts CHANGED
@@ -7,23 +7,12 @@ import {
7
7
  type GetPublicOrganizationSummaryResponseBody,
8
8
  } from "@superblocksteam/shared";
9
9
 
10
- import type { PlanSummary } from "./index.js";
11
-
12
- const {
13
- fetchApplicationCommits,
14
- fetchAuditEvents,
15
- fetchBillingUsageLimits,
16
- fetchOrganizationSummary,
17
- updateOrgBillingUsageLimit,
18
- updateUserBillingUsageLimit,
19
- } = vi.hoisted(() => ({
20
- fetchApplicationCommits: vi.fn(),
21
- fetchAuditEvents: vi.fn(),
22
- fetchBillingUsageLimits: vi.fn(),
23
- fetchOrganizationSummary: vi.fn(),
24
- updateOrgBillingUsageLimit: vi.fn(),
25
- updateUserBillingUsageLimit: vi.fn(),
26
- }));
10
+ const { fetchApplicationCommits, fetchAuditEvents, fetchOrganizationSummary } =
11
+ vi.hoisted(() => ({
12
+ fetchApplicationCommits: vi.fn(),
13
+ fetchAuditEvents: vi.fn(),
14
+ fetchOrganizationSummary: vi.fn(),
15
+ }));
27
16
 
28
17
  vi.mock("./client.js", async () => {
29
18
  const actual = await vi.importActual("./client.js");
@@ -32,55 +21,12 @@ vi.mock("./client.js", async () => {
32
21
  ...actual,
33
22
  fetchApplicationCommits,
34
23
  fetchAuditEvents,
35
- fetchBillingUsageLimits,
36
24
  fetchOrganizationSummary,
37
- updateOrgBillingUsageLimit,
38
- updateUserBillingUsageLimit,
39
25
  };
40
26
  });
41
27
 
42
28
  import { SuperblocksSdk } from "./sdk.js";
43
29
 
44
- describe("PlanSummary", () => {
45
- it("types enterprise contract limits and usage fields", () => {
46
- const plan: PlanSummary = {
47
- billingInterval: "annual",
48
- builderSeatsAssigned: 12,
49
- builderSeatsTotal: 20,
50
- contractEnd: "2027-05-01",
51
- contractStart: "2026-05-01",
52
- contractType: "dollar_commit",
53
- creditsPerSeat: null,
54
- currentPlanCredits: 0,
55
- currentUsageCredits: 0,
56
- cycleEnd: "2026-05-31",
57
- cycleStart: "2026-05-01",
58
- deployedAppCostCents: 2500,
59
- deployedAppPriceAnnual: null,
60
- deployedAppPriceMonthly: null,
61
- deployedAppsAdditional: 0,
62
- deployedAppsIncluded: 0,
63
- deployedAppsLimit: 0,
64
- deployedAppsUsed: 4,
65
- dollarCommitAmountCents: 1000000,
66
- dollarCommitUsedCents: 250000,
67
- overageAppsEnabled: true,
68
- overageCreditsEnabled: true,
69
- overageSeatsEnabled: false,
70
- pricePerSeatAnnual: null,
71
- pricePerSeatMonthly: null,
72
- seatsUnlimited: false,
73
- subscriptionStatus: "active",
74
- topupCreditsPurchased: 0,
75
- topupCreditsUsed: 0,
76
- usageResetPeriodLimit: 0,
77
- usageResetPeriodType: "monthly",
78
- };
79
-
80
- expect(plan.dollarCommitUsedCents).toBe(250000);
81
- });
82
- });
83
-
84
30
  describe("SuperblocksSdk.fetchOrganizationSummary", () => {
85
31
  beforeEach(() => {
86
32
  fetchApplicationCommits.mockReset();
@@ -120,91 +66,6 @@ describe("SuperblocksSdk.fetchOrganizationSummary", () => {
120
66
  });
121
67
  });
122
68
 
123
- describe("SuperblocksSdk billing usage limit methods", () => {
124
- beforeEach(() => {
125
- fetchBillingUsageLimits.mockReset();
126
- updateOrgBillingUsageLimit.mockReset();
127
- updateUserBillingUsageLimit.mockReset();
128
- });
129
-
130
- it("delegates listing usage limits with the SDK context", async () => {
131
- const expectedResponse = {
132
- limits: [
133
- {
134
- id: "limit-1",
135
- orgId: "org-1",
136
- userId: null,
137
- amountLimitCents: null,
138
- creditLimit: 5000,
139
- updatedAt: "2026-05-01T00:00:00.000Z",
140
- updatedBy: "admin-1",
141
- },
142
- ],
143
- orgLimit: null,
144
- };
145
- fetchBillingUsageLimits.mockResolvedValue(expectedResponse);
146
-
147
- const sdk = new SuperblocksSdk(
148
- "test-token",
149
- "https://staging.superblocks.com",
150
- "1.2.3",
151
- );
152
-
153
- await expect(sdk.fetchBillingUsageLimits()).resolves.toEqual(
154
- expectedResponse,
155
- );
156
- expect(fetchBillingUsageLimits).toHaveBeenCalledWith({
157
- cliVersion: "1.2.3",
158
- token: "test-token",
159
- superblocksBaseUrl: "https://staging.superblocks.com",
160
- });
161
- });
162
-
163
- it("delegates user usage limit updates with the SDK context", async () => {
164
- updateUserBillingUsageLimit.mockResolvedValue({ success: true });
165
-
166
- const sdk = new SuperblocksSdk(
167
- "test-token",
168
- "https://staging.superblocks.com",
169
- "1.2.3",
170
- );
171
-
172
- await expect(
173
- sdk.updateUserBillingUsageLimit({
174
- amountLimitCents: 2500,
175
- userId: "user-1",
176
- }),
177
- ).resolves.toEqual({ success: true });
178
- expect(updateUserBillingUsageLimit).toHaveBeenCalledWith({
179
- cliVersion: "1.2.3",
180
- token: "test-token",
181
- superblocksBaseUrl: "https://staging.superblocks.com",
182
- amountLimitCents: 2500,
183
- userId: "user-1",
184
- });
185
- });
186
-
187
- it("delegates organization usage limit updates with the SDK context", async () => {
188
- updateOrgBillingUsageLimit.mockResolvedValue({ success: true });
189
-
190
- const sdk = new SuperblocksSdk(
191
- "test-token",
192
- "https://staging.superblocks.com",
193
- "1.2.3",
194
- );
195
-
196
- await expect(
197
- sdk.updateOrgBillingUsageLimit({ creditLimit: 5000 }),
198
- ).resolves.toEqual({ success: true });
199
- expect(updateOrgBillingUsageLimit).toHaveBeenCalledWith({
200
- cliVersion: "1.2.3",
201
- token: "test-token",
202
- superblocksBaseUrl: "https://staging.superblocks.com",
203
- creditLimit: 5000,
204
- });
205
- });
206
- });
207
-
208
69
  describe("SuperblocksSdk.fetchApplicationCommits", () => {
209
70
  beforeEach(() => {
210
71
  fetchApplicationCommits.mockReset();
package/src/sdk.ts CHANGED
@@ -39,7 +39,6 @@ import {
39
39
  fetchChatHistory,
40
40
  fetchBillingPlanSummary,
41
41
  fetchBillingUsageDaily,
42
- fetchBillingUsageLimits,
43
42
  fetchBillingUsageRecords,
44
43
  fetchCurrentUser,
45
44
  fetchFact,
@@ -65,8 +64,6 @@ import {
65
64
  deployApi,
66
65
  fetchApplicationDeployments,
67
66
  undeployApplication,
68
- updateOrgBillingUsageLimit,
69
- updateUserBillingUsageLimit,
70
67
  } from "./client.js";
71
68
  import type {
72
69
  ApplicationGitConfig,
@@ -75,7 +72,6 @@ import type {
75
72
  AuditEventsAggregateResponse,
76
73
  CreateApplicationResult,
77
74
  CreateRbacAssignmentsRequest,
78
- BillingUsageLimitsResponse,
79
75
  DailyUsageRow,
80
76
  FolderMutationPayload,
81
77
  FolderSummary,
@@ -88,9 +84,7 @@ import type {
88
84
  PushMultiPageApplicationWithCommitConfig,
89
85
  SyncRequest,
90
86
  SyncResponse,
91
- UpdateOrgBillingUsageLimitRequest,
92
87
  UpdateRbacAssignmentRequest,
93
- UpdateUserBillingUsageLimitRequest,
94
88
  UsageRecordRow,
95
89
  } from "./client.js";
96
90
  import {
@@ -899,36 +893,6 @@ export class SuperblocksSdk {
899
893
  });
900
894
  }
901
895
 
902
- async fetchBillingUsageLimits(): Promise<BillingUsageLimitsResponse> {
903
- return fetchBillingUsageLimits({
904
- cliVersion: this.cliVersion,
905
- token: this.token,
906
- superblocksBaseUrl: this.superblocksBaseUrl,
907
- });
908
- }
909
-
910
- async updateUserBillingUsageLimit(
911
- input: UpdateUserBillingUsageLimitRequest,
912
- ): Promise<{ success: boolean }> {
913
- return updateUserBillingUsageLimit({
914
- cliVersion: this.cliVersion,
915
- token: this.token,
916
- superblocksBaseUrl: this.superblocksBaseUrl,
917
- ...input,
918
- });
919
- }
920
-
921
- async updateOrgBillingUsageLimit(
922
- input: UpdateOrgBillingUsageLimitRequest,
923
- ): Promise<{ success: boolean }> {
924
- return updateOrgBillingUsageLimit({
925
- cliVersion: this.cliVersion,
926
- token: this.token,
927
- superblocksBaseUrl: this.superblocksBaseUrl,
928
- ...input,
929
- });
930
- }
931
-
932
896
  async sync({
933
897
  applicationId,
934
898
  payload,
@@ -1,6 +1,6 @@
1
1
  import os from "node:os";
2
2
 
3
- import { metrics, type Meter, trace, type Tracer } from "@opentelemetry/api";
3
+ import { trace, type Tracer } from "@opentelemetry/api";
4
4
  import { logs, type Logger } from "@opentelemetry/api-logs";
5
5
  import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
6
6
  import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
@@ -230,11 +230,3 @@ export function getTracer(): Tracer {
230
230
  // Fallback to global API if telemetry not initialized
231
231
  return trace.getTracer(SERVICE_NAME, packageJson.version);
232
232
  }
233
-
234
- export function getMeter(): Meter {
235
- if (isTelemetryInitialized()) {
236
- return getTelemetryInstance().getMeter(SERVICE_NAME);
237
- }
238
- // Fallback to global API if telemetry not initialized
239
- return metrics.getMeter(SERVICE_NAME, packageJson.version);
240
- }
@@ -59,7 +59,7 @@ const winstonLogger = createLogger({
59
59
  transports: activeTransports,
60
60
  });
61
61
 
62
- export interface ErrorMeta {
62
+ interface ErrorMeta {
63
63
  error: {
64
64
  kind: string;
65
65
  message: string;
@@ -156,7 +156,7 @@ export function getErrorMeta(error: unknown): ErrorMeta {
156
156
  return {
157
157
  error: {
158
158
  kind: "Unknown Error",
159
- message: safeStringify(error) ?? String(error),
159
+ message: JSON.stringify(error),
160
160
  },
161
161
  };
162
162
  }
@@ -12,12 +12,12 @@ export interface UserMeDto {
12
12
  export interface FlagBootstrap {
13
13
  "ui.enable-resource-signing"?: boolean;
14
14
  "superblocks.git.split.large.steps.enabled"?: boolean;
15
+ "superblocks.git.split.large.steps.new.enabled"?: boolean;
15
16
  "superblocks.git.split.large.step.lines"?: number;
16
17
  "ui.code-mode.enable-session-recording"?: boolean;
17
18
  "superblocks.dev-server.inactivity-timeout.cloud"?: number;
18
19
  "superblocks.dev-server.inactivity-timeout.local"?: number;
19
20
  "superblocks.dev-server.llmobs.enabled"?: boolean;
20
- "superblocks.dev-server.memory-metrics.enabled"?: boolean;
21
21
  "superblocks.deploy.include-dot-superblocks"?: boolean;
22
22
  }
23
23
 
@@ -1,11 +1,11 @@
1
- import * as https from "node:https";
1
+ import * as https from "https";
2
2
  import path from "node:path";
3
3
  import { dirname } from "path";
4
4
 
5
5
  import { bold } from "colorette";
6
6
  import fs from "fs-extra";
7
7
  import { isEmpty, isArray, isObject, get } from "lodash-es";
8
- import semver from "semver";
8
+ import * as semver from "semver";
9
9
  import { simpleGit } from "simple-git";
10
10
  import type { SimpleGit, StatusResult } from "simple-git";
11
11
  import slugify from "slugify";
@@ -419,7 +419,10 @@ export async function writeResourceToDisk(
419
419
  configType: "APPLICATION",
420
420
  defaultPageId: resource.page?.id,
421
421
  id: resource.application.id,
422
- metadata: getResourceConfigMetadata(existingApplicationConfig),
422
+ metadata: getResourceConfigMetadata(
423
+ featureFlags,
424
+ existingApplicationConfig,
425
+ ),
423
426
  };
424
427
 
425
428
  const apiRepresentation =
@@ -503,7 +506,10 @@ export async function writeResourceToDisk(
503
506
  const backendConfig: SuperblocksBackendConfig = {
504
507
  id: resourceId,
505
508
  configType: "BACKEND",
506
- metadata: getResourceConfigMetadata(existingBackendConfig),
509
+ metadata: getResourceConfigMetadata(
510
+ featureFlags,
511
+ existingBackendConfig,
512
+ ),
507
513
  };
508
514
 
509
515
  const apiRepresentation =
@@ -588,6 +594,7 @@ export async function writeApplicationToDisk({
588
594
  appDirName,
589
595
  directoryContentsHash,
590
596
  branch,
597
+ featureFlags,
591
598
  );
592
599
  return {
593
600
  location: relativeLocation,
@@ -629,7 +636,10 @@ async function writeV1ApplicationToDisk(
629
636
  const newApplicationConfig: SuperblocksApplicationConfig = {
630
637
  configType: "APPLICATION",
631
638
  id: resource.application.id,
632
- metadata: getResourceConfigMetadata(existingApplicationConfig),
639
+ metadata: getResourceConfigMetadata(
640
+ featureFlags,
641
+ existingApplicationConfig,
642
+ ),
633
643
  };
634
644
 
635
645
  const apiRepresentation =
@@ -775,6 +785,7 @@ async function writeCodeModeApplicationToDisk(
775
785
  appDirName: string,
776
786
  directoryContentsHash: string | undefined,
777
787
  branch: string | undefined,
788
+ featureFlags: FeatureFlags,
778
789
  ): Promise<void> {
779
790
  // Find the existing application config and existing file paths
780
791
  const existingApplicationConfig =
@@ -783,7 +794,10 @@ async function writeCodeModeApplicationToDisk(
783
794
  const newApplicationConfig: SuperblocksApplicationV2Config = {
784
795
  configType: "APPLICATION_V2",
785
796
  id: resource.application.id,
786
- metadata: getResourceConfigMetadata(existingApplicationConfig),
797
+ metadata: getResourceConfigMetadata(
798
+ featureFlags,
799
+ existingApplicationConfig,
800
+ ),
787
801
  };
788
802
 
789
803
  await fs.ensureDir(`${appDirName}/${SUPERBLOCKS_HOME_FOLDER_NAME}`);
@@ -916,15 +930,20 @@ export function addExistingFilePathsForApi(
916
930
  }
917
931
 
918
932
  function getResourceConfigMetadata(
933
+ featureFlags: FeatureFlags,
919
934
  existingResourceConfig: SuperblocksResourceConfig | undefined,
920
935
  ): SuperblocksResourceConfigMetadata | undefined {
921
936
  if (!existingResourceConfig) {
922
- // This is a new application; tag the application config with the latest file version.
923
- return {
924
- fileVersion: LATEST_FILE_VERSION,
925
- };
937
+ // This is a new application, and we may need to add a metadata field to the application config
938
+ if (featureFlags.splitLargeApiStepsInNewEnabled()) {
939
+ return {
940
+ fileVersion: LATEST_FILE_VERSION,
941
+ };
942
+ }
943
+ } else if (existingResourceConfig.metadata) {
944
+ return existingResourceConfig.metadata;
926
945
  }
927
- return existingResourceConfig.metadata;
946
+ return undefined;
928
947
  }
929
948
 
930
949
  export async function removeResourceFromDisk(
@@ -662,6 +662,7 @@ describe("version-control", () => {
662
662
  describe("writeResourcesToDisk", () => {
663
663
  const mockFeatureFlags = new FeatureFlags({
664
664
  "superblocks.git.split.large.steps.enabled": true,
665
+ "superblocks.git.split.large.steps.new.enabled": true,
665
666
  "superblocks.git.split.large.step.lines": 10,
666
667
  });
667
668
 
@@ -930,6 +931,7 @@ describe("version-control", () => {
930
931
  describe("writeApplicationToDIsk", () => {
931
932
  const mockFeatureFlags = new FeatureFlags({
932
933
  "superblocks.git.split.large.steps.enabled": true,
934
+ "superblocks.git.split.large.steps.new.enabled": false,
933
935
  "superblocks.git.split.large.step.lines": 10,
934
936
  });
935
937