Skip to content

Commit 694f3db

Browse files
authored
chore: Update to async endpoints (#255)
1 parent 7d6df07 commit 694f3db

File tree

5 files changed

+23
-195
lines changed

5 files changed

+23
-195
lines changed

Diff for: api/__tests__/projects.test.ts

+1-95
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ import {
3030
queueBuild,
3131
uploadFileToBuild,
3232
uploadProject,
33-
listAppsForMigration,
34-
beginMigration,
35-
finishMigration,
3633
} from '../projects';
3734

3835
const createReadStreamMock = createReadStream as jest.MockedFunction<
@@ -637,105 +634,14 @@ describe('api/projects', () => {
637634
});
638635
});
639636

640-
describe('listAppsForMigration', () => {
641-
it('should call http correctly', async () => {
642-
await listAppsForMigration(accountId);
643-
expect(http.get).toHaveBeenCalledTimes(1);
644-
expect(http.get).toHaveBeenCalledWith(accountId, {
645-
url: `dfs/migrations/v2/list-apps`,
646-
});
647-
});
648-
});
649-
650-
describe('beginMigration', () => {
651-
it('should call http correctly', async () => {
652-
const applicationId = 123456;
653-
await beginMigration(accountId, applicationId);
654-
expect(http.post).toHaveBeenCalledTimes(1);
655-
expect(http.post).toHaveBeenCalledWith(accountId, {
656-
url: `dfs/migrations/v2/migrations`,
657-
data: {
658-
applicationId,
659-
},
660-
});
661-
});
662-
});
663-
664-
describe('finishMigration', () => {
665-
it('should call http correctly with stable platform version', async () => {
666-
const migrationId = 123456;
667-
const componentUids = { 'component-1': 'uid-1' };
668-
const targetPlatformVersion = '2025.2';
669-
await finishMigration(
670-
accountId,
671-
migrationId,
672-
componentUids,
673-
projectName,
674-
targetPlatformVersion
675-
);
676-
expect(http.post).toHaveBeenCalledTimes(1);
677-
expect(http.post).toHaveBeenCalledWith(accountId, {
678-
url: `dfs/migrations/v2/migrations/migrate/v20252`,
679-
data: {
680-
migrationId,
681-
projectName,
682-
componentUids,
683-
},
684-
});
685-
});
686-
687-
it('should call http correctly with unstable platform version', async () => {
688-
const migrationId = 123456;
689-
const componentUids = { 'component-1': 'uid-1' };
690-
const targetPlatformVersion = 'unstable';
691-
await finishMigration(
692-
accountId,
693-
migrationId,
694-
componentUids,
695-
projectName,
696-
targetPlatformVersion
697-
);
698-
expect(http.post).toHaveBeenCalledTimes(1);
699-
expect(http.post).toHaveBeenCalledWith(accountId, {
700-
url: `dfs/migrations/v2/migrations/migrate/unstable`,
701-
data: {
702-
migrationId,
703-
projectName,
704-
componentUids,
705-
},
706-
});
707-
});
708-
});
709-
710637
describe('checkMigrationStatus', () => {
711638
it('should call v1 api for stable platform version', async () => {
712639
const migrationId = 123456;
713-
const targetPlatformVersion = '2023.2';
714-
await checkMigrationStatus(accountId, migrationId, targetPlatformVersion);
640+
await checkMigrationStatus(accountId, migrationId);
715641
expect(http.get).toHaveBeenCalledTimes(1);
716642
expect(http.get).toHaveBeenCalledWith(accountId, {
717643
url: `dfs/migrations/v1/migrations/${migrationId}`,
718644
});
719645
});
720-
721-
it('should call v2 api for unstable platform version', async () => {
722-
const migrationId = 123456;
723-
const targetPlatformVersion = 'unstable';
724-
await checkMigrationStatus(accountId, migrationId, targetPlatformVersion);
725-
expect(http.get).toHaveBeenCalledTimes(1);
726-
expect(http.get).toHaveBeenCalledWith(accountId, {
727-
url: `dfs/migrations/v2/migrations/${migrationId}/status`,
728-
});
729-
});
730-
731-
it('should call v2 api for 2025.2 platform version', async () => {
732-
const migrationId = 123456;
733-
const targetPlatformVersion = '2025.2';
734-
await checkMigrationStatus(accountId, migrationId, targetPlatformVersion);
735-
expect(http.get).toHaveBeenCalledTimes(1);
736-
expect(http.get).toHaveBeenCalledWith(accountId, {
737-
url: `dfs/migrations/v2/migrations/${migrationId}/status`,
738-
});
739-
});
740646
});
741647
});

Diff for: api/projects.ts

+16-57
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ import {
99
FetchPlatformVersionResponse,
1010
WarnLogsResponse,
1111
UploadIRResponse,
12-
ListAppsResponse,
13-
BeginMigrationResponse,
14-
FinishMigrationResponse,
1512
} from '../types/Project';
1613
import { Build, FetchProjectBuildsResponse } from '../types/Build';
1714
import {
@@ -24,7 +21,6 @@ import {
2421
CloneAppResponse,
2522
PollAppResponse,
2623
} from '../types/Migration';
27-
import { PLATFORM_VERSIONS } from '../constants/projects';
2824

2925
const PROJECTS_API_PATH = 'dfs/v1/projects';
3026
const DEVELOPER_FILE_SYSTEM_PATH = 'dfs/v1';
@@ -33,7 +29,6 @@ const PROJECTS_DEPLOY_API_PATH_V3 = 'dfs/deploy/v3';
3329
const PROJECTS_LOGS_API_PATH = 'dfs/logging/v1';
3430
const DEVELOPER_PROJECTS_API_PATH = 'developer/projects/v1';
3531
const MIGRATIONS_API_PATH_V1 = 'dfs/migrations/v1';
36-
const MIGRATIONS_API_PATH_V2 = 'dfs/migrations/v2';
3732

3833
const PROJECTS_V3_API_PATH = 'project-components-external/v3';
3934

@@ -339,47 +334,9 @@ export function fetchDeployWarnLogs(
339334
});
340335
}
341336

342-
export async function listAppsForMigration(
343-
accountId: number
344-
): HubSpotPromise<ListAppsResponse> {
345-
return http.get<ListAppsResponse>(accountId, {
346-
url: `${MIGRATIONS_API_PATH_V2}/list-apps`,
347-
});
348-
}
349-
350-
export async function beginMigration(
351-
accountId: number,
352-
applicationId: number
353-
): HubSpotPromise<BeginMigrationResponse> {
354-
return http.post(accountId, {
355-
url: `${MIGRATIONS_API_PATH_V2}/migrations`,
356-
data: {
357-
applicationId,
358-
},
359-
});
360-
}
361-
362-
export async function finishMigration(
363-
portalId: number,
364-
migrationId: number,
365-
componentUids: Record<string, string>,
366-
projectName: string,
367-
targetPlatformVersion: string
368-
): HubSpotPromise<FinishMigrationResponse> {
369-
const pathPlatformVersion =
370-
targetPlatformVersion === PLATFORM_VERSIONS.unstable
371-
? targetPlatformVersion
372-
: `v${targetPlatformVersion.replace('.', '')}`;
373-
return http.post(portalId, {
374-
url: `${MIGRATIONS_API_PATH_V2}/migrations/migrate/${pathPlatformVersion}`,
375-
data: {
376-
migrationId,
377-
projectName,
378-
componentUids,
379-
},
380-
});
381-
}
382-
337+
/**
338+
* @deprecated
339+
*/
383340
export function migrateApp(
384341
accountId: number,
385342
appId: number,
@@ -395,25 +352,21 @@ export function migrateApp(
395352
});
396353
}
397354

355+
/**
356+
* @deprecated
357+
*/
398358
export function checkMigrationStatus(
399359
accountId: number,
400-
id: number,
401-
targetPlatformVersion: string = PLATFORM_VERSIONS.v2023_2
360+
id: number
402361
): HubSpotPromise<PollAppResponse> {
403-
if (
404-
targetPlatformVersion === PLATFORM_VERSIONS.unstable ||
405-
targetPlatformVersion === PLATFORM_VERSIONS.v2025_2
406-
) {
407-
return http.get<PollAppResponse>(accountId, {
408-
url: `${MIGRATIONS_API_PATH_V2}/migrations/${id}/status`,
409-
});
410-
}
411-
412362
return http.get<PollAppResponse>(accountId, {
413363
url: `${MIGRATIONS_API_PATH_V1}/migrations/${id}`,
414364
});
415365
}
416366

367+
/**
368+
* @deprecated
369+
*/
417370
export function cloneApp(
418371
accountId: number,
419372
appId: number
@@ -427,6 +380,9 @@ export function cloneApp(
427380
});
428381
}
429382

383+
/**
384+
* @deprecated
385+
*/
430386
export function checkCloneStatus(
431387
accountId: number,
432388
exportId: number
@@ -436,6 +392,9 @@ export function checkCloneStatus(
436392
});
437393
}
438394

395+
/**
396+
* @deprecated
397+
*/
439398
export function downloadClonedProject(
440399
accountId: number,
441400
exportId: number

Diff for: package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
"./config": "./config/index.js",
5555
"./constants/*": "./constants/*.js",
5656
"./models/*": "./models/*.js",
57-
"./types/*": "./types/*.d.ts"
57+
"./types/*": {
58+
"types": "./types/*.d.ts",
59+
"default": "./types/*.js"
60+
}
5861
},
5962
"dependencies": {
6063
"address": "2.0.2",

Diff for: types/Migration.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export const MIGRATION_STATUS = {
77
PREPARING: 'PREPARING',
88
PENDING: 'PENDING',
99
SUCCESS: 'SUCCESS',
10+
IN_PROGRESS: 'IN_PROGRESS',
11+
INPUT_REQUIRED: 'INPUT_REQUIRED',
1012
} as const;
1113

1214
export type MigrateAppResponse = {

Diff for: types/Project.ts

-42
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Build } from './Build';
22
import { GithubSourceData } from './Github';
33
import { ProjectLog } from './ProjectLog';
4-
import { UNMIGRATABLE_REASONS } from '../constants/projects';
54

65
export type Project = {
76
createdAt: number;
@@ -73,44 +72,3 @@ export type ProjectStandardError = {
7372
export type WarnLogsResponse = {
7473
logs: Array<ProjectLog>;
7574
};
76-
77-
interface BaseMigrationApp {
78-
appId: number;
79-
appName: string;
80-
isMigratable: boolean;
81-
migrationComponents: ListAppsMigrationComponent[];
82-
}
83-
84-
export interface MigratableApp extends BaseMigrationApp {
85-
isMigratable: true;
86-
}
87-
88-
export interface UnmigratableApp extends BaseMigrationApp {
89-
isMigratable: false;
90-
unmigratableReason: keyof typeof UNMIGRATABLE_REASONS;
91-
}
92-
93-
export type MigrationApp = MigratableApp | UnmigratableApp;
94-
95-
export interface ListAppsResponse {
96-
migratableApps: MigratableApp[];
97-
unmigratableApps: UnmigratableApp[];
98-
}
99-
100-
export interface BeginMigrationResponse {
101-
migrationId: number;
102-
componentsRequiringUids: Record<
103-
string,
104-
{ componentType: string; componentHint: string | null }
105-
>;
106-
}
107-
export interface ListAppsMigrationComponent {
108-
id: string;
109-
componentType: string;
110-
isSupported: boolean;
111-
}
112-
113-
export type FinishMigrationResponse = {
114-
projectName: string;
115-
buildId: number;
116-
};

0 commit comments

Comments
 (0)