@superblocksteam/sdk 2.0.99 → 2.0.100-next.1
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/cli-replacement/dev.d.mts.map +1 -1
- package/dist/cli-replacement/dev.mjs +64 -20
- package/dist/cli-replacement/dev.mjs.map +1 -1
- package/dist/cli-replacement/init.d.ts.map +1 -1
- package/dist/cli-replacement/init.js +1 -0
- package/dist/cli-replacement/init.js.map +1 -1
- package/dist/client.d.ts +8 -21
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -5
- package/dist/client.js.map +1 -1
- package/dist/collect-sdk-apis.d.mts +10 -6
- package/dist/collect-sdk-apis.d.mts.map +1 -1
- package/dist/collect-sdk-apis.mjs +20 -5
- package/dist/collect-sdk-apis.mjs.map +1 -1
- package/dist/collect-sdk-apis.test.mjs +53 -4
- package/dist/collect-sdk-apis.test.mjs.map +1 -1
- package/dist/dbfs/client.d.ts +2 -0
- package/dist/dbfs/client.d.ts.map +1 -1
- package/dist/dbfs/client.js +43 -17
- package/dist/dbfs/client.js.map +1 -1
- package/dist/dbfs/client.test.d.ts +2 -0
- package/dist/dbfs/client.test.d.ts.map +1 -0
- package/dist/dbfs/client.test.js +81 -0
- package/dist/dbfs/client.test.js.map +1 -0
- package/dist/extract-api-integrations.d.mts +17 -0
- package/dist/extract-api-integrations.d.mts.map +1 -0
- package/dist/extract-api-integrations.mjs +233 -0
- package/dist/extract-api-integrations.mjs.map +1 -0
- package/dist/extract-api-integrations.test.d.mts +2 -0
- package/dist/extract-api-integrations.test.d.mts.map +1 -0
- package/dist/extract-api-integrations.test.mjs +97 -0
- package/dist/extract-api-integrations.test.mjs.map +1 -0
- package/dist/sdk.d.ts +13 -6
- package/dist/sdk.d.ts.map +1 -1
- package/dist/sdk.js +13 -6
- package/dist/sdk.js.map +1 -1
- package/dist/sdk.test.d.ts +2 -0
- package/dist/sdk.test.d.ts.map +1 -0
- package/dist/sdk.test.js +71 -0
- package/dist/sdk.test.js.map +1 -0
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/index.js +9 -2
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/logging.d.ts.map +1 -1
- package/dist/telemetry/logging.js +1 -0
- package/dist/telemetry/logging.js.map +1 -1
- package/dist/version-control.d.mts +5 -3
- package/dist/version-control.d.mts.map +1 -1
- package/dist/version-control.mjs +18 -10
- 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.map +1 -1
- package/package.json +6 -6
- package/src/cli-replacement/dev.mts +73 -24
- package/src/cli-replacement/init.ts +1 -0
- package/src/client.ts +53 -22
- package/src/collect-sdk-apis.mts +30 -6
- package/src/collect-sdk-apis.test.mts +58 -4
- package/src/dbfs/client.test.ts +116 -0
- package/src/dbfs/client.ts +60 -21
- package/src/extract-api-integrations.mts +345 -0
- package/src/extract-api-integrations.test.mts +114 -0
- package/src/sdk.test.ts +106 -0
- package/src/sdk.ts +40 -3
- package/src/telemetry/index.ts +13 -2
- package/src/telemetry/logging.ts +1 -0
- package/src/version-control.mts +23 -8
- package/src/vite-plugin-generate-api-build-manifest.mts +7 -1
- package/test/version-control.test.mts +81 -1
- package/tsconfig.tsbuildinfo +1 -1
package/src/telemetry/logging.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type winston from "winston";
|
|
|
8
8
|
const activeTransports: winston.transport[] = [];
|
|
9
9
|
|
|
10
10
|
if (process.env.SUPERBLOCKS_IS_CSB === "true") {
|
|
11
|
+
// TODO(alex): Revisit this for cloud-prem if we want logger to write to stdout
|
|
11
12
|
activeTransports.push(
|
|
12
13
|
new transports.File({
|
|
13
14
|
format: format.json(),
|
package/src/version-control.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as https from "https";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { dirname } from "path";
|
|
4
|
-
import { ExportViewMode } from "@superblocksteam/shared";
|
|
4
|
+
import { DEFAULT_BRANCH, ExportViewMode } from "@superblocksteam/shared";
|
|
5
5
|
import {
|
|
6
6
|
RESOURCE_CONFIG_PATH,
|
|
7
7
|
SUPERBLOCKS_HOME_FOLDER_NAME,
|
|
@@ -46,13 +46,13 @@ import type {
|
|
|
46
46
|
} from "@superblocksteam/util";
|
|
47
47
|
import type { SimpleGit, StatusResult } from "simple-git";
|
|
48
48
|
|
|
49
|
+
export { DEFAULT_BRANCH };
|
|
50
|
+
|
|
49
51
|
const LATEST_EDITS_MODE = "latest-edits";
|
|
50
52
|
export const DRAFT_MODE = "draft";
|
|
51
53
|
const MOST_RECENT_COMMIT_MODE = "most-recent-commit";
|
|
52
54
|
const DEPLOYED_MODE = "deployed";
|
|
53
55
|
|
|
54
|
-
export const DEFAULT_BRANCH = "main";
|
|
55
|
-
|
|
56
56
|
export const modeFlagValuesMap: Record<string, string> = {
|
|
57
57
|
[LATEST_EDITS_MODE]: "Latest edits",
|
|
58
58
|
[DRAFT_MODE]: "Draft",
|
|
@@ -556,6 +556,8 @@ export async function writeApplicationToDisk({
|
|
|
556
556
|
resource,
|
|
557
557
|
projectRootFolder,
|
|
558
558
|
appRelativePath,
|
|
559
|
+
directoryContentsHash,
|
|
560
|
+
branch,
|
|
559
561
|
featureFlags,
|
|
560
562
|
migrateFromSinglePage,
|
|
561
563
|
preferredApiRepresentation,
|
|
@@ -566,6 +568,8 @@ export async function writeApplicationToDisk({
|
|
|
566
568
|
| CodeModeApplicationWrapper;
|
|
567
569
|
projectRootFolder: string;
|
|
568
570
|
appRelativePath?: string;
|
|
571
|
+
directoryContentsHash?: string;
|
|
572
|
+
branch?: string;
|
|
569
573
|
featureFlags: FeatureFlags;
|
|
570
574
|
migrateFromSinglePage?: boolean;
|
|
571
575
|
preferredApiRepresentation?: ApiRepresentation;
|
|
@@ -585,6 +589,8 @@ export async function writeApplicationToDisk({
|
|
|
585
589
|
sdk,
|
|
586
590
|
resource,
|
|
587
591
|
appDirName,
|
|
592
|
+
directoryContentsHash,
|
|
593
|
+
branch,
|
|
588
594
|
featureFlags,
|
|
589
595
|
);
|
|
590
596
|
return {
|
|
@@ -774,6 +780,8 @@ async function writeCodeModeApplicationToDisk(
|
|
|
774
780
|
sdk: SuperblocksSdk,
|
|
775
781
|
resource: CodeModeApplicationWrapper,
|
|
776
782
|
appDirName: string,
|
|
783
|
+
directoryContentsHash: string | undefined,
|
|
784
|
+
branch: string | undefined,
|
|
777
785
|
featureFlags: FeatureFlags,
|
|
778
786
|
): Promise<void> {
|
|
779
787
|
// Find the existing application config and existing file paths
|
|
@@ -798,11 +806,18 @@ async function writeCodeModeApplicationToDisk(
|
|
|
798
806
|
|
|
799
807
|
// This writes to DBFS
|
|
800
808
|
try {
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
809
|
+
if (directoryContentsHash) {
|
|
810
|
+
await sdk.dbfsGetDirectoryByHash({
|
|
811
|
+
hash: directoryContentsHash,
|
|
812
|
+
localDirectoryPath: appDirName,
|
|
813
|
+
});
|
|
814
|
+
} else {
|
|
815
|
+
await sdk.dbfsGetApplication({
|
|
816
|
+
applicationId: resource.application.id,
|
|
817
|
+
branch: branch ?? DEFAULT_BRANCH,
|
|
818
|
+
localDirectoryPath: appDirName,
|
|
819
|
+
});
|
|
820
|
+
}
|
|
806
821
|
} catch (e: any) {
|
|
807
822
|
// This is most likely to happen if the application is not initialized
|
|
808
823
|
logger.error(e.message);
|
|
@@ -61,7 +61,13 @@ export function generateApiBuildManifestPlugin(root: string) {
|
|
|
61
61
|
let buildManifest: {
|
|
62
62
|
apis: Record<string, { api: DeleteMeLibraryApi; scopeId: string }>;
|
|
63
63
|
apiDependencies: ApiDependency[];
|
|
64
|
-
sdkApis: Record<
|
|
64
|
+
sdkApis: Record<
|
|
65
|
+
string,
|
|
66
|
+
{
|
|
67
|
+
entryPoint: string;
|
|
68
|
+
integrations?: Array<{ key: string; pluginId: string; id: string }>;
|
|
69
|
+
}
|
|
70
|
+
>;
|
|
65
71
|
} = { apis: {}, apiDependencies: [], sdkApis: {} };
|
|
66
72
|
|
|
67
73
|
return {
|
|
@@ -2,7 +2,7 @@ import os from "node:os";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { readAppApiYamlFile, LoopType } from "@superblocksteam/util";
|
|
4
4
|
import fs from "fs-extra";
|
|
5
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
import { stringify as ymlstringify } from "yaml";
|
|
7
7
|
import { FeatureFlags } from "../src/flag.js";
|
|
8
8
|
import {
|
|
@@ -14,8 +14,10 @@ import {
|
|
|
14
14
|
} from "../src/version-control.mjs";
|
|
15
15
|
import type {
|
|
16
16
|
ApplicationWrapper,
|
|
17
|
+
CodeModeApplicationWrapper,
|
|
17
18
|
MultiPageApplicationWrapperWithComponents,
|
|
18
19
|
} from "../src/client.js";
|
|
20
|
+
import type { SuperblocksSdk } from "../src/sdk.js";
|
|
19
21
|
import type { ApiWithPb } from "../src/types/common.js";
|
|
20
22
|
import type { ApiRepresentation } from "../src/version-control.mjs";
|
|
21
23
|
import type {
|
|
@@ -930,6 +932,84 @@ describe("version-control", () => {
|
|
|
930
932
|
"superblocks.git.split.large.step.lines": 10,
|
|
931
933
|
});
|
|
932
934
|
|
|
935
|
+
it("should use the requested branch for code mode applications", async () => {
|
|
936
|
+
const dbfsGetApplication = vi.fn().mockResolvedValue(undefined);
|
|
937
|
+
const dbfsGetDirectoryByHash = vi.fn().mockResolvedValue(undefined);
|
|
938
|
+
const codeModeApp: CodeModeApplicationWrapper = {
|
|
939
|
+
type: "code-mode",
|
|
940
|
+
application: {
|
|
941
|
+
id: "d7278b3b-f355-4374-baae-cdcca40fb502",
|
|
942
|
+
name: "Code Mode App",
|
|
943
|
+
},
|
|
944
|
+
};
|
|
945
|
+
|
|
946
|
+
const resourceConfig = await writeApplicationToDisk({
|
|
947
|
+
sdk: {
|
|
948
|
+
dbfsGetDirectoryByHash,
|
|
949
|
+
dbfsGetApplication,
|
|
950
|
+
} as unknown as SuperblocksSdk,
|
|
951
|
+
resource: codeModeApp,
|
|
952
|
+
projectRootFolder: testDir,
|
|
953
|
+
branch: "feature/mcp-checkout",
|
|
954
|
+
featureFlags: mockFeatureFlags,
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
expect(resourceConfig.location).toBe("apps/code_mode_app");
|
|
958
|
+
expect(dbfsGetApplication).toHaveBeenCalledWith({
|
|
959
|
+
applicationId: "d7278b3b-f355-4374-baae-cdcca40fb502",
|
|
960
|
+
branch: "feature/mcp-checkout",
|
|
961
|
+
localDirectoryPath: path.join(testDir, "apps/code_mode_app"),
|
|
962
|
+
});
|
|
963
|
+
expect(dbfsGetDirectoryByHash).not.toHaveBeenCalled();
|
|
964
|
+
|
|
965
|
+
const config = await expectSuperblocksJsonFileExists(
|
|
966
|
+
`${testDir}/apps/code_mode_app/`,
|
|
967
|
+
);
|
|
968
|
+
expect(config).toMatchObject({
|
|
969
|
+
configType: "APPLICATION_V2",
|
|
970
|
+
id: "d7278b3b-f355-4374-baae-cdcca40fb502",
|
|
971
|
+
});
|
|
972
|
+
});
|
|
973
|
+
|
|
974
|
+
it("should use a historical directory hash for code mode applications when provided", async () => {
|
|
975
|
+
const dbfsGetApplication = vi.fn().mockResolvedValue(undefined);
|
|
976
|
+
const dbfsGetDirectoryByHash = vi.fn().mockResolvedValue(undefined);
|
|
977
|
+
const codeModeApp: CodeModeApplicationWrapper = {
|
|
978
|
+
type: "code-mode",
|
|
979
|
+
application: {
|
|
980
|
+
id: "d7278b3b-f355-4374-baae-cdcca40fb502",
|
|
981
|
+
name: "Code Mode App",
|
|
982
|
+
},
|
|
983
|
+
};
|
|
984
|
+
|
|
985
|
+
const resourceConfig = await writeApplicationToDisk({
|
|
986
|
+
sdk: {
|
|
987
|
+
dbfsGetDirectoryByHash,
|
|
988
|
+
dbfsGetApplication,
|
|
989
|
+
} as unknown as SuperblocksSdk,
|
|
990
|
+
resource: codeModeApp,
|
|
991
|
+
projectRootFolder: testDir,
|
|
992
|
+
directoryContentsHash: "dir-hash-123",
|
|
993
|
+
branch: "feature/mcp-checkout",
|
|
994
|
+
featureFlags: mockFeatureFlags,
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
expect(resourceConfig.location).toBe("apps/code_mode_app");
|
|
998
|
+
expect(dbfsGetDirectoryByHash).toHaveBeenCalledWith({
|
|
999
|
+
hash: "dir-hash-123",
|
|
1000
|
+
localDirectoryPath: path.join(testDir, "apps/code_mode_app"),
|
|
1001
|
+
});
|
|
1002
|
+
expect(dbfsGetApplication).not.toHaveBeenCalled();
|
|
1003
|
+
|
|
1004
|
+
const config = await expectSuperblocksJsonFileExists(
|
|
1005
|
+
`${testDir}/apps/code_mode_app/`,
|
|
1006
|
+
);
|
|
1007
|
+
expect(config).toMatchObject({
|
|
1008
|
+
configType: "APPLICATION_V2",
|
|
1009
|
+
id: "d7278b3b-f355-4374-baae-cdcca40fb502",
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
|
|
933
1013
|
it("should write multi-pageapp to disk", async () => {
|
|
934
1014
|
// Setup
|
|
935
1015
|
const resourceId = "9736f700-88d6-49fc-a519-245a20af248b";
|