6c65d26ced
Split out of #21240. Stacked on #21250 (review/merge that first). `yarn twenty dev --once --dry-run` computes the migration plan and prints the diff **without applying anything** (no migration, no app-record update, no SDK generation). Also renders the diff on a normal `dev --once` sync. <img width="646" height="179" alt="image" src="https://github.com/user-attachments/assets/59f3ddcd-2a5b-4b8a-b21a-c659abe16af0" />
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { type Manifest } from 'twenty-shared/application';
|
|
import { syncApplicationQueryFactory } from 'test/integration/metadata/suites/application/utils/sync-application-query-factory.util';
|
|
import { makeMetadataAPIRequest } from 'test/integration/metadata/suites/utils/make-metadata-api-request.util';
|
|
import { type CommonResponseBody } from 'test/integration/metadata/types/common-response-body.type';
|
|
import { warnIfErrorButNotExpectedToFail } from 'test/integration/metadata/utils/warn-if-error-but-not-expected-to-fail.util';
|
|
import { warnIfNoErrorButExpectedToFail } from 'test/integration/metadata/utils/warn-if-no-error-but-expected-to-fail.util';
|
|
|
|
type WorkspaceMigration = {
|
|
applicationUniversalIdentifier: string;
|
|
actions: unknown[];
|
|
};
|
|
|
|
export const syncApplication = async ({
|
|
manifest,
|
|
expectToFail = false,
|
|
token,
|
|
dryRun,
|
|
}: {
|
|
manifest: Manifest;
|
|
expectToFail?: boolean;
|
|
token?: string;
|
|
dryRun?: boolean;
|
|
}): CommonResponseBody<{
|
|
syncApplication: WorkspaceMigration;
|
|
}> => {
|
|
const graphqlOperation = syncApplicationQueryFactory({
|
|
manifest,
|
|
dryRun,
|
|
});
|
|
|
|
const response = await makeMetadataAPIRequest(graphqlOperation, token);
|
|
|
|
if (expectToFail === true) {
|
|
warnIfNoErrorButExpectedToFail({
|
|
response,
|
|
errorMessage: 'Sync application should have failed but did not',
|
|
});
|
|
}
|
|
|
|
if (expectToFail === false) {
|
|
warnIfErrorButNotExpectedToFail({
|
|
response,
|
|
errorMessage: 'Sync application has failed but should not',
|
|
});
|
|
}
|
|
|
|
return { data: response.body.data, errors: response.body.errors };
|
|
};
|