@superblocksteam/sdk 2.0.102 → 2.0.103
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/.turbo/turbo-build.log +1 -1
- package/dist/application-build.d.mts.map +1 -1
- package/dist/application-build.mjs +1 -1
- package/dist/application-build.mjs.map +1 -1
- package/dist/cli-replacement/auth-hot-reload.d.mts.map +1 -1
- package/dist/cli-replacement/auth-hot-reload.mjs.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts +1 -1
- package/dist/cli-replacement/automatic-upgrades.d.ts.map +1 -1
- package/dist/cli-replacement/automatic-upgrades.js +1 -1
- package/dist/cli-replacement/automatic-upgrades.js.map +1 -1
- package/dist/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +5 -7
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/cli-replacement/git-repo-setup.d.mts.map +1 -1
- package/dist/cli-replacement/git-repo-setup.mjs +30 -0
- package/dist/cli-replacement/git-repo-setup.mjs.map +1 -1
- package/dist/cli-replacement/git-repo-setup.test.mjs.map +1 -1
- package/dist/cli-replacement/init.d.ts +2 -2
- package/dist/cli-replacement/init.d.ts.map +1 -1
- package/dist/cli-replacement/init.js.map +1 -1
- package/dist/cli-replacement/version-detection.d.ts.map +1 -1
- package/dist/cli-replacement/version-detection.js.map +1 -1
- package/dist/cli-replacement/version-detection.test.js.map +1 -1
- package/dist/client-sync.test.mjs.map +1 -1
- package/dist/client.d.ts +252 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.fetch-audit-events.test.d.ts +2 -0
- package/dist/client.fetch-audit-events.test.d.ts.map +1 -0
- package/dist/client.fetch-audit-events.test.js +69 -0
- package/dist/client.fetch-audit-events.test.js.map +1 -0
- package/dist/client.js +762 -5
- package/dist/client.js.map +1 -1
- package/dist/collect-sdk-apis.d.mts.map +1 -1
- package/dist/collect-sdk-apis.mjs.map +1 -1
- package/dist/collect-sdk-apis.test.mjs.map +1 -1
- package/dist/dbfs/client.d.ts.map +1 -1
- package/dist/dbfs/client.js.map +1 -1
- package/dist/dbfs/client.test.js +1 -1
- package/dist/dbfs/client.test.js.map +1 -1
- package/dist/dbfs/local.d.ts.map +1 -1
- package/dist/dbfs/local.js.map +1 -1
- package/dist/dev-utils/custom-build.d.mts.map +1 -1
- package/dist/dev-utils/custom-build.mjs.map +1 -1
- package/dist/dev-utils/custom-config.d.mts.map +1 -1
- package/dist/dev-utils/custom-config.mjs.map +1 -1
- package/dist/dev-utils/dev-server.d.mts +2 -2
- package/dist/dev-utils/dev-server.d.mts.map +1 -1
- package/dist/dev-utils/dev-server.mjs +5 -4
- package/dist/dev-utils/dev-server.mjs.map +1 -1
- package/dist/dev-utils/token-manager.d.ts.map +1 -1
- package/dist/dev-utils/token-manager.js.map +1 -1
- package/dist/extract-api-integrations.d.mts +1 -16
- package/dist/extract-api-integrations.d.mts.map +1 -1
- package/dist/extract-api-integrations.mjs +1 -232
- package/dist/extract-api-integrations.mjs.map +1 -1
- package/dist/extract-api-integrations.test.mjs.map +1 -1
- package/dist/flag.d.ts.map +1 -1
- package/dist/flag.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/parse-sdk-registry.d.mts.map +1 -1
- package/dist/parse-sdk-registry.mjs.map +1 -1
- package/dist/parse-sdk-registry.test.mjs.map +1 -1
- package/dist/sdk.d.ts +59 -4
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +184 -1
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.test.js +72 -2
- package/dist/sdk.test.js.map +1 -1
- package/dist/socket/handlers.d.ts +1 -1
- package/dist/socket/handlers.d.ts.map +1 -1
- package/dist/socket/handlers.js.map +1 -1
- package/dist/socket/index.d.ts +1 -1
- package/dist/socket/index.d.ts.map +1 -1
- package/dist/socket/index.js.map +1 -1
- package/dist/socket/signing.d.ts +1 -1
- package/dist/socket/signing.d.ts.map +1 -1
- package/dist/socket/signing.js.map +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/logging.d.ts.map +1 -1
- package/dist/telemetry/logging.js +1 -1
- package/dist/telemetry/logging.js.map +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/version-control.d.mts +1 -1
- package/dist/version-control.d.mts.map +1 -1
- package/dist/version-control.mjs +2 -2
- package/dist/version-control.mjs.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.d.mts.map +1 -1
- package/dist/vite-plugin-generate-api-build-manifest.mjs +3 -3
- package/dist/vite-plugin-generate-api-build-manifest.mjs.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.d.mts.map +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs +1 -1
- package/dist/vite-plugin-inject-sb-ids-transform.mjs.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.d.mts.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.mjs.map +1 -1
- package/dist/vite-plugin-sdk-api-entry-point.test.mjs.map +1 -1
- package/eslint.config.js +2 -17
- package/package.json +6 -6
- package/src/application-build.mts +4 -1
- package/src/cli-replacement/auth-hot-reload.mts +2 -2
- package/src/cli-replacement/automatic-upgrades.ts +10 -7
- package/src/cli-replacement/dev.mts +17 -17
- package/src/cli-replacement/git-repo-setup.mts +34 -1
- package/src/cli-replacement/git-repo-setup.test.mts +4 -1
- package/src/cli-replacement/init.ts +5 -4
- package/src/cli-replacement/version-detection.test.ts +2 -0
- package/src/cli-replacement/version-detection.ts +1 -0
- package/src/client-sync.test.mts +1 -0
- package/src/client.fetch-audit-events.test.ts +82 -0
- package/src/client.ts +1204 -21
- package/src/collect-sdk-apis.mts +1 -0
- package/src/collect-sdk-apis.test.mts +2 -0
- package/src/dbfs/client.test.ts +2 -1
- package/src/dbfs/client.ts +1 -0
- package/src/dbfs/local.ts +2 -0
- package/src/dev-utils/custom-build.mts +3 -1
- package/src/dev-utils/custom-config.mts +1 -0
- package/src/dev-utils/dev-server.mts +22 -19
- package/src/dev-utils/token-manager.ts +1 -0
- package/src/extract-api-integrations.mts +5 -345
- package/src/extract-api-integrations.test.mts +1 -0
- package/src/flag.ts +1 -0
- package/src/index.ts +7 -0
- package/src/parse-sdk-registry.mts +1 -0
- package/src/parse-sdk-registry.test.mts +2 -0
- package/src/sdk.test.ts +85 -5
- package/src/sdk.ts +324 -14
- package/src/socket/handlers.ts +3 -2
- package/src/socket/index.ts +4 -3
- package/src/socket/signing.ts +5 -3
- package/src/telemetry/index.ts +5 -2
- package/src/telemetry/logging.ts +4 -3
- package/src/types/common.ts +2 -1
- package/src/utils.ts +4 -2
- package/src/version-control.mts +21 -18
- package/src/vite-plugin-generate-api-build-manifest.mts +10 -7
- package/src/vite-plugin-inject-sb-ids-transform.mts +5 -2
- package/src/vite-plugin-sdk-api-entry-point.mts +1 -0
- package/src/vite-plugin-sdk-api-entry-point.test.mts +2 -0
- package/test/clients.test.mts +4 -1
- package/test/safe-stringify.test.mts +1 -0
- package/test/version-control.test.mts +17 -14
- package/tsconfig.tsbuildinfo +1 -1
package/src/sdk.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CommitType,
|
|
3
3
|
ExportViewMode,
|
|
4
|
+
type AssignmentDto,
|
|
5
|
+
type OCSFAuditEvent,
|
|
6
|
+
type AuditLogDto,
|
|
7
|
+
type AuditLogEntity,
|
|
8
|
+
type FactDto,
|
|
9
|
+
type FactListQuery,
|
|
4
10
|
type GetPublicOrganizationSummaryResponseBody,
|
|
11
|
+
type IHomepageApplicationV2Dto,
|
|
5
12
|
} from "@superblocksteam/shared";
|
|
13
|
+
import type {
|
|
14
|
+
ComponentEvent,
|
|
15
|
+
LocalGitRepoState,
|
|
16
|
+
SuperblocksResourceType,
|
|
17
|
+
} from "@superblocksteam/util";
|
|
18
|
+
|
|
6
19
|
import {
|
|
20
|
+
createFolder,
|
|
21
|
+
createIntegration,
|
|
22
|
+
createRbacAssignments,
|
|
23
|
+
createApplication,
|
|
24
|
+
deleteFolder,
|
|
25
|
+
deleteIntegration,
|
|
26
|
+
deleteRbacAssignment,
|
|
7
27
|
fetchApi,
|
|
8
28
|
fetchApiCommits,
|
|
9
29
|
fetchApis,
|
|
@@ -12,8 +32,20 @@ import {
|
|
|
12
32
|
fetchApplicationCommits,
|
|
13
33
|
fetchApplications,
|
|
14
34
|
fetchApplicationWithComponents,
|
|
35
|
+
fetchAuditEntities,
|
|
36
|
+
fetchAuditEvents,
|
|
37
|
+
fetchAuditLogs,
|
|
38
|
+
fetchBillingPlanSummary,
|
|
39
|
+
fetchBillingUsageDaily,
|
|
40
|
+
fetchBillingUsageRecords,
|
|
15
41
|
fetchCurrentUser,
|
|
42
|
+
fetchFact,
|
|
43
|
+
fetchFacts,
|
|
44
|
+
fetchFolders,
|
|
45
|
+
fetchIntegrationById,
|
|
46
|
+
fetchIntegrations,
|
|
16
47
|
fetchOrganizationSummary,
|
|
48
|
+
fetchRbacAssignments,
|
|
17
49
|
getApplicationGitConfig,
|
|
18
50
|
getGitFreshToken,
|
|
19
51
|
sync,
|
|
@@ -22,10 +54,32 @@ import {
|
|
|
22
54
|
pushApplicationCodeMode,
|
|
23
55
|
registerComponents,
|
|
24
56
|
uploadComponents,
|
|
57
|
+
updateFolder,
|
|
58
|
+
updateIntegration,
|
|
59
|
+
updateRbacAssignment,
|
|
25
60
|
validateGitSetup,
|
|
26
61
|
deployApplication,
|
|
27
62
|
deployApi,
|
|
28
63
|
} from "./client.js";
|
|
64
|
+
import type {
|
|
65
|
+
ApplicationGitConfig,
|
|
66
|
+
CreateApplicationResult,
|
|
67
|
+
CreateRbacAssignmentsRequest,
|
|
68
|
+
DailyUsageRow,
|
|
69
|
+
FolderMutationPayload,
|
|
70
|
+
FolderSummary,
|
|
71
|
+
GitFreshToken,
|
|
72
|
+
IntegrationDetail,
|
|
73
|
+
IntegrationMutationPayload,
|
|
74
|
+
IntegrationSummary,
|
|
75
|
+
PlanSummary,
|
|
76
|
+
PushApiWithCommitConfig,
|
|
77
|
+
PushMultiPageApplicationWithCommitConfig,
|
|
78
|
+
SyncRequest,
|
|
79
|
+
SyncResponse,
|
|
80
|
+
UpdateRbacAssignmentRequest,
|
|
81
|
+
UsageRecordRow,
|
|
82
|
+
} from "./client.js";
|
|
29
83
|
import {
|
|
30
84
|
downloadApplicationDirectory,
|
|
31
85
|
downloadDirectoryByHash,
|
|
@@ -37,20 +91,7 @@ import {
|
|
|
37
91
|
} from "./dbfs/client.js";
|
|
38
92
|
import { hashLocalDirectory } from "./dbfs/local.js";
|
|
39
93
|
import { FeatureFlags } from "./flag.js";
|
|
40
|
-
import type {
|
|
41
|
-
ApplicationGitConfig,
|
|
42
|
-
GitFreshToken,
|
|
43
|
-
SyncRequest,
|
|
44
|
-
SyncResponse,
|
|
45
|
-
PushApiWithCommitConfig,
|
|
46
|
-
PushMultiPageApplicationWithCommitConfig,
|
|
47
|
-
} from "./client.js";
|
|
48
94
|
import type { UserMeDto } from "./types/index.js";
|
|
49
|
-
import type {
|
|
50
|
-
ComponentEvent,
|
|
51
|
-
LocalGitRepoState,
|
|
52
|
-
SuperblocksResourceType,
|
|
53
|
-
} from "@superblocksteam/util";
|
|
54
95
|
|
|
55
96
|
// Exporting here instead of index.ts because only sdk.ts is exposed outside in package.json
|
|
56
97
|
export * from "./errors.js";
|
|
@@ -220,7 +261,9 @@ export class SuperblocksSdk {
|
|
|
220
261
|
});
|
|
221
262
|
}
|
|
222
263
|
|
|
223
|
-
async fetchApplications(
|
|
264
|
+
async fetchApplications(
|
|
265
|
+
headers?: Record<string, string>,
|
|
266
|
+
): Promise<IHomepageApplicationV2Dto[]> {
|
|
224
267
|
return fetchApplications(
|
|
225
268
|
this.cliVersion,
|
|
226
269
|
this.token,
|
|
@@ -229,6 +272,214 @@ export class SuperblocksSdk {
|
|
|
229
272
|
);
|
|
230
273
|
}
|
|
231
274
|
|
|
275
|
+
async fetchRbacAssignments(
|
|
276
|
+
resourceType: string,
|
|
277
|
+
resourceId: string,
|
|
278
|
+
): Promise<AssignmentDto[]> {
|
|
279
|
+
return fetchRbacAssignments({
|
|
280
|
+
cliVersion: this.cliVersion,
|
|
281
|
+
token: this.token,
|
|
282
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
283
|
+
resourceType,
|
|
284
|
+
resourceId,
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
async createRbacAssignments(
|
|
289
|
+
payload: CreateRbacAssignmentsRequest,
|
|
290
|
+
): Promise<AssignmentDto[]> {
|
|
291
|
+
return createRbacAssignments({
|
|
292
|
+
cliVersion: this.cliVersion,
|
|
293
|
+
token: this.token,
|
|
294
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
295
|
+
payload,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async updateRbacAssignment(
|
|
300
|
+
assignmentRecordId: string,
|
|
301
|
+
payload: UpdateRbacAssignmentRequest,
|
|
302
|
+
): Promise<AssignmentDto> {
|
|
303
|
+
return updateRbacAssignment({
|
|
304
|
+
cliVersion: this.cliVersion,
|
|
305
|
+
token: this.token,
|
|
306
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
307
|
+
assignmentRecordId,
|
|
308
|
+
payload,
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async deleteRbacAssignment(
|
|
313
|
+
assignmentRecordId: string,
|
|
314
|
+
): Promise<AssignmentDto> {
|
|
315
|
+
return deleteRbacAssignment({
|
|
316
|
+
cliVersion: this.cliVersion,
|
|
317
|
+
token: this.token,
|
|
318
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
319
|
+
assignmentRecordId,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async fetchAuditLogs(filters: {
|
|
324
|
+
startTime: string;
|
|
325
|
+
endTime: string;
|
|
326
|
+
entityType?: number;
|
|
327
|
+
auditEntityId?: string;
|
|
328
|
+
auditEntityType?: number;
|
|
329
|
+
status?: string;
|
|
330
|
+
deployed?: boolean;
|
|
331
|
+
triggeredBy?: string[];
|
|
332
|
+
}): Promise<AuditLogDto[]> {
|
|
333
|
+
return fetchAuditLogs({
|
|
334
|
+
cliVersion: this.cliVersion,
|
|
335
|
+
token: this.token,
|
|
336
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
337
|
+
filters,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
async fetchAuditEvents(filters: {
|
|
342
|
+
timeStart: string;
|
|
343
|
+
timeEnd: string;
|
|
344
|
+
classUid?: number;
|
|
345
|
+
status?: number;
|
|
346
|
+
severity?: number;
|
|
347
|
+
actor?: string;
|
|
348
|
+
resourceType?: string;
|
|
349
|
+
resourceId?: string;
|
|
350
|
+
search?: string;
|
|
351
|
+
cursor?: string;
|
|
352
|
+
limit?: number;
|
|
353
|
+
}): Promise<{ events: OCSFAuditEvent[]; next_cursor: string | null }> {
|
|
354
|
+
return fetchAuditEvents({
|
|
355
|
+
cliVersion: this.cliVersion,
|
|
356
|
+
token: this.token,
|
|
357
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
358
|
+
filters,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async fetchAuditEntities(): Promise<AuditLogEntity[]> {
|
|
363
|
+
return fetchAuditEntities({
|
|
364
|
+
cliVersion: this.cliVersion,
|
|
365
|
+
token: this.token,
|
|
366
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
async fetchFacts(query?: FactListQuery): Promise<FactDto[]> {
|
|
371
|
+
return fetchFacts({
|
|
372
|
+
cliVersion: this.cliVersion,
|
|
373
|
+
token: this.token,
|
|
374
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
375
|
+
query,
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
async fetchFact(factId: string): Promise<FactDto> {
|
|
380
|
+
return fetchFact({
|
|
381
|
+
cliVersion: this.cliVersion,
|
|
382
|
+
token: this.token,
|
|
383
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
384
|
+
factId,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
async fetchIntegrations(filters?: {
|
|
389
|
+
kind?: string[];
|
|
390
|
+
slug?: string[];
|
|
391
|
+
}): Promise<IntegrationSummary[]> {
|
|
392
|
+
return fetchIntegrations({
|
|
393
|
+
cliVersion: this.cliVersion,
|
|
394
|
+
token: this.token,
|
|
395
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
396
|
+
filters,
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
async fetchIntegrationById(
|
|
401
|
+
integrationId: string,
|
|
402
|
+
): Promise<IntegrationDetail> {
|
|
403
|
+
return fetchIntegrationById({
|
|
404
|
+
cliVersion: this.cliVersion,
|
|
405
|
+
token: this.token,
|
|
406
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
407
|
+
integrationId,
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
async createIntegration(
|
|
412
|
+
payload: IntegrationMutationPayload,
|
|
413
|
+
): Promise<IntegrationDetail> {
|
|
414
|
+
return createIntegration({
|
|
415
|
+
cliVersion: this.cliVersion,
|
|
416
|
+
token: this.token,
|
|
417
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
418
|
+
payload,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
async updateIntegration(
|
|
423
|
+
integrationId: string,
|
|
424
|
+
payload: IntegrationMutationPayload,
|
|
425
|
+
): Promise<IntegrationDetail> {
|
|
426
|
+
return updateIntegration({
|
|
427
|
+
cliVersion: this.cliVersion,
|
|
428
|
+
token: this.token,
|
|
429
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
430
|
+
integrationId,
|
|
431
|
+
payload,
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
async deleteIntegration(integrationId: string): Promise<IntegrationDetail> {
|
|
436
|
+
return deleteIntegration({
|
|
437
|
+
cliVersion: this.cliVersion,
|
|
438
|
+
token: this.token,
|
|
439
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
440
|
+
integrationId,
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
async fetchFolders(): Promise<FolderSummary[]> {
|
|
445
|
+
return fetchFolders({
|
|
446
|
+
cliVersion: this.cliVersion,
|
|
447
|
+
token: this.token,
|
|
448
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
async createFolder(payload: FolderMutationPayload): Promise<FolderSummary> {
|
|
453
|
+
return createFolder({
|
|
454
|
+
cliVersion: this.cliVersion,
|
|
455
|
+
token: this.token,
|
|
456
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
457
|
+
payload,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
async updateFolder(
|
|
462
|
+
folderId: string,
|
|
463
|
+
payload: FolderMutationPayload,
|
|
464
|
+
): Promise<FolderSummary> {
|
|
465
|
+
return updateFolder({
|
|
466
|
+
cliVersion: this.cliVersion,
|
|
467
|
+
token: this.token,
|
|
468
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
469
|
+
folderId,
|
|
470
|
+
payload,
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async deleteFolder(folderId: string): Promise<FolderSummary> {
|
|
475
|
+
return deleteFolder({
|
|
476
|
+
cliVersion: this.cliVersion,
|
|
477
|
+
token: this.token,
|
|
478
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
479
|
+
folderId,
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
232
483
|
async fetchApi({
|
|
233
484
|
apiId,
|
|
234
485
|
branch,
|
|
@@ -502,6 +753,31 @@ export class SuperblocksSdk {
|
|
|
502
753
|
return await hashLocalDirectory(localDirectoryPath);
|
|
503
754
|
}
|
|
504
755
|
|
|
756
|
+
async createApplication({
|
|
757
|
+
name,
|
|
758
|
+
organizationId,
|
|
759
|
+
codeMode,
|
|
760
|
+
templateName,
|
|
761
|
+
folderId,
|
|
762
|
+
}: {
|
|
763
|
+
name: string;
|
|
764
|
+
organizationId: string;
|
|
765
|
+
codeMode?: boolean;
|
|
766
|
+
templateName?: string;
|
|
767
|
+
folderId?: string;
|
|
768
|
+
}): Promise<CreateApplicationResult> {
|
|
769
|
+
return createApplication({
|
|
770
|
+
cliVersion: this.cliVersion,
|
|
771
|
+
token: this.token,
|
|
772
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
773
|
+
name,
|
|
774
|
+
organizationId,
|
|
775
|
+
codeMode,
|
|
776
|
+
templateName,
|
|
777
|
+
folderId,
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
|
|
505
781
|
async deployApplication(applicationId: string, commitId?: string) {
|
|
506
782
|
return deployApplication(
|
|
507
783
|
this.cliVersion,
|
|
@@ -522,6 +798,40 @@ export class SuperblocksSdk {
|
|
|
522
798
|
);
|
|
523
799
|
}
|
|
524
800
|
|
|
801
|
+
async fetchBillingUsageDaily(
|
|
802
|
+
startDate: string,
|
|
803
|
+
endDate: string,
|
|
804
|
+
): Promise<DailyUsageRow[]> {
|
|
805
|
+
return fetchBillingUsageDaily({
|
|
806
|
+
cliVersion: this.cliVersion,
|
|
807
|
+
token: this.token,
|
|
808
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
809
|
+
startDate,
|
|
810
|
+
endDate,
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
async fetchBillingUsageRecords(
|
|
815
|
+
startDate: string,
|
|
816
|
+
endDate: string,
|
|
817
|
+
): Promise<UsageRecordRow[]> {
|
|
818
|
+
return fetchBillingUsageRecords({
|
|
819
|
+
cliVersion: this.cliVersion,
|
|
820
|
+
token: this.token,
|
|
821
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
822
|
+
startDate,
|
|
823
|
+
endDate,
|
|
824
|
+
});
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
async fetchBillingPlanSummary(): Promise<PlanSummary> {
|
|
828
|
+
return fetchBillingPlanSummary({
|
|
829
|
+
cliVersion: this.cliVersion,
|
|
830
|
+
token: this.token,
|
|
831
|
+
superblocksBaseUrl: this.superblocksBaseUrl,
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
|
|
525
835
|
async sync({
|
|
526
836
|
applicationId,
|
|
527
837
|
payload,
|
package/src/socket/handlers.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { signResource, verifyResources } from "./signing.js";
|
|
2
|
-
import type { AppToSign, AppToVerify, MethodHandlers } from "../types/index.js";
|
|
3
1
|
import type {
|
|
4
2
|
ApiToSign,
|
|
5
3
|
ApiToVerify,
|
|
@@ -9,6 +7,9 @@ import type {
|
|
|
9
7
|
} from "@superblocksteam/shared";
|
|
10
8
|
import type { Signature } from "@superblocksteam/util";
|
|
11
9
|
|
|
10
|
+
import type { AppToSign, AppToVerify, MethodHandlers } from "../types/index.js";
|
|
11
|
+
import { signResource, verifyResources } from "./signing.js";
|
|
12
|
+
|
|
12
13
|
// This file contains the definition of the protocol used for communication between the SB server and clients
|
|
13
14
|
|
|
14
15
|
export type ResponseMeta = {
|
package/src/socket/index.ts
CHANGED
|
@@ -3,15 +3,16 @@ import {
|
|
|
3
3
|
createISocketClient,
|
|
4
4
|
ISocketWithClientAuth,
|
|
5
5
|
} from "@superblocksteam/shared";
|
|
6
|
-
import { getTracer } from "../telemetry/index.js";
|
|
7
|
-
import { createRequestHandlers } from "./handlers.js";
|
|
8
|
-
import type { ISocketClient } from "../types/index.js";
|
|
9
6
|
import type {
|
|
10
7
|
ClientMethods,
|
|
11
8
|
RequestContextBase,
|
|
12
9
|
ServerMethods,
|
|
13
10
|
} from "@superblocksteam/shared";
|
|
14
11
|
|
|
12
|
+
import { getTracer } from "../telemetry/index.js";
|
|
13
|
+
import type { ISocketClient } from "../types/index.js";
|
|
14
|
+
import { createRequestHandlers } from "./handlers.js";
|
|
15
|
+
|
|
15
16
|
export type StdISocketRPCClient = ISocketClient<ServerMethods>;
|
|
16
17
|
|
|
17
18
|
export async function connectToISocketRPCServer({
|
package/src/socket/signing.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
-
import {
|
|
2
|
+
import type { AxiosRequestConfig, Method } from "axios";
|
|
3
|
+
|
|
4
|
+
import type { Signature } from "@superblocksteam/util";
|
|
5
|
+
|
|
3
6
|
import type {
|
|
4
7
|
ApiResource,
|
|
5
8
|
GenericResource,
|
|
6
9
|
SignatureResponse,
|
|
7
10
|
} from "../types/index.js";
|
|
8
|
-
import
|
|
9
|
-
import type { AxiosRequestConfig, Method } from "axios";
|
|
11
|
+
import { getSanitizedApi } from "../utils.js";
|
|
10
12
|
|
|
11
13
|
export async function signResource({
|
|
12
14
|
token,
|
package/src/telemetry/index.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import os from "node:os";
|
|
2
|
+
|
|
2
3
|
import { trace, type Tracer } from "@opentelemetry/api";
|
|
3
4
|
import { logs, type Logger } from "@opentelemetry/api-logs";
|
|
4
5
|
import { ExpressInstrumentation } from "@opentelemetry/instrumentation-express";
|
|
5
6
|
import { HttpInstrumentation } from "@opentelemetry/instrumentation-http";
|
|
7
|
+
import type ddTraceDefault from "dd-trace";
|
|
8
|
+
|
|
6
9
|
import {
|
|
7
10
|
DeploymentTypeEnum,
|
|
8
11
|
OBS_TAG_APPLICATION_ID,
|
|
@@ -18,7 +21,9 @@ import {
|
|
|
18
21
|
resetTelemetry,
|
|
19
22
|
getDefaultPolicy,
|
|
20
23
|
} from "@superblocksteam/telemetry";
|
|
24
|
+
|
|
21
25
|
import packageJson from "../../package.json" with { type: "json" };
|
|
26
|
+
import type { ApplicationConfigWithTokenConfigAndUserInfo } from "../types/index.js";
|
|
22
27
|
import {
|
|
23
28
|
ATTR_SUPERBLOCKS_BASE_URL,
|
|
24
29
|
ATTR_SUPERBLOCKS_CLI_TOKEN,
|
|
@@ -30,8 +35,6 @@ import {
|
|
|
30
35
|
import { applyLocalObsEnvVars, isLocalObsEnabled } from "./local-obs.js";
|
|
31
36
|
import { getLogger as getStandardLogger } from "./logging.js";
|
|
32
37
|
import { getConfiguration, SERVICE_NAME } from "./util.js";
|
|
33
|
-
import type { ApplicationConfigWithTokenConfigAndUserInfo } from "../types/index.js";
|
|
34
|
-
import type ddTraceDefault from "dd-trace";
|
|
35
38
|
|
|
36
39
|
// Apply local observability env vars early, before dd-trace auto-init
|
|
37
40
|
applyLocalObsEnvVars();
|
package/src/telemetry/logging.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
2
|
-
import { createLogger, format, transports } from "winston";
|
|
3
|
-
import { safeStringify } from "./safe-stringify.js";
|
|
4
|
-
import { getLogger as getTracedLogger } from "./index.js";
|
|
5
2
|
import type { AnyValueMap } from "@opentelemetry/api-logs";
|
|
3
|
+
import { createLogger, format, transports } from "winston";
|
|
6
4
|
import type winston from "winston";
|
|
7
5
|
|
|
6
|
+
import { getLogger as getTracedLogger } from "./index.js";
|
|
7
|
+
import { safeStringify } from "./safe-stringify.js";
|
|
8
|
+
|
|
8
9
|
const activeTransports: winston.transport[] = [];
|
|
9
10
|
|
|
10
11
|
if (process.env.SUPERBLOCKS_IS_CSB === "true") {
|
package/src/types/common.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import type { AxiosRequestConfig } from "axios";
|
|
3
|
+
|
|
4
|
+
import type { Api } from "@superblocksteam/util";
|
|
5
|
+
|
|
2
6
|
import {
|
|
3
7
|
AgentStatus,
|
|
4
8
|
OpenAiPluginId,
|
|
5
9
|
transcribeAudioToTextTranslateToEnglishTruthyValues,
|
|
6
10
|
} from "./types/index.js";
|
|
7
11
|
import type { Agent, AgentType } from "./types/index.js";
|
|
8
|
-
import type { Api } from "@superblocksteam/util";
|
|
9
|
-
import type { AxiosRequestConfig } from "axios";
|
|
10
12
|
|
|
11
13
|
export async function getAgentUrl(
|
|
12
14
|
agents: Agent[],
|
package/src/version-control.mts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import * as https from "https";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { dirname } from "path";
|
|
4
|
+
|
|
5
|
+
import { bold } from "colorette";
|
|
6
|
+
import fs from "fs-extra";
|
|
7
|
+
import { isEmpty, isArray, isObject, get } from "lodash-es";
|
|
8
|
+
import * as semver from "semver";
|
|
9
|
+
import { simpleGit } from "simple-git";
|
|
10
|
+
import type { SimpleGit, StatusResult } from "simple-git";
|
|
11
|
+
import slugify from "slugify";
|
|
12
|
+
import { parse, stringify as ymlstringify } from "yaml";
|
|
13
|
+
|
|
4
14
|
import { DEFAULT_BRANCH, ExportViewMode } from "@superblocksteam/shared";
|
|
5
15
|
import {
|
|
6
16
|
RESOURCE_CONFIG_PATH,
|
|
@@ -13,23 +23,6 @@ import {
|
|
|
13
23
|
writeApiFiles,
|
|
14
24
|
DEFAULT_LINES_FOR_LARGE_STEPS,
|
|
15
25
|
} from "@superblocksteam/util";
|
|
16
|
-
import { bold } from "colorette";
|
|
17
|
-
import fs from "fs-extra";
|
|
18
|
-
import { isEmpty, isArray, isObject, get } from "lodash-es";
|
|
19
|
-
import * as semver from "semver";
|
|
20
|
-
import { simpleGit } from "simple-git";
|
|
21
|
-
import slugify from "slugify";
|
|
22
|
-
import { parse, stringify as ymlstringify } from "yaml";
|
|
23
|
-
import { getLogger } from "./telemetry/logging.js";
|
|
24
|
-
import type {
|
|
25
|
-
ApplicationWrapper,
|
|
26
|
-
MultiPageApplicationWrapper,
|
|
27
|
-
MultiPageApplicationWrapperWithComponents,
|
|
28
|
-
CodeModeApplicationWrapper,
|
|
29
|
-
} from "./client.js";
|
|
30
|
-
import type { FeatureFlags } from "./flag.js";
|
|
31
|
-
import type { SuperblocksSdk } from "./sdk.js";
|
|
32
|
-
import type { ApiWithPb, Page } from "./types/index.js";
|
|
33
26
|
import type {
|
|
34
27
|
LocalGitRepoState,
|
|
35
28
|
SuperblocksBackendConfig,
|
|
@@ -44,7 +37,17 @@ import type {
|
|
|
44
37
|
ApiWrapper,
|
|
45
38
|
AdditionalStepFiles,
|
|
46
39
|
} from "@superblocksteam/util";
|
|
47
|
-
|
|
40
|
+
|
|
41
|
+
import type {
|
|
42
|
+
ApplicationWrapper,
|
|
43
|
+
MultiPageApplicationWrapper,
|
|
44
|
+
MultiPageApplicationWrapperWithComponents,
|
|
45
|
+
CodeModeApplicationWrapper,
|
|
46
|
+
} from "./client.js";
|
|
47
|
+
import type { FeatureFlags } from "./flag.js";
|
|
48
|
+
import type { SuperblocksSdk } from "./sdk.js";
|
|
49
|
+
import { getLogger } from "./telemetry/logging.js";
|
|
50
|
+
import type { ApiWithPb, Page } from "./types/index.js";
|
|
48
51
|
|
|
49
52
|
export { DEFAULT_BRANCH };
|
|
50
53
|
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
|
|
3
|
+
import { yellow, red } from "colorette";
|
|
4
|
+
import fg from "fast-glob";
|
|
5
|
+
import fs from "fs-extra";
|
|
6
|
+
import { createLogger } from "vite";
|
|
7
|
+
import type { Plugin } from "vite";
|
|
8
|
+
import yaml from "yaml";
|
|
9
|
+
|
|
10
|
+
import type { DeleteMeLibraryApi } from "@superblocksteam/library-shared/types";
|
|
2
11
|
import { isSdkApiTemplate } from "@superblocksteam/shared";
|
|
3
12
|
import { resolveLanguageSpecificStepContentFromBlocks } from "@superblocksteam/util";
|
|
4
13
|
import {
|
|
5
14
|
getPageName,
|
|
6
15
|
getScopeIdFromName,
|
|
7
16
|
} from "@superblocksteam/vite-plugin-file-sync";
|
|
8
|
-
|
|
9
|
-
import fg from "fast-glob";
|
|
10
|
-
import fs from "fs-extra";
|
|
11
|
-
import { createLogger } from "vite";
|
|
12
|
-
import yaml from "yaml";
|
|
17
|
+
|
|
13
18
|
import { collectSdkApisFromRegistry } from "./collect-sdk-apis.mjs";
|
|
14
19
|
import { getLogger } from "./telemetry/logging.js";
|
|
15
|
-
import type { DeleteMeLibraryApi } from "@superblocksteam/library-shared/types";
|
|
16
|
-
import type { Plugin } from "vite";
|
|
17
20
|
|
|
18
21
|
type ApiDependency = {
|
|
19
22
|
apiName: string;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
|
|
2
3
|
import { transformFromAstSync } from "@babel/core";
|
|
3
4
|
import { parse } from "@babel/parser";
|
|
4
5
|
import tsTransformPlugin from "@babel/plugin-transform-typescript";
|
|
5
|
-
import { supplementElementIds } from "@superblocksteam/vite-plugin-file-sync";
|
|
6
6
|
import { red, yellow } from "colorette";
|
|
7
7
|
import { createLogger } from "vite";
|
|
8
|
-
import { getLogger } from "./telemetry/logging.js";
|
|
9
8
|
import type { Plugin } from "vite";
|
|
10
9
|
|
|
10
|
+
import { supplementElementIds } from "@superblocksteam/vite-plugin-file-sync";
|
|
11
|
+
|
|
12
|
+
import { getLogger } from "./telemetry/logging.js";
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
* Creates a Vite plugin that injects Superblocks IDs into the application.
|
|
13
16
|
* This will primarily be used during builds, as the dev server leverages the
|
package/test/clients.test.mts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
|
|
3
4
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
import type { SuperblocksDevEnvironmentConfig } from "@superblocksteam/util";
|
|
7
|
+
|
|
4
8
|
import { BranchSource, getCurrentBranchInfo } from "../src/client.js";
|
|
5
9
|
import { getCurrentGitBranch } from "../src/version-control.mjs";
|
|
6
|
-
import type { SuperblocksDevEnvironmentConfig } from "@superblocksteam/util";
|
|
7
10
|
|
|
8
11
|
// The .superblocks folder is located in the 'test' directory, so we need to prefix the path in order to find it.
|
|
9
12
|
const testPathPrefix = "test";
|